babylon.module.d.ts 5.2 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997
  1. declare module "babylonjs/types" {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /** @hidden */
  41. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  42. }
  43. /** @hidden */
  44. /** @hidden */
  45. type DeepImmutableObject<T> = {
  46. readonly [K in keyof T]: DeepImmutable<T[K]>;
  47. };
  48. }
  49. declare module "babylonjs/Misc/arrayTools" {
  50. /**
  51. * Class containing a set of static utilities functions for arrays.
  52. */
  53. export class ArrayTools {
  54. /**
  55. * Returns an array of the given size filled with element built from the given constructor and the paramters
  56. * @param size the number of element to construct and put in the array
  57. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  58. * @returns a new array filled with new objects
  59. */
  60. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  61. }
  62. }
  63. declare module "babylonjs/Maths/math.scalar" {
  64. /**
  65. * Scalar computation library
  66. */
  67. export class Scalar {
  68. /**
  69. * Two pi constants convenient for computation.
  70. */
  71. static TwoPi: number;
  72. /**
  73. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  74. * @param a number
  75. * @param b number
  76. * @param epsilon (default = 1.401298E-45)
  77. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  78. */
  79. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  80. /**
  81. * Returns a string : the upper case translation of the number i to hexadecimal.
  82. * @param i number
  83. * @returns the upper case translation of the number i to hexadecimal.
  84. */
  85. static ToHex(i: number): string;
  86. /**
  87. * Returns -1 if value is negative and +1 is value is positive.
  88. * @param value the value
  89. * @returns the value itself if it's equal to zero.
  90. */
  91. static Sign(value: number): number;
  92. /**
  93. * Returns the value itself if it's between min and max.
  94. * Returns min if the value is lower than min.
  95. * Returns max if the value is greater than max.
  96. * @param value the value to clmap
  97. * @param min the min value to clamp to (default: 0)
  98. * @param max the max value to clamp to (default: 1)
  99. * @returns the clamped value
  100. */
  101. static Clamp(value: number, min?: number, max?: number): number;
  102. /**
  103. * the log2 of value.
  104. * @param value the value to compute log2 of
  105. * @returns the log2 of value.
  106. */
  107. static Log2(value: number): number;
  108. /**
  109. * Loops the value, so that it is never larger than length and never smaller than 0.
  110. *
  111. * This is similar to the modulo operator but it works with floating point numbers.
  112. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  113. * With t = 5 and length = 2.5, the result would be 0.0.
  114. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  115. * @param value the value
  116. * @param length the length
  117. * @returns the looped value
  118. */
  119. static Repeat(value: number, length: number): number;
  120. /**
  121. * Normalize the value between 0.0 and 1.0 using min and max values
  122. * @param value value to normalize
  123. * @param min max to normalize between
  124. * @param max min to normalize between
  125. * @returns the normalized value
  126. */
  127. static Normalize(value: number, min: number, max: number): number;
  128. /**
  129. * Denormalize the value from 0.0 and 1.0 using min and max values
  130. * @param normalized value to denormalize
  131. * @param min max to denormalize between
  132. * @param max min to denormalize between
  133. * @returns the denormalized value
  134. */
  135. static Denormalize(normalized: number, min: number, max: number): number;
  136. /**
  137. * Calculates the shortest difference between two given angles given in degrees.
  138. * @param current current angle in degrees
  139. * @param target target angle in degrees
  140. * @returns the delta
  141. */
  142. static DeltaAngle(current: number, target: number): number;
  143. /**
  144. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  145. * @param tx value
  146. * @param length length
  147. * @returns The returned value will move back and forth between 0 and length
  148. */
  149. static PingPong(tx: number, length: number): number;
  150. /**
  151. * Interpolates between min and max with smoothing at the limits.
  152. *
  153. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  154. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  155. * @param from from
  156. * @param to to
  157. * @param tx value
  158. * @returns the smooth stepped value
  159. */
  160. static SmoothStep(from: number, to: number, tx: number): number;
  161. /**
  162. * Moves a value current towards target.
  163. *
  164. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  165. * Negative values of maxDelta pushes the value away from target.
  166. * @param current current value
  167. * @param target target value
  168. * @param maxDelta max distance to move
  169. * @returns resulting value
  170. */
  171. static MoveTowards(current: number, target: number, maxDelta: number): number;
  172. /**
  173. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  174. *
  175. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  176. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  177. * @param current current value
  178. * @param target target value
  179. * @param maxDelta max distance to move
  180. * @returns resulting angle
  181. */
  182. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  183. /**
  184. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  185. * @param start start value
  186. * @param end target value
  187. * @param amount amount to lerp between
  188. * @returns the lerped value
  189. */
  190. static Lerp(start: number, end: number, amount: number): number;
  191. /**
  192. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  193. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  194. * @param start start value
  195. * @param end target value
  196. * @param amount amount to lerp between
  197. * @returns the lerped value
  198. */
  199. static LerpAngle(start: number, end: number, amount: number): number;
  200. /**
  201. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  202. * @param a start value
  203. * @param b target value
  204. * @param value value between a and b
  205. * @returns the inverseLerp value
  206. */
  207. static InverseLerp(a: number, b: number, value: number): number;
  208. /**
  209. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  210. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  211. * @param value1 spline value
  212. * @param tangent1 spline value
  213. * @param value2 spline value
  214. * @param tangent2 spline value
  215. * @param amount input value
  216. * @returns hermite result
  217. */
  218. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  219. /**
  220. * Returns a random float number between and min and max values
  221. * @param min min value of random
  222. * @param max max value of random
  223. * @returns random value
  224. */
  225. static RandomRange(min: number, max: number): number;
  226. /**
  227. * This function returns percentage of a number in a given range.
  228. *
  229. * RangeToPercent(40,20,60) will return 0.5 (50%)
  230. * RangeToPercent(34,0,100) will return 0.34 (34%)
  231. * @param number to convert to percentage
  232. * @param min min range
  233. * @param max max range
  234. * @returns the percentage
  235. */
  236. static RangeToPercent(number: number, min: number, max: number): number;
  237. /**
  238. * This function returns number that corresponds to the percentage in a given range.
  239. *
  240. * PercentToRange(0.34,0,100) will return 34.
  241. * @param percent to convert to number
  242. * @param min min range
  243. * @param max max range
  244. * @returns the number
  245. */
  246. static PercentToRange(percent: number, min: number, max: number): number;
  247. /**
  248. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  249. * @param angle The angle to normalize in radian.
  250. * @return The converted angle.
  251. */
  252. static NormalizeRadians(angle: number): number;
  253. }
  254. }
  255. declare module "babylonjs/Maths/math" {
  256. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  257. /**
  258. * Constant used to convert a value to gamma space
  259. * @ignorenaming
  260. */
  261. export const ToGammaSpace: number;
  262. /**
  263. * Constant used to convert a value to linear space
  264. * @ignorenaming
  265. */
  266. export const ToLinearSpace = 2.2;
  267. /**
  268. * Constant used to define the minimal number value in Babylon.js
  269. * @ignorenaming
  270. */
  271. let Epsilon: number;
  272. export { Epsilon };
  273. /**
  274. * Class used to hold a RBG color
  275. */
  276. export class Color3 {
  277. /**
  278. * Defines the red component (between 0 and 1, default is 0)
  279. */
  280. r: number;
  281. /**
  282. * Defines the green component (between 0 and 1, default is 0)
  283. */
  284. g: number;
  285. /**
  286. * Defines the blue component (between 0 and 1, default is 0)
  287. */
  288. b: number;
  289. /**
  290. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  291. * @param r defines the red component (between 0 and 1, default is 0)
  292. * @param g defines the green component (between 0 and 1, default is 0)
  293. * @param b defines the blue component (between 0 and 1, default is 0)
  294. */
  295. constructor(
  296. /**
  297. * Defines the red component (between 0 and 1, default is 0)
  298. */
  299. r?: number,
  300. /**
  301. * Defines the green component (between 0 and 1, default is 0)
  302. */
  303. g?: number,
  304. /**
  305. * Defines the blue component (between 0 and 1, default is 0)
  306. */
  307. b?: number);
  308. /**
  309. * Creates a string with the Color3 current values
  310. * @returns the string representation of the Color3 object
  311. */
  312. toString(): string;
  313. /**
  314. * Returns the string "Color3"
  315. * @returns "Color3"
  316. */
  317. getClassName(): string;
  318. /**
  319. * Compute the Color3 hash code
  320. * @returns an unique number that can be used to hash Color3 objects
  321. */
  322. getHashCode(): number;
  323. /**
  324. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  325. * @param array defines the array where to store the r,g,b components
  326. * @param index defines an optional index in the target array to define where to start storing values
  327. * @returns the current Color3 object
  328. */
  329. toArray(array: FloatArray, index?: number): Color3;
  330. /**
  331. * Returns a new Color4 object from the current Color3 and the given alpha
  332. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  333. * @returns a new Color4 object
  334. */
  335. toColor4(alpha?: number): Color4;
  336. /**
  337. * Returns a new array populated with 3 numeric elements : red, green and blue values
  338. * @returns the new array
  339. */
  340. asArray(): number[];
  341. /**
  342. * Returns the luminance value
  343. * @returns a float value
  344. */
  345. toLuminance(): number;
  346. /**
  347. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  348. * @param otherColor defines the second operand
  349. * @returns the new Color3 object
  350. */
  351. multiply(otherColor: DeepImmutable<Color3>): Color3;
  352. /**
  353. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  354. * @param otherColor defines the second operand
  355. * @param result defines the Color3 object where to store the result
  356. * @returns the current Color3
  357. */
  358. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  359. /**
  360. * Determines equality between Color3 objects
  361. * @param otherColor defines the second operand
  362. * @returns true if the rgb values are equal to the given ones
  363. */
  364. equals(otherColor: DeepImmutable<Color3>): boolean;
  365. /**
  366. * Determines equality between the current Color3 object and a set of r,b,g values
  367. * @param r defines the red component to check
  368. * @param g defines the green component to check
  369. * @param b defines the blue component to check
  370. * @returns true if the rgb values are equal to the given ones
  371. */
  372. equalsFloats(r: number, g: number, b: number): boolean;
  373. /**
  374. * Multiplies in place each rgb value by scale
  375. * @param scale defines the scaling factor
  376. * @returns the updated Color3
  377. */
  378. scale(scale: number): Color3;
  379. /**
  380. * Multiplies the rgb values by scale and stores the result into "result"
  381. * @param scale defines the scaling factor
  382. * @param result defines the Color3 object where to store the result
  383. * @returns the unmodified current Color3
  384. */
  385. scaleToRef(scale: number, result: Color3): Color3;
  386. /**
  387. * Scale the current Color3 values by a factor and add the result to a given Color3
  388. * @param scale defines the scale factor
  389. * @param result defines color to store the result into
  390. * @returns the unmodified current Color3
  391. */
  392. scaleAndAddToRef(scale: number, result: Color3): Color3;
  393. /**
  394. * Clamps the rgb values by the min and max values and stores the result into "result"
  395. * @param min defines minimum clamping value (default is 0)
  396. * @param max defines maximum clamping value (default is 1)
  397. * @param result defines color to store the result into
  398. * @returns the original Color3
  399. */
  400. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  401. /**
  402. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  403. * @param otherColor defines the second operand
  404. * @returns the new Color3
  405. */
  406. add(otherColor: DeepImmutable<Color3>): Color3;
  407. /**
  408. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  409. * @param otherColor defines the second operand
  410. * @param result defines Color3 object to store the result into
  411. * @returns the unmodified current Color3
  412. */
  413. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  414. /**
  415. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  416. * @param otherColor defines the second operand
  417. * @returns the new Color3
  418. */
  419. subtract(otherColor: DeepImmutable<Color3>): Color3;
  420. /**
  421. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  422. * @param otherColor defines the second operand
  423. * @param result defines Color3 object to store the result into
  424. * @returns the unmodified current Color3
  425. */
  426. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  427. /**
  428. * Copy the current object
  429. * @returns a new Color3 copied the current one
  430. */
  431. clone(): Color3;
  432. /**
  433. * Copies the rgb values from the source in the current Color3
  434. * @param source defines the source Color3 object
  435. * @returns the updated Color3 object
  436. */
  437. copyFrom(source: DeepImmutable<Color3>): Color3;
  438. /**
  439. * Updates the Color3 rgb values from the given floats
  440. * @param r defines the red component to read from
  441. * @param g defines the green component to read from
  442. * @param b defines the blue component to read from
  443. * @returns the current Color3 object
  444. */
  445. copyFromFloats(r: number, g: number, b: number): Color3;
  446. /**
  447. * Updates the Color3 rgb values from the given floats
  448. * @param r defines the red component to read from
  449. * @param g defines the green component to read from
  450. * @param b defines the blue component to read from
  451. * @returns the current Color3 object
  452. */
  453. set(r: number, g: number, b: number): Color3;
  454. /**
  455. * Compute the Color3 hexadecimal code as a string
  456. * @returns a string containing the hexadecimal representation of the Color3 object
  457. */
  458. toHexString(): string;
  459. /**
  460. * Computes a new Color3 converted from the current one to linear space
  461. * @returns a new Color3 object
  462. */
  463. toLinearSpace(): Color3;
  464. /**
  465. * Converts current color in rgb space to HSV values
  466. * @returns a new color3 representing the HSV values
  467. */
  468. toHSV(): Color3;
  469. /**
  470. * Converts current color in rgb space to HSV values
  471. * @param result defines the Color3 where to store the HSV values
  472. */
  473. toHSVToRef(result: Color3): void;
  474. /**
  475. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  476. * @param convertedColor defines the Color3 object where to store the linear space version
  477. * @returns the unmodified Color3
  478. */
  479. toLinearSpaceToRef(convertedColor: Color3): Color3;
  480. /**
  481. * Computes a new Color3 converted from the current one to gamma space
  482. * @returns a new Color3 object
  483. */
  484. toGammaSpace(): Color3;
  485. /**
  486. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  487. * @param convertedColor defines the Color3 object where to store the gamma space version
  488. * @returns the unmodified Color3
  489. */
  490. toGammaSpaceToRef(convertedColor: Color3): Color3;
  491. private static _BlackReadOnly;
  492. /**
  493. * Convert Hue, saturation and value to a Color3 (RGB)
  494. * @param hue defines the hue
  495. * @param saturation defines the saturation
  496. * @param value defines the value
  497. * @param result defines the Color3 where to store the RGB values
  498. */
  499. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  500. /**
  501. * Creates a new Color3 from the string containing valid hexadecimal values
  502. * @param hex defines a string containing valid hexadecimal values
  503. * @returns a new Color3 object
  504. */
  505. static FromHexString(hex: string): Color3;
  506. /**
  507. * Creates a new Color3 from the starting index of the given array
  508. * @param array defines the source array
  509. * @param offset defines an offset in the source array
  510. * @returns a new Color3 object
  511. */
  512. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  513. /**
  514. * Creates a new Color3 from integer values (< 256)
  515. * @param r defines the red component to read from (value between 0 and 255)
  516. * @param g defines the green component to read from (value between 0 and 255)
  517. * @param b defines the blue component to read from (value between 0 and 255)
  518. * @returns a new Color3 object
  519. */
  520. static FromInts(r: number, g: number, b: number): Color3;
  521. /**
  522. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  523. * @param start defines the start Color3 value
  524. * @param end defines the end Color3 value
  525. * @param amount defines the gradient value between start and end
  526. * @returns a new Color3 object
  527. */
  528. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  529. /**
  530. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  531. * @param left defines the start value
  532. * @param right defines the end value
  533. * @param amount defines the gradient factor
  534. * @param result defines the Color3 object where to store the result
  535. */
  536. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  537. /**
  538. * Returns a Color3 value containing a red color
  539. * @returns a new Color3 object
  540. */
  541. static Red(): Color3;
  542. /**
  543. * Returns a Color3 value containing a green color
  544. * @returns a new Color3 object
  545. */
  546. static Green(): Color3;
  547. /**
  548. * Returns a Color3 value containing a blue color
  549. * @returns a new Color3 object
  550. */
  551. static Blue(): Color3;
  552. /**
  553. * Returns a Color3 value containing a black color
  554. * @returns a new Color3 object
  555. */
  556. static Black(): Color3;
  557. /**
  558. * Gets a Color3 value containing a black color that must not be updated
  559. */
  560. static readonly BlackReadOnly: DeepImmutable<Color3>;
  561. /**
  562. * Returns a Color3 value containing a white color
  563. * @returns a new Color3 object
  564. */
  565. static White(): Color3;
  566. /**
  567. * Returns a Color3 value containing a purple color
  568. * @returns a new Color3 object
  569. */
  570. static Purple(): Color3;
  571. /**
  572. * Returns a Color3 value containing a magenta color
  573. * @returns a new Color3 object
  574. */
  575. static Magenta(): Color3;
  576. /**
  577. * Returns a Color3 value containing a yellow color
  578. * @returns a new Color3 object
  579. */
  580. static Yellow(): Color3;
  581. /**
  582. * Returns a Color3 value containing a gray color
  583. * @returns a new Color3 object
  584. */
  585. static Gray(): Color3;
  586. /**
  587. * Returns a Color3 value containing a teal color
  588. * @returns a new Color3 object
  589. */
  590. static Teal(): Color3;
  591. /**
  592. * Returns a Color3 value containing a random color
  593. * @returns a new Color3 object
  594. */
  595. static Random(): Color3;
  596. }
  597. /**
  598. * Class used to hold a RBGA color
  599. */
  600. export class Color4 {
  601. /**
  602. * Defines the red component (between 0 and 1, default is 0)
  603. */
  604. r: number;
  605. /**
  606. * Defines the green component (between 0 and 1, default is 0)
  607. */
  608. g: number;
  609. /**
  610. * Defines the blue component (between 0 and 1, default is 0)
  611. */
  612. b: number;
  613. /**
  614. * Defines the alpha component (between 0 and 1, default is 1)
  615. */
  616. a: number;
  617. /**
  618. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  619. * @param r defines the red component (between 0 and 1, default is 0)
  620. * @param g defines the green component (between 0 and 1, default is 0)
  621. * @param b defines the blue component (between 0 and 1, default is 0)
  622. * @param a defines the alpha component (between 0 and 1, default is 1)
  623. */
  624. constructor(
  625. /**
  626. * Defines the red component (between 0 and 1, default is 0)
  627. */
  628. r?: number,
  629. /**
  630. * Defines the green component (between 0 and 1, default is 0)
  631. */
  632. g?: number,
  633. /**
  634. * Defines the blue component (between 0 and 1, default is 0)
  635. */
  636. b?: number,
  637. /**
  638. * Defines the alpha component (between 0 and 1, default is 1)
  639. */
  640. a?: number);
  641. /**
  642. * Adds in place the given Color4 values to the current Color4 object
  643. * @param right defines the second operand
  644. * @returns the current updated Color4 object
  645. */
  646. addInPlace(right: DeepImmutable<Color4>): Color4;
  647. /**
  648. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  649. * @returns the new array
  650. */
  651. asArray(): number[];
  652. /**
  653. * Stores from the starting index in the given array the Color4 successive values
  654. * @param array defines the array where to store the r,g,b components
  655. * @param index defines an optional index in the target array to define where to start storing values
  656. * @returns the current Color4 object
  657. */
  658. toArray(array: number[], index?: number): Color4;
  659. /**
  660. * Determines equality between Color4 objects
  661. * @param otherColor defines the second operand
  662. * @returns true if the rgba values are equal to the given ones
  663. */
  664. equals(otherColor: DeepImmutable<Color4>): boolean;
  665. /**
  666. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  667. * @param right defines the second operand
  668. * @returns a new Color4 object
  669. */
  670. add(right: DeepImmutable<Color4>): Color4;
  671. /**
  672. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  673. * @param right defines the second operand
  674. * @returns a new Color4 object
  675. */
  676. subtract(right: DeepImmutable<Color4>): Color4;
  677. /**
  678. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  679. * @param right defines the second operand
  680. * @param result defines the Color4 object where to store the result
  681. * @returns the current Color4 object
  682. */
  683. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  684. /**
  685. * Creates a new Color4 with the current Color4 values multiplied by scale
  686. * @param scale defines the scaling factor to apply
  687. * @returns a new Color4 object
  688. */
  689. scale(scale: number): Color4;
  690. /**
  691. * Multiplies the current Color4 values by scale and stores the result in "result"
  692. * @param scale defines the scaling factor to apply
  693. * @param result defines the Color4 object where to store the result
  694. * @returns the current unmodified Color4
  695. */
  696. scaleToRef(scale: number, result: Color4): Color4;
  697. /**
  698. * Scale the current Color4 values by a factor and add the result to a given Color4
  699. * @param scale defines the scale factor
  700. * @param result defines the Color4 object where to store the result
  701. * @returns the unmodified current Color4
  702. */
  703. scaleAndAddToRef(scale: number, result: Color4): Color4;
  704. /**
  705. * Clamps the rgb values by the min and max values and stores the result into "result"
  706. * @param min defines minimum clamping value (default is 0)
  707. * @param max defines maximum clamping value (default is 1)
  708. * @param result defines color to store the result into.
  709. * @returns the cuurent Color4
  710. */
  711. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  712. /**
  713. * Multipy an Color4 value by another and return a new Color4 object
  714. * @param color defines the Color4 value to multiply by
  715. * @returns a new Color4 object
  716. */
  717. multiply(color: Color4): Color4;
  718. /**
  719. * Multipy a Color4 value by another and push the result in a reference value
  720. * @param color defines the Color4 value to multiply by
  721. * @param result defines the Color4 to fill the result in
  722. * @returns the result Color4
  723. */
  724. multiplyToRef(color: Color4, result: Color4): Color4;
  725. /**
  726. * Creates a string with the Color4 current values
  727. * @returns the string representation of the Color4 object
  728. */
  729. toString(): string;
  730. /**
  731. * Returns the string "Color4"
  732. * @returns "Color4"
  733. */
  734. getClassName(): string;
  735. /**
  736. * Compute the Color4 hash code
  737. * @returns an unique number that can be used to hash Color4 objects
  738. */
  739. getHashCode(): number;
  740. /**
  741. * Creates a new Color4 copied from the current one
  742. * @returns a new Color4 object
  743. */
  744. clone(): Color4;
  745. /**
  746. * Copies the given Color4 values into the current one
  747. * @param source defines the source Color4 object
  748. * @returns the current updated Color4 object
  749. */
  750. copyFrom(source: Color4): Color4;
  751. /**
  752. * Copies the given float values into the current one
  753. * @param r defines the red component to read from
  754. * @param g defines the green component to read from
  755. * @param b defines the blue component to read from
  756. * @param a defines the alpha component to read from
  757. * @returns the current updated Color4 object
  758. */
  759. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  760. /**
  761. * Copies the given float values into the current one
  762. * @param r defines the red component to read from
  763. * @param g defines the green component to read from
  764. * @param b defines the blue component to read from
  765. * @param a defines the alpha component to read from
  766. * @returns the current updated Color4 object
  767. */
  768. set(r: number, g: number, b: number, a: number): Color4;
  769. /**
  770. * Compute the Color4 hexadecimal code as a string
  771. * @returns a string containing the hexadecimal representation of the Color4 object
  772. */
  773. toHexString(): string;
  774. /**
  775. * Computes a new Color4 converted from the current one to linear space
  776. * @returns a new Color4 object
  777. */
  778. toLinearSpace(): Color4;
  779. /**
  780. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  781. * @param convertedColor defines the Color4 object where to store the linear space version
  782. * @returns the unmodified Color4
  783. */
  784. toLinearSpaceToRef(convertedColor: Color4): Color4;
  785. /**
  786. * Computes a new Color4 converted from the current one to gamma space
  787. * @returns a new Color4 object
  788. */
  789. toGammaSpace(): Color4;
  790. /**
  791. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  792. * @param convertedColor defines the Color4 object where to store the gamma space version
  793. * @returns the unmodified Color4
  794. */
  795. toGammaSpaceToRef(convertedColor: Color4): Color4;
  796. /**
  797. * Creates a new Color4 from the string containing valid hexadecimal values
  798. * @param hex defines a string containing valid hexadecimal values
  799. * @returns a new Color4 object
  800. */
  801. static FromHexString(hex: string): Color4;
  802. /**
  803. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  804. * @param left defines the start value
  805. * @param right defines the end value
  806. * @param amount defines the gradient factor
  807. * @returns a new Color4 object
  808. */
  809. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  810. /**
  811. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  812. * @param left defines the start value
  813. * @param right defines the end value
  814. * @param amount defines the gradient factor
  815. * @param result defines the Color4 object where to store data
  816. */
  817. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  818. /**
  819. * Creates a new Color4 from a Color3 and an alpha value
  820. * @param color3 defines the source Color3 to read from
  821. * @param alpha defines the alpha component (1.0 by default)
  822. * @returns a new Color4 object
  823. */
  824. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  825. /**
  826. * Creates a new Color4 from the starting index element of the given array
  827. * @param array defines the source array to read from
  828. * @param offset defines the offset in the source array
  829. * @returns a new Color4 object
  830. */
  831. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  832. /**
  833. * Creates a new Color3 from integer values (< 256)
  834. * @param r defines the red component to read from (value between 0 and 255)
  835. * @param g defines the green component to read from (value between 0 and 255)
  836. * @param b defines the blue component to read from (value between 0 and 255)
  837. * @param a defines the alpha component to read from (value between 0 and 255)
  838. * @returns a new Color3 object
  839. */
  840. static FromInts(r: number, g: number, b: number, a: number): Color4;
  841. /**
  842. * Check the content of a given array and convert it to an array containing RGBA data
  843. * If the original array was already containing count * 4 values then it is returned directly
  844. * @param colors defines the array to check
  845. * @param count defines the number of RGBA data to expect
  846. * @returns an array containing count * 4 values (RGBA)
  847. */
  848. static CheckColors4(colors: number[], count: number): number[];
  849. }
  850. /**
  851. * Class representing a vector containing 2 coordinates
  852. */
  853. export class Vector2 {
  854. /** defines the first coordinate */
  855. x: number;
  856. /** defines the second coordinate */
  857. y: number;
  858. /**
  859. * Creates a new Vector2 from the given x and y coordinates
  860. * @param x defines the first coordinate
  861. * @param y defines the second coordinate
  862. */
  863. constructor(
  864. /** defines the first coordinate */
  865. x?: number,
  866. /** defines the second coordinate */
  867. y?: number);
  868. /**
  869. * Gets a string with the Vector2 coordinates
  870. * @returns a string with the Vector2 coordinates
  871. */
  872. toString(): string;
  873. /**
  874. * Gets class name
  875. * @returns the string "Vector2"
  876. */
  877. getClassName(): string;
  878. /**
  879. * Gets current vector hash code
  880. * @returns the Vector2 hash code as a number
  881. */
  882. getHashCode(): number;
  883. /**
  884. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  885. * @param array defines the source array
  886. * @param index defines the offset in source array
  887. * @returns the current Vector2
  888. */
  889. toArray(array: FloatArray, index?: number): Vector2;
  890. /**
  891. * Copy the current vector to an array
  892. * @returns a new array with 2 elements: the Vector2 coordinates.
  893. */
  894. asArray(): number[];
  895. /**
  896. * Sets the Vector2 coordinates with the given Vector2 coordinates
  897. * @param source defines the source Vector2
  898. * @returns the current updated Vector2
  899. */
  900. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  901. /**
  902. * Sets the Vector2 coordinates with the given floats
  903. * @param x defines the first coordinate
  904. * @param y defines the second coordinate
  905. * @returns the current updated Vector2
  906. */
  907. copyFromFloats(x: number, y: number): Vector2;
  908. /**
  909. * Sets the Vector2 coordinates with the given floats
  910. * @param x defines the first coordinate
  911. * @param y defines the second coordinate
  912. * @returns the current updated Vector2
  913. */
  914. set(x: number, y: number): Vector2;
  915. /**
  916. * Add another vector with the current one
  917. * @param otherVector defines the other vector
  918. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  919. */
  920. add(otherVector: DeepImmutable<Vector2>): Vector2;
  921. /**
  922. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  923. * @param otherVector defines the other vector
  924. * @param result defines the target vector
  925. * @returns the unmodified current Vector2
  926. */
  927. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  928. /**
  929. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  930. * @param otherVector defines the other vector
  931. * @returns the current updated Vector2
  932. */
  933. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  934. /**
  935. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  936. * @param otherVector defines the other vector
  937. * @returns a new Vector2
  938. */
  939. addVector3(otherVector: Vector3): Vector2;
  940. /**
  941. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  942. * @param otherVector defines the other vector
  943. * @returns a new Vector2
  944. */
  945. subtract(otherVector: Vector2): Vector2;
  946. /**
  947. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  948. * @param otherVector defines the other vector
  949. * @param result defines the target vector
  950. * @returns the unmodified current Vector2
  951. */
  952. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  953. /**
  954. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  955. * @param otherVector defines the other vector
  956. * @returns the current updated Vector2
  957. */
  958. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  959. /**
  960. * Multiplies in place the current Vector2 coordinates by the given ones
  961. * @param otherVector defines the other vector
  962. * @returns the current updated Vector2
  963. */
  964. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  965. /**
  966. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  967. * @param otherVector defines the other vector
  968. * @returns a new Vector2
  969. */
  970. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  971. /**
  972. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  973. * @param otherVector defines the other vector
  974. * @param result defines the target vector
  975. * @returns the unmodified current Vector2
  976. */
  977. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  978. /**
  979. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  980. * @param x defines the first coordinate
  981. * @param y defines the second coordinate
  982. * @returns a new Vector2
  983. */
  984. multiplyByFloats(x: number, y: number): Vector2;
  985. /**
  986. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  987. * @param otherVector defines the other vector
  988. * @returns a new Vector2
  989. */
  990. divide(otherVector: Vector2): Vector2;
  991. /**
  992. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  993. * @param otherVector defines the other vector
  994. * @param result defines the target vector
  995. * @returns the unmodified current Vector2
  996. */
  997. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  998. /**
  999. * Divides the current Vector2 coordinates by the given ones
  1000. * @param otherVector defines the other vector
  1001. * @returns the current updated Vector2
  1002. */
  1003. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1004. /**
  1005. * Gets a new Vector2 with current Vector2 negated coordinates
  1006. * @returns a new Vector2
  1007. */
  1008. negate(): Vector2;
  1009. /**
  1010. * Multiply the Vector2 coordinates by scale
  1011. * @param scale defines the scaling factor
  1012. * @returns the current updated Vector2
  1013. */
  1014. scaleInPlace(scale: number): Vector2;
  1015. /**
  1016. * Returns a new Vector2 scaled by "scale" from the current Vector2
  1017. * @param scale defines the scaling factor
  1018. * @returns a new Vector2
  1019. */
  1020. scale(scale: number): Vector2;
  1021. /**
  1022. * Scale the current Vector2 values by a factor to a given Vector2
  1023. * @param scale defines the scale factor
  1024. * @param result defines the Vector2 object where to store the result
  1025. * @returns the unmodified current Vector2
  1026. */
  1027. scaleToRef(scale: number, result: Vector2): Vector2;
  1028. /**
  1029. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  1030. * @param scale defines the scale factor
  1031. * @param result defines the Vector2 object where to store the result
  1032. * @returns the unmodified current Vector2
  1033. */
  1034. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  1035. /**
  1036. * Gets a boolean if two vectors are equals
  1037. * @param otherVector defines the other vector
  1038. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  1039. */
  1040. equals(otherVector: DeepImmutable<Vector2>): boolean;
  1041. /**
  1042. * Gets a boolean if two vectors are equals (using an epsilon value)
  1043. * @param otherVector defines the other vector
  1044. * @param epsilon defines the minimal distance to consider equality
  1045. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  1046. */
  1047. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  1048. /**
  1049. * Gets a new Vector2 from current Vector2 floored values
  1050. * @returns a new Vector2
  1051. */
  1052. floor(): Vector2;
  1053. /**
  1054. * Gets a new Vector2 from current Vector2 floored values
  1055. * @returns a new Vector2
  1056. */
  1057. fract(): Vector2;
  1058. /**
  1059. * Gets the length of the vector
  1060. * @returns the vector length (float)
  1061. */
  1062. length(): number;
  1063. /**
  1064. * Gets the vector squared length
  1065. * @returns the vector squared length (float)
  1066. */
  1067. lengthSquared(): number;
  1068. /**
  1069. * Normalize the vector
  1070. * @returns the current updated Vector2
  1071. */
  1072. normalize(): Vector2;
  1073. /**
  1074. * Gets a new Vector2 copied from the Vector2
  1075. * @returns a new Vector2
  1076. */
  1077. clone(): Vector2;
  1078. /**
  1079. * Gets a new Vector2(0, 0)
  1080. * @returns a new Vector2
  1081. */
  1082. static Zero(): Vector2;
  1083. /**
  1084. * Gets a new Vector2(1, 1)
  1085. * @returns a new Vector2
  1086. */
  1087. static One(): Vector2;
  1088. /**
  1089. * Gets a new Vector2 set from the given index element of the given array
  1090. * @param array defines the data source
  1091. * @param offset defines the offset in the data source
  1092. * @returns a new Vector2
  1093. */
  1094. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  1095. /**
  1096. * Sets "result" from the given index element of the given array
  1097. * @param array defines the data source
  1098. * @param offset defines the offset in the data source
  1099. * @param result defines the target vector
  1100. */
  1101. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  1102. /**
  1103. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  1104. * @param value1 defines 1st point of control
  1105. * @param value2 defines 2nd point of control
  1106. * @param value3 defines 3rd point of control
  1107. * @param value4 defines 4th point of control
  1108. * @param amount defines the interpolation factor
  1109. * @returns a new Vector2
  1110. */
  1111. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  1112. /**
  1113. * Returns a new Vector2 set with same the coordinates than "value" ones if the vector "value" is in the square defined by "min" and "max".
  1114. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  1115. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  1116. * @param value defines the value to clamp
  1117. * @param min defines the lower limit
  1118. * @param max defines the upper limit
  1119. * @returns a new Vector2
  1120. */
  1121. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  1122. /**
  1123. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  1124. * @param value1 defines the 1st control point
  1125. * @param tangent1 defines the outgoing tangent
  1126. * @param value2 defines the 2nd control point
  1127. * @param tangent2 defines the incoming tangent
  1128. * @param amount defines the interpolation factor
  1129. * @returns a new Vector2
  1130. */
  1131. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  1132. /**
  1133. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  1134. * @param start defines the start vector
  1135. * @param end defines the end vector
  1136. * @param amount defines the interpolation factor
  1137. * @returns a new Vector2
  1138. */
  1139. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  1140. /**
  1141. * Gets the dot product of the vector "left" and the vector "right"
  1142. * @param left defines first vector
  1143. * @param right defines second vector
  1144. * @returns the dot product (float)
  1145. */
  1146. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  1147. /**
  1148. * Returns a new Vector2 equal to the normalized given vector
  1149. * @param vector defines the vector to normalize
  1150. * @returns a new Vector2
  1151. */
  1152. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  1153. /**
  1154. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  1155. * @param left defines 1st vector
  1156. * @param right defines 2nd vector
  1157. * @returns a new Vector2
  1158. */
  1159. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1160. /**
  1161. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  1162. * @param left defines 1st vector
  1163. * @param right defines 2nd vector
  1164. * @returns a new Vector2
  1165. */
  1166. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1167. /**
  1168. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  1169. * @param vector defines the vector to transform
  1170. * @param transformation defines the matrix to apply
  1171. * @returns a new Vector2
  1172. */
  1173. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  1174. /**
  1175. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  1176. * @param vector defines the vector to transform
  1177. * @param transformation defines the matrix to apply
  1178. * @param result defines the target vector
  1179. */
  1180. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  1181. /**
  1182. * Determines if a given vector is included in a triangle
  1183. * @param p defines the vector to test
  1184. * @param p0 defines 1st triangle point
  1185. * @param p1 defines 2nd triangle point
  1186. * @param p2 defines 3rd triangle point
  1187. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  1188. */
  1189. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  1190. /**
  1191. * Gets the distance between the vectors "value1" and "value2"
  1192. * @param value1 defines first vector
  1193. * @param value2 defines second vector
  1194. * @returns the distance between vectors
  1195. */
  1196. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1197. /**
  1198. * Returns the squared distance between the vectors "value1" and "value2"
  1199. * @param value1 defines first vector
  1200. * @param value2 defines second vector
  1201. * @returns the squared distance between vectors
  1202. */
  1203. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1204. /**
  1205. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  1206. * @param value1 defines first vector
  1207. * @param value2 defines second vector
  1208. * @returns a new Vector2
  1209. */
  1210. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  1211. /**
  1212. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  1213. * @param p defines the middle point
  1214. * @param segA defines one point of the segment
  1215. * @param segB defines the other point of the segment
  1216. * @returns the shortest distance
  1217. */
  1218. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  1219. }
  1220. /**
  1221. * Classed used to store (x,y,z) vector representation
  1222. * A Vector3 is the main object used in 3D geometry
  1223. * It can represent etiher the coordinates of a point the space, either a direction
  1224. * Reminder: js uses a left handed forward facing system
  1225. */
  1226. export class Vector3 {
  1227. /**
  1228. * Defines the first coordinates (on X axis)
  1229. */
  1230. x: number;
  1231. /**
  1232. * Defines the second coordinates (on Y axis)
  1233. */
  1234. y: number;
  1235. /**
  1236. * Defines the third coordinates (on Z axis)
  1237. */
  1238. z: number;
  1239. private static _UpReadOnly;
  1240. private static _ZeroReadOnly;
  1241. /**
  1242. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  1243. * @param x defines the first coordinates (on X axis)
  1244. * @param y defines the second coordinates (on Y axis)
  1245. * @param z defines the third coordinates (on Z axis)
  1246. */
  1247. constructor(
  1248. /**
  1249. * Defines the first coordinates (on X axis)
  1250. */
  1251. x?: number,
  1252. /**
  1253. * Defines the second coordinates (on Y axis)
  1254. */
  1255. y?: number,
  1256. /**
  1257. * Defines the third coordinates (on Z axis)
  1258. */
  1259. z?: number);
  1260. /**
  1261. * Creates a string representation of the Vector3
  1262. * @returns a string with the Vector3 coordinates.
  1263. */
  1264. toString(): string;
  1265. /**
  1266. * Gets the class name
  1267. * @returns the string "Vector3"
  1268. */
  1269. getClassName(): string;
  1270. /**
  1271. * Creates the Vector3 hash code
  1272. * @returns a number which tends to be unique between Vector3 instances
  1273. */
  1274. getHashCode(): number;
  1275. /**
  1276. * Creates an array containing three elements : the coordinates of the Vector3
  1277. * @returns a new array of numbers
  1278. */
  1279. asArray(): number[];
  1280. /**
  1281. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  1282. * @param array defines the destination array
  1283. * @param index defines the offset in the destination array
  1284. * @returns the current Vector3
  1285. */
  1286. toArray(array: FloatArray, index?: number): Vector3;
  1287. /**
  1288. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  1289. * @returns a new Quaternion object, computed from the Vector3 coordinates
  1290. */
  1291. toQuaternion(): Quaternion;
  1292. /**
  1293. * Adds the given vector to the current Vector3
  1294. * @param otherVector defines the second operand
  1295. * @returns the current updated Vector3
  1296. */
  1297. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1298. /**
  1299. * Adds the given coordinates to the current Vector3
  1300. * @param x defines the x coordinate of the operand
  1301. * @param y defines the y coordinate of the operand
  1302. * @param z defines the z coordinate of the operand
  1303. * @returns the current updated Vector3
  1304. */
  1305. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1306. /**
  1307. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  1308. * @param otherVector defines the second operand
  1309. * @returns the resulting Vector3
  1310. */
  1311. add(otherVector: DeepImmutable<Vector3>): Vector3;
  1312. /**
  1313. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  1314. * @param otherVector defines the second operand
  1315. * @param result defines the Vector3 object where to store the result
  1316. * @returns the current Vector3
  1317. */
  1318. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1319. /**
  1320. * Subtract the given vector from the current Vector3
  1321. * @param otherVector defines the second operand
  1322. * @returns the current updated Vector3
  1323. */
  1324. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1325. /**
  1326. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  1327. * @param otherVector defines the second operand
  1328. * @returns the resulting Vector3
  1329. */
  1330. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  1331. /**
  1332. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  1333. * @param otherVector defines the second operand
  1334. * @param result defines the Vector3 object where to store the result
  1335. * @returns the current Vector3
  1336. */
  1337. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1338. /**
  1339. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  1340. * @param x defines the x coordinate of the operand
  1341. * @param y defines the y coordinate of the operand
  1342. * @param z defines the z coordinate of the operand
  1343. * @returns the resulting Vector3
  1344. */
  1345. subtractFromFloats(x: number, y: number, z: number): Vector3;
  1346. /**
  1347. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  1348. * @param x defines the x coordinate of the operand
  1349. * @param y defines the y coordinate of the operand
  1350. * @param z defines the z coordinate of the operand
  1351. * @param result defines the Vector3 object where to store the result
  1352. * @returns the current Vector3
  1353. */
  1354. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  1355. /**
  1356. * Gets a new Vector3 set with the current Vector3 negated coordinates
  1357. * @returns a new Vector3
  1358. */
  1359. negate(): Vector3;
  1360. /**
  1361. * Multiplies the Vector3 coordinates by the float "scale"
  1362. * @param scale defines the multiplier factor
  1363. * @returns the current updated Vector3
  1364. */
  1365. scaleInPlace(scale: number): Vector3;
  1366. /**
  1367. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  1368. * @param scale defines the multiplier factor
  1369. * @returns a new Vector3
  1370. */
  1371. scale(scale: number): Vector3;
  1372. /**
  1373. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  1374. * @param scale defines the multiplier factor
  1375. * @param result defines the Vector3 object where to store the result
  1376. * @returns the current Vector3
  1377. */
  1378. scaleToRef(scale: number, result: Vector3): Vector3;
  1379. /**
  1380. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  1381. * @param scale defines the scale factor
  1382. * @param result defines the Vector3 object where to store the result
  1383. * @returns the unmodified current Vector3
  1384. */
  1385. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  1386. /**
  1387. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  1388. * @param otherVector defines the second operand
  1389. * @returns true if both vectors are equals
  1390. */
  1391. equals(otherVector: DeepImmutable<Vector3>): boolean;
  1392. /**
  1393. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  1394. * @param otherVector defines the second operand
  1395. * @param epsilon defines the minimal distance to define values as equals
  1396. * @returns true if both vectors are distant less than epsilon
  1397. */
  1398. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  1399. /**
  1400. * Returns true if the current Vector3 coordinates equals the given floats
  1401. * @param x defines the x coordinate of the operand
  1402. * @param y defines the y coordinate of the operand
  1403. * @param z defines the z coordinate of the operand
  1404. * @returns true if both vectors are equals
  1405. */
  1406. equalsToFloats(x: number, y: number, z: number): boolean;
  1407. /**
  1408. * Multiplies the current Vector3 coordinates by the given ones
  1409. * @param otherVector defines the second operand
  1410. * @returns the current updated Vector3
  1411. */
  1412. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1413. /**
  1414. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  1415. * @param otherVector defines the second operand
  1416. * @returns the new Vector3
  1417. */
  1418. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  1419. /**
  1420. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  1421. * @param otherVector defines the second operand
  1422. * @param result defines the Vector3 object where to store the result
  1423. * @returns the current Vector3
  1424. */
  1425. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1426. /**
  1427. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  1428. * @param x defines the x coordinate of the operand
  1429. * @param y defines the y coordinate of the operand
  1430. * @param z defines the z coordinate of the operand
  1431. * @returns the new Vector3
  1432. */
  1433. multiplyByFloats(x: number, y: number, z: number): Vector3;
  1434. /**
  1435. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  1436. * @param otherVector defines the second operand
  1437. * @returns the new Vector3
  1438. */
  1439. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  1440. /**
  1441. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  1442. * @param otherVector defines the second operand
  1443. * @param result defines the Vector3 object where to store the result
  1444. * @returns the current Vector3
  1445. */
  1446. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1447. /**
  1448. * Divides the current Vector3 coordinates by the given ones.
  1449. * @param otherVector defines the second operand
  1450. * @returns the current updated Vector3
  1451. */
  1452. divideInPlace(otherVector: Vector3): Vector3;
  1453. /**
  1454. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  1455. * @param other defines the second operand
  1456. * @returns the current updated Vector3
  1457. */
  1458. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1459. /**
  1460. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  1461. * @param other defines the second operand
  1462. * @returns the current updated Vector3
  1463. */
  1464. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1465. /**
  1466. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  1467. * @param x defines the x coordinate of the operand
  1468. * @param y defines the y coordinate of the operand
  1469. * @param z defines the z coordinate of the operand
  1470. * @returns the current updated Vector3
  1471. */
  1472. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1473. /**
  1474. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  1475. * @param x defines the x coordinate of the operand
  1476. * @param y defines the y coordinate of the operand
  1477. * @param z defines the z coordinate of the operand
  1478. * @returns the current updated Vector3
  1479. */
  1480. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1481. /**
  1482. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  1483. * Check if is non uniform within a certain amount of decimal places to account for this
  1484. * @param epsilon the amount the values can differ
  1485. * @returns if the the vector is non uniform to a certain number of decimal places
  1486. */
  1487. isNonUniformWithinEpsilon(epsilon: number): boolean;
  1488. /**
  1489. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  1490. */
  1491. readonly isNonUniform: boolean;
  1492. /**
  1493. * Gets a new Vector3 from current Vector3 floored values
  1494. * @returns a new Vector3
  1495. */
  1496. floor(): Vector3;
  1497. /**
  1498. * Gets a new Vector3 from current Vector3 floored values
  1499. * @returns a new Vector3
  1500. */
  1501. fract(): Vector3;
  1502. /**
  1503. * Gets the length of the Vector3
  1504. * @returns the length of the Vecto3
  1505. */
  1506. length(): number;
  1507. /**
  1508. * Gets the squared length of the Vector3
  1509. * @returns squared length of the Vector3
  1510. */
  1511. lengthSquared(): number;
  1512. /**
  1513. * Normalize the current Vector3.
  1514. * Please note that this is an in place operation.
  1515. * @returns the current updated Vector3
  1516. */
  1517. normalize(): Vector3;
  1518. /**
  1519. * Reorders the x y z properties of the vector in place
  1520. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  1521. * @returns the current updated vector
  1522. */
  1523. reorderInPlace(order: string): this;
  1524. /**
  1525. * Rotates the vector around 0,0,0 by a quaternion
  1526. * @param quaternion the rotation quaternion
  1527. * @param result vector to store the result
  1528. * @returns the resulting vector
  1529. */
  1530. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  1531. /**
  1532. * Rotates a vector around a given point
  1533. * @param quaternion the rotation quaternion
  1534. * @param point the point to rotate around
  1535. * @param result vector to store the result
  1536. * @returns the resulting vector
  1537. */
  1538. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  1539. /**
  1540. * Normalize the current Vector3 with the given input length.
  1541. * Please note that this is an in place operation.
  1542. * @param len the length of the vector
  1543. * @returns the current updated Vector3
  1544. */
  1545. normalizeFromLength(len: number): Vector3;
  1546. /**
  1547. * Normalize the current Vector3 to a new vector
  1548. * @returns the new Vector3
  1549. */
  1550. normalizeToNew(): Vector3;
  1551. /**
  1552. * Normalize the current Vector3 to the reference
  1553. * @param reference define the Vector3 to update
  1554. * @returns the updated Vector3
  1555. */
  1556. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  1557. /**
  1558. * Creates a new Vector3 copied from the current Vector3
  1559. * @returns the new Vector3
  1560. */
  1561. clone(): Vector3;
  1562. /**
  1563. * Copies the given vector coordinates to the current Vector3 ones
  1564. * @param source defines the source Vector3
  1565. * @returns the current updated Vector3
  1566. */
  1567. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  1568. /**
  1569. * Copies the given floats to the current Vector3 coordinates
  1570. * @param x defines the x coordinate of the operand
  1571. * @param y defines the y coordinate of the operand
  1572. * @param z defines the z coordinate of the operand
  1573. * @returns the current updated Vector3
  1574. */
  1575. copyFromFloats(x: number, y: number, z: number): Vector3;
  1576. /**
  1577. * Copies the given floats to the current Vector3 coordinates
  1578. * @param x defines the x coordinate of the operand
  1579. * @param y defines the y coordinate of the operand
  1580. * @param z defines the z coordinate of the operand
  1581. * @returns the current updated Vector3
  1582. */
  1583. set(x: number, y: number, z: number): Vector3;
  1584. /**
  1585. * Copies the given float to the current Vector3 coordinates
  1586. * @param v defines the x, y and z coordinates of the operand
  1587. * @returns the current updated Vector3
  1588. */
  1589. setAll(v: number): Vector3;
  1590. /**
  1591. * Get the clip factor between two vectors
  1592. * @param vector0 defines the first operand
  1593. * @param vector1 defines the second operand
  1594. * @param axis defines the axis to use
  1595. * @param size defines the size along the axis
  1596. * @returns the clip factor
  1597. */
  1598. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  1599. /**
  1600. * Get angle between two vectors
  1601. * @param vector0 angle between vector0 and vector1
  1602. * @param vector1 angle between vector0 and vector1
  1603. * @param normal direction of the normal
  1604. * @return the angle between vector0 and vector1
  1605. */
  1606. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  1607. /**
  1608. * Returns a new Vector3 set from the index "offset" of the given array
  1609. * @param array defines the source array
  1610. * @param offset defines the offset in the source array
  1611. * @returns the new Vector3
  1612. */
  1613. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  1614. /**
  1615. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  1616. * This function is deprecated. Use FromArray instead
  1617. * @param array defines the source array
  1618. * @param offset defines the offset in the source array
  1619. * @returns the new Vector3
  1620. */
  1621. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  1622. /**
  1623. * Sets the given vector "result" with the element values from the index "offset" of the given array
  1624. * @param array defines the source array
  1625. * @param offset defines the offset in the source array
  1626. * @param result defines the Vector3 where to store the result
  1627. */
  1628. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  1629. /**
  1630. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  1631. * This function is deprecated. Use FromArrayToRef instead.
  1632. * @param array defines the source array
  1633. * @param offset defines the offset in the source array
  1634. * @param result defines the Vector3 where to store the result
  1635. */
  1636. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  1637. /**
  1638. * Sets the given vector "result" with the given floats.
  1639. * @param x defines the x coordinate of the source
  1640. * @param y defines the y coordinate of the source
  1641. * @param z defines the z coordinate of the source
  1642. * @param result defines the Vector3 where to store the result
  1643. */
  1644. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  1645. /**
  1646. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  1647. * @returns a new empty Vector3
  1648. */
  1649. static Zero(): Vector3;
  1650. /**
  1651. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  1652. * @returns a new unit Vector3
  1653. */
  1654. static One(): Vector3;
  1655. /**
  1656. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  1657. * @returns a new up Vector3
  1658. */
  1659. static Up(): Vector3;
  1660. /**
  1661. * Gets a up Vector3 that must not be updated
  1662. */
  1663. static readonly UpReadOnly: DeepImmutable<Vector3>;
  1664. /**
  1665. * Gets a zero Vector3 that must not be updated
  1666. */
  1667. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  1668. /**
  1669. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  1670. * @returns a new down Vector3
  1671. */
  1672. static Down(): Vector3;
  1673. /**
  1674. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  1675. * @returns a new forward Vector3
  1676. */
  1677. static Forward(): Vector3;
  1678. /**
  1679. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  1680. * @returns a new forward Vector3
  1681. */
  1682. static Backward(): Vector3;
  1683. /**
  1684. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  1685. * @returns a new right Vector3
  1686. */
  1687. static Right(): Vector3;
  1688. /**
  1689. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  1690. * @returns a new left Vector3
  1691. */
  1692. static Left(): Vector3;
  1693. /**
  1694. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  1695. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1696. * @param vector defines the Vector3 to transform
  1697. * @param transformation defines the transformation matrix
  1698. * @returns the transformed Vector3
  1699. */
  1700. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1701. /**
  1702. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  1703. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1704. * @param vector defines the Vector3 to transform
  1705. * @param transformation defines the transformation matrix
  1706. * @param result defines the Vector3 where to store the result
  1707. */
  1708. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1709. /**
  1710. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  1711. * This method computes tranformed coordinates only, not transformed direction vectors
  1712. * @param x define the x coordinate of the source vector
  1713. * @param y define the y coordinate of the source vector
  1714. * @param z define the z coordinate of the source vector
  1715. * @param transformation defines the transformation matrix
  1716. * @param result defines the Vector3 where to store the result
  1717. */
  1718. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1719. /**
  1720. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  1721. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1722. * @param vector defines the Vector3 to transform
  1723. * @param transformation defines the transformation matrix
  1724. * @returns the new Vector3
  1725. */
  1726. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1727. /**
  1728. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  1729. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1730. * @param vector defines the Vector3 to transform
  1731. * @param transformation defines the transformation matrix
  1732. * @param result defines the Vector3 where to store the result
  1733. */
  1734. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1735. /**
  1736. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  1737. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1738. * @param x define the x coordinate of the source vector
  1739. * @param y define the y coordinate of the source vector
  1740. * @param z define the z coordinate of the source vector
  1741. * @param transformation defines the transformation matrix
  1742. * @param result defines the Vector3 where to store the result
  1743. */
  1744. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1745. /**
  1746. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  1747. * @param value1 defines the first control point
  1748. * @param value2 defines the second control point
  1749. * @param value3 defines the third control point
  1750. * @param value4 defines the fourth control point
  1751. * @param amount defines the amount on the spline to use
  1752. * @returns the new Vector3
  1753. */
  1754. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  1755. /**
  1756. * Returns a new Vector3 set with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  1757. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1758. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1759. * @param value defines the current value
  1760. * @param min defines the lower range value
  1761. * @param max defines the upper range value
  1762. * @returns the new Vector3
  1763. */
  1764. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  1765. /**
  1766. * Sets the given vector "result" with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  1767. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1768. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1769. * @param value defines the current value
  1770. * @param min defines the lower range value
  1771. * @param max defines the upper range value
  1772. * @param result defines the Vector3 where to store the result
  1773. */
  1774. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  1775. /**
  1776. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  1777. * @param value1 defines the first control point
  1778. * @param tangent1 defines the first tangent vector
  1779. * @param value2 defines the second control point
  1780. * @param tangent2 defines the second tangent vector
  1781. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  1782. * @returns the new Vector3
  1783. */
  1784. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  1785. /**
  1786. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  1787. * @param start defines the start value
  1788. * @param end defines the end value
  1789. * @param amount max defines amount between both (between 0 and 1)
  1790. * @returns the new Vector3
  1791. */
  1792. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  1793. /**
  1794. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  1795. * @param start defines the start value
  1796. * @param end defines the end value
  1797. * @param amount max defines amount between both (between 0 and 1)
  1798. * @param result defines the Vector3 where to store the result
  1799. */
  1800. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  1801. /**
  1802. * Returns the dot product (float) between the vectors "left" and "right"
  1803. * @param left defines the left operand
  1804. * @param right defines the right operand
  1805. * @returns the dot product
  1806. */
  1807. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  1808. /**
  1809. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  1810. * The cross product is then orthogonal to both "left" and "right"
  1811. * @param left defines the left operand
  1812. * @param right defines the right operand
  1813. * @returns the cross product
  1814. */
  1815. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1816. /**
  1817. * Sets the given vector "result" with the cross product of "left" and "right"
  1818. * The cross product is then orthogonal to both "left" and "right"
  1819. * @param left defines the left operand
  1820. * @param right defines the right operand
  1821. * @param result defines the Vector3 where to store the result
  1822. */
  1823. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  1824. /**
  1825. * Returns a new Vector3 as the normalization of the given vector
  1826. * @param vector defines the Vector3 to normalize
  1827. * @returns the new Vector3
  1828. */
  1829. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  1830. /**
  1831. * Sets the given vector "result" with the normalization of the given first vector
  1832. * @param vector defines the Vector3 to normalize
  1833. * @param result defines the Vector3 where to store the result
  1834. */
  1835. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  1836. /**
  1837. * Project a Vector3 onto screen space
  1838. * @param vector defines the Vector3 to project
  1839. * @param world defines the world matrix to use
  1840. * @param transform defines the transform (view x projection) matrix to use
  1841. * @param viewport defines the screen viewport to use
  1842. * @returns the new Vector3
  1843. */
  1844. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  1845. /** @hidden */
  1846. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  1847. /**
  1848. * Unproject from screen space to object space
  1849. * @param source defines the screen space Vector3 to use
  1850. * @param viewportWidth defines the current width of the viewport
  1851. * @param viewportHeight defines the current height of the viewport
  1852. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1853. * @param transform defines the transform (view x projection) matrix to use
  1854. * @returns the new Vector3
  1855. */
  1856. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  1857. /**
  1858. * Unproject from screen space to object space
  1859. * @param source defines the screen space Vector3 to use
  1860. * @param viewportWidth defines the current width of the viewport
  1861. * @param viewportHeight defines the current height of the viewport
  1862. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1863. * @param view defines the view matrix to use
  1864. * @param projection defines the projection matrix to use
  1865. * @returns the new Vector3
  1866. */
  1867. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  1868. /**
  1869. * Unproject from screen space to object space
  1870. * @param source defines the screen space Vector3 to use
  1871. * @param viewportWidth defines the current width of the viewport
  1872. * @param viewportHeight defines the current height of the viewport
  1873. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1874. * @param view defines the view matrix to use
  1875. * @param projection defines the projection matrix to use
  1876. * @param result defines the Vector3 where to store the result
  1877. */
  1878. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1879. /**
  1880. * Unproject from screen space to object space
  1881. * @param sourceX defines the screen space x coordinate to use
  1882. * @param sourceY defines the screen space y coordinate to use
  1883. * @param sourceZ defines the screen space z coordinate to use
  1884. * @param viewportWidth defines the current width of the viewport
  1885. * @param viewportHeight defines the current height of the viewport
  1886. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1887. * @param view defines the view matrix to use
  1888. * @param projection defines the projection matrix to use
  1889. * @param result defines the Vector3 where to store the result
  1890. */
  1891. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1892. /**
  1893. * Gets the minimal coordinate values between two Vector3
  1894. * @param left defines the first operand
  1895. * @param right defines the second operand
  1896. * @returns the new Vector3
  1897. */
  1898. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1899. /**
  1900. * Gets the maximal coordinate values between two Vector3
  1901. * @param left defines the first operand
  1902. * @param right defines the second operand
  1903. * @returns the new Vector3
  1904. */
  1905. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1906. /**
  1907. * Returns the distance between the vectors "value1" and "value2"
  1908. * @param value1 defines the first operand
  1909. * @param value2 defines the second operand
  1910. * @returns the distance
  1911. */
  1912. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1913. /**
  1914. * Returns the squared distance between the vectors "value1" and "value2"
  1915. * @param value1 defines the first operand
  1916. * @param value2 defines the second operand
  1917. * @returns the squared distance
  1918. */
  1919. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1920. /**
  1921. * Returns a new Vector3 located at the center between "value1" and "value2"
  1922. * @param value1 defines the first operand
  1923. * @param value2 defines the second operand
  1924. * @returns the new Vector3
  1925. */
  1926. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  1927. /**
  1928. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  1929. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  1930. * to something in order to rotate it from its local system to the given target system
  1931. * Note: axis1, axis2 and axis3 are normalized during this operation
  1932. * @param axis1 defines the first axis
  1933. * @param axis2 defines the second axis
  1934. * @param axis3 defines the third axis
  1935. * @returns a new Vector3
  1936. */
  1937. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  1938. /**
  1939. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  1940. * @param axis1 defines the first axis
  1941. * @param axis2 defines the second axis
  1942. * @param axis3 defines the third axis
  1943. * @param ref defines the Vector3 where to store the result
  1944. */
  1945. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  1946. }
  1947. /**
  1948. * Vector4 class created for EulerAngle class conversion to Quaternion
  1949. */
  1950. export class Vector4 {
  1951. /** x value of the vector */
  1952. x: number;
  1953. /** y value of the vector */
  1954. y: number;
  1955. /** z value of the vector */
  1956. z: number;
  1957. /** w value of the vector */
  1958. w: number;
  1959. /**
  1960. * Creates a Vector4 object from the given floats.
  1961. * @param x x value of the vector
  1962. * @param y y value of the vector
  1963. * @param z z value of the vector
  1964. * @param w w value of the vector
  1965. */
  1966. constructor(
  1967. /** x value of the vector */
  1968. x: number,
  1969. /** y value of the vector */
  1970. y: number,
  1971. /** z value of the vector */
  1972. z: number,
  1973. /** w value of the vector */
  1974. w: number);
  1975. /**
  1976. * Returns the string with the Vector4 coordinates.
  1977. * @returns a string containing all the vector values
  1978. */
  1979. toString(): string;
  1980. /**
  1981. * Returns the string "Vector4".
  1982. * @returns "Vector4"
  1983. */
  1984. getClassName(): string;
  1985. /**
  1986. * Returns the Vector4 hash code.
  1987. * @returns a unique hash code
  1988. */
  1989. getHashCode(): number;
  1990. /**
  1991. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  1992. * @returns the resulting array
  1993. */
  1994. asArray(): number[];
  1995. /**
  1996. * Populates the given array from the given index with the Vector4 coordinates.
  1997. * @param array array to populate
  1998. * @param index index of the array to start at (default: 0)
  1999. * @returns the Vector4.
  2000. */
  2001. toArray(array: FloatArray, index?: number): Vector4;
  2002. /**
  2003. * Adds the given vector to the current Vector4.
  2004. * @param otherVector the vector to add
  2005. * @returns the updated Vector4.
  2006. */
  2007. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2008. /**
  2009. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  2010. * @param otherVector the vector to add
  2011. * @returns the resulting vector
  2012. */
  2013. add(otherVector: DeepImmutable<Vector4>): Vector4;
  2014. /**
  2015. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  2016. * @param otherVector the vector to add
  2017. * @param result the vector to store the result
  2018. * @returns the current Vector4.
  2019. */
  2020. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2021. /**
  2022. * Subtract in place the given vector from the current Vector4.
  2023. * @param otherVector the vector to subtract
  2024. * @returns the updated Vector4.
  2025. */
  2026. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2027. /**
  2028. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  2029. * @param otherVector the vector to add
  2030. * @returns the new vector with the result
  2031. */
  2032. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  2033. /**
  2034. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  2035. * @param otherVector the vector to subtract
  2036. * @param result the vector to store the result
  2037. * @returns the current Vector4.
  2038. */
  2039. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2040. /**
  2041. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2042. */
  2043. /**
  2044. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2045. * @param x value to subtract
  2046. * @param y value to subtract
  2047. * @param z value to subtract
  2048. * @param w value to subtract
  2049. * @returns new vector containing the result
  2050. */
  2051. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2052. /**
  2053. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2054. * @param x value to subtract
  2055. * @param y value to subtract
  2056. * @param z value to subtract
  2057. * @param w value to subtract
  2058. * @param result the vector to store the result in
  2059. * @returns the current Vector4.
  2060. */
  2061. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  2062. /**
  2063. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  2064. * @returns a new vector with the negated values
  2065. */
  2066. negate(): Vector4;
  2067. /**
  2068. * Multiplies the current Vector4 coordinates by scale (float).
  2069. * @param scale the number to scale with
  2070. * @returns the updated Vector4.
  2071. */
  2072. scaleInPlace(scale: number): Vector4;
  2073. /**
  2074. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  2075. * @param scale the number to scale with
  2076. * @returns a new vector with the result
  2077. */
  2078. scale(scale: number): Vector4;
  2079. /**
  2080. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  2081. * @param scale the number to scale with
  2082. * @param result a vector to store the result in
  2083. * @returns the current Vector4.
  2084. */
  2085. scaleToRef(scale: number, result: Vector4): Vector4;
  2086. /**
  2087. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  2088. * @param scale defines the scale factor
  2089. * @param result defines the Vector4 object where to store the result
  2090. * @returns the unmodified current Vector4
  2091. */
  2092. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  2093. /**
  2094. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  2095. * @param otherVector the vector to compare against
  2096. * @returns true if they are equal
  2097. */
  2098. equals(otherVector: DeepImmutable<Vector4>): boolean;
  2099. /**
  2100. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  2101. * @param otherVector vector to compare against
  2102. * @param epsilon (Default: very small number)
  2103. * @returns true if they are equal
  2104. */
  2105. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  2106. /**
  2107. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  2108. * @param x x value to compare against
  2109. * @param y y value to compare against
  2110. * @param z z value to compare against
  2111. * @param w w value to compare against
  2112. * @returns true if equal
  2113. */
  2114. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  2115. /**
  2116. * Multiplies in place the current Vector4 by the given one.
  2117. * @param otherVector vector to multiple with
  2118. * @returns the updated Vector4.
  2119. */
  2120. multiplyInPlace(otherVector: Vector4): Vector4;
  2121. /**
  2122. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  2123. * @param otherVector vector to multiple with
  2124. * @returns resulting new vector
  2125. */
  2126. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  2127. /**
  2128. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  2129. * @param otherVector vector to multiple with
  2130. * @param result vector to store the result
  2131. * @returns the current Vector4.
  2132. */
  2133. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2134. /**
  2135. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  2136. * @param x x value multiply with
  2137. * @param y y value multiply with
  2138. * @param z z value multiply with
  2139. * @param w w value multiply with
  2140. * @returns resulting new vector
  2141. */
  2142. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  2143. /**
  2144. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  2145. * @param otherVector vector to devide with
  2146. * @returns resulting new vector
  2147. */
  2148. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  2149. /**
  2150. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  2151. * @param otherVector vector to devide with
  2152. * @param result vector to store the result
  2153. * @returns the current Vector4.
  2154. */
  2155. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2156. /**
  2157. * Divides the current Vector3 coordinates by the given ones.
  2158. * @param otherVector vector to devide with
  2159. * @returns the updated Vector3.
  2160. */
  2161. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2162. /**
  2163. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  2164. * @param other defines the second operand
  2165. * @returns the current updated Vector4
  2166. */
  2167. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2168. /**
  2169. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  2170. * @param other defines the second operand
  2171. * @returns the current updated Vector4
  2172. */
  2173. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2174. /**
  2175. * Gets a new Vector4 from current Vector4 floored values
  2176. * @returns a new Vector4
  2177. */
  2178. floor(): Vector4;
  2179. /**
  2180. * Gets a new Vector4 from current Vector3 floored values
  2181. * @returns a new Vector4
  2182. */
  2183. fract(): Vector4;
  2184. /**
  2185. * Returns the Vector4 length (float).
  2186. * @returns the length
  2187. */
  2188. length(): number;
  2189. /**
  2190. * Returns the Vector4 squared length (float).
  2191. * @returns the length squared
  2192. */
  2193. lengthSquared(): number;
  2194. /**
  2195. * Normalizes in place the Vector4.
  2196. * @returns the updated Vector4.
  2197. */
  2198. normalize(): Vector4;
  2199. /**
  2200. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  2201. * @returns this converted to a new vector3
  2202. */
  2203. toVector3(): Vector3;
  2204. /**
  2205. * Returns a new Vector4 copied from the current one.
  2206. * @returns the new cloned vector
  2207. */
  2208. clone(): Vector4;
  2209. /**
  2210. * Updates the current Vector4 with the given one coordinates.
  2211. * @param source the source vector to copy from
  2212. * @returns the updated Vector4.
  2213. */
  2214. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  2215. /**
  2216. * Updates the current Vector4 coordinates with the given floats.
  2217. * @param x float to copy from
  2218. * @param y float to copy from
  2219. * @param z float to copy from
  2220. * @param w float to copy from
  2221. * @returns the updated Vector4.
  2222. */
  2223. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2224. /**
  2225. * Updates the current Vector4 coordinates with the given floats.
  2226. * @param x float to set from
  2227. * @param y float to set from
  2228. * @param z float to set from
  2229. * @param w float to set from
  2230. * @returns the updated Vector4.
  2231. */
  2232. set(x: number, y: number, z: number, w: number): Vector4;
  2233. /**
  2234. * Copies the given float to the current Vector3 coordinates
  2235. * @param v defines the x, y, z and w coordinates of the operand
  2236. * @returns the current updated Vector3
  2237. */
  2238. setAll(v: number): Vector4;
  2239. /**
  2240. * Returns a new Vector4 set from the starting index of the given array.
  2241. * @param array the array to pull values from
  2242. * @param offset the offset into the array to start at
  2243. * @returns the new vector
  2244. */
  2245. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  2246. /**
  2247. * Updates the given vector "result" from the starting index of the given array.
  2248. * @param array the array to pull values from
  2249. * @param offset the offset into the array to start at
  2250. * @param result the vector to store the result in
  2251. */
  2252. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  2253. /**
  2254. * Updates the given vector "result" from the starting index of the given Float32Array.
  2255. * @param array the array to pull values from
  2256. * @param offset the offset into the array to start at
  2257. * @param result the vector to store the result in
  2258. */
  2259. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  2260. /**
  2261. * Updates the given vector "result" coordinates from the given floats.
  2262. * @param x float to set from
  2263. * @param y float to set from
  2264. * @param z float to set from
  2265. * @param w float to set from
  2266. * @param result the vector to the floats in
  2267. */
  2268. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  2269. /**
  2270. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  2271. * @returns the new vector
  2272. */
  2273. static Zero(): Vector4;
  2274. /**
  2275. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  2276. * @returns the new vector
  2277. */
  2278. static One(): Vector4;
  2279. /**
  2280. * Returns a new normalized Vector4 from the given one.
  2281. * @param vector the vector to normalize
  2282. * @returns the vector
  2283. */
  2284. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  2285. /**
  2286. * Updates the given vector "result" from the normalization of the given one.
  2287. * @param vector the vector to normalize
  2288. * @param result the vector to store the result in
  2289. */
  2290. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  2291. /**
  2292. * Returns a vector with the minimum values from the left and right vectors
  2293. * @param left left vector to minimize
  2294. * @param right right vector to minimize
  2295. * @returns a new vector with the minimum of the left and right vector values
  2296. */
  2297. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2298. /**
  2299. * Returns a vector with the maximum values from the left and right vectors
  2300. * @param left left vector to maximize
  2301. * @param right right vector to maximize
  2302. * @returns a new vector with the maximum of the left and right vector values
  2303. */
  2304. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2305. /**
  2306. * Returns the distance (float) between the vectors "value1" and "value2".
  2307. * @param value1 value to calulate the distance between
  2308. * @param value2 value to calulate the distance between
  2309. * @return the distance between the two vectors
  2310. */
  2311. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2312. /**
  2313. * Returns the squared distance (float) between the vectors "value1" and "value2".
  2314. * @param value1 value to calulate the distance between
  2315. * @param value2 value to calulate the distance between
  2316. * @return the distance between the two vectors squared
  2317. */
  2318. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2319. /**
  2320. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  2321. * @param value1 value to calulate the center between
  2322. * @param value2 value to calulate the center between
  2323. * @return the center between the two vectors
  2324. */
  2325. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  2326. /**
  2327. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  2328. * This methods computes transformed normalized direction vectors only.
  2329. * @param vector the vector to transform
  2330. * @param transformation the transformation matrix to apply
  2331. * @returns the new vector
  2332. */
  2333. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  2334. /**
  2335. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  2336. * This methods computes transformed normalized direction vectors only.
  2337. * @param vector the vector to transform
  2338. * @param transformation the transformation matrix to apply
  2339. * @param result the vector to store the result in
  2340. */
  2341. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2342. /**
  2343. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  2344. * This methods computes transformed normalized direction vectors only.
  2345. * @param x value to transform
  2346. * @param y value to transform
  2347. * @param z value to transform
  2348. * @param w value to transform
  2349. * @param transformation the transformation matrix to apply
  2350. * @param result the vector to store the results in
  2351. */
  2352. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2353. /**
  2354. * Creates a new Vector4 from a Vector3
  2355. * @param source defines the source data
  2356. * @param w defines the 4th component (default is 0)
  2357. * @returns a new Vector4
  2358. */
  2359. static FromVector3(source: Vector3, w?: number): Vector4;
  2360. }
  2361. /**
  2362. * Interface for the size containing width and height
  2363. */
  2364. export interface ISize {
  2365. /**
  2366. * Width
  2367. */
  2368. width: number;
  2369. /**
  2370. * Heighht
  2371. */
  2372. height: number;
  2373. }
  2374. /**
  2375. * Size containing widht and height
  2376. */
  2377. export class Size implements ISize {
  2378. /**
  2379. * Width
  2380. */
  2381. width: number;
  2382. /**
  2383. * Height
  2384. */
  2385. height: number;
  2386. /**
  2387. * Creates a Size object from the given width and height (floats).
  2388. * @param width width of the new size
  2389. * @param height height of the new size
  2390. */
  2391. constructor(width: number, height: number);
  2392. /**
  2393. * Returns a string with the Size width and height
  2394. * @returns a string with the Size width and height
  2395. */
  2396. toString(): string;
  2397. /**
  2398. * "Size"
  2399. * @returns the string "Size"
  2400. */
  2401. getClassName(): string;
  2402. /**
  2403. * Returns the Size hash code.
  2404. * @returns a hash code for a unique width and height
  2405. */
  2406. getHashCode(): number;
  2407. /**
  2408. * Updates the current size from the given one.
  2409. * @param src the given size
  2410. */
  2411. copyFrom(src: Size): void;
  2412. /**
  2413. * Updates in place the current Size from the given floats.
  2414. * @param width width of the new size
  2415. * @param height height of the new size
  2416. * @returns the updated Size.
  2417. */
  2418. copyFromFloats(width: number, height: number): Size;
  2419. /**
  2420. * Updates in place the current Size from the given floats.
  2421. * @param width width to set
  2422. * @param height height to set
  2423. * @returns the updated Size.
  2424. */
  2425. set(width: number, height: number): Size;
  2426. /**
  2427. * Multiplies the width and height by numbers
  2428. * @param w factor to multiple the width by
  2429. * @param h factor to multiple the height by
  2430. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  2431. */
  2432. multiplyByFloats(w: number, h: number): Size;
  2433. /**
  2434. * Clones the size
  2435. * @returns a new Size copied from the given one.
  2436. */
  2437. clone(): Size;
  2438. /**
  2439. * True if the current Size and the given one width and height are strictly equal.
  2440. * @param other the other size to compare against
  2441. * @returns True if the current Size and the given one width and height are strictly equal.
  2442. */
  2443. equals(other: Size): boolean;
  2444. /**
  2445. * The surface of the Size : width * height (float).
  2446. */
  2447. readonly surface: number;
  2448. /**
  2449. * Create a new size of zero
  2450. * @returns a new Size set to (0.0, 0.0)
  2451. */
  2452. static Zero(): Size;
  2453. /**
  2454. * Sums the width and height of two sizes
  2455. * @param otherSize size to add to this size
  2456. * @returns a new Size set as the addition result of the current Size and the given one.
  2457. */
  2458. add(otherSize: Size): Size;
  2459. /**
  2460. * Subtracts the width and height of two
  2461. * @param otherSize size to subtract to this size
  2462. * @returns a new Size set as the subtraction result of the given one from the current Size.
  2463. */
  2464. subtract(otherSize: Size): Size;
  2465. /**
  2466. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  2467. * @param start starting size to lerp between
  2468. * @param end end size to lerp between
  2469. * @param amount amount to lerp between the start and end values
  2470. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  2471. */
  2472. static Lerp(start: Size, end: Size, amount: number): Size;
  2473. }
  2474. /**
  2475. * Class used to store quaternion data
  2476. * @see https://en.wikipedia.org/wiki/Quaternion
  2477. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  2478. */
  2479. export class Quaternion {
  2480. /** defines the first component (0 by default) */
  2481. x: number;
  2482. /** defines the second component (0 by default) */
  2483. y: number;
  2484. /** defines the third component (0 by default) */
  2485. z: number;
  2486. /** defines the fourth component (1.0 by default) */
  2487. w: number;
  2488. /**
  2489. * Creates a new Quaternion from the given floats
  2490. * @param x defines the first component (0 by default)
  2491. * @param y defines the second component (0 by default)
  2492. * @param z defines the third component (0 by default)
  2493. * @param w defines the fourth component (1.0 by default)
  2494. */
  2495. constructor(
  2496. /** defines the first component (0 by default) */
  2497. x?: number,
  2498. /** defines the second component (0 by default) */
  2499. y?: number,
  2500. /** defines the third component (0 by default) */
  2501. z?: number,
  2502. /** defines the fourth component (1.0 by default) */
  2503. w?: number);
  2504. /**
  2505. * Gets a string representation for the current quaternion
  2506. * @returns a string with the Quaternion coordinates
  2507. */
  2508. toString(): string;
  2509. /**
  2510. * Gets the class name of the quaternion
  2511. * @returns the string "Quaternion"
  2512. */
  2513. getClassName(): string;
  2514. /**
  2515. * Gets a hash code for this quaternion
  2516. * @returns the quaternion hash code
  2517. */
  2518. getHashCode(): number;
  2519. /**
  2520. * Copy the quaternion to an array
  2521. * @returns a new array populated with 4 elements from the quaternion coordinates
  2522. */
  2523. asArray(): number[];
  2524. /**
  2525. * Check if two quaternions are equals
  2526. * @param otherQuaternion defines the second operand
  2527. * @return true if the current quaternion and the given one coordinates are strictly equals
  2528. */
  2529. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  2530. /**
  2531. * Clone the current quaternion
  2532. * @returns a new quaternion copied from the current one
  2533. */
  2534. clone(): Quaternion;
  2535. /**
  2536. * Copy a quaternion to the current one
  2537. * @param other defines the other quaternion
  2538. * @returns the updated current quaternion
  2539. */
  2540. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  2541. /**
  2542. * Updates the current quaternion with the given float coordinates
  2543. * @param x defines the x coordinate
  2544. * @param y defines the y coordinate
  2545. * @param z defines the z coordinate
  2546. * @param w defines the w coordinate
  2547. * @returns the updated current quaternion
  2548. */
  2549. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  2550. /**
  2551. * Updates the current quaternion from the given float coordinates
  2552. * @param x defines the x coordinate
  2553. * @param y defines the y coordinate
  2554. * @param z defines the z coordinate
  2555. * @param w defines the w coordinate
  2556. * @returns the updated current quaternion
  2557. */
  2558. set(x: number, y: number, z: number, w: number): Quaternion;
  2559. /**
  2560. * Adds two quaternions
  2561. * @param other defines the second operand
  2562. * @returns a new quaternion as the addition result of the given one and the current quaternion
  2563. */
  2564. add(other: DeepImmutable<Quaternion>): Quaternion;
  2565. /**
  2566. * Add a quaternion to the current one
  2567. * @param other defines the quaternion to add
  2568. * @returns the current quaternion
  2569. */
  2570. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  2571. /**
  2572. * Subtract two quaternions
  2573. * @param other defines the second operand
  2574. * @returns a new quaternion as the subtraction result of the given one from the current one
  2575. */
  2576. subtract(other: Quaternion): Quaternion;
  2577. /**
  2578. * Multiplies the current quaternion by a scale factor
  2579. * @param value defines the scale factor
  2580. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  2581. */
  2582. scale(value: number): Quaternion;
  2583. /**
  2584. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  2585. * @param scale defines the scale factor
  2586. * @param result defines the Quaternion object where to store the result
  2587. * @returns the unmodified current quaternion
  2588. */
  2589. scaleToRef(scale: number, result: Quaternion): Quaternion;
  2590. /**
  2591. * Multiplies in place the current quaternion by a scale factor
  2592. * @param value defines the scale factor
  2593. * @returns the current modified quaternion
  2594. */
  2595. scaleInPlace(value: number): Quaternion;
  2596. /**
  2597. * Scale the current quaternion values by a factor and add the result to a given quaternion
  2598. * @param scale defines the scale factor
  2599. * @param result defines the Quaternion object where to store the result
  2600. * @returns the unmodified current quaternion
  2601. */
  2602. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  2603. /**
  2604. * Multiplies two quaternions
  2605. * @param q1 defines the second operand
  2606. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  2607. */
  2608. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  2609. /**
  2610. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  2611. * @param q1 defines the second operand
  2612. * @param result defines the target quaternion
  2613. * @returns the current quaternion
  2614. */
  2615. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  2616. /**
  2617. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  2618. * @param q1 defines the second operand
  2619. * @returns the currentupdated quaternion
  2620. */
  2621. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  2622. /**
  2623. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  2624. * @param ref defines the target quaternion
  2625. * @returns the current quaternion
  2626. */
  2627. conjugateToRef(ref: Quaternion): Quaternion;
  2628. /**
  2629. * Conjugates in place (1-q) the current quaternion
  2630. * @returns the current updated quaternion
  2631. */
  2632. conjugateInPlace(): Quaternion;
  2633. /**
  2634. * Conjugates in place (1-q) the current quaternion
  2635. * @returns a new quaternion
  2636. */
  2637. conjugate(): Quaternion;
  2638. /**
  2639. * Gets length of current quaternion
  2640. * @returns the quaternion length (float)
  2641. */
  2642. length(): number;
  2643. /**
  2644. * Normalize in place the current quaternion
  2645. * @returns the current updated quaternion
  2646. */
  2647. normalize(): Quaternion;
  2648. /**
  2649. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  2650. * @param order is a reserved parameter and is ignore for now
  2651. * @returns a new Vector3 containing the Euler angles
  2652. */
  2653. toEulerAngles(order?: string): Vector3;
  2654. /**
  2655. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  2656. * @param result defines the vector which will be filled with the Euler angles
  2657. * @param order is a reserved parameter and is ignore for now
  2658. * @returns the current unchanged quaternion
  2659. */
  2660. toEulerAnglesToRef(result: Vector3): Quaternion;
  2661. /**
  2662. * Updates the given rotation matrix with the current quaternion values
  2663. * @param result defines the target matrix
  2664. * @returns the current unchanged quaternion
  2665. */
  2666. toRotationMatrix(result: Matrix): Quaternion;
  2667. /**
  2668. * Updates the current quaternion from the given rotation matrix values
  2669. * @param matrix defines the source matrix
  2670. * @returns the current updated quaternion
  2671. */
  2672. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2673. /**
  2674. * Creates a new quaternion from a rotation matrix
  2675. * @param matrix defines the source matrix
  2676. * @returns a new quaternion created from the given rotation matrix values
  2677. */
  2678. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2679. /**
  2680. * Updates the given quaternion with the given rotation matrix values
  2681. * @param matrix defines the source matrix
  2682. * @param result defines the target quaternion
  2683. */
  2684. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  2685. /**
  2686. * Returns the dot product (float) between the quaternions "left" and "right"
  2687. * @param left defines the left operand
  2688. * @param right defines the right operand
  2689. * @returns the dot product
  2690. */
  2691. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  2692. /**
  2693. * Checks if the two quaternions are close to each other
  2694. * @param quat0 defines the first quaternion to check
  2695. * @param quat1 defines the second quaternion to check
  2696. * @returns true if the two quaternions are close to each other
  2697. */
  2698. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  2699. /**
  2700. * Creates an empty quaternion
  2701. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  2702. */
  2703. static Zero(): Quaternion;
  2704. /**
  2705. * Inverse a given quaternion
  2706. * @param q defines the source quaternion
  2707. * @returns a new quaternion as the inverted current quaternion
  2708. */
  2709. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  2710. /**
  2711. * Inverse a given quaternion
  2712. * @param q defines the source quaternion
  2713. * @param result the quaternion the result will be stored in
  2714. * @returns the result quaternion
  2715. */
  2716. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  2717. /**
  2718. * Creates an identity quaternion
  2719. * @returns the identity quaternion
  2720. */
  2721. static Identity(): Quaternion;
  2722. /**
  2723. * Gets a boolean indicating if the given quaternion is identity
  2724. * @param quaternion defines the quaternion to check
  2725. * @returns true if the quaternion is identity
  2726. */
  2727. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  2728. /**
  2729. * Creates a quaternion from a rotation around an axis
  2730. * @param axis defines the axis to use
  2731. * @param angle defines the angle to use
  2732. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  2733. */
  2734. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  2735. /**
  2736. * Creates a rotation around an axis and stores it into the given quaternion
  2737. * @param axis defines the axis to use
  2738. * @param angle defines the angle to use
  2739. * @param result defines the target quaternion
  2740. * @returns the target quaternion
  2741. */
  2742. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  2743. /**
  2744. * Creates a new quaternion from data stored into an array
  2745. * @param array defines the data source
  2746. * @param offset defines the offset in the source array where the data starts
  2747. * @returns a new quaternion
  2748. */
  2749. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  2750. /**
  2751. * Create a quaternion from Euler rotation angles
  2752. * @param x Pitch
  2753. * @param y Yaw
  2754. * @param z Roll
  2755. * @returns the new Quaternion
  2756. */
  2757. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  2758. /**
  2759. * Updates a quaternion from Euler rotation angles
  2760. * @param x Pitch
  2761. * @param y Yaw
  2762. * @param z Roll
  2763. * @param result the quaternion to store the result
  2764. * @returns the updated quaternion
  2765. */
  2766. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  2767. /**
  2768. * Create a quaternion from Euler rotation vector
  2769. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2770. * @returns the new Quaternion
  2771. */
  2772. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  2773. /**
  2774. * Updates a quaternion from Euler rotation vector
  2775. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2776. * @param result the quaternion to store the result
  2777. * @returns the updated quaternion
  2778. */
  2779. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  2780. /**
  2781. * Creates a new quaternion from the given Euler float angles (y, x, z)
  2782. * @param yaw defines the rotation around Y axis
  2783. * @param pitch defines the rotation around X axis
  2784. * @param roll defines the rotation around Z axis
  2785. * @returns the new quaternion
  2786. */
  2787. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  2788. /**
  2789. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  2790. * @param yaw defines the rotation around Y axis
  2791. * @param pitch defines the rotation around X axis
  2792. * @param roll defines the rotation around Z axis
  2793. * @param result defines the target quaternion
  2794. */
  2795. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  2796. /**
  2797. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  2798. * @param alpha defines the rotation around first axis
  2799. * @param beta defines the rotation around second axis
  2800. * @param gamma defines the rotation around third axis
  2801. * @returns the new quaternion
  2802. */
  2803. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  2804. /**
  2805. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  2806. * @param alpha defines the rotation around first axis
  2807. * @param beta defines the rotation around second axis
  2808. * @param gamma defines the rotation around third axis
  2809. * @param result defines the target quaternion
  2810. */
  2811. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  2812. /**
  2813. * Creates a new quaternion containing the rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation)
  2814. * @param axis1 defines the first axis
  2815. * @param axis2 defines the second axis
  2816. * @param axis3 defines the third axis
  2817. * @returns the new quaternion
  2818. */
  2819. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  2820. /**
  2821. * Creates a rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation) and stores it in the target quaternion
  2822. * @param axis1 defines the first axis
  2823. * @param axis2 defines the second axis
  2824. * @param axis3 defines the third axis
  2825. * @param ref defines the target quaternion
  2826. */
  2827. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  2828. /**
  2829. * Interpolates between two quaternions
  2830. * @param left defines first quaternion
  2831. * @param right defines second quaternion
  2832. * @param amount defines the gradient to use
  2833. * @returns the new interpolated quaternion
  2834. */
  2835. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2836. /**
  2837. * Interpolates between two quaternions and stores it into a target quaternion
  2838. * @param left defines first quaternion
  2839. * @param right defines second quaternion
  2840. * @param amount defines the gradient to use
  2841. * @param result defines the target quaternion
  2842. */
  2843. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  2844. /**
  2845. * Interpolate between two quaternions using Hermite interpolation
  2846. * @param value1 defines first quaternion
  2847. * @param tangent1 defines the incoming tangent
  2848. * @param value2 defines second quaternion
  2849. * @param tangent2 defines the outgoing tangent
  2850. * @param amount defines the target quaternion
  2851. * @returns the new interpolated quaternion
  2852. */
  2853. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2854. }
  2855. /**
  2856. * Class used to store matrix data (4x4)
  2857. */
  2858. export class Matrix {
  2859. private static _updateFlagSeed;
  2860. private static _identityReadOnly;
  2861. private _isIdentity;
  2862. private _isIdentityDirty;
  2863. private _isIdentity3x2;
  2864. private _isIdentity3x2Dirty;
  2865. /**
  2866. * Gets the update flag of the matrix which is an unique number for the matrix.
  2867. * It will be incremented every time the matrix data change.
  2868. * You can use it to speed the comparison between two versions of the same matrix.
  2869. */
  2870. updateFlag: number;
  2871. private readonly _m;
  2872. /**
  2873. * Gets the internal data of the matrix
  2874. */
  2875. readonly m: DeepImmutable<Float32Array>;
  2876. /** @hidden */
  2877. _markAsUpdated(): void;
  2878. /** @hidden */
  2879. private _updateIdentityStatus;
  2880. /**
  2881. * Creates an empty matrix (filled with zeros)
  2882. */
  2883. constructor();
  2884. /**
  2885. * Check if the current matrix is identity
  2886. * @returns true is the matrix is the identity matrix
  2887. */
  2888. isIdentity(): boolean;
  2889. /**
  2890. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  2891. * @returns true is the matrix is the identity matrix
  2892. */
  2893. isIdentityAs3x2(): boolean;
  2894. /**
  2895. * Gets the determinant of the matrix
  2896. * @returns the matrix determinant
  2897. */
  2898. determinant(): number;
  2899. /**
  2900. * Returns the matrix as a Float32Array
  2901. * @returns the matrix underlying array
  2902. */
  2903. toArray(): DeepImmutable<Float32Array>;
  2904. /**
  2905. * Returns the matrix as a Float32Array
  2906. * @returns the matrix underlying array.
  2907. */
  2908. asArray(): DeepImmutable<Float32Array>;
  2909. /**
  2910. * Inverts the current matrix in place
  2911. * @returns the current inverted matrix
  2912. */
  2913. invert(): Matrix;
  2914. /**
  2915. * Sets all the matrix elements to zero
  2916. * @returns the current matrix
  2917. */
  2918. reset(): Matrix;
  2919. /**
  2920. * Adds the current matrix with a second one
  2921. * @param other defines the matrix to add
  2922. * @returns a new matrix as the addition of the current matrix and the given one
  2923. */
  2924. add(other: DeepImmutable<Matrix>): Matrix;
  2925. /**
  2926. * Sets the given matrix "result" to the addition of the current matrix and the given one
  2927. * @param other defines the matrix to add
  2928. * @param result defines the target matrix
  2929. * @returns the current matrix
  2930. */
  2931. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2932. /**
  2933. * Adds in place the given matrix to the current matrix
  2934. * @param other defines the second operand
  2935. * @returns the current updated matrix
  2936. */
  2937. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  2938. /**
  2939. * Sets the given matrix to the current inverted Matrix
  2940. * @param other defines the target matrix
  2941. * @returns the unmodified current matrix
  2942. */
  2943. invertToRef(other: Matrix): Matrix;
  2944. /**
  2945. * add a value at the specified position in the current Matrix
  2946. * @param index the index of the value within the matrix. between 0 and 15.
  2947. * @param value the value to be added
  2948. * @returns the current updated matrix
  2949. */
  2950. addAtIndex(index: number, value: number): Matrix;
  2951. /**
  2952. * mutiply the specified position in the current Matrix by a value
  2953. * @param index the index of the value within the matrix. between 0 and 15.
  2954. * @param value the value to be added
  2955. * @returns the current updated matrix
  2956. */
  2957. multiplyAtIndex(index: number, value: number): Matrix;
  2958. /**
  2959. * Inserts the translation vector (using 3 floats) in the current matrix
  2960. * @param x defines the 1st component of the translation
  2961. * @param y defines the 2nd component of the translation
  2962. * @param z defines the 3rd component of the translation
  2963. * @returns the current updated matrix
  2964. */
  2965. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2966. /**
  2967. * Adds the translation vector (using 3 floats) in the current matrix
  2968. * @param x defines the 1st component of the translation
  2969. * @param y defines the 2nd component of the translation
  2970. * @param z defines the 3rd component of the translation
  2971. * @returns the current updated matrix
  2972. */
  2973. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2974. /**
  2975. * Inserts the translation vector in the current matrix
  2976. * @param vector3 defines the translation to insert
  2977. * @returns the current updated matrix
  2978. */
  2979. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  2980. /**
  2981. * Gets the translation value of the current matrix
  2982. * @returns a new Vector3 as the extracted translation from the matrix
  2983. */
  2984. getTranslation(): Vector3;
  2985. /**
  2986. * Fill a Vector3 with the extracted translation from the matrix
  2987. * @param result defines the Vector3 where to store the translation
  2988. * @returns the current matrix
  2989. */
  2990. getTranslationToRef(result: Vector3): Matrix;
  2991. /**
  2992. * Remove rotation and scaling part from the matrix
  2993. * @returns the updated matrix
  2994. */
  2995. removeRotationAndScaling(): Matrix;
  2996. /**
  2997. * Multiply two matrices
  2998. * @param other defines the second operand
  2999. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  3000. */
  3001. multiply(other: DeepImmutable<Matrix>): Matrix;
  3002. /**
  3003. * Copy the current matrix from the given one
  3004. * @param other defines the source matrix
  3005. * @returns the current updated matrix
  3006. */
  3007. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  3008. /**
  3009. * Populates the given array from the starting index with the current matrix values
  3010. * @param array defines the target array
  3011. * @param offset defines the offset in the target array where to start storing values
  3012. * @returns the current matrix
  3013. */
  3014. copyToArray(array: Float32Array, offset?: number): Matrix;
  3015. /**
  3016. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  3017. * @param other defines the second operand
  3018. * @param result defines the matrix where to store the multiplication
  3019. * @returns the current matrix
  3020. */
  3021. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3022. /**
  3023. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  3024. * @param other defines the second operand
  3025. * @param result defines the array where to store the multiplication
  3026. * @param offset defines the offset in the target array where to start storing values
  3027. * @returns the current matrix
  3028. */
  3029. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  3030. /**
  3031. * Check equality between this matrix and a second one
  3032. * @param value defines the second matrix to compare
  3033. * @returns true is the current matrix and the given one values are strictly equal
  3034. */
  3035. equals(value: DeepImmutable<Matrix>): boolean;
  3036. /**
  3037. * Clone the current matrix
  3038. * @returns a new matrix from the current matrix
  3039. */
  3040. clone(): Matrix;
  3041. /**
  3042. * Returns the name of the current matrix class
  3043. * @returns the string "Matrix"
  3044. */
  3045. getClassName(): string;
  3046. /**
  3047. * Gets the hash code of the current matrix
  3048. * @returns the hash code
  3049. */
  3050. getHashCode(): number;
  3051. /**
  3052. * Decomposes the current Matrix into a translation, rotation and scaling components
  3053. * @param scale defines the scale vector3 given as a reference to update
  3054. * @param rotation defines the rotation quaternion given as a reference to update
  3055. * @param translation defines the translation vector3 given as a reference to update
  3056. * @returns true if operation was successful
  3057. */
  3058. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  3059. /**
  3060. * Gets specific row of the matrix
  3061. * @param index defines the number of the row to get
  3062. * @returns the index-th row of the current matrix as a new Vector4
  3063. */
  3064. getRow(index: number): Nullable<Vector4>;
  3065. /**
  3066. * Sets the index-th row of the current matrix to the vector4 values
  3067. * @param index defines the number of the row to set
  3068. * @param row defines the target vector4
  3069. * @returns the updated current matrix
  3070. */
  3071. setRow(index: number, row: Vector4): Matrix;
  3072. /**
  3073. * Compute the transpose of the matrix
  3074. * @returns the new transposed matrix
  3075. */
  3076. transpose(): Matrix;
  3077. /**
  3078. * Compute the transpose of the matrix and store it in a given matrix
  3079. * @param result defines the target matrix
  3080. * @returns the current matrix
  3081. */
  3082. transposeToRef(result: Matrix): Matrix;
  3083. /**
  3084. * Sets the index-th row of the current matrix with the given 4 x float values
  3085. * @param index defines the row index
  3086. * @param x defines the x component to set
  3087. * @param y defines the y component to set
  3088. * @param z defines the z component to set
  3089. * @param w defines the w component to set
  3090. * @returns the updated current matrix
  3091. */
  3092. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  3093. /**
  3094. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  3095. * @param scale defines the scale factor
  3096. * @returns a new matrix
  3097. */
  3098. scale(scale: number): Matrix;
  3099. /**
  3100. * Scale the current matrix values by a factor to a given result matrix
  3101. * @param scale defines the scale factor
  3102. * @param result defines the matrix to store the result
  3103. * @returns the current matrix
  3104. */
  3105. scaleToRef(scale: number, result: Matrix): Matrix;
  3106. /**
  3107. * Scale the current matrix values by a factor and add the result to a given matrix
  3108. * @param scale defines the scale factor
  3109. * @param result defines the Matrix to store the result
  3110. * @returns the current matrix
  3111. */
  3112. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  3113. /**
  3114. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  3115. * @param ref matrix to store the result
  3116. */
  3117. toNormalMatrix(ref: Matrix): void;
  3118. /**
  3119. * Gets only rotation part of the current matrix
  3120. * @returns a new matrix sets to the extracted rotation matrix from the current one
  3121. */
  3122. getRotationMatrix(): Matrix;
  3123. /**
  3124. * Extracts the rotation matrix from the current one and sets it as the given "result"
  3125. * @param result defines the target matrix to store data to
  3126. * @returns the current matrix
  3127. */
  3128. getRotationMatrixToRef(result: Matrix): Matrix;
  3129. /**
  3130. * Toggles model matrix from being right handed to left handed in place and vice versa
  3131. */
  3132. toggleModelMatrixHandInPlace(): void;
  3133. /**
  3134. * Toggles projection matrix from being right handed to left handed in place and vice versa
  3135. */
  3136. toggleProjectionMatrixHandInPlace(): void;
  3137. /**
  3138. * Creates a matrix from an array
  3139. * @param array defines the source array
  3140. * @param offset defines an offset in the source array
  3141. * @returns a new Matrix set from the starting index of the given array
  3142. */
  3143. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  3144. /**
  3145. * Copy the content of an array into a given matrix
  3146. * @param array defines the source array
  3147. * @param offset defines an offset in the source array
  3148. * @param result defines the target matrix
  3149. */
  3150. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  3151. /**
  3152. * Stores an array into a matrix after having multiplied each component by a given factor
  3153. * @param array defines the source array
  3154. * @param offset defines the offset in the source array
  3155. * @param scale defines the scaling factor
  3156. * @param result defines the target matrix
  3157. */
  3158. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  3159. /**
  3160. * Gets an identity matrix that must not be updated
  3161. */
  3162. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  3163. /**
  3164. * Stores a list of values (16) inside a given matrix
  3165. * @param initialM11 defines 1st value of 1st row
  3166. * @param initialM12 defines 2nd value of 1st row
  3167. * @param initialM13 defines 3rd value of 1st row
  3168. * @param initialM14 defines 4th value of 1st row
  3169. * @param initialM21 defines 1st value of 2nd row
  3170. * @param initialM22 defines 2nd value of 2nd row
  3171. * @param initialM23 defines 3rd value of 2nd row
  3172. * @param initialM24 defines 4th value of 2nd row
  3173. * @param initialM31 defines 1st value of 3rd row
  3174. * @param initialM32 defines 2nd value of 3rd row
  3175. * @param initialM33 defines 3rd value of 3rd row
  3176. * @param initialM34 defines 4th value of 3rd row
  3177. * @param initialM41 defines 1st value of 4th row
  3178. * @param initialM42 defines 2nd value of 4th row
  3179. * @param initialM43 defines 3rd value of 4th row
  3180. * @param initialM44 defines 4th value of 4th row
  3181. * @param result defines the target matrix
  3182. */
  3183. static FromValuesToRef(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number, result: Matrix): void;
  3184. /**
  3185. * Creates new matrix from a list of values (16)
  3186. * @param initialM11 defines 1st value of 1st row
  3187. * @param initialM12 defines 2nd value of 1st row
  3188. * @param initialM13 defines 3rd value of 1st row
  3189. * @param initialM14 defines 4th value of 1st row
  3190. * @param initialM21 defines 1st value of 2nd row
  3191. * @param initialM22 defines 2nd value of 2nd row
  3192. * @param initialM23 defines 3rd value of 2nd row
  3193. * @param initialM24 defines 4th value of 2nd row
  3194. * @param initialM31 defines 1st value of 3rd row
  3195. * @param initialM32 defines 2nd value of 3rd row
  3196. * @param initialM33 defines 3rd value of 3rd row
  3197. * @param initialM34 defines 4th value of 3rd row
  3198. * @param initialM41 defines 1st value of 4th row
  3199. * @param initialM42 defines 2nd value of 4th row
  3200. * @param initialM43 defines 3rd value of 4th row
  3201. * @param initialM44 defines 4th value of 4th row
  3202. * @returns the new matrix
  3203. */
  3204. static FromValues(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number): Matrix;
  3205. /**
  3206. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3207. * @param scale defines the scale vector3
  3208. * @param rotation defines the rotation quaternion
  3209. * @param translation defines the translation vector3
  3210. * @returns a new matrix
  3211. */
  3212. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  3213. /**
  3214. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3215. * @param scale defines the scale vector3
  3216. * @param rotation defines the rotation quaternion
  3217. * @param translation defines the translation vector3
  3218. * @param result defines the target matrix
  3219. */
  3220. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  3221. /**
  3222. * Creates a new identity matrix
  3223. * @returns a new identity matrix
  3224. */
  3225. static Identity(): Matrix;
  3226. /**
  3227. * Creates a new identity matrix and stores the result in a given matrix
  3228. * @param result defines the target matrix
  3229. */
  3230. static IdentityToRef(result: Matrix): void;
  3231. /**
  3232. * Creates a new zero matrix
  3233. * @returns a new zero matrix
  3234. */
  3235. static Zero(): Matrix;
  3236. /**
  3237. * Creates a new rotation matrix for "angle" radians around the X axis
  3238. * @param angle defines the angle (in radians) to use
  3239. * @return the new matrix
  3240. */
  3241. static RotationX(angle: number): Matrix;
  3242. /**
  3243. * Creates a new matrix as the invert of a given matrix
  3244. * @param source defines the source matrix
  3245. * @returns the new matrix
  3246. */
  3247. static Invert(source: DeepImmutable<Matrix>): Matrix;
  3248. /**
  3249. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  3250. * @param angle defines the angle (in radians) to use
  3251. * @param result defines the target matrix
  3252. */
  3253. static RotationXToRef(angle: number, result: Matrix): void;
  3254. /**
  3255. * Creates a new rotation matrix for "angle" radians around the Y axis
  3256. * @param angle defines the angle (in radians) to use
  3257. * @return the new matrix
  3258. */
  3259. static RotationY(angle: number): Matrix;
  3260. /**
  3261. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  3262. * @param angle defines the angle (in radians) to use
  3263. * @param result defines the target matrix
  3264. */
  3265. static RotationYToRef(angle: number, result: Matrix): void;
  3266. /**
  3267. * Creates a new rotation matrix for "angle" radians around the Z axis
  3268. * @param angle defines the angle (in radians) to use
  3269. * @return the new matrix
  3270. */
  3271. static RotationZ(angle: number): Matrix;
  3272. /**
  3273. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  3274. * @param angle defines the angle (in radians) to use
  3275. * @param result defines the target matrix
  3276. */
  3277. static RotationZToRef(angle: number, result: Matrix): void;
  3278. /**
  3279. * Creates a new rotation matrix for "angle" radians around the given axis
  3280. * @param axis defines the axis to use
  3281. * @param angle defines the angle (in radians) to use
  3282. * @return the new matrix
  3283. */
  3284. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  3285. /**
  3286. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  3287. * @param axis defines the axis to use
  3288. * @param angle defines the angle (in radians) to use
  3289. * @param result defines the target matrix
  3290. */
  3291. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  3292. /**
  3293. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  3294. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  3295. * @param from defines the vector to align
  3296. * @param to defines the vector to align to
  3297. * @param result defines the target matrix
  3298. */
  3299. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  3300. /**
  3301. * Creates a rotation matrix
  3302. * @param yaw defines the yaw angle in radians (Y axis)
  3303. * @param pitch defines the pitch angle in radians (X axis)
  3304. * @param roll defines the roll angle in radians (X axis)
  3305. * @returns the new rotation matrix
  3306. */
  3307. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  3308. /**
  3309. * Creates a rotation matrix and stores it in a given matrix
  3310. * @param yaw defines the yaw angle in radians (Y axis)
  3311. * @param pitch defines the pitch angle in radians (X axis)
  3312. * @param roll defines the roll angle in radians (X axis)
  3313. * @param result defines the target matrix
  3314. */
  3315. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  3316. /**
  3317. * Creates a scaling matrix
  3318. * @param x defines the scale factor on X axis
  3319. * @param y defines the scale factor on Y axis
  3320. * @param z defines the scale factor on Z axis
  3321. * @returns the new matrix
  3322. */
  3323. static Scaling(x: number, y: number, z: number): Matrix;
  3324. /**
  3325. * Creates a scaling matrix and stores it in a given matrix
  3326. * @param x defines the scale factor on X axis
  3327. * @param y defines the scale factor on Y axis
  3328. * @param z defines the scale factor on Z axis
  3329. * @param result defines the target matrix
  3330. */
  3331. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  3332. /**
  3333. * Creates a translation matrix
  3334. * @param x defines the translation on X axis
  3335. * @param y defines the translation on Y axis
  3336. * @param z defines the translationon Z axis
  3337. * @returns the new matrix
  3338. */
  3339. static Translation(x: number, y: number, z: number): Matrix;
  3340. /**
  3341. * Creates a translation matrix and stores it in a given matrix
  3342. * @param x defines the translation on X axis
  3343. * @param y defines the translation on Y axis
  3344. * @param z defines the translationon Z axis
  3345. * @param result defines the target matrix
  3346. */
  3347. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  3348. /**
  3349. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3350. * @param startValue defines the start value
  3351. * @param endValue defines the end value
  3352. * @param gradient defines the gradient factor
  3353. * @returns the new matrix
  3354. */
  3355. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3356. /**
  3357. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3358. * @param startValue defines the start value
  3359. * @param endValue defines the end value
  3360. * @param gradient defines the gradient factor
  3361. * @param result defines the Matrix object where to store data
  3362. */
  3363. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3364. /**
  3365. * Builds a new matrix whose values are computed by:
  3366. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3367. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3368. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3369. * @param startValue defines the first matrix
  3370. * @param endValue defines the second matrix
  3371. * @param gradient defines the gradient between the two matrices
  3372. * @returns the new matrix
  3373. */
  3374. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3375. /**
  3376. * Update a matrix to values which are computed by:
  3377. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3378. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3379. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3380. * @param startValue defines the first matrix
  3381. * @param endValue defines the second matrix
  3382. * @param gradient defines the gradient between the two matrices
  3383. * @param result defines the target matrix
  3384. */
  3385. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3386. /**
  3387. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  3388. * This function works in left handed mode
  3389. * @param eye defines the final position of the entity
  3390. * @param target defines where the entity should look at
  3391. * @param up defines the up vector for the entity
  3392. * @returns the new matrix
  3393. */
  3394. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3395. /**
  3396. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  3397. * This function works in left handed mode
  3398. * @param eye defines the final position of the entity
  3399. * @param target defines where the entity should look at
  3400. * @param up defines the up vector for the entity
  3401. * @param result defines the target matrix
  3402. */
  3403. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3404. /**
  3405. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  3406. * This function works in right handed mode
  3407. * @param eye defines the final position of the entity
  3408. * @param target defines where the entity should look at
  3409. * @param up defines the up vector for the entity
  3410. * @returns the new matrix
  3411. */
  3412. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3413. /**
  3414. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  3415. * This function works in right handed mode
  3416. * @param eye defines the final position of the entity
  3417. * @param target defines where the entity should look at
  3418. * @param up defines the up vector for the entity
  3419. * @param result defines the target matrix
  3420. */
  3421. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3422. /**
  3423. * Create a left-handed orthographic projection matrix
  3424. * @param width defines the viewport width
  3425. * @param height defines the viewport height
  3426. * @param znear defines the near clip plane
  3427. * @param zfar defines the far clip plane
  3428. * @returns a new matrix as a left-handed orthographic projection matrix
  3429. */
  3430. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3431. /**
  3432. * Store a left-handed orthographic projection to a given matrix
  3433. * @param width defines the viewport width
  3434. * @param height defines the viewport height
  3435. * @param znear defines the near clip plane
  3436. * @param zfar defines the far clip plane
  3437. * @param result defines the target matrix
  3438. */
  3439. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  3440. /**
  3441. * Create a left-handed orthographic projection matrix
  3442. * @param left defines the viewport left coordinate
  3443. * @param right defines the viewport right coordinate
  3444. * @param bottom defines the viewport bottom coordinate
  3445. * @param top defines the viewport top coordinate
  3446. * @param znear defines the near clip plane
  3447. * @param zfar defines the far clip plane
  3448. * @returns a new matrix as a left-handed orthographic projection matrix
  3449. */
  3450. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3451. /**
  3452. * Stores a left-handed orthographic projection into a given matrix
  3453. * @param left defines the viewport left coordinate
  3454. * @param right defines the viewport right coordinate
  3455. * @param bottom defines the viewport bottom coordinate
  3456. * @param top defines the viewport top coordinate
  3457. * @param znear defines the near clip plane
  3458. * @param zfar defines the far clip plane
  3459. * @param result defines the target matrix
  3460. */
  3461. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3462. /**
  3463. * Creates a right-handed orthographic projection matrix
  3464. * @param left defines the viewport left coordinate
  3465. * @param right defines the viewport right coordinate
  3466. * @param bottom defines the viewport bottom coordinate
  3467. * @param top defines the viewport top coordinate
  3468. * @param znear defines the near clip plane
  3469. * @param zfar defines the far clip plane
  3470. * @returns a new matrix as a right-handed orthographic projection matrix
  3471. */
  3472. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3473. /**
  3474. * Stores a right-handed orthographic projection into a given matrix
  3475. * @param left defines the viewport left coordinate
  3476. * @param right defines the viewport right coordinate
  3477. * @param bottom defines the viewport bottom coordinate
  3478. * @param top defines the viewport top coordinate
  3479. * @param znear defines the near clip plane
  3480. * @param zfar defines the far clip plane
  3481. * @param result defines the target matrix
  3482. */
  3483. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3484. /**
  3485. * Creates a left-handed perspective projection matrix
  3486. * @param width defines the viewport width
  3487. * @param height defines the viewport height
  3488. * @param znear defines the near clip plane
  3489. * @param zfar defines the far clip plane
  3490. * @returns a new matrix as a left-handed perspective projection matrix
  3491. */
  3492. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3493. /**
  3494. * Creates a left-handed perspective projection matrix
  3495. * @param fov defines the horizontal field of view
  3496. * @param aspect defines the aspect ratio
  3497. * @param znear defines the near clip plane
  3498. * @param zfar defines the far clip plane
  3499. * @returns a new matrix as a left-handed perspective projection matrix
  3500. */
  3501. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3502. /**
  3503. * Stores a left-handed perspective projection into a given matrix
  3504. * @param fov defines the horizontal field of view
  3505. * @param aspect defines the aspect ratio
  3506. * @param znear defines the near clip plane
  3507. * @param zfar defines the far clip plane
  3508. * @param result defines the target matrix
  3509. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3510. */
  3511. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3512. /**
  3513. * Creates a right-handed perspective projection matrix
  3514. * @param fov defines the horizontal field of view
  3515. * @param aspect defines the aspect ratio
  3516. * @param znear defines the near clip plane
  3517. * @param zfar defines the far clip plane
  3518. * @returns a new matrix as a right-handed perspective projection matrix
  3519. */
  3520. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3521. /**
  3522. * Stores a right-handed perspective projection into a given matrix
  3523. * @param fov defines the horizontal field of view
  3524. * @param aspect defines the aspect ratio
  3525. * @param znear defines the near clip plane
  3526. * @param zfar defines the far clip plane
  3527. * @param result defines the target matrix
  3528. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3529. */
  3530. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3531. /**
  3532. * Stores a perspective projection for WebVR info a given matrix
  3533. * @param fov defines the field of view
  3534. * @param znear defines the near clip plane
  3535. * @param zfar defines the far clip plane
  3536. * @param result defines the target matrix
  3537. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  3538. */
  3539. static PerspectiveFovWebVRToRef(fov: {
  3540. upDegrees: number;
  3541. downDegrees: number;
  3542. leftDegrees: number;
  3543. rightDegrees: number;
  3544. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  3545. /**
  3546. * Computes a complete transformation matrix
  3547. * @param viewport defines the viewport to use
  3548. * @param world defines the world matrix
  3549. * @param view defines the view matrix
  3550. * @param projection defines the projection matrix
  3551. * @param zmin defines the near clip plane
  3552. * @param zmax defines the far clip plane
  3553. * @returns the transformation matrix
  3554. */
  3555. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  3556. /**
  3557. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  3558. * @param matrix defines the matrix to use
  3559. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  3560. */
  3561. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  3562. /**
  3563. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  3564. * @param matrix defines the matrix to use
  3565. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  3566. */
  3567. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  3568. /**
  3569. * Compute the transpose of a given matrix
  3570. * @param matrix defines the matrix to transpose
  3571. * @returns the new matrix
  3572. */
  3573. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  3574. /**
  3575. * Compute the transpose of a matrix and store it in a target matrix
  3576. * @param matrix defines the matrix to transpose
  3577. * @param result defines the target matrix
  3578. */
  3579. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  3580. /**
  3581. * Computes a reflection matrix from a plane
  3582. * @param plane defines the reflection plane
  3583. * @returns a new matrix
  3584. */
  3585. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  3586. /**
  3587. * Computes a reflection matrix from a plane
  3588. * @param plane defines the reflection plane
  3589. * @param result defines the target matrix
  3590. */
  3591. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  3592. /**
  3593. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  3594. * @param xaxis defines the value of the 1st axis
  3595. * @param yaxis defines the value of the 2nd axis
  3596. * @param zaxis defines the value of the 3rd axis
  3597. * @param result defines the target matrix
  3598. */
  3599. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  3600. /**
  3601. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  3602. * @param quat defines the quaternion to use
  3603. * @param result defines the target matrix
  3604. */
  3605. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  3606. }
  3607. /**
  3608. * Represens a plane by the equation ax + by + cz + d = 0
  3609. */
  3610. export class Plane {
  3611. /**
  3612. * Normal of the plane (a,b,c)
  3613. */
  3614. normal: Vector3;
  3615. /**
  3616. * d component of the plane
  3617. */
  3618. d: number;
  3619. /**
  3620. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  3621. * @param a a component of the plane
  3622. * @param b b component of the plane
  3623. * @param c c component of the plane
  3624. * @param d d component of the plane
  3625. */
  3626. constructor(a: number, b: number, c: number, d: number);
  3627. /**
  3628. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  3629. */
  3630. asArray(): number[];
  3631. /**
  3632. * @returns a new plane copied from the current Plane.
  3633. */
  3634. clone(): Plane;
  3635. /**
  3636. * @returns the string "Plane".
  3637. */
  3638. getClassName(): string;
  3639. /**
  3640. * @returns the Plane hash code.
  3641. */
  3642. getHashCode(): number;
  3643. /**
  3644. * Normalize the current Plane in place.
  3645. * @returns the updated Plane.
  3646. */
  3647. normalize(): Plane;
  3648. /**
  3649. * Applies a transformation the plane and returns the result
  3650. * @param transformation the transformation matrix to be applied to the plane
  3651. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  3652. */
  3653. transform(transformation: DeepImmutable<Matrix>): Plane;
  3654. /**
  3655. * Calcualtte the dot product between the point and the plane normal
  3656. * @param point point to calculate the dot product with
  3657. * @returns the dot product (float) of the point coordinates and the plane normal.
  3658. */
  3659. dotCoordinate(point: DeepImmutable<Vector3>): number;
  3660. /**
  3661. * Updates the current Plane from the plane defined by the three given points.
  3662. * @param point1 one of the points used to contruct the plane
  3663. * @param point2 one of the points used to contruct the plane
  3664. * @param point3 one of the points used to contruct the plane
  3665. * @returns the updated Plane.
  3666. */
  3667. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3668. /**
  3669. * Checks if the plane is facing a given direction
  3670. * @param direction the direction to check if the plane is facing
  3671. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  3672. * @returns True is the vector "direction" is the same side than the plane normal.
  3673. */
  3674. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  3675. /**
  3676. * Calculates the distance to a point
  3677. * @param point point to calculate distance to
  3678. * @returns the signed distance (float) from the given point to the Plane.
  3679. */
  3680. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  3681. /**
  3682. * Creates a plane from an array
  3683. * @param array the array to create a plane from
  3684. * @returns a new Plane from the given array.
  3685. */
  3686. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  3687. /**
  3688. * Creates a plane from three points
  3689. * @param point1 point used to create the plane
  3690. * @param point2 point used to create the plane
  3691. * @param point3 point used to create the plane
  3692. * @returns a new Plane defined by the three given points.
  3693. */
  3694. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3695. /**
  3696. * Creates a plane from an origin point and a normal
  3697. * @param origin origin of the plane to be constructed
  3698. * @param normal normal of the plane to be constructed
  3699. * @returns a new Plane the normal vector to this plane at the given origin point.
  3700. * Note : the vector "normal" is updated because normalized.
  3701. */
  3702. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  3703. /**
  3704. * Calculates the distance from a plane and a point
  3705. * @param origin origin of the plane to be constructed
  3706. * @param normal normal of the plane to be constructed
  3707. * @param point point to calculate distance to
  3708. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  3709. */
  3710. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  3711. }
  3712. /**
  3713. * Class used to represent a viewport on screen
  3714. */
  3715. export class Viewport {
  3716. /** viewport left coordinate */
  3717. x: number;
  3718. /** viewport top coordinate */
  3719. y: number;
  3720. /**viewport width */
  3721. width: number;
  3722. /** viewport height */
  3723. height: number;
  3724. /**
  3725. * Creates a Viewport object located at (x, y) and sized (width, height)
  3726. * @param x defines viewport left coordinate
  3727. * @param y defines viewport top coordinate
  3728. * @param width defines the viewport width
  3729. * @param height defines the viewport height
  3730. */
  3731. constructor(
  3732. /** viewport left coordinate */
  3733. x: number,
  3734. /** viewport top coordinate */
  3735. y: number,
  3736. /**viewport width */
  3737. width: number,
  3738. /** viewport height */
  3739. height: number);
  3740. /**
  3741. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  3742. * @param renderWidth defines the rendering width
  3743. * @param renderHeight defines the rendering height
  3744. * @returns a new Viewport
  3745. */
  3746. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  3747. /**
  3748. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  3749. * @param renderWidth defines the rendering width
  3750. * @param renderHeight defines the rendering height
  3751. * @param ref defines the target viewport
  3752. * @returns the current viewport
  3753. */
  3754. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  3755. /**
  3756. * Returns a new Viewport copied from the current one
  3757. * @returns a new Viewport
  3758. */
  3759. clone(): Viewport;
  3760. }
  3761. /**
  3762. * Reprasents a camera frustum
  3763. */
  3764. export class Frustum {
  3765. /**
  3766. * Gets the planes representing the frustum
  3767. * @param transform matrix to be applied to the returned planes
  3768. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  3769. */
  3770. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  3771. /**
  3772. * Gets the near frustum plane transformed by the transform matrix
  3773. * @param transform transformation matrix to be applied to the resulting frustum plane
  3774. * @param frustumPlane the resuling frustum plane
  3775. */
  3776. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3777. /**
  3778. * Gets the far frustum plane transformed by the transform matrix
  3779. * @param transform transformation matrix to be applied to the resulting frustum plane
  3780. * @param frustumPlane the resuling frustum plane
  3781. */
  3782. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3783. /**
  3784. * Gets the left frustum plane transformed by the transform matrix
  3785. * @param transform transformation matrix to be applied to the resulting frustum plane
  3786. * @param frustumPlane the resuling frustum plane
  3787. */
  3788. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3789. /**
  3790. * Gets the right frustum plane transformed by the transform matrix
  3791. * @param transform transformation matrix to be applied to the resulting frustum plane
  3792. * @param frustumPlane the resuling frustum plane
  3793. */
  3794. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3795. /**
  3796. * Gets the top frustum plane transformed by the transform matrix
  3797. * @param transform transformation matrix to be applied to the resulting frustum plane
  3798. * @param frustumPlane the resuling frustum plane
  3799. */
  3800. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3801. /**
  3802. * Gets the bottom frustum plane transformed by the transform matrix
  3803. * @param transform transformation matrix to be applied to the resulting frustum plane
  3804. * @param frustumPlane the resuling frustum plane
  3805. */
  3806. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3807. /**
  3808. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  3809. * @param transform transformation matrix to be applied to the resulting frustum planes
  3810. * @param frustumPlanes the resuling frustum planes
  3811. */
  3812. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  3813. }
  3814. /** Defines supported spaces */
  3815. export enum Space {
  3816. /** Local (object) space */
  3817. LOCAL = 0,
  3818. /** World space */
  3819. WORLD = 1,
  3820. /** Bone space */
  3821. BONE = 2
  3822. }
  3823. /** Defines the 3 main axes */
  3824. export class Axis {
  3825. /** X axis */
  3826. static X: Vector3;
  3827. /** Y axis */
  3828. static Y: Vector3;
  3829. /** Z axis */
  3830. static Z: Vector3;
  3831. }
  3832. /** Class used to represent a Bezier curve */
  3833. export class BezierCurve {
  3834. /**
  3835. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  3836. * @param t defines the time
  3837. * @param x1 defines the left coordinate on X axis
  3838. * @param y1 defines the left coordinate on Y axis
  3839. * @param x2 defines the right coordinate on X axis
  3840. * @param y2 defines the right coordinate on Y axis
  3841. * @returns the interpolated value
  3842. */
  3843. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  3844. }
  3845. /**
  3846. * Defines potential orientation for back face culling
  3847. */
  3848. export enum Orientation {
  3849. /**
  3850. * Clockwise
  3851. */
  3852. CW = 0,
  3853. /** Counter clockwise */
  3854. CCW = 1
  3855. }
  3856. /**
  3857. * Defines angle representation
  3858. */
  3859. export class Angle {
  3860. private _radians;
  3861. /**
  3862. * Creates an Angle object of "radians" radians (float).
  3863. * @param radians the angle in radians
  3864. */
  3865. constructor(radians: number);
  3866. /**
  3867. * Get value in degrees
  3868. * @returns the Angle value in degrees (float)
  3869. */
  3870. degrees(): number;
  3871. /**
  3872. * Get value in radians
  3873. * @returns the Angle value in radians (float)
  3874. */
  3875. radians(): number;
  3876. /**
  3877. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  3878. * @param a defines first vector
  3879. * @param b defines second vector
  3880. * @returns a new Angle
  3881. */
  3882. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  3883. /**
  3884. * Gets a new Angle object from the given float in radians
  3885. * @param radians defines the angle value in radians
  3886. * @returns a new Angle
  3887. */
  3888. static FromRadians(radians: number): Angle;
  3889. /**
  3890. * Gets a new Angle object from the given float in degrees
  3891. * @param degrees defines the angle value in degrees
  3892. * @returns a new Angle
  3893. */
  3894. static FromDegrees(degrees: number): Angle;
  3895. }
  3896. /**
  3897. * This represents an arc in a 2d space.
  3898. */
  3899. export class Arc2 {
  3900. /** Defines the start point of the arc */
  3901. startPoint: Vector2;
  3902. /** Defines the mid point of the arc */
  3903. midPoint: Vector2;
  3904. /** Defines the end point of the arc */
  3905. endPoint: Vector2;
  3906. /**
  3907. * Defines the center point of the arc.
  3908. */
  3909. centerPoint: Vector2;
  3910. /**
  3911. * Defines the radius of the arc.
  3912. */
  3913. radius: number;
  3914. /**
  3915. * Defines the angle of the arc (from mid point to end point).
  3916. */
  3917. angle: Angle;
  3918. /**
  3919. * Defines the start angle of the arc (from start point to middle point).
  3920. */
  3921. startAngle: Angle;
  3922. /**
  3923. * Defines the orientation of the arc (clock wise/counter clock wise).
  3924. */
  3925. orientation: Orientation;
  3926. /**
  3927. * Creates an Arc object from the three given points : start, middle and end.
  3928. * @param startPoint Defines the start point of the arc
  3929. * @param midPoint Defines the midlle point of the arc
  3930. * @param endPoint Defines the end point of the arc
  3931. */
  3932. constructor(
  3933. /** Defines the start point of the arc */
  3934. startPoint: Vector2,
  3935. /** Defines the mid point of the arc */
  3936. midPoint: Vector2,
  3937. /** Defines the end point of the arc */
  3938. endPoint: Vector2);
  3939. }
  3940. /**
  3941. * Represents a 2D path made up of multiple 2D points
  3942. */
  3943. export class Path2 {
  3944. private _points;
  3945. private _length;
  3946. /**
  3947. * If the path start and end point are the same
  3948. */
  3949. closed: boolean;
  3950. /**
  3951. * Creates a Path2 object from the starting 2D coordinates x and y.
  3952. * @param x the starting points x value
  3953. * @param y the starting points y value
  3954. */
  3955. constructor(x: number, y: number);
  3956. /**
  3957. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  3958. * @param x the added points x value
  3959. * @param y the added points y value
  3960. * @returns the updated Path2.
  3961. */
  3962. addLineTo(x: number, y: number): Path2;
  3963. /**
  3964. * Adds _numberOfSegments_ segments according to the arc definition (middle point coordinates, end point coordinates, the arc start point being the current Path2 last point) to the current Path2.
  3965. * @param midX middle point x value
  3966. * @param midY middle point y value
  3967. * @param endX end point x value
  3968. * @param endY end point y value
  3969. * @param numberOfSegments (default: 36)
  3970. * @returns the updated Path2.
  3971. */
  3972. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  3973. /**
  3974. * Closes the Path2.
  3975. * @returns the Path2.
  3976. */
  3977. close(): Path2;
  3978. /**
  3979. * Gets the sum of the distance between each sequential point in the path
  3980. * @returns the Path2 total length (float).
  3981. */
  3982. length(): number;
  3983. /**
  3984. * Gets the points which construct the path
  3985. * @returns the Path2 internal array of points.
  3986. */
  3987. getPoints(): Vector2[];
  3988. /**
  3989. * Retreives the point at the distance aways from the starting point
  3990. * @param normalizedLengthPosition the length along the path to retreive the point from
  3991. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  3992. */
  3993. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  3994. /**
  3995. * Creates a new path starting from an x and y position
  3996. * @param x starting x value
  3997. * @param y starting y value
  3998. * @returns a new Path2 starting at the coordinates (x, y).
  3999. */
  4000. static StartingAt(x: number, y: number): Path2;
  4001. }
  4002. /**
  4003. * Represents a 3D path made up of multiple 3D points
  4004. */
  4005. export class Path3D {
  4006. /**
  4007. * an array of Vector3, the curve axis of the Path3D
  4008. */
  4009. path: Vector3[];
  4010. private _curve;
  4011. private _distances;
  4012. private _tangents;
  4013. private _normals;
  4014. private _binormals;
  4015. private _raw;
  4016. /**
  4017. * new Path3D(path, normal, raw)
  4018. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4019. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4020. * @param path an array of Vector3, the curve axis of the Path3D
  4021. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4022. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4023. */
  4024. constructor(
  4025. /**
  4026. * an array of Vector3, the curve axis of the Path3D
  4027. */
  4028. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  4029. /**
  4030. * Returns the Path3D array of successive Vector3 designing its curve.
  4031. * @returns the Path3D array of successive Vector3 designing its curve.
  4032. */
  4033. getCurve(): Vector3[];
  4034. /**
  4035. * Returns an array populated with tangent vectors on each Path3D curve point.
  4036. * @returns an array populated with tangent vectors on each Path3D curve point.
  4037. */
  4038. getTangents(): Vector3[];
  4039. /**
  4040. * Returns an array populated with normal vectors on each Path3D curve point.
  4041. * @returns an array populated with normal vectors on each Path3D curve point.
  4042. */
  4043. getNormals(): Vector3[];
  4044. /**
  4045. * Returns an array populated with binormal vectors on each Path3D curve point.
  4046. * @returns an array populated with binormal vectors on each Path3D curve point.
  4047. */
  4048. getBinormals(): Vector3[];
  4049. /**
  4050. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4051. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4052. */
  4053. getDistances(): number[];
  4054. /**
  4055. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4056. * @param path path which all values are copied into the curves points
  4057. * @param firstNormal which should be projected onto the curve
  4058. * @returns the same object updated.
  4059. */
  4060. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  4061. private _compute;
  4062. private _getFirstNonNullVector;
  4063. private _getLastNonNullVector;
  4064. private _normalVector;
  4065. }
  4066. /**
  4067. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4068. * A Curve3 is designed from a series of successive Vector3.
  4069. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4070. */
  4071. export class Curve3 {
  4072. private _points;
  4073. private _length;
  4074. /**
  4075. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4076. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4077. * @param v1 (Vector3) the control point
  4078. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4079. * @param nbPoints (integer) the wanted number of points in the curve
  4080. * @returns the created Curve3
  4081. */
  4082. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4083. /**
  4084. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4085. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4086. * @param v1 (Vector3) the first control point
  4087. * @param v2 (Vector3) the second control point
  4088. * @param v3 (Vector3) the end point of the Cubic Bezier
  4089. * @param nbPoints (integer) the wanted number of points in the curve
  4090. * @returns the created Curve3
  4091. */
  4092. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4093. /**
  4094. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4095. * @param p1 (Vector3) the origin point of the Hermite Spline
  4096. * @param t1 (Vector3) the tangent vector at the origin point
  4097. * @param p2 (Vector3) the end point of the Hermite Spline
  4098. * @param t2 (Vector3) the tangent vector at the end point
  4099. * @param nbPoints (integer) the wanted number of points in the curve
  4100. * @returns the created Curve3
  4101. */
  4102. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4103. /**
  4104. * Returns a Curve3 object along a CatmullRom Spline curve :
  4105. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  4106. * @param nbPoints (integer) the wanted number of points between each curve control points
  4107. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  4108. * @returns the created Curve3
  4109. */
  4110. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  4111. /**
  4112. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4113. * A Curve3 is designed from a series of successive Vector3.
  4114. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  4115. * @param points points which make up the curve
  4116. */
  4117. constructor(points: Vector3[]);
  4118. /**
  4119. * @returns the Curve3 stored array of successive Vector3
  4120. */
  4121. getPoints(): Vector3[];
  4122. /**
  4123. * @returns the computed length (float) of the curve.
  4124. */
  4125. length(): number;
  4126. /**
  4127. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  4128. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  4129. * curveA and curveB keep unchanged.
  4130. * @param curve the curve to continue from this curve
  4131. * @returns the newly constructed curve
  4132. */
  4133. continue(curve: DeepImmutable<Curve3>): Curve3;
  4134. private _computeLength;
  4135. }
  4136. /**
  4137. * Contains position and normal vectors for a vertex
  4138. */
  4139. export class PositionNormalVertex {
  4140. /** the position of the vertex (defaut: 0,0,0) */
  4141. position: Vector3;
  4142. /** the normal of the vertex (defaut: 0,1,0) */
  4143. normal: Vector3;
  4144. /**
  4145. * Creates a PositionNormalVertex
  4146. * @param position the position of the vertex (defaut: 0,0,0)
  4147. * @param normal the normal of the vertex (defaut: 0,1,0)
  4148. */
  4149. constructor(
  4150. /** the position of the vertex (defaut: 0,0,0) */
  4151. position?: Vector3,
  4152. /** the normal of the vertex (defaut: 0,1,0) */
  4153. normal?: Vector3);
  4154. /**
  4155. * Clones the PositionNormalVertex
  4156. * @returns the cloned PositionNormalVertex
  4157. */
  4158. clone(): PositionNormalVertex;
  4159. }
  4160. /**
  4161. * Contains position, normal and uv vectors for a vertex
  4162. */
  4163. export class PositionNormalTextureVertex {
  4164. /** the position of the vertex (defaut: 0,0,0) */
  4165. position: Vector3;
  4166. /** the normal of the vertex (defaut: 0,1,0) */
  4167. normal: Vector3;
  4168. /** the uv of the vertex (default: 0,0) */
  4169. uv: Vector2;
  4170. /**
  4171. * Creates a PositionNormalTextureVertex
  4172. * @param position the position of the vertex (defaut: 0,0,0)
  4173. * @param normal the normal of the vertex (defaut: 0,1,0)
  4174. * @param uv the uv of the vertex (default: 0,0)
  4175. */
  4176. constructor(
  4177. /** the position of the vertex (defaut: 0,0,0) */
  4178. position?: Vector3,
  4179. /** the normal of the vertex (defaut: 0,1,0) */
  4180. normal?: Vector3,
  4181. /** the uv of the vertex (default: 0,0) */
  4182. uv?: Vector2);
  4183. /**
  4184. * Clones the PositionNormalTextureVertex
  4185. * @returns the cloned PositionNormalTextureVertex
  4186. */
  4187. clone(): PositionNormalTextureVertex;
  4188. }
  4189. /**
  4190. * @hidden
  4191. */
  4192. export class Tmp {
  4193. static Color3: Color3[];
  4194. static Color4: Color4[];
  4195. static Vector2: Vector2[];
  4196. static Vector3: Vector3[];
  4197. static Vector4: Vector4[];
  4198. static Quaternion: Quaternion[];
  4199. static Matrix: Matrix[];
  4200. }
  4201. }
  4202. declare module "babylonjs/Offline/IOfflineProvider" {
  4203. /**
  4204. * Class used to enable access to offline support
  4205. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  4206. */
  4207. export interface IOfflineProvider {
  4208. /**
  4209. * Gets a boolean indicating if scene must be saved in the database
  4210. */
  4211. enableSceneOffline: boolean;
  4212. /**
  4213. * Gets a boolean indicating if textures must be saved in the database
  4214. */
  4215. enableTexturesOffline: boolean;
  4216. /**
  4217. * Open the offline support and make it available
  4218. * @param successCallback defines the callback to call on success
  4219. * @param errorCallback defines the callback to call on error
  4220. */
  4221. open(successCallback: () => void, errorCallback: () => void): void;
  4222. /**
  4223. * Loads an image from the offline support
  4224. * @param url defines the url to load from
  4225. * @param image defines the target DOM image
  4226. */
  4227. loadImage(url: string, image: HTMLImageElement): void;
  4228. /**
  4229. * Loads a file from offline support
  4230. * @param url defines the URL to load from
  4231. * @param sceneLoaded defines a callback to call on success
  4232. * @param progressCallBack defines a callback to call when progress changed
  4233. * @param errorCallback defines a callback to call on error
  4234. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  4235. */
  4236. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  4237. }
  4238. }
  4239. declare module "babylonjs/Misc/observable" {
  4240. import { Nullable } from "babylonjs/types";
  4241. /**
  4242. * A class serves as a medium between the observable and its observers
  4243. */
  4244. export class EventState {
  4245. /**
  4246. * Create a new EventState
  4247. * @param mask defines the mask associated with this state
  4248. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4249. * @param target defines the original target of the state
  4250. * @param currentTarget defines the current target of the state
  4251. */
  4252. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  4253. /**
  4254. * Initialize the current event state
  4255. * @param mask defines the mask associated with this state
  4256. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4257. * @param target defines the original target of the state
  4258. * @param currentTarget defines the current target of the state
  4259. * @returns the current event state
  4260. */
  4261. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  4262. /**
  4263. * An Observer can set this property to true to prevent subsequent observers of being notified
  4264. */
  4265. skipNextObservers: boolean;
  4266. /**
  4267. * Get the mask value that were used to trigger the event corresponding to this EventState object
  4268. */
  4269. mask: number;
  4270. /**
  4271. * The object that originally notified the event
  4272. */
  4273. target?: any;
  4274. /**
  4275. * The current object in the bubbling phase
  4276. */
  4277. currentTarget?: any;
  4278. /**
  4279. * This will be populated with the return value of the last function that was executed.
  4280. * If it is the first function in the callback chain it will be the event data.
  4281. */
  4282. lastReturnValue?: any;
  4283. }
  4284. /**
  4285. * Represent an Observer registered to a given Observable object.
  4286. */
  4287. export class Observer<T> {
  4288. /**
  4289. * Defines the callback to call when the observer is notified
  4290. */
  4291. callback: (eventData: T, eventState: EventState) => void;
  4292. /**
  4293. * Defines the mask of the observer (used to filter notifications)
  4294. */
  4295. mask: number;
  4296. /**
  4297. * Defines the current scope used to restore the JS context
  4298. */
  4299. scope: any;
  4300. /** @hidden */
  4301. _willBeUnregistered: boolean;
  4302. /**
  4303. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  4304. */
  4305. unregisterOnNextCall: boolean;
  4306. /**
  4307. * Creates a new observer
  4308. * @param callback defines the callback to call when the observer is notified
  4309. * @param mask defines the mask of the observer (used to filter notifications)
  4310. * @param scope defines the current scope used to restore the JS context
  4311. */
  4312. constructor(
  4313. /**
  4314. * Defines the callback to call when the observer is notified
  4315. */
  4316. callback: (eventData: T, eventState: EventState) => void,
  4317. /**
  4318. * Defines the mask of the observer (used to filter notifications)
  4319. */
  4320. mask: number,
  4321. /**
  4322. * Defines the current scope used to restore the JS context
  4323. */
  4324. scope?: any);
  4325. }
  4326. /**
  4327. * Represent a list of observers registered to multiple Observables object.
  4328. */
  4329. export class MultiObserver<T> {
  4330. private _observers;
  4331. private _observables;
  4332. /**
  4333. * Release associated resources
  4334. */
  4335. dispose(): void;
  4336. /**
  4337. * Raise a callback when one of the observable will notify
  4338. * @param observables defines a list of observables to watch
  4339. * @param callback defines the callback to call on notification
  4340. * @param mask defines the mask used to filter notifications
  4341. * @param scope defines the current scope used to restore the JS context
  4342. * @returns the new MultiObserver
  4343. */
  4344. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  4345. }
  4346. /**
  4347. * The Observable class is a simple implementation of the Observable pattern.
  4348. *
  4349. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  4350. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  4351. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  4352. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  4353. */
  4354. export class Observable<T> {
  4355. private _observers;
  4356. private _eventState;
  4357. private _onObserverAdded;
  4358. /**
  4359. * Creates a new observable
  4360. * @param onObserverAdded defines a callback to call when a new observer is added
  4361. */
  4362. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  4363. /**
  4364. * Create a new Observer with the specified callback
  4365. * @param callback the callback that will be executed for that Observer
  4366. * @param mask the mask used to filter observers
  4367. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  4368. * @param scope optional scope for the callback to be called from
  4369. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  4370. * @returns the new observer created for the callback
  4371. */
  4372. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  4373. /**
  4374. * Create a new Observer with the specified callback and unregisters after the next notification
  4375. * @param callback the callback that will be executed for that Observer
  4376. * @returns the new observer created for the callback
  4377. */
  4378. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  4379. /**
  4380. * Remove an Observer from the Observable object
  4381. * @param observer the instance of the Observer to remove
  4382. * @returns false if it doesn't belong to this Observable
  4383. */
  4384. remove(observer: Nullable<Observer<T>>): boolean;
  4385. /**
  4386. * Remove a callback from the Observable object
  4387. * @param callback the callback to remove
  4388. * @param scope optional scope. If used only the callbacks with this scope will be removed
  4389. * @returns false if it doesn't belong to this Observable
  4390. */
  4391. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  4392. private _deferUnregister;
  4393. private _remove;
  4394. /**
  4395. * Moves the observable to the top of the observer list making it get called first when notified
  4396. * @param observer the observer to move
  4397. */
  4398. makeObserverTopPriority(observer: Observer<T>): void;
  4399. /**
  4400. * Moves the observable to the bottom of the observer list making it get called last when notified
  4401. * @param observer the observer to move
  4402. */
  4403. makeObserverBottomPriority(observer: Observer<T>): void;
  4404. /**
  4405. * Notify all Observers by calling their respective callback with the given data
  4406. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  4407. * @param eventData defines the data to send to all observers
  4408. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  4409. * @param target defines the original target of the state
  4410. * @param currentTarget defines the current target of the state
  4411. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  4412. */
  4413. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  4414. /**
  4415. * Calling this will execute each callback, expecting it to be a promise or return a value.
  4416. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  4417. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  4418. * and it is crucial that all callbacks will be executed.
  4419. * The order of the callbacks is kept, callbacks are not executed parallel.
  4420. *
  4421. * @param eventData The data to be sent to each callback
  4422. * @param mask is used to filter observers defaults to -1
  4423. * @param target defines the callback target (see EventState)
  4424. * @param currentTarget defines he current object in the bubbling phase
  4425. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  4426. */
  4427. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  4428. /**
  4429. * Notify a specific observer
  4430. * @param observer defines the observer to notify
  4431. * @param eventData defines the data to be sent to each callback
  4432. * @param mask is used to filter observers defaults to -1
  4433. */
  4434. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  4435. /**
  4436. * Gets a boolean indicating if the observable has at least one observer
  4437. * @returns true is the Observable has at least one Observer registered
  4438. */
  4439. hasObservers(): boolean;
  4440. /**
  4441. * Clear the list of observers
  4442. */
  4443. clear(): void;
  4444. /**
  4445. * Clone the current observable
  4446. * @returns a new observable
  4447. */
  4448. clone(): Observable<T>;
  4449. /**
  4450. * Does this observable handles observer registered with a given mask
  4451. * @param mask defines the mask to be tested
  4452. * @return whether or not one observer registered with the given mask is handeled
  4453. **/
  4454. hasSpecificMask(mask?: number): boolean;
  4455. }
  4456. }
  4457. declare module "babylonjs/Misc/filesInputStore" {
  4458. /**
  4459. * Class used to help managing file picking and drag'n'drop
  4460. * File Storage
  4461. */
  4462. export class FilesInputStore {
  4463. /**
  4464. * List of files ready to be loaded
  4465. */
  4466. static FilesToLoad: {
  4467. [key: string]: File;
  4468. };
  4469. }
  4470. }
  4471. declare module "babylonjs/Engines/constants" {
  4472. /** Defines the cross module used constants to avoid circular dependncies */
  4473. export class Constants {
  4474. /** Defines that alpha blending is disabled */
  4475. static readonly ALPHA_DISABLE: number;
  4476. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  4477. static readonly ALPHA_ADD: number;
  4478. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  4479. static readonly ALPHA_COMBINE: number;
  4480. /** Defines that alpha blending to DEST - SRC * DEST */
  4481. static readonly ALPHA_SUBTRACT: number;
  4482. /** Defines that alpha blending to SRC * DEST */
  4483. static readonly ALPHA_MULTIPLY: number;
  4484. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  4485. static readonly ALPHA_MAXIMIZED: number;
  4486. /** Defines that alpha blending to SRC + DEST */
  4487. static readonly ALPHA_ONEONE: number;
  4488. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  4489. static readonly ALPHA_PREMULTIPLIED: number;
  4490. /**
  4491. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  4492. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  4493. */
  4494. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4495. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  4496. static readonly ALPHA_INTERPOLATE: number;
  4497. /**
  4498. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  4499. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  4500. */
  4501. static readonly ALPHA_SCREENMODE: number;
  4502. /** Defines that the ressource is not delayed*/
  4503. static readonly DELAYLOADSTATE_NONE: number;
  4504. /** Defines that the ressource was successfully delay loaded */
  4505. static readonly DELAYLOADSTATE_LOADED: number;
  4506. /** Defines that the ressource is currently delay loading */
  4507. static readonly DELAYLOADSTATE_LOADING: number;
  4508. /** Defines that the ressource is delayed and has not started loading */
  4509. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4510. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  4511. static readonly NEVER: number;
  4512. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  4513. static readonly ALWAYS: number;
  4514. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  4515. static readonly LESS: number;
  4516. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  4517. static readonly EQUAL: number;
  4518. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  4519. static readonly LEQUAL: number;
  4520. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  4521. static readonly GREATER: number;
  4522. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  4523. static readonly GEQUAL: number;
  4524. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  4525. static readonly NOTEQUAL: number;
  4526. /** Passed to stencilOperation to specify that stencil value must be kept */
  4527. static readonly KEEP: number;
  4528. /** Passed to stencilOperation to specify that stencil value must be replaced */
  4529. static readonly REPLACE: number;
  4530. /** Passed to stencilOperation to specify that stencil value must be incremented */
  4531. static readonly INCR: number;
  4532. /** Passed to stencilOperation to specify that stencil value must be decremented */
  4533. static readonly DECR: number;
  4534. /** Passed to stencilOperation to specify that stencil value must be inverted */
  4535. static readonly INVERT: number;
  4536. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  4537. static readonly INCR_WRAP: number;
  4538. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  4539. static readonly DECR_WRAP: number;
  4540. /** Texture is not repeating outside of 0..1 UVs */
  4541. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  4542. /** Texture is repeating outside of 0..1 UVs */
  4543. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  4544. /** Texture is repeating and mirrored */
  4545. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  4546. /** ALPHA */
  4547. static readonly TEXTUREFORMAT_ALPHA: number;
  4548. /** LUMINANCE */
  4549. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4550. /** LUMINANCE_ALPHA */
  4551. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4552. /** RGB */
  4553. static readonly TEXTUREFORMAT_RGB: number;
  4554. /** RGBA */
  4555. static readonly TEXTUREFORMAT_RGBA: number;
  4556. /** RED */
  4557. static readonly TEXTUREFORMAT_RED: number;
  4558. /** RED (2nd reference) */
  4559. static readonly TEXTUREFORMAT_R: number;
  4560. /** RG */
  4561. static readonly TEXTUREFORMAT_RG: number;
  4562. /** RED_INTEGER */
  4563. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  4564. /** RED_INTEGER (2nd reference) */
  4565. static readonly TEXTUREFORMAT_R_INTEGER: number;
  4566. /** RG_INTEGER */
  4567. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  4568. /** RGB_INTEGER */
  4569. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  4570. /** RGBA_INTEGER */
  4571. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  4572. /** UNSIGNED_BYTE */
  4573. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  4574. /** UNSIGNED_BYTE (2nd reference) */
  4575. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4576. /** FLOAT */
  4577. static readonly TEXTURETYPE_FLOAT: number;
  4578. /** HALF_FLOAT */
  4579. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4580. /** BYTE */
  4581. static readonly TEXTURETYPE_BYTE: number;
  4582. /** SHORT */
  4583. static readonly TEXTURETYPE_SHORT: number;
  4584. /** UNSIGNED_SHORT */
  4585. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  4586. /** INT */
  4587. static readonly TEXTURETYPE_INT: number;
  4588. /** UNSIGNED_INT */
  4589. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  4590. /** UNSIGNED_SHORT_4_4_4_4 */
  4591. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  4592. /** UNSIGNED_SHORT_5_5_5_1 */
  4593. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  4594. /** UNSIGNED_SHORT_5_6_5 */
  4595. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  4596. /** UNSIGNED_INT_2_10_10_10_REV */
  4597. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  4598. /** UNSIGNED_INT_24_8 */
  4599. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  4600. /** UNSIGNED_INT_10F_11F_11F_REV */
  4601. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  4602. /** UNSIGNED_INT_5_9_9_9_REV */
  4603. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  4604. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  4605. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  4606. /** nearest is mag = nearest and min = nearest and mip = linear */
  4607. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  4608. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4609. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  4610. /** Trilinear is mag = linear and min = linear and mip = linear */
  4611. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  4612. /** nearest is mag = nearest and min = nearest and mip = linear */
  4613. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  4614. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4615. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  4616. /** Trilinear is mag = linear and min = linear and mip = linear */
  4617. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  4618. /** mag = nearest and min = nearest and mip = nearest */
  4619. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  4620. /** mag = nearest and min = linear and mip = nearest */
  4621. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  4622. /** mag = nearest and min = linear and mip = linear */
  4623. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  4624. /** mag = nearest and min = linear and mip = none */
  4625. static readonly TEXTURE_NEAREST_LINEAR: number;
  4626. /** mag = nearest and min = nearest and mip = none */
  4627. static readonly TEXTURE_NEAREST_NEAREST: number;
  4628. /** mag = linear and min = nearest and mip = nearest */
  4629. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  4630. /** mag = linear and min = nearest and mip = linear */
  4631. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  4632. /** mag = linear and min = linear and mip = none */
  4633. static readonly TEXTURE_LINEAR_LINEAR: number;
  4634. /** mag = linear and min = nearest and mip = none */
  4635. static readonly TEXTURE_LINEAR_NEAREST: number;
  4636. /** Explicit coordinates mode */
  4637. static readonly TEXTURE_EXPLICIT_MODE: number;
  4638. /** Spherical coordinates mode */
  4639. static readonly TEXTURE_SPHERICAL_MODE: number;
  4640. /** Planar coordinates mode */
  4641. static readonly TEXTURE_PLANAR_MODE: number;
  4642. /** Cubic coordinates mode */
  4643. static readonly TEXTURE_CUBIC_MODE: number;
  4644. /** Projection coordinates mode */
  4645. static readonly TEXTURE_PROJECTION_MODE: number;
  4646. /** Skybox coordinates mode */
  4647. static readonly TEXTURE_SKYBOX_MODE: number;
  4648. /** Inverse Cubic coordinates mode */
  4649. static readonly TEXTURE_INVCUBIC_MODE: number;
  4650. /** Equirectangular coordinates mode */
  4651. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  4652. /** Equirectangular Fixed coordinates mode */
  4653. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  4654. /** Equirectangular Fixed Mirrored coordinates mode */
  4655. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  4656. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  4657. static readonly SCALEMODE_FLOOR: number;
  4658. /** Defines that texture rescaling will look for the nearest power of 2 size */
  4659. static readonly SCALEMODE_NEAREST: number;
  4660. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  4661. static readonly SCALEMODE_CEILING: number;
  4662. /**
  4663. * The dirty texture flag value
  4664. */
  4665. static readonly MATERIAL_TextureDirtyFlag: number;
  4666. /**
  4667. * The dirty light flag value
  4668. */
  4669. static readonly MATERIAL_LightDirtyFlag: number;
  4670. /**
  4671. * The dirty fresnel flag value
  4672. */
  4673. static readonly MATERIAL_FresnelDirtyFlag: number;
  4674. /**
  4675. * The dirty attribute flag value
  4676. */
  4677. static readonly MATERIAL_AttributesDirtyFlag: number;
  4678. /**
  4679. * The dirty misc flag value
  4680. */
  4681. static readonly MATERIAL_MiscDirtyFlag: number;
  4682. /**
  4683. * The all dirty flag value
  4684. */
  4685. static readonly MATERIAL_AllDirtyFlag: number;
  4686. /**
  4687. * Returns the triangle fill mode
  4688. */
  4689. static readonly MATERIAL_TriangleFillMode: number;
  4690. /**
  4691. * Returns the wireframe mode
  4692. */
  4693. static readonly MATERIAL_WireFrameFillMode: number;
  4694. /**
  4695. * Returns the point fill mode
  4696. */
  4697. static readonly MATERIAL_PointFillMode: number;
  4698. /**
  4699. * Returns the point list draw mode
  4700. */
  4701. static readonly MATERIAL_PointListDrawMode: number;
  4702. /**
  4703. * Returns the line list draw mode
  4704. */
  4705. static readonly MATERIAL_LineListDrawMode: number;
  4706. /**
  4707. * Returns the line loop draw mode
  4708. */
  4709. static readonly MATERIAL_LineLoopDrawMode: number;
  4710. /**
  4711. * Returns the line strip draw mode
  4712. */
  4713. static readonly MATERIAL_LineStripDrawMode: number;
  4714. /**
  4715. * Returns the triangle strip draw mode
  4716. */
  4717. static readonly MATERIAL_TriangleStripDrawMode: number;
  4718. /**
  4719. * Returns the triangle fan draw mode
  4720. */
  4721. static readonly MATERIAL_TriangleFanDrawMode: number;
  4722. /**
  4723. * Stores the clock-wise side orientation
  4724. */
  4725. static readonly MATERIAL_ClockWiseSideOrientation: number;
  4726. /**
  4727. * Stores the counter clock-wise side orientation
  4728. */
  4729. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  4730. /**
  4731. * Nothing
  4732. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4733. */
  4734. static readonly ACTION_NothingTrigger: number;
  4735. /**
  4736. * On pick
  4737. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4738. */
  4739. static readonly ACTION_OnPickTrigger: number;
  4740. /**
  4741. * On left pick
  4742. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4743. */
  4744. static readonly ACTION_OnLeftPickTrigger: number;
  4745. /**
  4746. * On right pick
  4747. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4748. */
  4749. static readonly ACTION_OnRightPickTrigger: number;
  4750. /**
  4751. * On center pick
  4752. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4753. */
  4754. static readonly ACTION_OnCenterPickTrigger: number;
  4755. /**
  4756. * On pick down
  4757. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4758. */
  4759. static readonly ACTION_OnPickDownTrigger: number;
  4760. /**
  4761. * On double pick
  4762. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4763. */
  4764. static readonly ACTION_OnDoublePickTrigger: number;
  4765. /**
  4766. * On pick up
  4767. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4768. */
  4769. static readonly ACTION_OnPickUpTrigger: number;
  4770. /**
  4771. * On pick out.
  4772. * This trigger will only be raised if you also declared a OnPickDown
  4773. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4774. */
  4775. static readonly ACTION_OnPickOutTrigger: number;
  4776. /**
  4777. * On long press
  4778. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4779. */
  4780. static readonly ACTION_OnLongPressTrigger: number;
  4781. /**
  4782. * On pointer over
  4783. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4784. */
  4785. static readonly ACTION_OnPointerOverTrigger: number;
  4786. /**
  4787. * On pointer out
  4788. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4789. */
  4790. static readonly ACTION_OnPointerOutTrigger: number;
  4791. /**
  4792. * On every frame
  4793. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4794. */
  4795. static readonly ACTION_OnEveryFrameTrigger: number;
  4796. /**
  4797. * On intersection enter
  4798. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4799. */
  4800. static readonly ACTION_OnIntersectionEnterTrigger: number;
  4801. /**
  4802. * On intersection exit
  4803. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4804. */
  4805. static readonly ACTION_OnIntersectionExitTrigger: number;
  4806. /**
  4807. * On key down
  4808. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4809. */
  4810. static readonly ACTION_OnKeyDownTrigger: number;
  4811. /**
  4812. * On key up
  4813. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4814. */
  4815. static readonly ACTION_OnKeyUpTrigger: number;
  4816. /**
  4817. * Billboard mode will only apply to Y axis
  4818. */
  4819. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  4820. /**
  4821. * Billboard mode will apply to all axes
  4822. */
  4823. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  4824. /**
  4825. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  4826. */
  4827. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  4828. /**
  4829. * Gets or sets base Assets URL
  4830. */
  4831. static readonly PARTICLES_BaseAssetsUrl: string;
  4832. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  4833. * Test order :
  4834. * Is the bounding sphere outside the frustum ?
  4835. * If not, are the bounding box vertices outside the frustum ?
  4836. * It not, then the cullable object is in the frustum.
  4837. */
  4838. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  4839. /** Culling strategy : Bounding Sphere Only.
  4840. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  4841. * It's also less accurate than the standard because some not visible objects can still be selected.
  4842. * Test : is the bounding sphere outside the frustum ?
  4843. * If not, then the cullable object is in the frustum.
  4844. */
  4845. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  4846. /** Culling strategy : Optimistic Inclusion.
  4847. * This in an inclusion test first, then the standard exclusion test.
  4848. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  4849. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  4850. * Anyway, it's as accurate as the standard strategy.
  4851. * Test :
  4852. * Is the cullable object bounding sphere center in the frustum ?
  4853. * If not, apply the default culling strategy.
  4854. */
  4855. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  4856. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  4857. * This in an inclusion test first, then the bounding sphere only exclusion test.
  4858. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  4859. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  4860. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  4861. * Test :
  4862. * Is the cullable object bounding sphere center in the frustum ?
  4863. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  4864. */
  4865. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  4866. /**
  4867. * No logging while loading
  4868. */
  4869. static readonly SCENELOADER_NO_LOGGING: number;
  4870. /**
  4871. * Minimal logging while loading
  4872. */
  4873. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  4874. /**
  4875. * Summary logging while loading
  4876. */
  4877. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  4878. /**
  4879. * Detailled logging while loading
  4880. */
  4881. static readonly SCENELOADER_DETAILED_LOGGING: number;
  4882. }
  4883. }
  4884. declare module "babylonjs/Misc/domManagement" {
  4885. /**
  4886. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  4887. * Babylon.js
  4888. */
  4889. export class DomManagement {
  4890. /**
  4891. * Checks if the window object exists
  4892. * @returns true if the window object exists
  4893. */
  4894. static IsWindowObjectExist(): boolean;
  4895. /**
  4896. * Extracts text content from a DOM element hierarchy
  4897. * @param element defines the root element
  4898. * @returns a string
  4899. */
  4900. static GetDOMTextContent(element: HTMLElement): string;
  4901. }
  4902. }
  4903. declare module "babylonjs/Misc/logger" {
  4904. /**
  4905. * Logger used througouht the application to allow configuration of
  4906. * the log level required for the messages.
  4907. */
  4908. export class Logger {
  4909. /**
  4910. * No log
  4911. */
  4912. static readonly NoneLogLevel: number;
  4913. /**
  4914. * Only message logs
  4915. */
  4916. static readonly MessageLogLevel: number;
  4917. /**
  4918. * Only warning logs
  4919. */
  4920. static readonly WarningLogLevel: number;
  4921. /**
  4922. * Only error logs
  4923. */
  4924. static readonly ErrorLogLevel: number;
  4925. /**
  4926. * All logs
  4927. */
  4928. static readonly AllLogLevel: number;
  4929. private static _LogCache;
  4930. /**
  4931. * Gets a value indicating the number of loading errors
  4932. * @ignorenaming
  4933. */
  4934. static errorsCount: number;
  4935. /**
  4936. * Callback called when a new log is added
  4937. */
  4938. static OnNewCacheEntry: (entry: string) => void;
  4939. private static _AddLogEntry;
  4940. private static _FormatMessage;
  4941. private static _LogDisabled;
  4942. private static _LogEnabled;
  4943. private static _WarnDisabled;
  4944. private static _WarnEnabled;
  4945. private static _ErrorDisabled;
  4946. private static _ErrorEnabled;
  4947. /**
  4948. * Log a message to the console
  4949. */
  4950. static Log: (message: string) => void;
  4951. /**
  4952. * Write a warning message to the console
  4953. */
  4954. static Warn: (message: string) => void;
  4955. /**
  4956. * Write an error message to the console
  4957. */
  4958. static Error: (message: string) => void;
  4959. /**
  4960. * Gets current log cache (list of logs)
  4961. */
  4962. static readonly LogCache: string;
  4963. /**
  4964. * Clears the log cache
  4965. */
  4966. static ClearLogCache(): void;
  4967. /**
  4968. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  4969. */
  4970. static LogLevels: number;
  4971. }
  4972. }
  4973. declare module "babylonjs/Misc/typeStore" {
  4974. /** @hidden */
  4975. export class _TypeStore {
  4976. /** @hidden */
  4977. static RegisteredTypes: {
  4978. [key: string]: Object;
  4979. };
  4980. /** @hidden */
  4981. static GetClass(fqdn: string): any;
  4982. }
  4983. }
  4984. declare module "babylonjs/Misc/deepCopier" {
  4985. /**
  4986. * Class containing a set of static utilities functions for deep copy.
  4987. */
  4988. export class DeepCopier {
  4989. /**
  4990. * Tries to copy an object by duplicating every property
  4991. * @param source defines the source object
  4992. * @param destination defines the target object
  4993. * @param doNotCopyList defines a list of properties to avoid
  4994. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  4995. */
  4996. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  4997. }
  4998. }
  4999. declare module "babylonjs/Misc/precisionDate" {
  5000. /**
  5001. * Class containing a set of static utilities functions for precision date
  5002. */
  5003. export class PrecisionDate {
  5004. /**
  5005. * Gets either window.performance.now() if supported or Date.now() else
  5006. */
  5007. static readonly Now: number;
  5008. }
  5009. }
  5010. declare module "babylonjs/Misc/devTools" {
  5011. /** @hidden */
  5012. export class _DevTools {
  5013. static WarnImport(name: string): string;
  5014. }
  5015. }
  5016. declare module "babylonjs/Misc/webRequest" {
  5017. /**
  5018. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  5019. */
  5020. export class WebRequest {
  5021. private _xhr;
  5022. /**
  5023. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  5024. * i.e. when loading files, where the server/service expects an Authorization header
  5025. */
  5026. static CustomRequestHeaders: {
  5027. [key: string]: string;
  5028. };
  5029. /**
  5030. * Add callback functions in this array to update all the requests before they get sent to the network
  5031. */
  5032. static CustomRequestModifiers: ((request: XMLHttpRequest) => void)[];
  5033. private _injectCustomRequestHeaders;
  5034. /**
  5035. * Gets or sets a function to be called when loading progress changes
  5036. */
  5037. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  5038. /**
  5039. * Returns client's state
  5040. */
  5041. readonly readyState: number;
  5042. /**
  5043. * Returns client's status
  5044. */
  5045. readonly status: number;
  5046. /**
  5047. * Returns client's status as a text
  5048. */
  5049. readonly statusText: string;
  5050. /**
  5051. * Returns client's response
  5052. */
  5053. readonly response: any;
  5054. /**
  5055. * Returns client's response url
  5056. */
  5057. readonly responseURL: string;
  5058. /**
  5059. * Returns client's response as text
  5060. */
  5061. readonly responseText: string;
  5062. /**
  5063. * Gets or sets the expected response type
  5064. */
  5065. responseType: XMLHttpRequestResponseType;
  5066. /** @hidden */
  5067. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  5068. /** @hidden */
  5069. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  5070. /**
  5071. * Cancels any network activity
  5072. */
  5073. abort(): void;
  5074. /**
  5075. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  5076. * @param body defines an optional request body
  5077. */
  5078. send(body?: Document | BodyInit | null): void;
  5079. /**
  5080. * Sets the request method, request URL
  5081. * @param method defines the method to use (GET, POST, etc..)
  5082. * @param url defines the url to connect with
  5083. */
  5084. open(method: string, url: string): void;
  5085. }
  5086. }
  5087. declare module "babylonjs/Misc/andOrNotEvaluator" {
  5088. /**
  5089. * Class used to evalaute queries containing `and` and `or` operators
  5090. */
  5091. export class AndOrNotEvaluator {
  5092. /**
  5093. * Evaluate a query
  5094. * @param query defines the query to evaluate
  5095. * @param evaluateCallback defines the callback used to filter result
  5096. * @returns true if the query matches
  5097. */
  5098. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  5099. private static _HandleParenthesisContent;
  5100. private static _SimplifyNegation;
  5101. }
  5102. }
  5103. declare module "babylonjs/Misc/tags" {
  5104. /**
  5105. * Class used to store custom tags
  5106. */
  5107. export class Tags {
  5108. /**
  5109. * Adds support for tags on the given object
  5110. * @param obj defines the object to use
  5111. */
  5112. static EnableFor(obj: any): void;
  5113. /**
  5114. * Removes tags support
  5115. * @param obj defines the object to use
  5116. */
  5117. static DisableFor(obj: any): void;
  5118. /**
  5119. * Gets a boolean indicating if the given object has tags
  5120. * @param obj defines the object to use
  5121. * @returns a boolean
  5122. */
  5123. static HasTags(obj: any): boolean;
  5124. /**
  5125. * Gets the tags available on a given object
  5126. * @param obj defines the object to use
  5127. * @param asString defines if the tags must be returned as a string instead of an array of strings
  5128. * @returns the tags
  5129. */
  5130. static GetTags(obj: any, asString?: boolean): any;
  5131. /**
  5132. * Adds tags to an object
  5133. * @param obj defines the object to use
  5134. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5135. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5136. */
  5137. static AddTagsTo(obj: any, tagsString: string): void;
  5138. /**
  5139. * @hidden
  5140. */
  5141. static _AddTagTo(obj: any, tag: string): void;
  5142. /**
  5143. * Removes specific tags from a specific object
  5144. * @param obj defines the object to use
  5145. * @param tagsString defines the tags to remove
  5146. */
  5147. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5148. /**
  5149. * @hidden
  5150. */
  5151. static _RemoveTagFrom(obj: any, tag: string): void;
  5152. /**
  5153. * Defines if tags hosted on an object match a given query
  5154. * @param obj defines the object to use
  5155. * @param tagsQuery defines the tag query
  5156. * @returns a boolean
  5157. */
  5158. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5159. }
  5160. }
  5161. declare module "babylonjs/Materials/materialDefines" {
  5162. /**
  5163. * Manages the defines for the Material
  5164. */
  5165. export class MaterialDefines {
  5166. /** @hidden */
  5167. protected _keys: string[];
  5168. private _isDirty;
  5169. /** @hidden */
  5170. _renderId: number;
  5171. /** @hidden */
  5172. _areLightsDirty: boolean;
  5173. /** @hidden */
  5174. _areAttributesDirty: boolean;
  5175. /** @hidden */
  5176. _areTexturesDirty: boolean;
  5177. /** @hidden */
  5178. _areFresnelDirty: boolean;
  5179. /** @hidden */
  5180. _areMiscDirty: boolean;
  5181. /** @hidden */
  5182. _areImageProcessingDirty: boolean;
  5183. /** @hidden */
  5184. _normals: boolean;
  5185. /** @hidden */
  5186. _uvs: boolean;
  5187. /** @hidden */
  5188. _needNormals: boolean;
  5189. /** @hidden */
  5190. _needUVs: boolean;
  5191. [id: string]: any;
  5192. /**
  5193. * Specifies if the material needs to be re-calculated
  5194. */
  5195. readonly isDirty: boolean;
  5196. /**
  5197. * Marks the material to indicate that it has been re-calculated
  5198. */
  5199. markAsProcessed(): void;
  5200. /**
  5201. * Marks the material to indicate that it needs to be re-calculated
  5202. */
  5203. markAsUnprocessed(): void;
  5204. /**
  5205. * Marks the material to indicate all of its defines need to be re-calculated
  5206. */
  5207. markAllAsDirty(): void;
  5208. /**
  5209. * Marks the material to indicate that image processing needs to be re-calculated
  5210. */
  5211. markAsImageProcessingDirty(): void;
  5212. /**
  5213. * Marks the material to indicate the lights need to be re-calculated
  5214. */
  5215. markAsLightDirty(): void;
  5216. /**
  5217. * Marks the attribute state as changed
  5218. */
  5219. markAsAttributesDirty(): void;
  5220. /**
  5221. * Marks the texture state as changed
  5222. */
  5223. markAsTexturesDirty(): void;
  5224. /**
  5225. * Marks the fresnel state as changed
  5226. */
  5227. markAsFresnelDirty(): void;
  5228. /**
  5229. * Marks the misc state as changed
  5230. */
  5231. markAsMiscDirty(): void;
  5232. /**
  5233. * Rebuilds the material defines
  5234. */
  5235. rebuild(): void;
  5236. /**
  5237. * Specifies if two material defines are equal
  5238. * @param other - A material define instance to compare to
  5239. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  5240. */
  5241. isEqual(other: MaterialDefines): boolean;
  5242. /**
  5243. * Clones this instance's defines to another instance
  5244. * @param other - material defines to clone values to
  5245. */
  5246. cloneTo(other: MaterialDefines): void;
  5247. /**
  5248. * Resets the material define values
  5249. */
  5250. reset(): void;
  5251. /**
  5252. * Converts the material define values to a string
  5253. * @returns - String of material define information
  5254. */
  5255. toString(): string;
  5256. }
  5257. }
  5258. declare module "babylonjs/Engines/IPipelineContext" {
  5259. /**
  5260. * Class used to store and describe the pipeline context associated with an effect
  5261. */
  5262. export interface IPipelineContext {
  5263. /**
  5264. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  5265. */
  5266. isAsync: boolean;
  5267. /**
  5268. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  5269. */
  5270. isReady: boolean;
  5271. /** @hidden */
  5272. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  5273. }
  5274. }
  5275. declare module "babylonjs/Meshes/dataBuffer" {
  5276. /**
  5277. * Class used to store gfx data (like WebGLBuffer)
  5278. */
  5279. export class DataBuffer {
  5280. /**
  5281. * Gets or sets the number of objects referencing this buffer
  5282. */
  5283. references: number;
  5284. /** Gets or sets the size of the underlying buffer */
  5285. capacity: number;
  5286. /**
  5287. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  5288. */
  5289. is32Bits: boolean;
  5290. /**
  5291. * Gets the underlying buffer
  5292. */
  5293. readonly underlyingResource: any;
  5294. }
  5295. }
  5296. declare module "babylonjs/Misc/performanceMonitor" {
  5297. /**
  5298. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  5299. */
  5300. export class PerformanceMonitor {
  5301. private _enabled;
  5302. private _rollingFrameTime;
  5303. private _lastFrameTimeMs;
  5304. /**
  5305. * constructor
  5306. * @param frameSampleSize The number of samples required to saturate the sliding window
  5307. */
  5308. constructor(frameSampleSize?: number);
  5309. /**
  5310. * Samples current frame
  5311. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  5312. */
  5313. sampleFrame(timeMs?: number): void;
  5314. /**
  5315. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5316. */
  5317. readonly averageFrameTime: number;
  5318. /**
  5319. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5320. */
  5321. readonly averageFrameTimeVariance: number;
  5322. /**
  5323. * Returns the frame time of the most recent frame
  5324. */
  5325. readonly instantaneousFrameTime: number;
  5326. /**
  5327. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  5328. */
  5329. readonly averageFPS: number;
  5330. /**
  5331. * Returns the average framerate in frames per second using the most recent frame time
  5332. */
  5333. readonly instantaneousFPS: number;
  5334. /**
  5335. * Returns true if enough samples have been taken to completely fill the sliding window
  5336. */
  5337. readonly isSaturated: boolean;
  5338. /**
  5339. * Enables contributions to the sliding window sample set
  5340. */
  5341. enable(): void;
  5342. /**
  5343. * Disables contributions to the sliding window sample set
  5344. * Samples will not be interpolated over the disabled period
  5345. */
  5346. disable(): void;
  5347. /**
  5348. * Returns true if sampling is enabled
  5349. */
  5350. readonly isEnabled: boolean;
  5351. /**
  5352. * Resets performance monitor
  5353. */
  5354. reset(): void;
  5355. }
  5356. /**
  5357. * RollingAverage
  5358. *
  5359. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  5360. */
  5361. export class RollingAverage {
  5362. /**
  5363. * Current average
  5364. */
  5365. average: number;
  5366. /**
  5367. * Current variance
  5368. */
  5369. variance: number;
  5370. protected _samples: Array<number>;
  5371. protected _sampleCount: number;
  5372. protected _pos: number;
  5373. protected _m2: number;
  5374. /**
  5375. * constructor
  5376. * @param length The number of samples required to saturate the sliding window
  5377. */
  5378. constructor(length: number);
  5379. /**
  5380. * Adds a sample to the sample set
  5381. * @param v The sample value
  5382. */
  5383. add(v: number): void;
  5384. /**
  5385. * Returns previously added values or null if outside of history or outside the sliding window domain
  5386. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  5387. * @return Value previously recorded with add() or null if outside of range
  5388. */
  5389. history(i: number): number;
  5390. /**
  5391. * Returns true if enough samples have been taken to completely fill the sliding window
  5392. * @return true if sample-set saturated
  5393. */
  5394. isSaturated(): boolean;
  5395. /**
  5396. * Resets the rolling average (equivalent to 0 samples taken so far)
  5397. */
  5398. reset(): void;
  5399. /**
  5400. * Wraps a value around the sample range boundaries
  5401. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  5402. * @return Wrapped position in sample range
  5403. */
  5404. protected _wrapPosition(i: number): number;
  5405. }
  5406. }
  5407. declare module "babylonjs/Misc/stringDictionary" {
  5408. import { Nullable } from "babylonjs/types";
  5409. /**
  5410. * This class implement a typical dictionary using a string as key and the generic type T as value.
  5411. * The underlying implementation relies on an associative array to ensure the best performances.
  5412. * The value can be anything including 'null' but except 'undefined'
  5413. */
  5414. export class StringDictionary<T> {
  5415. /**
  5416. * This will clear this dictionary and copy the content from the 'source' one.
  5417. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  5418. * @param source the dictionary to take the content from and copy to this dictionary
  5419. */
  5420. copyFrom(source: StringDictionary<T>): void;
  5421. /**
  5422. * Get a value based from its key
  5423. * @param key the given key to get the matching value from
  5424. * @return the value if found, otherwise undefined is returned
  5425. */
  5426. get(key: string): T | undefined;
  5427. /**
  5428. * Get a value from its key or add it if it doesn't exist.
  5429. * This method will ensure you that a given key/data will be present in the dictionary.
  5430. * @param key the given key to get the matching value from
  5431. * @param factory the factory that will create the value if the key is not present in the dictionary.
  5432. * The factory will only be invoked if there's no data for the given key.
  5433. * @return the value corresponding to the key.
  5434. */
  5435. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  5436. /**
  5437. * Get a value from its key if present in the dictionary otherwise add it
  5438. * @param key the key to get the value from
  5439. * @param val if there's no such key/value pair in the dictionary add it with this value
  5440. * @return the value corresponding to the key
  5441. */
  5442. getOrAdd(key: string, val: T): T;
  5443. /**
  5444. * Check if there's a given key in the dictionary
  5445. * @param key the key to check for
  5446. * @return true if the key is present, false otherwise
  5447. */
  5448. contains(key: string): boolean;
  5449. /**
  5450. * Add a new key and its corresponding value
  5451. * @param key the key to add
  5452. * @param value the value corresponding to the key
  5453. * @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
  5454. */
  5455. add(key: string, value: T): boolean;
  5456. /**
  5457. * Update a specific value associated to a key
  5458. * @param key defines the key to use
  5459. * @param value defines the value to store
  5460. * @returns true if the value was updated (or false if the key was not found)
  5461. */
  5462. set(key: string, value: T): boolean;
  5463. /**
  5464. * Get the element of the given key and remove it from the dictionary
  5465. * @param key defines the key to search
  5466. * @returns the value associated with the key or null if not found
  5467. */
  5468. getAndRemove(key: string): Nullable<T>;
  5469. /**
  5470. * Remove a key/value from the dictionary.
  5471. * @param key the key to remove
  5472. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  5473. */
  5474. remove(key: string): boolean;
  5475. /**
  5476. * Clear the whole content of the dictionary
  5477. */
  5478. clear(): void;
  5479. /**
  5480. * Gets the current count
  5481. */
  5482. readonly count: number;
  5483. /**
  5484. * Execute a callback on each key/val of the dictionary.
  5485. * Note that you can remove any element in this dictionary in the callback implementation
  5486. * @param callback the callback to execute on a given key/value pair
  5487. */
  5488. forEach(callback: (key: string, val: T) => void): void;
  5489. /**
  5490. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  5491. * If the callback returns null or undefined the method will iterate to the next key/value pair
  5492. * Note that you can remove any element in this dictionary in the callback implementation
  5493. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  5494. * @returns the first item
  5495. */
  5496. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  5497. private _count;
  5498. private _data;
  5499. }
  5500. }
  5501. declare module "babylonjs/Misc/promise" {
  5502. /**
  5503. * Helper class that provides a small promise polyfill
  5504. */
  5505. export class PromisePolyfill {
  5506. /**
  5507. * Static function used to check if the polyfill is required
  5508. * If this is the case then the function will inject the polyfill to window.Promise
  5509. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  5510. */
  5511. static Apply(force?: boolean): void;
  5512. }
  5513. }
  5514. declare module "babylonjs/Meshes/buffer" {
  5515. import { Nullable, DataArray } from "babylonjs/types";
  5516. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  5517. /**
  5518. * Class used to store data that will be store in GPU memory
  5519. */
  5520. export class Buffer {
  5521. private _engine;
  5522. private _buffer;
  5523. /** @hidden */
  5524. _data: Nullable<DataArray>;
  5525. private _updatable;
  5526. private _instanced;
  5527. /**
  5528. * Gets the byte stride.
  5529. */
  5530. readonly byteStride: number;
  5531. /**
  5532. * Constructor
  5533. * @param engine the engine
  5534. * @param data the data to use for this buffer
  5535. * @param updatable whether the data is updatable
  5536. * @param stride the stride (optional)
  5537. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5538. * @param instanced whether the buffer is instanced (optional)
  5539. * @param useBytes set to true if the stride in in bytes (optional)
  5540. */
  5541. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  5542. /**
  5543. * Create a new VertexBuffer based on the current buffer
  5544. * @param kind defines the vertex buffer kind (position, normal, etc.)
  5545. * @param offset defines offset in the buffer (0 by default)
  5546. * @param size defines the size in floats of attributes (position is 3 for instance)
  5547. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  5548. * @param instanced defines if the vertex buffer contains indexed data
  5549. * @param useBytes defines if the offset and stride are in bytes
  5550. * @returns the new vertex buffer
  5551. */
  5552. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  5553. /**
  5554. * Gets a boolean indicating if the Buffer is updatable?
  5555. * @returns true if the buffer is updatable
  5556. */
  5557. isUpdatable(): boolean;
  5558. /**
  5559. * Gets current buffer's data
  5560. * @returns a DataArray or null
  5561. */
  5562. getData(): Nullable<DataArray>;
  5563. /**
  5564. * Gets underlying native buffer
  5565. * @returns underlying native buffer
  5566. */
  5567. getBuffer(): Nullable<DataBuffer>;
  5568. /**
  5569. * Gets the stride in float32 units (i.e. byte stride / 4).
  5570. * May not be an integer if the byte stride is not divisible by 4.
  5571. * DEPRECATED. Use byteStride instead.
  5572. * @returns the stride in float32 units
  5573. */
  5574. getStrideSize(): number;
  5575. /**
  5576. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5577. * @param data defines the data to store
  5578. */
  5579. create(data?: Nullable<DataArray>): void;
  5580. /** @hidden */
  5581. _rebuild(): void;
  5582. /**
  5583. * Update current buffer data
  5584. * @param data defines the data to store
  5585. */
  5586. update(data: DataArray): void;
  5587. /**
  5588. * Updates the data directly.
  5589. * @param data the new data
  5590. * @param offset the new offset
  5591. * @param vertexCount the vertex count (optional)
  5592. * @param useBytes set to true if the offset is in bytes
  5593. */
  5594. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  5595. /**
  5596. * Release all resources
  5597. */
  5598. dispose(): void;
  5599. }
  5600. /**
  5601. * Specialized buffer used to store vertex data
  5602. */
  5603. export class VertexBuffer {
  5604. /** @hidden */
  5605. _buffer: Buffer;
  5606. private _kind;
  5607. private _size;
  5608. private _ownsBuffer;
  5609. private _instanced;
  5610. private _instanceDivisor;
  5611. /**
  5612. * The byte type.
  5613. */
  5614. static readonly BYTE: number;
  5615. /**
  5616. * The unsigned byte type.
  5617. */
  5618. static readonly UNSIGNED_BYTE: number;
  5619. /**
  5620. * The short type.
  5621. */
  5622. static readonly SHORT: number;
  5623. /**
  5624. * The unsigned short type.
  5625. */
  5626. static readonly UNSIGNED_SHORT: number;
  5627. /**
  5628. * The integer type.
  5629. */
  5630. static readonly INT: number;
  5631. /**
  5632. * The unsigned integer type.
  5633. */
  5634. static readonly UNSIGNED_INT: number;
  5635. /**
  5636. * The float type.
  5637. */
  5638. static readonly FLOAT: number;
  5639. /**
  5640. * Gets or sets the instance divisor when in instanced mode
  5641. */
  5642. instanceDivisor: number;
  5643. /**
  5644. * Gets the byte stride.
  5645. */
  5646. readonly byteStride: number;
  5647. /**
  5648. * Gets the byte offset.
  5649. */
  5650. readonly byteOffset: number;
  5651. /**
  5652. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  5653. */
  5654. readonly normalized: boolean;
  5655. /**
  5656. * Gets the data type of each component in the array.
  5657. */
  5658. readonly type: number;
  5659. /**
  5660. * Constructor
  5661. * @param engine the engine
  5662. * @param data the data to use for this vertex buffer
  5663. * @param kind the vertex buffer kind
  5664. * @param updatable whether the data is updatable
  5665. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5666. * @param stride the stride (optional)
  5667. * @param instanced whether the buffer is instanced (optional)
  5668. * @param offset the offset of the data (optional)
  5669. * @param size the number of components (optional)
  5670. * @param type the type of the component (optional)
  5671. * @param normalized whether the data contains normalized data (optional)
  5672. * @param useBytes set to true if stride and offset are in bytes (optional)
  5673. */
  5674. 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);
  5675. /** @hidden */
  5676. _rebuild(): void;
  5677. /**
  5678. * Returns the kind of the VertexBuffer (string)
  5679. * @returns a string
  5680. */
  5681. getKind(): string;
  5682. /**
  5683. * Gets a boolean indicating if the VertexBuffer is updatable?
  5684. * @returns true if the buffer is updatable
  5685. */
  5686. isUpdatable(): boolean;
  5687. /**
  5688. * Gets current buffer's data
  5689. * @returns a DataArray or null
  5690. */
  5691. getData(): Nullable<DataArray>;
  5692. /**
  5693. * Gets underlying native buffer
  5694. * @returns underlying native buffer
  5695. */
  5696. getBuffer(): Nullable<DataBuffer>;
  5697. /**
  5698. * Gets the stride in float32 units (i.e. byte stride / 4).
  5699. * May not be an integer if the byte stride is not divisible by 4.
  5700. * DEPRECATED. Use byteStride instead.
  5701. * @returns the stride in float32 units
  5702. */
  5703. getStrideSize(): number;
  5704. /**
  5705. * Returns the offset as a multiple of the type byte length.
  5706. * DEPRECATED. Use byteOffset instead.
  5707. * @returns the offset in bytes
  5708. */
  5709. getOffset(): number;
  5710. /**
  5711. * Returns the number of components per vertex attribute (integer)
  5712. * @returns the size in float
  5713. */
  5714. getSize(): number;
  5715. /**
  5716. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  5717. * @returns true if this buffer is instanced
  5718. */
  5719. getIsInstanced(): boolean;
  5720. /**
  5721. * Returns the instancing divisor, zero for non-instanced (integer).
  5722. * @returns a number
  5723. */
  5724. getInstanceDivisor(): number;
  5725. /**
  5726. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5727. * @param data defines the data to store
  5728. */
  5729. create(data?: DataArray): void;
  5730. /**
  5731. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  5732. * This function will create a new buffer if the current one is not updatable
  5733. * @param data defines the data to store
  5734. */
  5735. update(data: DataArray): void;
  5736. /**
  5737. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  5738. * Returns the directly updated WebGLBuffer.
  5739. * @param data the new data
  5740. * @param offset the new offset
  5741. * @param useBytes set to true if the offset is in bytes
  5742. */
  5743. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  5744. /**
  5745. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  5746. */
  5747. dispose(): void;
  5748. /**
  5749. * Enumerates each value of this vertex buffer as numbers.
  5750. * @param count the number of values to enumerate
  5751. * @param callback the callback function called for each value
  5752. */
  5753. forEach(count: number, callback: (value: number, index: number) => void): void;
  5754. /**
  5755. * Positions
  5756. */
  5757. static readonly PositionKind: string;
  5758. /**
  5759. * Normals
  5760. */
  5761. static readonly NormalKind: string;
  5762. /**
  5763. * Tangents
  5764. */
  5765. static readonly TangentKind: string;
  5766. /**
  5767. * Texture coordinates
  5768. */
  5769. static readonly UVKind: string;
  5770. /**
  5771. * Texture coordinates 2
  5772. */
  5773. static readonly UV2Kind: string;
  5774. /**
  5775. * Texture coordinates 3
  5776. */
  5777. static readonly UV3Kind: string;
  5778. /**
  5779. * Texture coordinates 4
  5780. */
  5781. static readonly UV4Kind: string;
  5782. /**
  5783. * Texture coordinates 5
  5784. */
  5785. static readonly UV5Kind: string;
  5786. /**
  5787. * Texture coordinates 6
  5788. */
  5789. static readonly UV6Kind: string;
  5790. /**
  5791. * Colors
  5792. */
  5793. static readonly ColorKind: string;
  5794. /**
  5795. * Matrix indices (for bones)
  5796. */
  5797. static readonly MatricesIndicesKind: string;
  5798. /**
  5799. * Matrix weights (for bones)
  5800. */
  5801. static readonly MatricesWeightsKind: string;
  5802. /**
  5803. * Additional matrix indices (for bones)
  5804. */
  5805. static readonly MatricesIndicesExtraKind: string;
  5806. /**
  5807. * Additional matrix weights (for bones)
  5808. */
  5809. static readonly MatricesWeightsExtraKind: string;
  5810. /**
  5811. * Deduces the stride given a kind.
  5812. * @param kind The kind string to deduce
  5813. * @returns The deduced stride
  5814. */
  5815. static DeduceStride(kind: string): number;
  5816. /**
  5817. * Gets the byte length of the given type.
  5818. * @param type the type
  5819. * @returns the number of bytes
  5820. */
  5821. static GetTypeByteLength(type: number): number;
  5822. /**
  5823. * Enumerates each value of the given parameters as numbers.
  5824. * @param data the data to enumerate
  5825. * @param byteOffset the byte offset of the data
  5826. * @param byteStride the byte stride of the data
  5827. * @param componentCount the number of components per element
  5828. * @param componentType the type of the component
  5829. * @param count the total number of components
  5830. * @param normalized whether the data is normalized
  5831. * @param callback the callback function called for each value
  5832. */
  5833. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  5834. private static _GetFloatValue;
  5835. }
  5836. }
  5837. declare module "babylonjs/Maths/sphericalPolynomial" {
  5838. import { Vector3, Color3 } from "babylonjs/Maths/math";
  5839. /**
  5840. * Class representing spherical harmonics coefficients to the 3rd degree
  5841. */
  5842. export class SphericalHarmonics {
  5843. /**
  5844. * Defines whether or not the harmonics have been prescaled for rendering.
  5845. */
  5846. preScaled: boolean;
  5847. /**
  5848. * The l0,0 coefficients of the spherical harmonics
  5849. */
  5850. l00: Vector3;
  5851. /**
  5852. * The l1,-1 coefficients of the spherical harmonics
  5853. */
  5854. l1_1: Vector3;
  5855. /**
  5856. * The l1,0 coefficients of the spherical harmonics
  5857. */
  5858. l10: Vector3;
  5859. /**
  5860. * The l1,1 coefficients of the spherical harmonics
  5861. */
  5862. l11: Vector3;
  5863. /**
  5864. * The l2,-2 coefficients of the spherical harmonics
  5865. */
  5866. l2_2: Vector3;
  5867. /**
  5868. * The l2,-1 coefficients of the spherical harmonics
  5869. */
  5870. l2_1: Vector3;
  5871. /**
  5872. * The l2,0 coefficients of the spherical harmonics
  5873. */
  5874. l20: Vector3;
  5875. /**
  5876. * The l2,1 coefficients of the spherical harmonics
  5877. */
  5878. l21: Vector3;
  5879. /**
  5880. * The l2,2 coefficients of the spherical harmonics
  5881. */
  5882. l22: Vector3;
  5883. /**
  5884. * Adds a light to the spherical harmonics
  5885. * @param direction the direction of the light
  5886. * @param color the color of the light
  5887. * @param deltaSolidAngle the delta solid angle of the light
  5888. */
  5889. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  5890. /**
  5891. * Scales the spherical harmonics by the given amount
  5892. * @param scale the amount to scale
  5893. */
  5894. scaleInPlace(scale: number): void;
  5895. /**
  5896. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  5897. *
  5898. * ```
  5899. * E_lm = A_l * L_lm
  5900. * ```
  5901. *
  5902. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  5903. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  5904. * the scaling factors are given in equation 9.
  5905. */
  5906. convertIncidentRadianceToIrradiance(): void;
  5907. /**
  5908. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  5909. *
  5910. * ```
  5911. * L = (1/pi) * E * rho
  5912. * ```
  5913. *
  5914. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  5915. */
  5916. convertIrradianceToLambertianRadiance(): void;
  5917. /**
  5918. * Integrates the reconstruction coefficients directly in to the SH preventing further
  5919. * required operations at run time.
  5920. *
  5921. * This is simply done by scaling back the SH with Ylm constants parameter.
  5922. * The trigonometric part being applied by the shader at run time.
  5923. */
  5924. preScaleForRendering(): void;
  5925. /**
  5926. * Constructs a spherical harmonics from an array.
  5927. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  5928. * @returns the spherical harmonics
  5929. */
  5930. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  5931. /**
  5932. * Gets the spherical harmonics from polynomial
  5933. * @param polynomial the spherical polynomial
  5934. * @returns the spherical harmonics
  5935. */
  5936. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  5937. }
  5938. /**
  5939. * Class representing spherical polynomial coefficients to the 3rd degree
  5940. */
  5941. export class SphericalPolynomial {
  5942. private _harmonics;
  5943. /**
  5944. * The spherical harmonics used to create the polynomials.
  5945. */
  5946. readonly preScaledHarmonics: SphericalHarmonics;
  5947. /**
  5948. * The x coefficients of the spherical polynomial
  5949. */
  5950. x: Vector3;
  5951. /**
  5952. * The y coefficients of the spherical polynomial
  5953. */
  5954. y: Vector3;
  5955. /**
  5956. * The z coefficients of the spherical polynomial
  5957. */
  5958. z: Vector3;
  5959. /**
  5960. * The xx coefficients of the spherical polynomial
  5961. */
  5962. xx: Vector3;
  5963. /**
  5964. * The yy coefficients of the spherical polynomial
  5965. */
  5966. yy: Vector3;
  5967. /**
  5968. * The zz coefficients of the spherical polynomial
  5969. */
  5970. zz: Vector3;
  5971. /**
  5972. * The xy coefficients of the spherical polynomial
  5973. */
  5974. xy: Vector3;
  5975. /**
  5976. * The yz coefficients of the spherical polynomial
  5977. */
  5978. yz: Vector3;
  5979. /**
  5980. * The zx coefficients of the spherical polynomial
  5981. */
  5982. zx: Vector3;
  5983. /**
  5984. * Adds an ambient color to the spherical polynomial
  5985. * @param color the color to add
  5986. */
  5987. addAmbient(color: Color3): void;
  5988. /**
  5989. * Scales the spherical polynomial by the given amount
  5990. * @param scale the amount to scale
  5991. */
  5992. scaleInPlace(scale: number): void;
  5993. /**
  5994. * Gets the spherical polynomial from harmonics
  5995. * @param harmonics the spherical harmonics
  5996. * @returns the spherical polynomial
  5997. */
  5998. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  5999. /**
  6000. * Constructs a spherical polynomial from an array.
  6001. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  6002. * @returns the spherical polynomial
  6003. */
  6004. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  6005. }
  6006. }
  6007. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  6008. import { Nullable } from "babylonjs/types";
  6009. /**
  6010. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  6011. */
  6012. export interface CubeMapInfo {
  6013. /**
  6014. * The pixel array for the front face.
  6015. * This is stored in format, left to right, up to down format.
  6016. */
  6017. front: Nullable<ArrayBufferView>;
  6018. /**
  6019. * The pixel array for the back face.
  6020. * This is stored in format, left to right, up to down format.
  6021. */
  6022. back: Nullable<ArrayBufferView>;
  6023. /**
  6024. * The pixel array for the left face.
  6025. * This is stored in format, left to right, up to down format.
  6026. */
  6027. left: Nullable<ArrayBufferView>;
  6028. /**
  6029. * The pixel array for the right face.
  6030. * This is stored in format, left to right, up to down format.
  6031. */
  6032. right: Nullable<ArrayBufferView>;
  6033. /**
  6034. * The pixel array for the up face.
  6035. * This is stored in format, left to right, up to down format.
  6036. */
  6037. up: Nullable<ArrayBufferView>;
  6038. /**
  6039. * The pixel array for the down face.
  6040. * This is stored in format, left to right, up to down format.
  6041. */
  6042. down: Nullable<ArrayBufferView>;
  6043. /**
  6044. * The size of the cubemap stored.
  6045. *
  6046. * Each faces will be size * size pixels.
  6047. */
  6048. size: number;
  6049. /**
  6050. * The format of the texture.
  6051. *
  6052. * RGBA, RGB.
  6053. */
  6054. format: number;
  6055. /**
  6056. * The type of the texture data.
  6057. *
  6058. * UNSIGNED_INT, FLOAT.
  6059. */
  6060. type: number;
  6061. /**
  6062. * Specifies whether the texture is in gamma space.
  6063. */
  6064. gammaSpace: boolean;
  6065. }
  6066. /**
  6067. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  6068. */
  6069. export class PanoramaToCubeMapTools {
  6070. private static FACE_FRONT;
  6071. private static FACE_BACK;
  6072. private static FACE_RIGHT;
  6073. private static FACE_LEFT;
  6074. private static FACE_DOWN;
  6075. private static FACE_UP;
  6076. /**
  6077. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  6078. *
  6079. * @param float32Array The source data.
  6080. * @param inputWidth The width of the input panorama.
  6081. * @param inputHeight The height of the input panorama.
  6082. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  6083. * @return The cubemap data
  6084. */
  6085. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  6086. private static CreateCubemapTexture;
  6087. private static CalcProjectionSpherical;
  6088. }
  6089. }
  6090. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  6091. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  6092. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  6093. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  6094. /**
  6095. * Helper class dealing with the extraction of spherical polynomial dataArray
  6096. * from a cube map.
  6097. */
  6098. export class CubeMapToSphericalPolynomialTools {
  6099. private static FileFaces;
  6100. /**
  6101. * Converts a texture to the according Spherical Polynomial data.
  6102. * This extracts the first 3 orders only as they are the only one used in the lighting.
  6103. *
  6104. * @param texture The texture to extract the information from.
  6105. * @return The Spherical Polynomial data.
  6106. */
  6107. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  6108. /**
  6109. * Converts a cubemap to the according Spherical Polynomial data.
  6110. * This extracts the first 3 orders only as they are the only one used in the lighting.
  6111. *
  6112. * @param cubeInfo The Cube map to extract the information from.
  6113. * @return The Spherical Polynomial data.
  6114. */
  6115. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  6116. }
  6117. }
  6118. declare module "babylonjs/Engines/engineStore" {
  6119. import { Nullable } from "babylonjs/types";
  6120. import { Engine } from "babylonjs/Engines/engine";
  6121. import { Scene } from "babylonjs/scene";
  6122. /**
  6123. * The engine store class is responsible to hold all the instances of Engine and Scene created
  6124. * during the life time of the application.
  6125. */
  6126. export class EngineStore {
  6127. /** Gets the list of created engines */
  6128. static Instances: import("babylonjs/Engines/engine").Engine[];
  6129. /** @hidden */
  6130. static _LastCreatedScene: Nullable<Scene>;
  6131. /**
  6132. * Gets the latest created engine
  6133. */
  6134. static readonly LastCreatedEngine: Nullable<Engine>;
  6135. /**
  6136. * Gets the latest created scene
  6137. */
  6138. static readonly LastCreatedScene: Nullable<Scene>;
  6139. }
  6140. }
  6141. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  6142. /**
  6143. * Define options used to create a render target texture
  6144. */
  6145. export class RenderTargetCreationOptions {
  6146. /**
  6147. * Specifies is mipmaps must be generated
  6148. */
  6149. generateMipMaps?: boolean;
  6150. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  6151. generateDepthBuffer?: boolean;
  6152. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  6153. generateStencilBuffer?: boolean;
  6154. /** Defines texture type (int by default) */
  6155. type?: number;
  6156. /** Defines sampling mode (trilinear by default) */
  6157. samplingMode?: number;
  6158. /** Defines format (RGBA by default) */
  6159. format?: number;
  6160. }
  6161. }
  6162. declare module "babylonjs/States/alphaCullingState" {
  6163. /**
  6164. * @hidden
  6165. **/
  6166. export class _AlphaState {
  6167. private _isAlphaBlendDirty;
  6168. private _isBlendFunctionParametersDirty;
  6169. private _isBlendEquationParametersDirty;
  6170. private _isBlendConstantsDirty;
  6171. private _alphaBlend;
  6172. private _blendFunctionParameters;
  6173. private _blendEquationParameters;
  6174. private _blendConstants;
  6175. /**
  6176. * Initializes the state.
  6177. */
  6178. constructor();
  6179. readonly isDirty: boolean;
  6180. alphaBlend: boolean;
  6181. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  6182. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  6183. setAlphaEquationParameters(rgb: number, alpha: number): void;
  6184. reset(): void;
  6185. apply(gl: WebGLRenderingContext): void;
  6186. }
  6187. }
  6188. declare module "babylonjs/States/depthCullingState" {
  6189. import { Nullable } from "babylonjs/types";
  6190. /**
  6191. * @hidden
  6192. **/
  6193. export class _DepthCullingState {
  6194. private _isDepthTestDirty;
  6195. private _isDepthMaskDirty;
  6196. private _isDepthFuncDirty;
  6197. private _isCullFaceDirty;
  6198. private _isCullDirty;
  6199. private _isZOffsetDirty;
  6200. private _isFrontFaceDirty;
  6201. private _depthTest;
  6202. private _depthMask;
  6203. private _depthFunc;
  6204. private _cull;
  6205. private _cullFace;
  6206. private _zOffset;
  6207. private _frontFace;
  6208. /**
  6209. * Initializes the state.
  6210. */
  6211. constructor();
  6212. readonly isDirty: boolean;
  6213. zOffset: number;
  6214. cullFace: Nullable<number>;
  6215. cull: Nullable<boolean>;
  6216. depthFunc: Nullable<number>;
  6217. depthMask: boolean;
  6218. depthTest: boolean;
  6219. frontFace: Nullable<number>;
  6220. reset(): void;
  6221. apply(gl: WebGLRenderingContext): void;
  6222. }
  6223. }
  6224. declare module "babylonjs/States/stencilState" {
  6225. /**
  6226. * @hidden
  6227. **/
  6228. export class _StencilState {
  6229. /** 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 */
  6230. static readonly ALWAYS: number;
  6231. /** Passed to stencilOperation to specify that stencil value must be kept */
  6232. static readonly KEEP: number;
  6233. /** Passed to stencilOperation to specify that stencil value must be replaced */
  6234. static readonly REPLACE: number;
  6235. private _isStencilTestDirty;
  6236. private _isStencilMaskDirty;
  6237. private _isStencilFuncDirty;
  6238. private _isStencilOpDirty;
  6239. private _stencilTest;
  6240. private _stencilMask;
  6241. private _stencilFunc;
  6242. private _stencilFuncRef;
  6243. private _stencilFuncMask;
  6244. private _stencilOpStencilFail;
  6245. private _stencilOpDepthFail;
  6246. private _stencilOpStencilDepthPass;
  6247. readonly isDirty: boolean;
  6248. stencilFunc: number;
  6249. stencilFuncRef: number;
  6250. stencilFuncMask: number;
  6251. stencilOpStencilFail: number;
  6252. stencilOpDepthFail: number;
  6253. stencilOpStencilDepthPass: number;
  6254. stencilMask: number;
  6255. stencilTest: boolean;
  6256. constructor();
  6257. reset(): void;
  6258. apply(gl: WebGLRenderingContext): void;
  6259. }
  6260. }
  6261. declare module "babylonjs/States/index" {
  6262. export * from "babylonjs/States/alphaCullingState";
  6263. export * from "babylonjs/States/depthCullingState";
  6264. export * from "babylonjs/States/stencilState";
  6265. }
  6266. declare module "babylonjs/Instrumentation/timeToken" {
  6267. import { Nullable } from "babylonjs/types";
  6268. /**
  6269. * @hidden
  6270. **/
  6271. export class _TimeToken {
  6272. _startTimeQuery: Nullable<WebGLQuery>;
  6273. _endTimeQuery: Nullable<WebGLQuery>;
  6274. _timeElapsedQuery: Nullable<WebGLQuery>;
  6275. _timeElapsedQueryEnded: boolean;
  6276. }
  6277. }
  6278. declare module "babylonjs/Materials/Textures/internalTexture" {
  6279. import { Observable } from "babylonjs/Misc/observable";
  6280. import { Nullable, int } from "babylonjs/types";
  6281. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  6282. import { Engine } from "babylonjs/Engines/engine";
  6283. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  6284. /**
  6285. * Class used to store data associated with WebGL texture data for the engine
  6286. * This class should not be used directly
  6287. */
  6288. export class InternalTexture {
  6289. /** hidden */
  6290. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  6291. /**
  6292. * The source of the texture data is unknown
  6293. */
  6294. static DATASOURCE_UNKNOWN: number;
  6295. /**
  6296. * Texture data comes from an URL
  6297. */
  6298. static DATASOURCE_URL: number;
  6299. /**
  6300. * Texture data is only used for temporary storage
  6301. */
  6302. static DATASOURCE_TEMP: number;
  6303. /**
  6304. * Texture data comes from raw data (ArrayBuffer)
  6305. */
  6306. static DATASOURCE_RAW: number;
  6307. /**
  6308. * Texture content is dynamic (video or dynamic texture)
  6309. */
  6310. static DATASOURCE_DYNAMIC: number;
  6311. /**
  6312. * Texture content is generated by rendering to it
  6313. */
  6314. static DATASOURCE_RENDERTARGET: number;
  6315. /**
  6316. * Texture content is part of a multi render target process
  6317. */
  6318. static DATASOURCE_MULTIRENDERTARGET: number;
  6319. /**
  6320. * Texture data comes from a cube data file
  6321. */
  6322. static DATASOURCE_CUBE: number;
  6323. /**
  6324. * Texture data comes from a raw cube data
  6325. */
  6326. static DATASOURCE_CUBERAW: number;
  6327. /**
  6328. * Texture data come from a prefiltered cube data file
  6329. */
  6330. static DATASOURCE_CUBEPREFILTERED: number;
  6331. /**
  6332. * Texture content is raw 3D data
  6333. */
  6334. static DATASOURCE_RAW3D: number;
  6335. /**
  6336. * Texture content is a depth texture
  6337. */
  6338. static DATASOURCE_DEPTHTEXTURE: number;
  6339. /**
  6340. * Texture data comes from a raw cube data encoded with RGBD
  6341. */
  6342. static DATASOURCE_CUBERAW_RGBD: number;
  6343. /**
  6344. * Defines if the texture is ready
  6345. */
  6346. isReady: boolean;
  6347. /**
  6348. * Defines if the texture is a cube texture
  6349. */
  6350. isCube: boolean;
  6351. /**
  6352. * Defines if the texture contains 3D data
  6353. */
  6354. is3D: boolean;
  6355. /**
  6356. * Defines if the texture contains multiview data
  6357. */
  6358. isMultiview: boolean;
  6359. /**
  6360. * Gets the URL used to load this texture
  6361. */
  6362. url: string;
  6363. /**
  6364. * Gets the sampling mode of the texture
  6365. */
  6366. samplingMode: number;
  6367. /**
  6368. * Gets a boolean indicating if the texture needs mipmaps generation
  6369. */
  6370. generateMipMaps: boolean;
  6371. /**
  6372. * Gets the number of samples used by the texture (WebGL2+ only)
  6373. */
  6374. samples: number;
  6375. /**
  6376. * Gets the type of the texture (int, float...)
  6377. */
  6378. type: number;
  6379. /**
  6380. * Gets the format of the texture (RGB, RGBA...)
  6381. */
  6382. format: number;
  6383. /**
  6384. * Observable called when the texture is loaded
  6385. */
  6386. onLoadedObservable: Observable<InternalTexture>;
  6387. /**
  6388. * Gets the width of the texture
  6389. */
  6390. width: number;
  6391. /**
  6392. * Gets the height of the texture
  6393. */
  6394. height: number;
  6395. /**
  6396. * Gets the depth of the texture
  6397. */
  6398. depth: number;
  6399. /**
  6400. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  6401. */
  6402. baseWidth: number;
  6403. /**
  6404. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  6405. */
  6406. baseHeight: number;
  6407. /**
  6408. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  6409. */
  6410. baseDepth: number;
  6411. /**
  6412. * Gets a boolean indicating if the texture is inverted on Y axis
  6413. */
  6414. invertY: boolean;
  6415. /** @hidden */
  6416. _invertVScale: boolean;
  6417. /** @hidden */
  6418. _associatedChannel: number;
  6419. /** @hidden */
  6420. _dataSource: number;
  6421. /** @hidden */
  6422. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  6423. /** @hidden */
  6424. _bufferView: Nullable<ArrayBufferView>;
  6425. /** @hidden */
  6426. _bufferViewArray: Nullable<ArrayBufferView[]>;
  6427. /** @hidden */
  6428. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  6429. /** @hidden */
  6430. _size: number;
  6431. /** @hidden */
  6432. _extension: string;
  6433. /** @hidden */
  6434. _files: Nullable<string[]>;
  6435. /** @hidden */
  6436. _workingCanvas: Nullable<HTMLCanvasElement>;
  6437. /** @hidden */
  6438. _workingContext: Nullable<CanvasRenderingContext2D>;
  6439. /** @hidden */
  6440. _framebuffer: Nullable<WebGLFramebuffer>;
  6441. /** @hidden */
  6442. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  6443. /** @hidden */
  6444. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  6445. /** @hidden */
  6446. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  6447. /** @hidden */
  6448. _attachments: Nullable<number[]>;
  6449. /** @hidden */
  6450. _cachedCoordinatesMode: Nullable<number>;
  6451. /** @hidden */
  6452. _cachedWrapU: Nullable<number>;
  6453. /** @hidden */
  6454. _cachedWrapV: Nullable<number>;
  6455. /** @hidden */
  6456. _cachedWrapR: Nullable<number>;
  6457. /** @hidden */
  6458. _cachedAnisotropicFilteringLevel: Nullable<number>;
  6459. /** @hidden */
  6460. _isDisabled: boolean;
  6461. /** @hidden */
  6462. _compression: Nullable<string>;
  6463. /** @hidden */
  6464. _generateStencilBuffer: boolean;
  6465. /** @hidden */
  6466. _generateDepthBuffer: boolean;
  6467. /** @hidden */
  6468. _comparisonFunction: number;
  6469. /** @hidden */
  6470. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  6471. /** @hidden */
  6472. _lodGenerationScale: number;
  6473. /** @hidden */
  6474. _lodGenerationOffset: number;
  6475. /** @hidden */
  6476. _colorTextureArray: Nullable<WebGLTexture>;
  6477. /** @hidden */
  6478. _depthStencilTextureArray: Nullable<WebGLTexture>;
  6479. /** @hidden */
  6480. _lodTextureHigh: Nullable<BaseTexture>;
  6481. /** @hidden */
  6482. _lodTextureMid: Nullable<BaseTexture>;
  6483. /** @hidden */
  6484. _lodTextureLow: Nullable<BaseTexture>;
  6485. /** @hidden */
  6486. _isRGBD: boolean;
  6487. /** @hidden */
  6488. _webGLTexture: Nullable<WebGLTexture>;
  6489. /** @hidden */
  6490. _references: number;
  6491. private _engine;
  6492. /**
  6493. * Gets the Engine the texture belongs to.
  6494. * @returns The babylon engine
  6495. */
  6496. getEngine(): Engine;
  6497. /**
  6498. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  6499. */
  6500. readonly dataSource: number;
  6501. /**
  6502. * Creates a new InternalTexture
  6503. * @param engine defines the engine to use
  6504. * @param dataSource defines the type of data that will be used
  6505. * @param delayAllocation if the texture allocation should be delayed (default: false)
  6506. */
  6507. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  6508. /**
  6509. * Increments the number of references (ie. the number of Texture that point to it)
  6510. */
  6511. incrementReferences(): void;
  6512. /**
  6513. * Change the size of the texture (not the size of the content)
  6514. * @param width defines the new width
  6515. * @param height defines the new height
  6516. * @param depth defines the new depth (1 by default)
  6517. */
  6518. updateSize(width: int, height: int, depth?: int): void;
  6519. /** @hidden */
  6520. _rebuild(): void;
  6521. /** @hidden */
  6522. _swapAndDie(target: InternalTexture): void;
  6523. /**
  6524. * Dispose the current allocated resources
  6525. */
  6526. dispose(): void;
  6527. }
  6528. }
  6529. declare module "babylonjs/Animations/easing" {
  6530. /**
  6531. * This represents the main contract an easing function should follow.
  6532. * Easing functions are used throughout the animation system.
  6533. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6534. */
  6535. export interface IEasingFunction {
  6536. /**
  6537. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6538. * of the easing function.
  6539. * The link below provides some of the most common examples of easing functions.
  6540. * @see https://easings.net/
  6541. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6542. * @returns the corresponding value on the curve defined by the easing function
  6543. */
  6544. ease(gradient: number): number;
  6545. }
  6546. /**
  6547. * Base class used for every default easing function.
  6548. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6549. */
  6550. export class EasingFunction implements IEasingFunction {
  6551. /**
  6552. * Interpolation follows the mathematical formula associated with the easing function.
  6553. */
  6554. static readonly EASINGMODE_EASEIN: number;
  6555. /**
  6556. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  6557. */
  6558. static readonly EASINGMODE_EASEOUT: number;
  6559. /**
  6560. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  6561. */
  6562. static readonly EASINGMODE_EASEINOUT: number;
  6563. private _easingMode;
  6564. /**
  6565. * Sets the easing mode of the current function.
  6566. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  6567. */
  6568. setEasingMode(easingMode: number): void;
  6569. /**
  6570. * Gets the current easing mode.
  6571. * @returns the easing mode
  6572. */
  6573. getEasingMode(): number;
  6574. /**
  6575. * @hidden
  6576. */
  6577. easeInCore(gradient: number): number;
  6578. /**
  6579. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6580. * of the easing function.
  6581. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6582. * @returns the corresponding value on the curve defined by the easing function
  6583. */
  6584. ease(gradient: number): number;
  6585. }
  6586. /**
  6587. * Easing function with a circle shape (see link below).
  6588. * @see https://easings.net/#easeInCirc
  6589. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6590. */
  6591. export class CircleEase extends EasingFunction implements IEasingFunction {
  6592. /** @hidden */
  6593. easeInCore(gradient: number): number;
  6594. }
  6595. /**
  6596. * Easing function with a ease back shape (see link below).
  6597. * @see https://easings.net/#easeInBack
  6598. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6599. */
  6600. export class BackEase extends EasingFunction implements IEasingFunction {
  6601. /** Defines the amplitude of the function */
  6602. amplitude: number;
  6603. /**
  6604. * Instantiates a back ease easing
  6605. * @see https://easings.net/#easeInBack
  6606. * @param amplitude Defines the amplitude of the function
  6607. */
  6608. constructor(
  6609. /** Defines the amplitude of the function */
  6610. amplitude?: number);
  6611. /** @hidden */
  6612. easeInCore(gradient: number): number;
  6613. }
  6614. /**
  6615. * Easing function with a bouncing shape (see link below).
  6616. * @see https://easings.net/#easeInBounce
  6617. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6618. */
  6619. export class BounceEase extends EasingFunction implements IEasingFunction {
  6620. /** Defines the number of bounces */
  6621. bounces: number;
  6622. /** Defines the amplitude of the bounce */
  6623. bounciness: number;
  6624. /**
  6625. * Instantiates a bounce easing
  6626. * @see https://easings.net/#easeInBounce
  6627. * @param bounces Defines the number of bounces
  6628. * @param bounciness Defines the amplitude of the bounce
  6629. */
  6630. constructor(
  6631. /** Defines the number of bounces */
  6632. bounces?: number,
  6633. /** Defines the amplitude of the bounce */
  6634. bounciness?: number);
  6635. /** @hidden */
  6636. easeInCore(gradient: number): number;
  6637. }
  6638. /**
  6639. * Easing function with a power of 3 shape (see link below).
  6640. * @see https://easings.net/#easeInCubic
  6641. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6642. */
  6643. export class CubicEase extends EasingFunction implements IEasingFunction {
  6644. /** @hidden */
  6645. easeInCore(gradient: number): number;
  6646. }
  6647. /**
  6648. * Easing function with an elastic shape (see link below).
  6649. * @see https://easings.net/#easeInElastic
  6650. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6651. */
  6652. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6653. /** Defines the number of oscillations*/
  6654. oscillations: number;
  6655. /** Defines the amplitude of the oscillations*/
  6656. springiness: number;
  6657. /**
  6658. * Instantiates an elastic easing function
  6659. * @see https://easings.net/#easeInElastic
  6660. * @param oscillations Defines the number of oscillations
  6661. * @param springiness Defines the amplitude of the oscillations
  6662. */
  6663. constructor(
  6664. /** Defines the number of oscillations*/
  6665. oscillations?: number,
  6666. /** Defines the amplitude of the oscillations*/
  6667. springiness?: number);
  6668. /** @hidden */
  6669. easeInCore(gradient: number): number;
  6670. }
  6671. /**
  6672. * Easing function with an exponential shape (see link below).
  6673. * @see https://easings.net/#easeInExpo
  6674. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6675. */
  6676. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6677. /** Defines the exponent of the function */
  6678. exponent: number;
  6679. /**
  6680. * Instantiates an exponential easing function
  6681. * @see https://easings.net/#easeInExpo
  6682. * @param exponent Defines the exponent of the function
  6683. */
  6684. constructor(
  6685. /** Defines the exponent of the function */
  6686. exponent?: number);
  6687. /** @hidden */
  6688. easeInCore(gradient: number): number;
  6689. }
  6690. /**
  6691. * Easing function with a power shape (see link below).
  6692. * @see https://easings.net/#easeInQuad
  6693. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6694. */
  6695. export class PowerEase extends EasingFunction implements IEasingFunction {
  6696. /** Defines the power of the function */
  6697. power: number;
  6698. /**
  6699. * Instantiates an power base easing function
  6700. * @see https://easings.net/#easeInQuad
  6701. * @param power Defines the power of the function
  6702. */
  6703. constructor(
  6704. /** Defines the power of the function */
  6705. power?: number);
  6706. /** @hidden */
  6707. easeInCore(gradient: number): number;
  6708. }
  6709. /**
  6710. * Easing function with a power of 2 shape (see link below).
  6711. * @see https://easings.net/#easeInQuad
  6712. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6713. */
  6714. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6715. /** @hidden */
  6716. easeInCore(gradient: number): number;
  6717. }
  6718. /**
  6719. * Easing function with a power of 4 shape (see link below).
  6720. * @see https://easings.net/#easeInQuart
  6721. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6722. */
  6723. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6724. /** @hidden */
  6725. easeInCore(gradient: number): number;
  6726. }
  6727. /**
  6728. * Easing function with a power of 5 shape (see link below).
  6729. * @see https://easings.net/#easeInQuint
  6730. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6731. */
  6732. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6733. /** @hidden */
  6734. easeInCore(gradient: number): number;
  6735. }
  6736. /**
  6737. * Easing function with a sin shape (see link below).
  6738. * @see https://easings.net/#easeInSine
  6739. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6740. */
  6741. export class SineEase extends EasingFunction implements IEasingFunction {
  6742. /** @hidden */
  6743. easeInCore(gradient: number): number;
  6744. }
  6745. /**
  6746. * Easing function with a bezier shape (see link below).
  6747. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6748. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6749. */
  6750. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6751. /** Defines the x component of the start tangent in the bezier curve */
  6752. x1: number;
  6753. /** Defines the y component of the start tangent in the bezier curve */
  6754. y1: number;
  6755. /** Defines the x component of the end tangent in the bezier curve */
  6756. x2: number;
  6757. /** Defines the y component of the end tangent in the bezier curve */
  6758. y2: number;
  6759. /**
  6760. * Instantiates a bezier function
  6761. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6762. * @param x1 Defines the x component of the start tangent in the bezier curve
  6763. * @param y1 Defines the y component of the start tangent in the bezier curve
  6764. * @param x2 Defines the x component of the end tangent in the bezier curve
  6765. * @param y2 Defines the y component of the end tangent in the bezier curve
  6766. */
  6767. constructor(
  6768. /** Defines the x component of the start tangent in the bezier curve */
  6769. x1?: number,
  6770. /** Defines the y component of the start tangent in the bezier curve */
  6771. y1?: number,
  6772. /** Defines the x component of the end tangent in the bezier curve */
  6773. x2?: number,
  6774. /** Defines the y component of the end tangent in the bezier curve */
  6775. y2?: number);
  6776. /** @hidden */
  6777. easeInCore(gradient: number): number;
  6778. }
  6779. }
  6780. declare module "babylonjs/Animations/animationKey" {
  6781. /**
  6782. * Defines an interface which represents an animation key frame
  6783. */
  6784. export interface IAnimationKey {
  6785. /**
  6786. * Frame of the key frame
  6787. */
  6788. frame: number;
  6789. /**
  6790. * Value at the specifies key frame
  6791. */
  6792. value: any;
  6793. /**
  6794. * The input tangent for the cubic hermite spline
  6795. */
  6796. inTangent?: any;
  6797. /**
  6798. * The output tangent for the cubic hermite spline
  6799. */
  6800. outTangent?: any;
  6801. /**
  6802. * The animation interpolation type
  6803. */
  6804. interpolation?: AnimationKeyInterpolation;
  6805. }
  6806. /**
  6807. * Enum for the animation key frame interpolation type
  6808. */
  6809. export enum AnimationKeyInterpolation {
  6810. /**
  6811. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6812. */
  6813. STEP = 1
  6814. }
  6815. }
  6816. declare module "babylonjs/Animations/animationRange" {
  6817. /**
  6818. * Represents the range of an animation
  6819. */
  6820. export class AnimationRange {
  6821. /**The name of the animation range**/
  6822. name: string;
  6823. /**The starting frame of the animation */
  6824. from: number;
  6825. /**The ending frame of the animation*/
  6826. to: number;
  6827. /**
  6828. * Initializes the range of an animation
  6829. * @param name The name of the animation range
  6830. * @param from The starting frame of the animation
  6831. * @param to The ending frame of the animation
  6832. */
  6833. constructor(
  6834. /**The name of the animation range**/
  6835. name: string,
  6836. /**The starting frame of the animation */
  6837. from: number,
  6838. /**The ending frame of the animation*/
  6839. to: number);
  6840. /**
  6841. * Makes a copy of the animation range
  6842. * @returns A copy of the animation range
  6843. */
  6844. clone(): AnimationRange;
  6845. }
  6846. }
  6847. declare module "babylonjs/Animations/animationEvent" {
  6848. /**
  6849. * Composed of a frame, and an action function
  6850. */
  6851. export class AnimationEvent {
  6852. /** The frame for which the event is triggered **/
  6853. frame: number;
  6854. /** The event to perform when triggered **/
  6855. action: (currentFrame: number) => void;
  6856. /** Specifies if the event should be triggered only once**/
  6857. onlyOnce?: boolean | undefined;
  6858. /**
  6859. * Specifies if the animation event is done
  6860. */
  6861. isDone: boolean;
  6862. /**
  6863. * Initializes the animation event
  6864. * @param frame The frame for which the event is triggered
  6865. * @param action The event to perform when triggered
  6866. * @param onlyOnce Specifies if the event should be triggered only once
  6867. */
  6868. constructor(
  6869. /** The frame for which the event is triggered **/
  6870. frame: number,
  6871. /** The event to perform when triggered **/
  6872. action: (currentFrame: number) => void,
  6873. /** Specifies if the event should be triggered only once**/
  6874. onlyOnce?: boolean | undefined);
  6875. /** @hidden */
  6876. _clone(): AnimationEvent;
  6877. }
  6878. }
  6879. declare module "babylonjs/Behaviors/behavior" {
  6880. import { Nullable } from "babylonjs/types";
  6881. /**
  6882. * Interface used to define a behavior
  6883. */
  6884. export interface Behavior<T> {
  6885. /** gets or sets behavior's name */
  6886. name: string;
  6887. /**
  6888. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6889. */
  6890. init(): void;
  6891. /**
  6892. * Called when the behavior is attached to a target
  6893. * @param target defines the target where the behavior is attached to
  6894. */
  6895. attach(target: T): void;
  6896. /**
  6897. * Called when the behavior is detached from its target
  6898. */
  6899. detach(): void;
  6900. }
  6901. /**
  6902. * Interface implemented by classes supporting behaviors
  6903. */
  6904. export interface IBehaviorAware<T> {
  6905. /**
  6906. * Attach a behavior
  6907. * @param behavior defines the behavior to attach
  6908. * @returns the current host
  6909. */
  6910. addBehavior(behavior: Behavior<T>): T;
  6911. /**
  6912. * Remove a behavior from the current object
  6913. * @param behavior defines the behavior to detach
  6914. * @returns the current host
  6915. */
  6916. removeBehavior(behavior: Behavior<T>): T;
  6917. /**
  6918. * Gets a behavior using its name to search
  6919. * @param name defines the name to search
  6920. * @returns the behavior or null if not found
  6921. */
  6922. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6923. }
  6924. }
  6925. declare module "babylonjs/Collisions/intersectionInfo" {
  6926. import { Nullable } from "babylonjs/types";
  6927. /**
  6928. * @hidden
  6929. */
  6930. export class IntersectionInfo {
  6931. bu: Nullable<number>;
  6932. bv: Nullable<number>;
  6933. distance: number;
  6934. faceId: number;
  6935. subMeshId: number;
  6936. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6937. }
  6938. }
  6939. declare module "babylonjs/Culling/boundingSphere" {
  6940. import { DeepImmutable } from "babylonjs/types";
  6941. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  6942. /**
  6943. * Class used to store bounding sphere information
  6944. */
  6945. export class BoundingSphere {
  6946. /**
  6947. * Gets the center of the bounding sphere in local space
  6948. */
  6949. readonly center: Vector3;
  6950. /**
  6951. * Radius of the bounding sphere in local space
  6952. */
  6953. radius: number;
  6954. /**
  6955. * Gets the center of the bounding sphere in world space
  6956. */
  6957. readonly centerWorld: Vector3;
  6958. /**
  6959. * Radius of the bounding sphere in world space
  6960. */
  6961. radiusWorld: number;
  6962. /**
  6963. * Gets the minimum vector in local space
  6964. */
  6965. readonly minimum: Vector3;
  6966. /**
  6967. * Gets the maximum vector in local space
  6968. */
  6969. readonly maximum: Vector3;
  6970. private _worldMatrix;
  6971. private static readonly TmpVector3;
  6972. /**
  6973. * Creates a new bounding sphere
  6974. * @param min defines the minimum vector (in local space)
  6975. * @param max defines the maximum vector (in local space)
  6976. * @param worldMatrix defines the new world matrix
  6977. */
  6978. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6979. /**
  6980. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6981. * @param min defines the new minimum vector (in local space)
  6982. * @param max defines the new maximum vector (in local space)
  6983. * @param worldMatrix defines the new world matrix
  6984. */
  6985. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6986. /**
  6987. * Scale the current bounding sphere by applying a scale factor
  6988. * @param factor defines the scale factor to apply
  6989. * @returns the current bounding box
  6990. */
  6991. scale(factor: number): BoundingSphere;
  6992. /**
  6993. * Gets the world matrix of the bounding box
  6994. * @returns a matrix
  6995. */
  6996. getWorldMatrix(): DeepImmutable<Matrix>;
  6997. /** @hidden */
  6998. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6999. /**
  7000. * Tests if the bounding sphere is intersecting the frustum planes
  7001. * @param frustumPlanes defines the frustum planes to test
  7002. * @returns true if there is an intersection
  7003. */
  7004. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7005. /**
  7006. * Tests if the bounding sphere center is in between the frustum planes.
  7007. * Used for optimistic fast inclusion.
  7008. * @param frustumPlanes defines the frustum planes to test
  7009. * @returns true if the sphere center is in between the frustum planes
  7010. */
  7011. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7012. /**
  7013. * Tests if a point is inside the bounding sphere
  7014. * @param point defines the point to test
  7015. * @returns true if the point is inside the bounding sphere
  7016. */
  7017. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7018. /**
  7019. * Checks if two sphere intersct
  7020. * @param sphere0 sphere 0
  7021. * @param sphere1 sphere 1
  7022. * @returns true if the speres intersect
  7023. */
  7024. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  7025. }
  7026. }
  7027. declare module "babylonjs/Culling/boundingBox" {
  7028. import { DeepImmutable } from "babylonjs/types";
  7029. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  7030. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7031. import { ICullable } from "babylonjs/Culling/boundingInfo";
  7032. /**
  7033. * Class used to store bounding box information
  7034. */
  7035. export class BoundingBox implements ICullable {
  7036. /**
  7037. * Gets the 8 vectors representing the bounding box in local space
  7038. */
  7039. readonly vectors: Vector3[];
  7040. /**
  7041. * Gets the center of the bounding box in local space
  7042. */
  7043. readonly center: Vector3;
  7044. /**
  7045. * Gets the center of the bounding box in world space
  7046. */
  7047. readonly centerWorld: Vector3;
  7048. /**
  7049. * Gets the extend size in local space
  7050. */
  7051. readonly extendSize: Vector3;
  7052. /**
  7053. * Gets the extend size in world space
  7054. */
  7055. readonly extendSizeWorld: Vector3;
  7056. /**
  7057. * Gets the OBB (object bounding box) directions
  7058. */
  7059. readonly directions: Vector3[];
  7060. /**
  7061. * Gets the 8 vectors representing the bounding box in world space
  7062. */
  7063. readonly vectorsWorld: Vector3[];
  7064. /**
  7065. * Gets the minimum vector in world space
  7066. */
  7067. readonly minimumWorld: Vector3;
  7068. /**
  7069. * Gets the maximum vector in world space
  7070. */
  7071. readonly maximumWorld: Vector3;
  7072. /**
  7073. * Gets the minimum vector in local space
  7074. */
  7075. readonly minimum: Vector3;
  7076. /**
  7077. * Gets the maximum vector in local space
  7078. */
  7079. readonly maximum: Vector3;
  7080. private _worldMatrix;
  7081. private static readonly TmpVector3;
  7082. /**
  7083. * @hidden
  7084. */
  7085. _tag: number;
  7086. /**
  7087. * Creates a new bounding box
  7088. * @param min defines the minimum vector (in local space)
  7089. * @param max defines the maximum vector (in local space)
  7090. * @param worldMatrix defines the new world matrix
  7091. */
  7092. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7093. /**
  7094. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7095. * @param min defines the new minimum vector (in local space)
  7096. * @param max defines the new maximum vector (in local space)
  7097. * @param worldMatrix defines the new world matrix
  7098. */
  7099. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7100. /**
  7101. * Scale the current bounding box by applying a scale factor
  7102. * @param factor defines the scale factor to apply
  7103. * @returns the current bounding box
  7104. */
  7105. scale(factor: number): BoundingBox;
  7106. /**
  7107. * Gets the world matrix of the bounding box
  7108. * @returns a matrix
  7109. */
  7110. getWorldMatrix(): DeepImmutable<Matrix>;
  7111. /** @hidden */
  7112. _update(world: DeepImmutable<Matrix>): void;
  7113. /**
  7114. * Tests if the bounding box is intersecting the frustum planes
  7115. * @param frustumPlanes defines the frustum planes to test
  7116. * @returns true if there is an intersection
  7117. */
  7118. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7119. /**
  7120. * Tests if the bounding box is entirely inside the frustum planes
  7121. * @param frustumPlanes defines the frustum planes to test
  7122. * @returns true if there is an inclusion
  7123. */
  7124. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7125. /**
  7126. * Tests if a point is inside the bounding box
  7127. * @param point defines the point to test
  7128. * @returns true if the point is inside the bounding box
  7129. */
  7130. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7131. /**
  7132. * Tests if the bounding box intersects with a bounding sphere
  7133. * @param sphere defines the sphere to test
  7134. * @returns true if there is an intersection
  7135. */
  7136. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7137. /**
  7138. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7139. * @param min defines the min vector to use
  7140. * @param max defines the max vector to use
  7141. * @returns true if there is an intersection
  7142. */
  7143. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7144. /**
  7145. * Tests if two bounding boxes are intersections
  7146. * @param box0 defines the first box to test
  7147. * @param box1 defines the second box to test
  7148. * @returns true if there is an intersection
  7149. */
  7150. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7151. /**
  7152. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7153. * @param minPoint defines the minimum vector of the bounding box
  7154. * @param maxPoint defines the maximum vector of the bounding box
  7155. * @param sphereCenter defines the sphere center
  7156. * @param sphereRadius defines the sphere radius
  7157. * @returns true if there is an intersection
  7158. */
  7159. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7160. /**
  7161. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7162. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7163. * @param frustumPlanes defines the frustum planes to test
  7164. * @return true if there is an inclusion
  7165. */
  7166. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7167. /**
  7168. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7169. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7170. * @param frustumPlanes defines the frustum planes to test
  7171. * @return true if there is an intersection
  7172. */
  7173. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7174. }
  7175. }
  7176. declare module "babylonjs/Collisions/collider" {
  7177. import { Nullable, IndicesArray } from "babylonjs/types";
  7178. import { Vector3, Plane } from "babylonjs/Maths/math";
  7179. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7180. /** @hidden */
  7181. export class Collider {
  7182. /** Define if a collision was found */
  7183. collisionFound: boolean;
  7184. /**
  7185. * Define last intersection point in local space
  7186. */
  7187. intersectionPoint: Vector3;
  7188. /**
  7189. * Define last collided mesh
  7190. */
  7191. collidedMesh: Nullable<AbstractMesh>;
  7192. private _collisionPoint;
  7193. private _planeIntersectionPoint;
  7194. private _tempVector;
  7195. private _tempVector2;
  7196. private _tempVector3;
  7197. private _tempVector4;
  7198. private _edge;
  7199. private _baseToVertex;
  7200. private _destinationPoint;
  7201. private _slidePlaneNormal;
  7202. private _displacementVector;
  7203. /** @hidden */
  7204. _radius: Vector3;
  7205. /** @hidden */
  7206. _retry: number;
  7207. private _velocity;
  7208. private _basePoint;
  7209. private _epsilon;
  7210. /** @hidden */
  7211. _velocityWorldLength: number;
  7212. /** @hidden */
  7213. _basePointWorld: Vector3;
  7214. private _velocityWorld;
  7215. private _normalizedVelocity;
  7216. /** @hidden */
  7217. _initialVelocity: Vector3;
  7218. /** @hidden */
  7219. _initialPosition: Vector3;
  7220. private _nearestDistance;
  7221. private _collisionMask;
  7222. collisionMask: number;
  7223. /**
  7224. * Gets the plane normal used to compute the sliding response (in local space)
  7225. */
  7226. readonly slidePlaneNormal: Vector3;
  7227. /** @hidden */
  7228. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7229. /** @hidden */
  7230. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7231. /** @hidden */
  7232. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7233. /** @hidden */
  7234. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  7235. /** @hidden */
  7236. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  7237. /** @hidden */
  7238. _getResponse(pos: Vector3, vel: Vector3): void;
  7239. }
  7240. }
  7241. declare module "babylonjs/Culling/boundingInfo" {
  7242. import { DeepImmutable } from "babylonjs/types";
  7243. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  7244. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7245. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7246. import { Collider } from "babylonjs/Collisions/collider";
  7247. /**
  7248. * Interface for cullable objects
  7249. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7250. */
  7251. export interface ICullable {
  7252. /**
  7253. * Checks if the object or part of the object is in the frustum
  7254. * @param frustumPlanes Camera near/planes
  7255. * @returns true if the object is in frustum otherwise false
  7256. */
  7257. isInFrustum(frustumPlanes: Plane[]): boolean;
  7258. /**
  7259. * Checks if a cullable object (mesh...) is in the camera frustum
  7260. * Unlike isInFrustum this cheks the full bounding box
  7261. * @param frustumPlanes Camera near/planes
  7262. * @returns true if the object is in frustum otherwise false
  7263. */
  7264. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7265. }
  7266. /**
  7267. * Info for a bounding data of a mesh
  7268. */
  7269. export class BoundingInfo implements ICullable {
  7270. /**
  7271. * Bounding box for the mesh
  7272. */
  7273. readonly boundingBox: BoundingBox;
  7274. /**
  7275. * Bounding sphere for the mesh
  7276. */
  7277. readonly boundingSphere: BoundingSphere;
  7278. private _isLocked;
  7279. private static readonly TmpVector3;
  7280. /**
  7281. * Constructs bounding info
  7282. * @param minimum min vector of the bounding box/sphere
  7283. * @param maximum max vector of the bounding box/sphere
  7284. * @param worldMatrix defines the new world matrix
  7285. */
  7286. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7287. /**
  7288. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7289. * @param min defines the new minimum vector (in local space)
  7290. * @param max defines the new maximum vector (in local space)
  7291. * @param worldMatrix defines the new world matrix
  7292. */
  7293. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7294. /**
  7295. * min vector of the bounding box/sphere
  7296. */
  7297. readonly minimum: Vector3;
  7298. /**
  7299. * max vector of the bounding box/sphere
  7300. */
  7301. readonly maximum: Vector3;
  7302. /**
  7303. * If the info is locked and won't be updated to avoid perf overhead
  7304. */
  7305. isLocked: boolean;
  7306. /**
  7307. * Updates the bounding sphere and box
  7308. * @param world world matrix to be used to update
  7309. */
  7310. update(world: DeepImmutable<Matrix>): void;
  7311. /**
  7312. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7313. * @param center New center of the bounding info
  7314. * @param extend New extend of the bounding info
  7315. * @returns the current bounding info
  7316. */
  7317. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7318. /**
  7319. * Scale the current bounding info by applying a scale factor
  7320. * @param factor defines the scale factor to apply
  7321. * @returns the current bounding info
  7322. */
  7323. scale(factor: number): BoundingInfo;
  7324. /**
  7325. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7326. * @param frustumPlanes defines the frustum to test
  7327. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7328. * @returns true if the bounding info is in the frustum planes
  7329. */
  7330. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7331. /**
  7332. * Gets the world distance between the min and max points of the bounding box
  7333. */
  7334. readonly diagonalLength: number;
  7335. /**
  7336. * Checks if a cullable object (mesh...) is in the camera frustum
  7337. * Unlike isInFrustum this cheks the full bounding box
  7338. * @param frustumPlanes Camera near/planes
  7339. * @returns true if the object is in frustum otherwise false
  7340. */
  7341. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7342. /** @hidden */
  7343. _checkCollision(collider: Collider): boolean;
  7344. /**
  7345. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7346. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7347. * @param point the point to check intersection with
  7348. * @returns if the point intersects
  7349. */
  7350. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7351. /**
  7352. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7353. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7354. * @param boundingInfo the bounding info to check intersection with
  7355. * @param precise if the intersection should be done using OBB
  7356. * @returns if the bounding info intersects
  7357. */
  7358. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7359. }
  7360. }
  7361. declare module "babylonjs/Misc/smartArray" {
  7362. /**
  7363. * Defines an array and its length.
  7364. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  7365. */
  7366. export interface ISmartArrayLike<T> {
  7367. /**
  7368. * The data of the array.
  7369. */
  7370. data: Array<T>;
  7371. /**
  7372. * The active length of the array.
  7373. */
  7374. length: number;
  7375. }
  7376. /**
  7377. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7378. */
  7379. export class SmartArray<T> implements ISmartArrayLike<T> {
  7380. /**
  7381. * The full set of data from the array.
  7382. */
  7383. data: Array<T>;
  7384. /**
  7385. * The active length of the array.
  7386. */
  7387. length: number;
  7388. protected _id: number;
  7389. /**
  7390. * Instantiates a Smart Array.
  7391. * @param capacity defines the default capacity of the array.
  7392. */
  7393. constructor(capacity: number);
  7394. /**
  7395. * Pushes a value at the end of the active data.
  7396. * @param value defines the object to push in the array.
  7397. */
  7398. push(value: T): void;
  7399. /**
  7400. * Iterates over the active data and apply the lambda to them.
  7401. * @param func defines the action to apply on each value.
  7402. */
  7403. forEach(func: (content: T) => void): void;
  7404. /**
  7405. * Sorts the full sets of data.
  7406. * @param compareFn defines the comparison function to apply.
  7407. */
  7408. sort(compareFn: (a: T, b: T) => number): void;
  7409. /**
  7410. * Resets the active data to an empty array.
  7411. */
  7412. reset(): void;
  7413. /**
  7414. * Releases all the data from the array as well as the array.
  7415. */
  7416. dispose(): void;
  7417. /**
  7418. * Concats the active data with a given array.
  7419. * @param array defines the data to concatenate with.
  7420. */
  7421. concat(array: any): void;
  7422. /**
  7423. * Returns the position of a value in the active data.
  7424. * @param value defines the value to find the index for
  7425. * @returns the index if found in the active data otherwise -1
  7426. */
  7427. indexOf(value: T): number;
  7428. /**
  7429. * Returns whether an element is part of the active data.
  7430. * @param value defines the value to look for
  7431. * @returns true if found in the active data otherwise false
  7432. */
  7433. contains(value: T): boolean;
  7434. private static _GlobalId;
  7435. }
  7436. /**
  7437. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7438. * The data in this array can only be present once
  7439. */
  7440. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  7441. private _duplicateId;
  7442. /**
  7443. * Pushes a value at the end of the active data.
  7444. * THIS DOES NOT PREVENT DUPPLICATE DATA
  7445. * @param value defines the object to push in the array.
  7446. */
  7447. push(value: T): void;
  7448. /**
  7449. * Pushes a value at the end of the active data.
  7450. * If the data is already present, it won t be added again
  7451. * @param value defines the object to push in the array.
  7452. * @returns true if added false if it was already present
  7453. */
  7454. pushNoDuplicate(value: T): boolean;
  7455. /**
  7456. * Resets the active data to an empty array.
  7457. */
  7458. reset(): void;
  7459. /**
  7460. * Concats the active data with a given array.
  7461. * This ensures no dupplicate will be present in the result.
  7462. * @param array defines the data to concatenate with.
  7463. */
  7464. concatWithNoDuplicate(array: any): void;
  7465. }
  7466. }
  7467. declare module "babylonjs/Materials/multiMaterial" {
  7468. import { Nullable } from "babylonjs/types";
  7469. import { Scene } from "babylonjs/scene";
  7470. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7471. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  7472. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7473. import { Material } from "babylonjs/Materials/material";
  7474. /**
  7475. * A multi-material is used to apply different materials to different parts of the same object without the need of
  7476. * separate meshes. This can be use to improve performances.
  7477. * @see http://doc.babylonjs.com/how_to/multi_materials
  7478. */
  7479. export class MultiMaterial extends Material {
  7480. private _subMaterials;
  7481. /**
  7482. * Gets or Sets the list of Materials used within the multi material.
  7483. * They need to be ordered according to the submeshes order in the associated mesh
  7484. */
  7485. subMaterials: Nullable<Material>[];
  7486. /**
  7487. * Function used to align with Node.getChildren()
  7488. * @returns the list of Materials used within the multi material
  7489. */
  7490. getChildren(): Nullable<Material>[];
  7491. /**
  7492. * Instantiates a new Multi Material
  7493. * A multi-material is used to apply different materials to different parts of the same object without the need of
  7494. * separate meshes. This can be use to improve performances.
  7495. * @see http://doc.babylonjs.com/how_to/multi_materials
  7496. * @param name Define the name in the scene
  7497. * @param scene Define the scene the material belongs to
  7498. */
  7499. constructor(name: string, scene: Scene);
  7500. private _hookArray;
  7501. /**
  7502. * Get one of the submaterial by its index in the submaterials array
  7503. * @param index The index to look the sub material at
  7504. * @returns The Material if the index has been defined
  7505. */
  7506. getSubMaterial(index: number): Nullable<Material>;
  7507. /**
  7508. * Get the list of active textures for the whole sub materials list.
  7509. * @returns All the textures that will be used during the rendering
  7510. */
  7511. getActiveTextures(): BaseTexture[];
  7512. /**
  7513. * Gets the current class name of the material e.g. "MultiMaterial"
  7514. * Mainly use in serialization.
  7515. * @returns the class name
  7516. */
  7517. getClassName(): string;
  7518. /**
  7519. * Checks if the material is ready to render the requested sub mesh
  7520. * @param mesh Define the mesh the submesh belongs to
  7521. * @param subMesh Define the sub mesh to look readyness for
  7522. * @param useInstances Define whether or not the material is used with instances
  7523. * @returns true if ready, otherwise false
  7524. */
  7525. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  7526. /**
  7527. * Clones the current material and its related sub materials
  7528. * @param name Define the name of the newly cloned material
  7529. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  7530. * @returns the cloned material
  7531. */
  7532. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  7533. /**
  7534. * Serializes the materials into a JSON representation.
  7535. * @returns the JSON representation
  7536. */
  7537. serialize(): any;
  7538. /**
  7539. * Dispose the material and release its associated resources
  7540. * @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)
  7541. * @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)
  7542. * @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)
  7543. */
  7544. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  7545. /**
  7546. * Creates a MultiMaterial from parsed MultiMaterial data.
  7547. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  7548. * @param scene defines the hosting scene
  7549. * @returns a new MultiMaterial
  7550. */
  7551. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  7552. }
  7553. }
  7554. declare module "babylonjs/Loading/sceneLoaderFlags" {
  7555. /**
  7556. * Class used to represent data loading progression
  7557. */
  7558. export class SceneLoaderFlags {
  7559. private static _ForceFullSceneLoadingForIncremental;
  7560. private static _ShowLoadingScreen;
  7561. private static _CleanBoneMatrixWeights;
  7562. private static _loggingLevel;
  7563. /**
  7564. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  7565. */
  7566. static ForceFullSceneLoadingForIncremental: boolean;
  7567. /**
  7568. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  7569. */
  7570. static ShowLoadingScreen: boolean;
  7571. /**
  7572. * Defines the current logging level (while loading the scene)
  7573. * @ignorenaming
  7574. */
  7575. static loggingLevel: number;
  7576. /**
  7577. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  7578. */
  7579. static CleanBoneMatrixWeights: boolean;
  7580. }
  7581. }
  7582. declare module "babylonjs/Meshes/transformNode" {
  7583. import { DeepImmutable } from "babylonjs/types";
  7584. import { Observable } from "babylonjs/Misc/observable";
  7585. import { Nullable } from "babylonjs/types";
  7586. import { Camera } from "babylonjs/Cameras/camera";
  7587. import { Scene } from "babylonjs/scene";
  7588. import { Quaternion, Matrix, Vector3, Space } from "babylonjs/Maths/math";
  7589. import { Node } from "babylonjs/node";
  7590. import { Bone } from "babylonjs/Bones/bone";
  7591. /**
  7592. * 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.
  7593. * @see https://doc.babylonjs.com/how_to/transformnode
  7594. */
  7595. export class TransformNode extends Node {
  7596. /**
  7597. * Object will not rotate to face the camera
  7598. */
  7599. static BILLBOARDMODE_NONE: number;
  7600. /**
  7601. * Object will rotate to face the camera but only on the x axis
  7602. */
  7603. static BILLBOARDMODE_X: number;
  7604. /**
  7605. * Object will rotate to face the camera but only on the y axis
  7606. */
  7607. static BILLBOARDMODE_Y: number;
  7608. /**
  7609. * Object will rotate to face the camera but only on the z axis
  7610. */
  7611. static BILLBOARDMODE_Z: number;
  7612. /**
  7613. * Object will rotate to face the camera
  7614. */
  7615. static BILLBOARDMODE_ALL: number;
  7616. private _forward;
  7617. private _forwardInverted;
  7618. private _up;
  7619. private _right;
  7620. private _rightInverted;
  7621. private _position;
  7622. private _rotation;
  7623. private _rotationQuaternion;
  7624. protected _scaling: Vector3;
  7625. protected _isDirty: boolean;
  7626. private _transformToBoneReferal;
  7627. private _billboardMode;
  7628. /**
  7629. * Gets or sets the billboard mode. Default is 0.
  7630. *
  7631. * | Value | Type | Description |
  7632. * | --- | --- | --- |
  7633. * | 0 | BILLBOARDMODE_NONE | |
  7634. * | 1 | BILLBOARDMODE_X | |
  7635. * | 2 | BILLBOARDMODE_Y | |
  7636. * | 4 | BILLBOARDMODE_Z | |
  7637. * | 7 | BILLBOARDMODE_ALL | |
  7638. *
  7639. */
  7640. billboardMode: number;
  7641. private _preserveParentRotationForBillboard;
  7642. /**
  7643. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  7644. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  7645. */
  7646. preserveParentRotationForBillboard: boolean;
  7647. /**
  7648. * 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
  7649. */
  7650. scalingDeterminant: number;
  7651. private _infiniteDistance;
  7652. /**
  7653. * Gets or sets the distance of the object to max, often used by skybox
  7654. */
  7655. infiniteDistance: boolean;
  7656. /**
  7657. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  7658. * By default the system will update normals to compensate
  7659. */
  7660. ignoreNonUniformScaling: boolean;
  7661. /**
  7662. * 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
  7663. */
  7664. reIntegrateRotationIntoRotationQuaternion: boolean;
  7665. /** @hidden */
  7666. _poseMatrix: Nullable<Matrix>;
  7667. /** @hidden */
  7668. _localMatrix: Matrix;
  7669. private _usePivotMatrix;
  7670. private _absolutePosition;
  7671. private _pivotMatrix;
  7672. private _pivotMatrixInverse;
  7673. protected _postMultiplyPivotMatrix: boolean;
  7674. protected _isWorldMatrixFrozen: boolean;
  7675. /** @hidden */
  7676. _indexInSceneTransformNodesArray: number;
  7677. /**
  7678. * An event triggered after the world matrix is updated
  7679. */
  7680. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  7681. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  7682. /**
  7683. * Gets a string identifying the name of the class
  7684. * @returns "TransformNode" string
  7685. */
  7686. getClassName(): string;
  7687. /**
  7688. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  7689. */
  7690. position: Vector3;
  7691. /**
  7692. * 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)).
  7693. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  7694. */
  7695. rotation: Vector3;
  7696. /**
  7697. * 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)).
  7698. */
  7699. scaling: Vector3;
  7700. /**
  7701. * 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).
  7702. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  7703. */
  7704. rotationQuaternion: Nullable<Quaternion>;
  7705. /**
  7706. * The forward direction of that transform in world space.
  7707. */
  7708. readonly forward: Vector3;
  7709. /**
  7710. * The up direction of that transform in world space.
  7711. */
  7712. readonly up: Vector3;
  7713. /**
  7714. * The right direction of that transform in world space.
  7715. */
  7716. readonly right: Vector3;
  7717. /**
  7718. * Copies the parameter passed Matrix into the mesh Pose matrix.
  7719. * @param matrix the matrix to copy the pose from
  7720. * @returns this TransformNode.
  7721. */
  7722. updatePoseMatrix(matrix: Matrix): TransformNode;
  7723. /**
  7724. * Returns the mesh Pose matrix.
  7725. * @returns the pose matrix
  7726. */
  7727. getPoseMatrix(): Matrix;
  7728. /** @hidden */
  7729. _isSynchronized(): boolean;
  7730. /** @hidden */
  7731. _initCache(): void;
  7732. /**
  7733. * Flag the transform node as dirty (Forcing it to update everything)
  7734. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  7735. * @returns this transform node
  7736. */
  7737. markAsDirty(property: string): TransformNode;
  7738. /**
  7739. * Returns the current mesh absolute position.
  7740. * Returns a Vector3.
  7741. */
  7742. readonly absolutePosition: Vector3;
  7743. /**
  7744. * Sets a new matrix to apply before all other transformation
  7745. * @param matrix defines the transform matrix
  7746. * @returns the current TransformNode
  7747. */
  7748. setPreTransformMatrix(matrix: Matrix): TransformNode;
  7749. /**
  7750. * Sets a new pivot matrix to the current node
  7751. * @param matrix defines the new pivot matrix to use
  7752. * @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
  7753. * @returns the current TransformNode
  7754. */
  7755. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  7756. /**
  7757. * Returns the mesh pivot matrix.
  7758. * Default : Identity.
  7759. * @returns the matrix
  7760. */
  7761. getPivotMatrix(): Matrix;
  7762. /**
  7763. * Prevents the World matrix to be computed any longer.
  7764. * @returns the TransformNode.
  7765. */
  7766. freezeWorldMatrix(): TransformNode;
  7767. /**
  7768. * Allows back the World matrix computation.
  7769. * @returns the TransformNode.
  7770. */
  7771. unfreezeWorldMatrix(): this;
  7772. /**
  7773. * True if the World matrix has been frozen.
  7774. */
  7775. readonly isWorldMatrixFrozen: boolean;
  7776. /**
  7777. * Retuns the mesh absolute position in the World.
  7778. * @returns a Vector3.
  7779. */
  7780. getAbsolutePosition(): Vector3;
  7781. /**
  7782. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  7783. * @param absolutePosition the absolute position to set
  7784. * @returns the TransformNode.
  7785. */
  7786. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  7787. /**
  7788. * Sets the mesh position in its local space.
  7789. * @param vector3 the position to set in localspace
  7790. * @returns the TransformNode.
  7791. */
  7792. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  7793. /**
  7794. * Returns the mesh position in the local space from the current World matrix values.
  7795. * @returns a new Vector3.
  7796. */
  7797. getPositionExpressedInLocalSpace(): Vector3;
  7798. /**
  7799. * Translates the mesh along the passed Vector3 in its local space.
  7800. * @param vector3 the distance to translate in localspace
  7801. * @returns the TransformNode.
  7802. */
  7803. locallyTranslate(vector3: Vector3): TransformNode;
  7804. private static _lookAtVectorCache;
  7805. /**
  7806. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  7807. * @param targetPoint the position (must be in same space as current mesh) to look at
  7808. * @param yawCor optional yaw (y-axis) correction in radians
  7809. * @param pitchCor optional pitch (x-axis) correction in radians
  7810. * @param rollCor optional roll (z-axis) correction in radians
  7811. * @param space the choosen space of the target
  7812. * @returns the TransformNode.
  7813. */
  7814. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  7815. /**
  7816. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  7817. * This Vector3 is expressed in the World space.
  7818. * @param localAxis axis to rotate
  7819. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  7820. */
  7821. getDirection(localAxis: Vector3): Vector3;
  7822. /**
  7823. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  7824. * localAxis is expressed in the mesh local space.
  7825. * result is computed in the Wordl space from the mesh World matrix.
  7826. * @param localAxis axis to rotate
  7827. * @param result the resulting transformnode
  7828. * @returns this TransformNode.
  7829. */
  7830. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  7831. /**
  7832. * Sets this transform node rotation to the given local axis.
  7833. * @param localAxis the axis in local space
  7834. * @param yawCor optional yaw (y-axis) correction in radians
  7835. * @param pitchCor optional pitch (x-axis) correction in radians
  7836. * @param rollCor optional roll (z-axis) correction in radians
  7837. * @returns this TransformNode
  7838. */
  7839. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  7840. /**
  7841. * Sets a new pivot point to the current node
  7842. * @param point defines the new pivot point to use
  7843. * @param space defines if the point is in world or local space (local by default)
  7844. * @returns the current TransformNode
  7845. */
  7846. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  7847. /**
  7848. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  7849. * @returns the pivot point
  7850. */
  7851. getPivotPoint(): Vector3;
  7852. /**
  7853. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  7854. * @param result the vector3 to store the result
  7855. * @returns this TransformNode.
  7856. */
  7857. getPivotPointToRef(result: Vector3): TransformNode;
  7858. /**
  7859. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  7860. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  7861. */
  7862. getAbsolutePivotPoint(): Vector3;
  7863. /**
  7864. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  7865. * @param result vector3 to store the result
  7866. * @returns this TransformNode.
  7867. */
  7868. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  7869. /**
  7870. * Defines the passed node as the parent of the current node.
  7871. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  7872. * @see https://doc.babylonjs.com/how_to/parenting
  7873. * @param node the node ot set as the parent
  7874. * @returns this TransformNode.
  7875. */
  7876. setParent(node: Nullable<Node>): TransformNode;
  7877. private _nonUniformScaling;
  7878. /**
  7879. * True if the scaling property of this object is non uniform eg. (1,2,1)
  7880. */
  7881. readonly nonUniformScaling: boolean;
  7882. /** @hidden */
  7883. _updateNonUniformScalingState(value: boolean): boolean;
  7884. /**
  7885. * Attach the current TransformNode to another TransformNode associated with a bone
  7886. * @param bone Bone affecting the TransformNode
  7887. * @param affectedTransformNode TransformNode associated with the bone
  7888. * @returns this object
  7889. */
  7890. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  7891. /**
  7892. * Detach the transform node if its associated with a bone
  7893. * @returns this object
  7894. */
  7895. detachFromBone(): TransformNode;
  7896. private static _rotationAxisCache;
  7897. /**
  7898. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  7899. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  7900. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  7901. * The passed axis is also normalized.
  7902. * @param axis the axis to rotate around
  7903. * @param amount the amount to rotate in radians
  7904. * @param space Space to rotate in (Default: local)
  7905. * @returns the TransformNode.
  7906. */
  7907. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  7908. /**
  7909. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  7910. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  7911. * The passed axis is also normalized. .
  7912. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  7913. * @param point the point to rotate around
  7914. * @param axis the axis to rotate around
  7915. * @param amount the amount to rotate in radians
  7916. * @returns the TransformNode
  7917. */
  7918. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  7919. /**
  7920. * Translates the mesh along the axis vector for the passed distance in the given space.
  7921. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  7922. * @param axis the axis to translate in
  7923. * @param distance the distance to translate
  7924. * @param space Space to rotate in (Default: local)
  7925. * @returns the TransformNode.
  7926. */
  7927. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  7928. /**
  7929. * Adds a rotation step to the mesh current rotation.
  7930. * x, y, z are Euler angles expressed in radians.
  7931. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  7932. * This means this rotation is made in the mesh local space only.
  7933. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  7934. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  7935. * ```javascript
  7936. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  7937. * ```
  7938. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  7939. * 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.
  7940. * @param x Rotation to add
  7941. * @param y Rotation to add
  7942. * @param z Rotation to add
  7943. * @returns the TransformNode.
  7944. */
  7945. addRotation(x: number, y: number, z: number): TransformNode;
  7946. /**
  7947. * @hidden
  7948. */
  7949. protected _getEffectiveParent(): Nullable<Node>;
  7950. /**
  7951. * Computes the world matrix of the node
  7952. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  7953. * @returns the world matrix
  7954. */
  7955. computeWorldMatrix(force?: boolean): Matrix;
  7956. protected _afterComputeWorldMatrix(): void;
  7957. /**
  7958. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  7959. * @param func callback function to add
  7960. *
  7961. * @returns the TransformNode.
  7962. */
  7963. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  7964. /**
  7965. * Removes a registered callback function.
  7966. * @param func callback function to remove
  7967. * @returns the TransformNode.
  7968. */
  7969. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  7970. /**
  7971. * Gets the position of the current mesh in camera space
  7972. * @param camera defines the camera to use
  7973. * @returns a position
  7974. */
  7975. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  7976. /**
  7977. * Returns the distance from the mesh to the active camera
  7978. * @param camera defines the camera to use
  7979. * @returns the distance
  7980. */
  7981. getDistanceToCamera(camera?: Nullable<Camera>): number;
  7982. /**
  7983. * Clone the current transform node
  7984. * @param name Name of the new clone
  7985. * @param newParent New parent for the clone
  7986. * @param doNotCloneChildren Do not clone children hierarchy
  7987. * @returns the new transform node
  7988. */
  7989. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  7990. /**
  7991. * Serializes the objects information.
  7992. * @param currentSerializationObject defines the object to serialize in
  7993. * @returns the serialized object
  7994. */
  7995. serialize(currentSerializationObject?: any): any;
  7996. /**
  7997. * Returns a new TransformNode object parsed from the source provided.
  7998. * @param parsedTransformNode is the source.
  7999. * @param scene the scne the object belongs to
  8000. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  8001. * @returns a new TransformNode object parsed from the source provided.
  8002. */
  8003. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  8004. /**
  8005. * Get all child-transformNodes of this node
  8006. * @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
  8007. * @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
  8008. * @returns an array of TransformNode
  8009. */
  8010. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  8011. /**
  8012. * Releases resources associated with this transform node.
  8013. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  8014. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  8015. */
  8016. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  8017. }
  8018. }
  8019. declare module "babylonjs/Animations/animationPropertiesOverride" {
  8020. /**
  8021. * Class used to override all child animations of a given target
  8022. */
  8023. export class AnimationPropertiesOverride {
  8024. /**
  8025. * Gets or sets a value indicating if animation blending must be used
  8026. */
  8027. enableBlending: boolean;
  8028. /**
  8029. * Gets or sets the blending speed to use when enableBlending is true
  8030. */
  8031. blendingSpeed: number;
  8032. /**
  8033. * Gets or sets the default loop mode to use
  8034. */
  8035. loopMode: number;
  8036. }
  8037. }
  8038. declare module "babylonjs/Bones/bone" {
  8039. import { Skeleton } from "babylonjs/Bones/skeleton";
  8040. import { Vector3, Quaternion, Matrix, Space } from "babylonjs/Maths/math";
  8041. import { Nullable } from "babylonjs/types";
  8042. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8043. import { TransformNode } from "babylonjs/Meshes/transformNode";
  8044. import { Node } from "babylonjs/node";
  8045. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  8046. /**
  8047. * Class used to store bone information
  8048. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  8049. */
  8050. export class Bone extends Node {
  8051. /**
  8052. * defines the bone name
  8053. */
  8054. name: string;
  8055. private static _tmpVecs;
  8056. private static _tmpQuat;
  8057. private static _tmpMats;
  8058. /**
  8059. * Gets the list of child bones
  8060. */
  8061. children: Bone[];
  8062. /** Gets the animations associated with this bone */
  8063. animations: import("babylonjs/Animations/animation").Animation[];
  8064. /**
  8065. * Gets or sets bone length
  8066. */
  8067. length: number;
  8068. /**
  8069. * @hidden Internal only
  8070. * Set this value to map this bone to a different index in the transform matrices
  8071. * Set this value to -1 to exclude the bone from the transform matrices
  8072. */
  8073. _index: Nullable<number>;
  8074. private _skeleton;
  8075. private _localMatrix;
  8076. private _restPose;
  8077. private _baseMatrix;
  8078. private _absoluteTransform;
  8079. private _invertedAbsoluteTransform;
  8080. private _parent;
  8081. private _scalingDeterminant;
  8082. private _worldTransform;
  8083. private _localScaling;
  8084. private _localRotation;
  8085. private _localPosition;
  8086. private _needToDecompose;
  8087. private _needToCompose;
  8088. /** @hidden */
  8089. _linkedTransformNode: Nullable<TransformNode>;
  8090. /** @hidden */
  8091. _waitingTransformNodeId: Nullable<string>;
  8092. /** @hidden */
  8093. /** @hidden */
  8094. _matrix: Matrix;
  8095. /**
  8096. * Create a new bone
  8097. * @param name defines the bone name
  8098. * @param skeleton defines the parent skeleton
  8099. * @param parentBone defines the parent (can be null if the bone is the root)
  8100. * @param localMatrix defines the local matrix
  8101. * @param restPose defines the rest pose matrix
  8102. * @param baseMatrix defines the base matrix
  8103. * @param index defines index of the bone in the hiearchy
  8104. */
  8105. constructor(
  8106. /**
  8107. * defines the bone name
  8108. */
  8109. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  8110. /**
  8111. * Gets the current object class name.
  8112. * @return the class name
  8113. */
  8114. getClassName(): string;
  8115. /**
  8116. * Gets the parent skeleton
  8117. * @returns a skeleton
  8118. */
  8119. getSkeleton(): Skeleton;
  8120. /**
  8121. * Gets parent bone
  8122. * @returns a bone or null if the bone is the root of the bone hierarchy
  8123. */
  8124. getParent(): Nullable<Bone>;
  8125. /**
  8126. * Returns an array containing the root bones
  8127. * @returns an array containing the root bones
  8128. */
  8129. getChildren(): Array<Bone>;
  8130. /**
  8131. * Sets the parent bone
  8132. * @param parent defines the parent (can be null if the bone is the root)
  8133. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  8134. */
  8135. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  8136. /**
  8137. * Gets the local matrix
  8138. * @returns a matrix
  8139. */
  8140. getLocalMatrix(): Matrix;
  8141. /**
  8142. * Gets the base matrix (initial matrix which remains unchanged)
  8143. * @returns a matrix
  8144. */
  8145. getBaseMatrix(): Matrix;
  8146. /**
  8147. * Gets the rest pose matrix
  8148. * @returns a matrix
  8149. */
  8150. getRestPose(): Matrix;
  8151. /**
  8152. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  8153. */
  8154. getWorldMatrix(): Matrix;
  8155. /**
  8156. * Sets the local matrix to rest pose matrix
  8157. */
  8158. returnToRest(): void;
  8159. /**
  8160. * Gets the inverse of the absolute transform matrix.
  8161. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  8162. * @returns a matrix
  8163. */
  8164. getInvertedAbsoluteTransform(): Matrix;
  8165. /**
  8166. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  8167. * @returns a matrix
  8168. */
  8169. getAbsoluteTransform(): Matrix;
  8170. /**
  8171. * Links with the given transform node.
  8172. * The local matrix of this bone is copied from the transform node every frame.
  8173. * @param transformNode defines the transform node to link to
  8174. */
  8175. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  8176. /** Gets or sets current position (in local space) */
  8177. position: Vector3;
  8178. /** Gets or sets current rotation (in local space) */
  8179. rotation: Vector3;
  8180. /** Gets or sets current rotation quaternion (in local space) */
  8181. rotationQuaternion: Quaternion;
  8182. /** Gets or sets current scaling (in local space) */
  8183. scaling: Vector3;
  8184. /**
  8185. * Gets the animation properties override
  8186. */
  8187. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  8188. private _decompose;
  8189. private _compose;
  8190. /**
  8191. * Update the base and local matrices
  8192. * @param matrix defines the new base or local matrix
  8193. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  8194. * @param updateLocalMatrix defines if the local matrix should be updated
  8195. */
  8196. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  8197. /** @hidden */
  8198. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  8199. /**
  8200. * Flag the bone as dirty (Forcing it to update everything)
  8201. */
  8202. markAsDirty(): void;
  8203. private _markAsDirtyAndCompose;
  8204. private _markAsDirtyAndDecompose;
  8205. /**
  8206. * Translate the bone in local or world space
  8207. * @param vec The amount to translate the bone
  8208. * @param space The space that the translation is in
  8209. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8210. */
  8211. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8212. /**
  8213. * Set the postion of the bone in local or world space
  8214. * @param position The position to set the bone
  8215. * @param space The space that the position is in
  8216. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8217. */
  8218. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8219. /**
  8220. * Set the absolute position of the bone (world space)
  8221. * @param position The position to set the bone
  8222. * @param mesh The mesh that this bone is attached to
  8223. */
  8224. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  8225. /**
  8226. * Scale the bone on the x, y and z axes (in local space)
  8227. * @param x The amount to scale the bone on the x axis
  8228. * @param y The amount to scale the bone on the y axis
  8229. * @param z The amount to scale the bone on the z axis
  8230. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  8231. */
  8232. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  8233. /**
  8234. * Set the bone scaling in local space
  8235. * @param scale defines the scaling vector
  8236. */
  8237. setScale(scale: Vector3): void;
  8238. /**
  8239. * Gets the current scaling in local space
  8240. * @returns the current scaling vector
  8241. */
  8242. getScale(): Vector3;
  8243. /**
  8244. * Gets the current scaling in local space and stores it in a target vector
  8245. * @param result defines the target vector
  8246. */
  8247. getScaleToRef(result: Vector3): void;
  8248. /**
  8249. * Set the yaw, pitch, and roll of the bone in local or world space
  8250. * @param yaw The rotation of the bone on the y axis
  8251. * @param pitch The rotation of the bone on the x axis
  8252. * @param roll The rotation of the bone on the z axis
  8253. * @param space The space that the axes of rotation are in
  8254. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8255. */
  8256. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  8257. /**
  8258. * Add a rotation to the bone on an axis in local or world space
  8259. * @param axis The axis to rotate the bone on
  8260. * @param amount The amount to rotate the bone
  8261. * @param space The space that the axis is in
  8262. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8263. */
  8264. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  8265. /**
  8266. * Set the rotation of the bone to a particular axis angle in local or world space
  8267. * @param axis The axis to rotate the bone on
  8268. * @param angle The angle that the bone should be rotated to
  8269. * @param space The space that the axis is in
  8270. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8271. */
  8272. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  8273. /**
  8274. * Set the euler rotation of the bone in local of world space
  8275. * @param rotation The euler rotation that the bone should be set to
  8276. * @param space The space that the rotation is in
  8277. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8278. */
  8279. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8280. /**
  8281. * Set the quaternion rotation of the bone in local of world space
  8282. * @param quat The quaternion rotation that the bone should be set to
  8283. * @param space The space that the rotation is in
  8284. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8285. */
  8286. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  8287. /**
  8288. * Set the rotation matrix of the bone in local of world space
  8289. * @param rotMat The rotation matrix that the bone should be set to
  8290. * @param space The space that the rotation is in
  8291. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8292. */
  8293. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  8294. private _rotateWithMatrix;
  8295. private _getNegativeRotationToRef;
  8296. /**
  8297. * Get the position of the bone in local or world space
  8298. * @param space The space that the returned position is in
  8299. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8300. * @returns The position of the bone
  8301. */
  8302. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  8303. /**
  8304. * Copy the position of the bone to a vector3 in local or world space
  8305. * @param space The space that the returned position is in
  8306. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8307. * @param result The vector3 to copy the position to
  8308. */
  8309. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  8310. /**
  8311. * Get the absolute position of the bone (world space)
  8312. * @param mesh The mesh that this bone is attached to
  8313. * @returns The absolute position of the bone
  8314. */
  8315. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  8316. /**
  8317. * Copy the absolute position of the bone (world space) to the result param
  8318. * @param mesh The mesh that this bone is attached to
  8319. * @param result The vector3 to copy the absolute position to
  8320. */
  8321. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  8322. /**
  8323. * Compute the absolute transforms of this bone and its children
  8324. */
  8325. computeAbsoluteTransforms(): void;
  8326. /**
  8327. * Get the world direction from an axis that is in the local space of the bone
  8328. * @param localAxis The local direction that is used to compute the world direction
  8329. * @param mesh The mesh that this bone is attached to
  8330. * @returns The world direction
  8331. */
  8332. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8333. /**
  8334. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  8335. * @param localAxis The local direction that is used to compute the world direction
  8336. * @param mesh The mesh that this bone is attached to
  8337. * @param result The vector3 that the world direction will be copied to
  8338. */
  8339. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8340. /**
  8341. * Get the euler rotation of the bone in local or world space
  8342. * @param space The space that the rotation should be in
  8343. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8344. * @returns The euler rotation
  8345. */
  8346. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  8347. /**
  8348. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  8349. * @param space The space that the rotation should be in
  8350. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8351. * @param result The vector3 that the rotation should be copied to
  8352. */
  8353. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8354. /**
  8355. * Get the quaternion rotation of the bone in either local or world space
  8356. * @param space The space that the rotation should be in
  8357. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8358. * @returns The quaternion rotation
  8359. */
  8360. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  8361. /**
  8362. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  8363. * @param space The space that the rotation should be in
  8364. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8365. * @param result The quaternion that the rotation should be copied to
  8366. */
  8367. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  8368. /**
  8369. * Get the rotation matrix of the bone in local or world space
  8370. * @param space The space that the rotation should be in
  8371. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8372. * @returns The rotation matrix
  8373. */
  8374. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  8375. /**
  8376. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  8377. * @param space The space that the rotation should be in
  8378. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8379. * @param result The quaternion that the rotation should be copied to
  8380. */
  8381. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  8382. /**
  8383. * Get the world position of a point that is in the local space of the bone
  8384. * @param position The local position
  8385. * @param mesh The mesh that this bone is attached to
  8386. * @returns The world position
  8387. */
  8388. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8389. /**
  8390. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  8391. * @param position The local position
  8392. * @param mesh The mesh that this bone is attached to
  8393. * @param result The vector3 that the world position should be copied to
  8394. */
  8395. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8396. /**
  8397. * Get the local position of a point that is in world space
  8398. * @param position The world position
  8399. * @param mesh The mesh that this bone is attached to
  8400. * @returns The local position
  8401. */
  8402. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8403. /**
  8404. * Get the local position of a point that is in world space and copy it to the result param
  8405. * @param position The world position
  8406. * @param mesh The mesh that this bone is attached to
  8407. * @param result The vector3 that the local position should be copied to
  8408. */
  8409. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8410. }
  8411. }
  8412. declare module "babylonjs/Misc/iInspectable" {
  8413. /**
  8414. * Enum that determines the text-wrapping mode to use.
  8415. */
  8416. export enum InspectableType {
  8417. /**
  8418. * Checkbox for booleans
  8419. */
  8420. Checkbox = 0,
  8421. /**
  8422. * Sliders for numbers
  8423. */
  8424. Slider = 1,
  8425. /**
  8426. * Vector3
  8427. */
  8428. Vector3 = 2,
  8429. /**
  8430. * Quaternions
  8431. */
  8432. Quaternion = 3,
  8433. /**
  8434. * Color3
  8435. */
  8436. Color3 = 4
  8437. }
  8438. /**
  8439. * Interface used to define custom inspectable properties.
  8440. * This interface is used by the inspector to display custom property grids
  8441. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  8442. */
  8443. export interface IInspectable {
  8444. /**
  8445. * Gets the label to display
  8446. */
  8447. label: string;
  8448. /**
  8449. * Gets the name of the property to edit
  8450. */
  8451. propertyName: string;
  8452. /**
  8453. * Gets the type of the editor to use
  8454. */
  8455. type: InspectableType;
  8456. /**
  8457. * Gets the minimum value of the property when using in "slider" mode
  8458. */
  8459. min?: number;
  8460. /**
  8461. * Gets the maximum value of the property when using in "slider" mode
  8462. */
  8463. max?: number;
  8464. /**
  8465. * Gets the setp to use when using in "slider" mode
  8466. */
  8467. step?: number;
  8468. }
  8469. }
  8470. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  8471. import { Nullable } from "babylonjs/types";
  8472. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  8473. /**
  8474. * This represents the required contract to create a new type of texture loader.
  8475. */
  8476. export interface IInternalTextureLoader {
  8477. /**
  8478. * Defines wether the loader supports cascade loading the different faces.
  8479. */
  8480. supportCascades: boolean;
  8481. /**
  8482. * This returns if the loader support the current file information.
  8483. * @param extension defines the file extension of the file being loaded
  8484. * @param textureFormatInUse defines the current compressed format in use iun the engine
  8485. * @param fallback defines the fallback internal texture if any
  8486. * @param isBase64 defines whether the texture is encoded as a base64
  8487. * @param isBuffer defines whether the texture data are stored as a buffer
  8488. * @returns true if the loader can load the specified file
  8489. */
  8490. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  8491. /**
  8492. * Transform the url before loading if required.
  8493. * @param rootUrl the url of the texture
  8494. * @param textureFormatInUse defines the current compressed format in use iun the engine
  8495. * @returns the transformed texture
  8496. */
  8497. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  8498. /**
  8499. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  8500. * @param rootUrl the url of the texture
  8501. * @param textureFormatInUse defines the current compressed format in use iun the engine
  8502. * @returns the fallback texture
  8503. */
  8504. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  8505. /**
  8506. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  8507. * @param data contains the texture data
  8508. * @param texture defines the BabylonJS internal texture
  8509. * @param createPolynomials will be true if polynomials have been requested
  8510. * @param onLoad defines the callback to trigger once the texture is ready
  8511. * @param onError defines the callback to trigger in case of error
  8512. */
  8513. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  8514. /**
  8515. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  8516. * @param data contains the texture data
  8517. * @param texture defines the BabylonJS internal texture
  8518. * @param callback defines the method to call once ready to upload
  8519. */
  8520. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  8521. }
  8522. }
  8523. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  8524. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  8525. import { Nullable } from "babylonjs/types";
  8526. import { Scene } from "babylonjs/scene";
  8527. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  8528. module "babylonjs/Engines/engine" {
  8529. interface Engine {
  8530. /**
  8531. * Creates a depth stencil cube texture.
  8532. * This is only available in WebGL 2.
  8533. * @param size The size of face edge in the cube texture.
  8534. * @param options The options defining the cube texture.
  8535. * @returns The cube texture
  8536. */
  8537. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  8538. /**
  8539. * Creates a cube texture
  8540. * @param rootUrl defines the url where the files to load is located
  8541. * @param scene defines the current scene
  8542. * @param files defines the list of files to load (1 per face)
  8543. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  8544. * @param onLoad defines an optional callback raised when the texture is loaded
  8545. * @param onError defines an optional callback raised if there is an issue to load the texture
  8546. * @param format defines the format of the data
  8547. * @param forcedExtension defines the extension to use to pick the right loader
  8548. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  8549. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8550. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8551. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  8552. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  8553. * @returns the cube texture as an InternalTexture
  8554. */
  8555. 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;
  8556. /**
  8557. * Creates a cube texture
  8558. * @param rootUrl defines the url where the files to load is located
  8559. * @param scene defines the current scene
  8560. * @param files defines the list of files to load (1 per face)
  8561. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  8562. * @param onLoad defines an optional callback raised when the texture is loaded
  8563. * @param onError defines an optional callback raised if there is an issue to load the texture
  8564. * @param format defines the format of the data
  8565. * @param forcedExtension defines the extension to use to pick the right loader
  8566. * @returns the cube texture as an InternalTexture
  8567. */
  8568. 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;
  8569. /**
  8570. * Creates a cube texture
  8571. * @param rootUrl defines the url where the files to load is located
  8572. * @param scene defines the current scene
  8573. * @param files defines the list of files to load (1 per face)
  8574. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  8575. * @param onLoad defines an optional callback raised when the texture is loaded
  8576. * @param onError defines an optional callback raised if there is an issue to load the texture
  8577. * @param format defines the format of the data
  8578. * @param forcedExtension defines the extension to use to pick the right loader
  8579. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  8580. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8581. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8582. * @returns the cube texture as an InternalTexture
  8583. */
  8584. 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;
  8585. /** @hidden */
  8586. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  8587. /** @hidden */
  8588. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  8589. /** @hidden */
  8590. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  8591. /** @hidden */
  8592. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  8593. }
  8594. }
  8595. }
  8596. declare module "babylonjs/Materials/Textures/cubeTexture" {
  8597. import { Nullable } from "babylonjs/types";
  8598. import { Scene } from "babylonjs/scene";
  8599. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  8600. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8601. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  8602. /**
  8603. * Class for creating a cube texture
  8604. */
  8605. export class CubeTexture extends BaseTexture {
  8606. private _delayedOnLoad;
  8607. /**
  8608. * The url of the texture
  8609. */
  8610. url: string;
  8611. /**
  8612. * Gets or sets the center of the bounding box associated with the cube texture.
  8613. * It must define where the camera used to render the texture was set
  8614. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8615. */
  8616. boundingBoxPosition: Vector3;
  8617. private _boundingBoxSize;
  8618. /**
  8619. * Gets or sets the size of the bounding box associated with the cube texture
  8620. * When defined, the cubemap will switch to local mode
  8621. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  8622. * @example https://www.babylonjs-playground.com/#RNASML
  8623. */
  8624. /**
  8625. * Returns the bounding box size
  8626. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8627. */
  8628. boundingBoxSize: Vector3;
  8629. protected _rotationY: number;
  8630. /**
  8631. * Sets texture matrix rotation angle around Y axis in radians.
  8632. */
  8633. /**
  8634. * Gets texture matrix rotation angle around Y axis radians.
  8635. */
  8636. rotationY: number;
  8637. /**
  8638. * Are mip maps generated for this texture or not.
  8639. */
  8640. readonly noMipmap: boolean;
  8641. private _noMipmap;
  8642. private _files;
  8643. private _extensions;
  8644. private _textureMatrix;
  8645. private _format;
  8646. private _createPolynomials;
  8647. /** @hidden */
  8648. _prefiltered: boolean;
  8649. /**
  8650. * Creates a cube texture from an array of image urls
  8651. * @param files defines an array of image urls
  8652. * @param scene defines the hosting scene
  8653. * @param noMipmap specifies if mip maps are not used
  8654. * @returns a cube texture
  8655. */
  8656. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  8657. /**
  8658. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  8659. * @param url defines the url of the prefiltered texture
  8660. * @param scene defines the scene the texture is attached to
  8661. * @param forcedExtension defines the extension of the file if different from the url
  8662. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8663. * @return the prefiltered texture
  8664. */
  8665. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  8666. /**
  8667. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  8668. * as prefiltered data.
  8669. * @param rootUrl defines the url of the texture or the root name of the six images
  8670. * @param scene defines the scene the texture is attached to
  8671. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  8672. * @param noMipmap defines if mipmaps should be created or not
  8673. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  8674. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  8675. * @param onError defines a callback triggered in case of error during load
  8676. * @param format defines the internal format to use for the texture once loaded
  8677. * @param prefiltered defines whether or not the texture is created from prefiltered data
  8678. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  8679. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8680. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8681. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8682. * @return the cube texture
  8683. */
  8684. 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);
  8685. /**
  8686. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  8687. */
  8688. readonly isPrefiltered: boolean;
  8689. /**
  8690. * Get the current class name of the texture useful for serialization or dynamic coding.
  8691. * @returns "CubeTexture"
  8692. */
  8693. getClassName(): string;
  8694. /**
  8695. * Update the url (and optional buffer) of this texture if url was null during construction.
  8696. * @param url the url of the texture
  8697. * @param forcedExtension defines the extension to use
  8698. * @param onLoad callback called when the texture is loaded (defaults to null)
  8699. */
  8700. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  8701. /**
  8702. * Delays loading of the cube texture
  8703. * @param forcedExtension defines the extension to use
  8704. */
  8705. delayLoad(forcedExtension?: string): void;
  8706. /**
  8707. * Returns the reflection texture matrix
  8708. * @returns the reflection texture matrix
  8709. */
  8710. getReflectionTextureMatrix(): Matrix;
  8711. /**
  8712. * Sets the reflection texture matrix
  8713. * @param value Reflection texture matrix
  8714. */
  8715. setReflectionTextureMatrix(value: Matrix): void;
  8716. /**
  8717. * Parses text to create a cube texture
  8718. * @param parsedTexture define the serialized text to read from
  8719. * @param scene defines the hosting scene
  8720. * @param rootUrl defines the root url of the cube texture
  8721. * @returns a cube texture
  8722. */
  8723. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  8724. /**
  8725. * Makes a clone, or deep copy, of the cube texture
  8726. * @returns a new cube texture
  8727. */
  8728. clone(): CubeTexture;
  8729. }
  8730. }
  8731. declare module "babylonjs/Shaders/postprocess.vertex" {
  8732. /** @hidden */
  8733. export var postprocessVertexShader: {
  8734. name: string;
  8735. shader: string;
  8736. };
  8737. }
  8738. declare module "babylonjs/Cameras/targetCamera" {
  8739. import { Nullable } from "babylonjs/types";
  8740. import { Camera } from "babylonjs/Cameras/camera";
  8741. import { Scene } from "babylonjs/scene";
  8742. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math";
  8743. /**
  8744. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8745. * This is the base of the follow, arc rotate cameras and Free camera
  8746. * @see http://doc.babylonjs.com/features/cameras
  8747. */
  8748. export class TargetCamera extends Camera {
  8749. private static _RigCamTransformMatrix;
  8750. private static _TargetTransformMatrix;
  8751. private static _TargetFocalPoint;
  8752. /**
  8753. * Define the current direction the camera is moving to
  8754. */
  8755. cameraDirection: Vector3;
  8756. /**
  8757. * Define the current rotation the camera is rotating to
  8758. */
  8759. cameraRotation: Vector2;
  8760. /**
  8761. * When set, the up vector of the camera will be updated by the rotation of the camera
  8762. */
  8763. updateUpVectorFromRotation: boolean;
  8764. private _tmpQuaternion;
  8765. /**
  8766. * Define the current rotation of the camera
  8767. */
  8768. rotation: Vector3;
  8769. /**
  8770. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8771. */
  8772. rotationQuaternion: Quaternion;
  8773. /**
  8774. * Define the current speed of the camera
  8775. */
  8776. speed: number;
  8777. /**
  8778. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8779. * around all axis.
  8780. */
  8781. noRotationConstraint: boolean;
  8782. /**
  8783. * Define the current target of the camera as an object or a position.
  8784. */
  8785. lockedTarget: any;
  8786. /** @hidden */
  8787. _currentTarget: Vector3;
  8788. /** @hidden */
  8789. _initialFocalDistance: number;
  8790. /** @hidden */
  8791. _viewMatrix: Matrix;
  8792. /** @hidden */
  8793. _camMatrix: Matrix;
  8794. /** @hidden */
  8795. _cameraTransformMatrix: Matrix;
  8796. /** @hidden */
  8797. _cameraRotationMatrix: Matrix;
  8798. /** @hidden */
  8799. _referencePoint: Vector3;
  8800. /** @hidden */
  8801. _transformedReferencePoint: Vector3;
  8802. protected _globalCurrentTarget: Vector3;
  8803. protected _globalCurrentUpVector: Vector3;
  8804. /** @hidden */
  8805. _reset: () => void;
  8806. private _defaultUp;
  8807. /**
  8808. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  8809. * This is the base of the follow, arc rotate cameras and Free camera
  8810. * @see http://doc.babylonjs.com/features/cameras
  8811. * @param name Defines the name of the camera in the scene
  8812. * @param position Defines the start position of the camera in the scene
  8813. * @param scene Defines the scene the camera belongs to
  8814. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8815. */
  8816. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8817. /**
  8818. * Gets the position in front of the camera at a given distance.
  8819. * @param distance The distance from the camera we want the position to be
  8820. * @returns the position
  8821. */
  8822. getFrontPosition(distance: number): Vector3;
  8823. /** @hidden */
  8824. _getLockedTargetPosition(): Nullable<Vector3>;
  8825. private _storedPosition;
  8826. private _storedRotation;
  8827. private _storedRotationQuaternion;
  8828. /**
  8829. * Store current camera state of the camera (fov, position, rotation, etc..)
  8830. * @returns the camera
  8831. */
  8832. storeState(): Camera;
  8833. /**
  8834. * Restored camera state. You must call storeState() first
  8835. * @returns whether it was successful or not
  8836. * @hidden
  8837. */
  8838. _restoreStateValues(): boolean;
  8839. /** @hidden */
  8840. _initCache(): void;
  8841. /** @hidden */
  8842. _updateCache(ignoreParentClass?: boolean): void;
  8843. /** @hidden */
  8844. _isSynchronizedViewMatrix(): boolean;
  8845. /** @hidden */
  8846. _computeLocalCameraSpeed(): number;
  8847. /**
  8848. * Defines the target the camera should look at.
  8849. * This will automatically adapt alpha beta and radius to fit within the new target.
  8850. * @param target Defines the new target as a Vector or a mesh
  8851. */
  8852. setTarget(target: Vector3): void;
  8853. /**
  8854. * Return the current target position of the camera. This value is expressed in local space.
  8855. * @returns the target position
  8856. */
  8857. getTarget(): Vector3;
  8858. /** @hidden */
  8859. _decideIfNeedsToMove(): boolean;
  8860. /** @hidden */
  8861. _updatePosition(): void;
  8862. /** @hidden */
  8863. _checkInputs(): void;
  8864. protected _updateCameraRotationMatrix(): void;
  8865. /**
  8866. * 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)
  8867. * @returns the current camera
  8868. */
  8869. private _rotateUpVectorWithCameraRotationMatrix;
  8870. private _cachedRotationZ;
  8871. private _cachedQuaternionRotationZ;
  8872. /** @hidden */
  8873. _getViewMatrix(): Matrix;
  8874. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8875. /**
  8876. * @hidden
  8877. */
  8878. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8879. /**
  8880. * @hidden
  8881. */
  8882. _updateRigCameras(): void;
  8883. private _getRigCamPositionAndTarget;
  8884. /**
  8885. * Gets the current object class name.
  8886. * @return the class name
  8887. */
  8888. getClassName(): string;
  8889. }
  8890. }
  8891. declare module "babylonjs/Cameras/cameraInputsManager" {
  8892. import { Nullable } from "babylonjs/types";
  8893. import { Camera } from "babylonjs/Cameras/camera";
  8894. /**
  8895. * @ignore
  8896. * This is a list of all the different input types that are available in the application.
  8897. * Fo instance: ArcRotateCameraGamepadInput...
  8898. */
  8899. export var CameraInputTypes: {};
  8900. /**
  8901. * This is the contract to implement in order to create a new input class.
  8902. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  8903. */
  8904. export interface ICameraInput<TCamera extends Camera> {
  8905. /**
  8906. * Defines the camera the input is attached to.
  8907. */
  8908. camera: Nullable<TCamera>;
  8909. /**
  8910. * Gets the class name of the current intput.
  8911. * @returns the class name
  8912. */
  8913. getClassName(): string;
  8914. /**
  8915. * Get the friendly name associated with the input class.
  8916. * @returns the input friendly name
  8917. */
  8918. getSimpleName(): string;
  8919. /**
  8920. * Attach the input controls to a specific dom element to get the input from.
  8921. * @param element Defines the element the controls should be listened from
  8922. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8923. */
  8924. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8925. /**
  8926. * Detach the current controls from the specified dom element.
  8927. * @param element Defines the element to stop listening the inputs from
  8928. */
  8929. detachControl(element: Nullable<HTMLElement>): void;
  8930. /**
  8931. * Update the current camera state depending on the inputs that have been used this frame.
  8932. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8933. */
  8934. checkInputs?: () => void;
  8935. }
  8936. /**
  8937. * Represents a map of input types to input instance or input index to input instance.
  8938. */
  8939. export interface CameraInputsMap<TCamera extends Camera> {
  8940. /**
  8941. * Accessor to the input by input type.
  8942. */
  8943. [name: string]: ICameraInput<TCamera>;
  8944. /**
  8945. * Accessor to the input by input index.
  8946. */
  8947. [idx: number]: ICameraInput<TCamera>;
  8948. }
  8949. /**
  8950. * This represents the input manager used within a camera.
  8951. * It helps dealing with all the different kind of input attached to a camera.
  8952. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8953. */
  8954. export class CameraInputsManager<TCamera extends Camera> {
  8955. /**
  8956. * Defines the list of inputs attahed to the camera.
  8957. */
  8958. attached: CameraInputsMap<TCamera>;
  8959. /**
  8960. * Defines the dom element the camera is collecting inputs from.
  8961. * This is null if the controls have not been attached.
  8962. */
  8963. attachedElement: Nullable<HTMLElement>;
  8964. /**
  8965. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8966. */
  8967. noPreventDefault: boolean;
  8968. /**
  8969. * Defined the camera the input manager belongs to.
  8970. */
  8971. camera: TCamera;
  8972. /**
  8973. * Update the current camera state depending on the inputs that have been used this frame.
  8974. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8975. */
  8976. checkInputs: () => void;
  8977. /**
  8978. * Instantiate a new Camera Input Manager.
  8979. * @param camera Defines the camera the input manager blongs to
  8980. */
  8981. constructor(camera: TCamera);
  8982. /**
  8983. * Add an input method to a camera
  8984. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8985. * @param input camera input method
  8986. */
  8987. add(input: ICameraInput<TCamera>): void;
  8988. /**
  8989. * Remove a specific input method from a camera
  8990. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  8991. * @param inputToRemove camera input method
  8992. */
  8993. remove(inputToRemove: ICameraInput<TCamera>): void;
  8994. /**
  8995. * Remove a specific input type from a camera
  8996. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  8997. * @param inputType the type of the input to remove
  8998. */
  8999. removeByType(inputType: string): void;
  9000. private _addCheckInputs;
  9001. /**
  9002. * Attach the input controls to the currently attached dom element to listen the events from.
  9003. * @param input Defines the input to attach
  9004. */
  9005. attachInput(input: ICameraInput<TCamera>): void;
  9006. /**
  9007. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  9008. * @param element Defines the dom element to collect the events from
  9009. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  9010. */
  9011. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  9012. /**
  9013. * Detach the current manager inputs controls from a specific dom element.
  9014. * @param element Defines the dom element to collect the events from
  9015. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  9016. */
  9017. detachElement(element: HTMLElement, disconnect?: boolean): void;
  9018. /**
  9019. * Rebuild the dynamic inputCheck function from the current list of
  9020. * defined inputs in the manager.
  9021. */
  9022. rebuildInputCheck(): void;
  9023. /**
  9024. * Remove all attached input methods from a camera
  9025. */
  9026. clear(): void;
  9027. /**
  9028. * Serialize the current input manager attached to a camera.
  9029. * This ensures than once parsed,
  9030. * the input associated to the camera will be identical to the current ones
  9031. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  9032. */
  9033. serialize(serializedCamera: any): void;
  9034. /**
  9035. * Parses an input manager serialized JSON to restore the previous list of inputs
  9036. * and states associated to a camera.
  9037. * @param parsedCamera Defines the JSON to parse
  9038. */
  9039. parse(parsedCamera: any): void;
  9040. }
  9041. }
  9042. declare module "babylonjs/Events/keyboardEvents" {
  9043. /**
  9044. * Gather the list of keyboard event types as constants.
  9045. */
  9046. export class KeyboardEventTypes {
  9047. /**
  9048. * The keydown event is fired when a key becomes active (pressed).
  9049. */
  9050. static readonly KEYDOWN: number;
  9051. /**
  9052. * The keyup event is fired when a key has been released.
  9053. */
  9054. static readonly KEYUP: number;
  9055. }
  9056. /**
  9057. * This class is used to store keyboard related info for the onKeyboardObservable event.
  9058. */
  9059. export class KeyboardInfo {
  9060. /**
  9061. * Defines the type of event (KeyboardEventTypes)
  9062. */
  9063. type: number;
  9064. /**
  9065. * Defines the related dom event
  9066. */
  9067. event: KeyboardEvent;
  9068. /**
  9069. * Instantiates a new keyboard info.
  9070. * This class is used to store keyboard related info for the onKeyboardObservable event.
  9071. * @param type Defines the type of event (KeyboardEventTypes)
  9072. * @param event Defines the related dom event
  9073. */
  9074. constructor(
  9075. /**
  9076. * Defines the type of event (KeyboardEventTypes)
  9077. */
  9078. type: number,
  9079. /**
  9080. * Defines the related dom event
  9081. */
  9082. event: KeyboardEvent);
  9083. }
  9084. /**
  9085. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  9086. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  9087. */
  9088. export class KeyboardInfoPre extends KeyboardInfo {
  9089. /**
  9090. * Defines the type of event (KeyboardEventTypes)
  9091. */
  9092. type: number;
  9093. /**
  9094. * Defines the related dom event
  9095. */
  9096. event: KeyboardEvent;
  9097. /**
  9098. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  9099. */
  9100. skipOnPointerObservable: boolean;
  9101. /**
  9102. * Instantiates a new keyboard pre info.
  9103. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  9104. * @param type Defines the type of event (KeyboardEventTypes)
  9105. * @param event Defines the related dom event
  9106. */
  9107. constructor(
  9108. /**
  9109. * Defines the type of event (KeyboardEventTypes)
  9110. */
  9111. type: number,
  9112. /**
  9113. * Defines the related dom event
  9114. */
  9115. event: KeyboardEvent);
  9116. }
  9117. }
  9118. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  9119. import { Nullable } from "babylonjs/types";
  9120. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  9121. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  9122. /**
  9123. * Manage the keyboard inputs to control the movement of a free camera.
  9124. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  9125. */
  9126. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  9127. /**
  9128. * Defines the camera the input is attached to.
  9129. */
  9130. camera: FreeCamera;
  9131. /**
  9132. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  9133. */
  9134. keysUp: number[];
  9135. /**
  9136. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  9137. */
  9138. keysDown: number[];
  9139. /**
  9140. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  9141. */
  9142. keysLeft: number[];
  9143. /**
  9144. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  9145. */
  9146. keysRight: number[];
  9147. private _keys;
  9148. private _onCanvasBlurObserver;
  9149. private _onKeyboardObserver;
  9150. private _engine;
  9151. private _scene;
  9152. /**
  9153. * Attach the input controls to a specific dom element to get the input from.
  9154. * @param element Defines the element the controls should be listened from
  9155. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  9156. */
  9157. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  9158. /**
  9159. * Detach the current controls from the specified dom element.
  9160. * @param element Defines the element to stop listening the inputs from
  9161. */
  9162. detachControl(element: Nullable<HTMLElement>): void;
  9163. /**
  9164. * Update the current camera state depending on the inputs that have been used this frame.
  9165. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  9166. */
  9167. checkInputs(): void;
  9168. /**
  9169. * Gets the class name of the current intput.
  9170. * @returns the class name
  9171. */
  9172. getClassName(): string;
  9173. /** @hidden */
  9174. _onLostFocus(): void;
  9175. /**
  9176. * Get the friendly name associated with the input class.
  9177. * @returns the input friendly name
  9178. */
  9179. getSimpleName(): string;
  9180. }
  9181. }
  9182. declare module "babylonjs/Lights/shadowLight" {
  9183. import { Camera } from "babylonjs/Cameras/camera";
  9184. import { Scene } from "babylonjs/scene";
  9185. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  9186. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9187. import { Light } from "babylonjs/Lights/light";
  9188. /**
  9189. * Interface describing all the common properties and methods a shadow light needs to implement.
  9190. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  9191. * as well as binding the different shadow properties to the effects.
  9192. */
  9193. export interface IShadowLight extends Light {
  9194. /**
  9195. * The light id in the scene (used in scene.findLighById for instance)
  9196. */
  9197. id: string;
  9198. /**
  9199. * The position the shdow will be casted from.
  9200. */
  9201. position: Vector3;
  9202. /**
  9203. * In 2d mode (needCube being false), the direction used to cast the shadow.
  9204. */
  9205. direction: Vector3;
  9206. /**
  9207. * The transformed position. Position of the light in world space taking parenting in account.
  9208. */
  9209. transformedPosition: Vector3;
  9210. /**
  9211. * The transformed direction. Direction of the light in world space taking parenting in account.
  9212. */
  9213. transformedDirection: Vector3;
  9214. /**
  9215. * The friendly name of the light in the scene.
  9216. */
  9217. name: string;
  9218. /**
  9219. * Defines the shadow projection clipping minimum z value.
  9220. */
  9221. shadowMinZ: number;
  9222. /**
  9223. * Defines the shadow projection clipping maximum z value.
  9224. */
  9225. shadowMaxZ: number;
  9226. /**
  9227. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9228. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9229. */
  9230. computeTransformedInformation(): boolean;
  9231. /**
  9232. * Gets the scene the light belongs to.
  9233. * @returns The scene
  9234. */
  9235. getScene(): Scene;
  9236. /**
  9237. * Callback defining a custom Projection Matrix Builder.
  9238. * This can be used to override the default projection matrix computation.
  9239. */
  9240. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9241. /**
  9242. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9243. * @param matrix The materix to updated with the projection information
  9244. * @param viewMatrix The transform matrix of the light
  9245. * @param renderList The list of mesh to render in the map
  9246. * @returns The current light
  9247. */
  9248. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9249. /**
  9250. * Gets the current depth scale used in ESM.
  9251. * @returns The scale
  9252. */
  9253. getDepthScale(): number;
  9254. /**
  9255. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9256. * @returns true if a cube texture needs to be use
  9257. */
  9258. needCube(): boolean;
  9259. /**
  9260. * Detects if the projection matrix requires to be recomputed this frame.
  9261. * @returns true if it requires to be recomputed otherwise, false.
  9262. */
  9263. needProjectionMatrixCompute(): boolean;
  9264. /**
  9265. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9266. */
  9267. forceProjectionMatrixCompute(): void;
  9268. /**
  9269. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9270. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9271. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9272. */
  9273. getShadowDirection(faceIndex?: number): Vector3;
  9274. /**
  9275. * Gets the minZ used for shadow according to both the scene and the light.
  9276. * @param activeCamera The camera we are returning the min for
  9277. * @returns the depth min z
  9278. */
  9279. getDepthMinZ(activeCamera: Camera): number;
  9280. /**
  9281. * Gets the maxZ used for shadow according to both the scene and the light.
  9282. * @param activeCamera The camera we are returning the max for
  9283. * @returns the depth max z
  9284. */
  9285. getDepthMaxZ(activeCamera: Camera): number;
  9286. }
  9287. /**
  9288. * Base implementation IShadowLight
  9289. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9290. */
  9291. export abstract class ShadowLight extends Light implements IShadowLight {
  9292. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9293. protected _position: Vector3;
  9294. protected _setPosition(value: Vector3): void;
  9295. /**
  9296. * Sets the position the shadow will be casted from. Also use as the light position for both
  9297. * point and spot lights.
  9298. */
  9299. /**
  9300. * Sets the position the shadow will be casted from. Also use as the light position for both
  9301. * point and spot lights.
  9302. */
  9303. position: Vector3;
  9304. protected _direction: Vector3;
  9305. protected _setDirection(value: Vector3): void;
  9306. /**
  9307. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9308. * Also use as the light direction on spot and directional lights.
  9309. */
  9310. /**
  9311. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9312. * Also use as the light direction on spot and directional lights.
  9313. */
  9314. direction: Vector3;
  9315. private _shadowMinZ;
  9316. /**
  9317. * Gets the shadow projection clipping minimum z value.
  9318. */
  9319. /**
  9320. * Sets the shadow projection clipping minimum z value.
  9321. */
  9322. shadowMinZ: number;
  9323. private _shadowMaxZ;
  9324. /**
  9325. * Sets the shadow projection clipping maximum z value.
  9326. */
  9327. /**
  9328. * Gets the shadow projection clipping maximum z value.
  9329. */
  9330. shadowMaxZ: number;
  9331. /**
  9332. * Callback defining a custom Projection Matrix Builder.
  9333. * This can be used to override the default projection matrix computation.
  9334. */
  9335. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9336. /**
  9337. * The transformed position. Position of the light in world space taking parenting in account.
  9338. */
  9339. transformedPosition: Vector3;
  9340. /**
  9341. * The transformed direction. Direction of the light in world space taking parenting in account.
  9342. */
  9343. transformedDirection: Vector3;
  9344. private _needProjectionMatrixCompute;
  9345. /**
  9346. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9347. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9348. */
  9349. computeTransformedInformation(): boolean;
  9350. /**
  9351. * Return the depth scale used for the shadow map.
  9352. * @returns the depth scale.
  9353. */
  9354. getDepthScale(): number;
  9355. /**
  9356. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9357. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9358. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9359. */
  9360. getShadowDirection(faceIndex?: number): Vector3;
  9361. /**
  9362. * Returns the ShadowLight absolute position in the World.
  9363. * @returns the position vector in world space
  9364. */
  9365. getAbsolutePosition(): Vector3;
  9366. /**
  9367. * Sets the ShadowLight direction toward the passed target.
  9368. * @param target The point to target in local space
  9369. * @returns the updated ShadowLight direction
  9370. */
  9371. setDirectionToTarget(target: Vector3): Vector3;
  9372. /**
  9373. * Returns the light rotation in euler definition.
  9374. * @returns the x y z rotation in local space.
  9375. */
  9376. getRotation(): Vector3;
  9377. /**
  9378. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9379. * @returns true if a cube texture needs to be use
  9380. */
  9381. needCube(): boolean;
  9382. /**
  9383. * Detects if the projection matrix requires to be recomputed this frame.
  9384. * @returns true if it requires to be recomputed otherwise, false.
  9385. */
  9386. needProjectionMatrixCompute(): boolean;
  9387. /**
  9388. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9389. */
  9390. forceProjectionMatrixCompute(): void;
  9391. /** @hidden */
  9392. _initCache(): void;
  9393. /** @hidden */
  9394. _isSynchronized(): boolean;
  9395. /**
  9396. * Computes the world matrix of the node
  9397. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9398. * @returns the world matrix
  9399. */
  9400. computeWorldMatrix(force?: boolean): Matrix;
  9401. /**
  9402. * Gets the minZ used for shadow according to both the scene and the light.
  9403. * @param activeCamera The camera we are returning the min for
  9404. * @returns the depth min z
  9405. */
  9406. getDepthMinZ(activeCamera: Camera): number;
  9407. /**
  9408. * Gets the maxZ used for shadow according to both the scene and the light.
  9409. * @param activeCamera The camera we are returning the max for
  9410. * @returns the depth max z
  9411. */
  9412. getDepthMaxZ(activeCamera: Camera): number;
  9413. /**
  9414. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9415. * @param matrix The materix to updated with the projection information
  9416. * @param viewMatrix The transform matrix of the light
  9417. * @param renderList The list of mesh to render in the map
  9418. * @returns The current light
  9419. */
  9420. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9421. }
  9422. }
  9423. declare module "babylonjs/Materials/materialHelper" {
  9424. import { Nullable } from "babylonjs/types";
  9425. import { Scene } from "babylonjs/scene";
  9426. import { Engine } from "babylonjs/Engines/engine";
  9427. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9428. import { Light } from "babylonjs/Lights/light";
  9429. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9430. import { Effect, EffectFallbacks, EffectCreationOptions } from "babylonjs/Materials/effect";
  9431. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  9432. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9433. /**
  9434. * "Static Class" containing the most commonly used helper while dealing with material for
  9435. * rendering purpose.
  9436. *
  9437. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9438. *
  9439. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9440. */
  9441. export class MaterialHelper {
  9442. /**
  9443. * Bind the current view position to an effect.
  9444. * @param effect The effect to be bound
  9445. * @param scene The scene the eyes position is used from
  9446. */
  9447. static BindEyePosition(effect: Effect, scene: Scene): void;
  9448. /**
  9449. * Helps preparing the defines values about the UVs in used in the effect.
  9450. * UVs are shared as much as we can accross channels in the shaders.
  9451. * @param texture The texture we are preparing the UVs for
  9452. * @param defines The defines to update
  9453. * @param key The channel key "diffuse", "specular"... used in the shader
  9454. */
  9455. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9456. /**
  9457. * Binds a texture matrix value to its corrsponding uniform
  9458. * @param texture The texture to bind the matrix for
  9459. * @param uniformBuffer The uniform buffer receivin the data
  9460. * @param key The channel key "diffuse", "specular"... used in the shader
  9461. */
  9462. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9463. /**
  9464. * Gets the current status of the fog (should it be enabled?)
  9465. * @param mesh defines the mesh to evaluate for fog support
  9466. * @param scene defines the hosting scene
  9467. * @returns true if fog must be enabled
  9468. */
  9469. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  9470. /**
  9471. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9472. * @param mesh defines the current mesh
  9473. * @param scene defines the current scene
  9474. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9475. * @param pointsCloud defines if point cloud rendering has to be turned on
  9476. * @param fogEnabled defines if fog has to be turned on
  9477. * @param alphaTest defines if alpha testing has to be turned on
  9478. * @param defines defines the current list of defines
  9479. */
  9480. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9481. /**
  9482. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9483. * @param scene defines the current scene
  9484. * @param engine defines the current engine
  9485. * @param defines specifies the list of active defines
  9486. * @param useInstances defines if instances have to be turned on
  9487. * @param useClipPlane defines if clip plane have to be turned on
  9488. */
  9489. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9490. /**
  9491. * Prepares the defines for bones
  9492. * @param mesh The mesh containing the geometry data we will draw
  9493. * @param defines The defines to update
  9494. */
  9495. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  9496. /**
  9497. * Prepares the defines for morph targets
  9498. * @param mesh The mesh containing the geometry data we will draw
  9499. * @param defines The defines to update
  9500. */
  9501. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  9502. /**
  9503. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9504. * @param mesh The mesh containing the geometry data we will draw
  9505. * @param defines The defines to update
  9506. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9507. * @param useBones Precise whether bones should be used or not (override mesh info)
  9508. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9509. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9510. * @returns false if defines are considered not dirty and have not been checked
  9511. */
  9512. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9513. /**
  9514. * Prepares the defines related to multiview
  9515. * @param scene The scene we are intending to draw
  9516. * @param defines The defines to update
  9517. */
  9518. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9519. /**
  9520. * Prepares the defines related to the light information passed in parameter
  9521. * @param scene The scene we are intending to draw
  9522. * @param mesh The mesh the effect is compiling for
  9523. * @param defines The defines to update
  9524. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9525. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9526. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9527. * @returns true if normals will be required for the rest of the effect
  9528. */
  9529. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9530. /**
  9531. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  9532. * that won t be acctive due to defines being turned off.
  9533. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9534. * @param samplersList The samplers list
  9535. * @param defines The defines helping in the list generation
  9536. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9537. */
  9538. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9539. /**
  9540. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9541. * @param defines The defines to update while falling back
  9542. * @param fallbacks The authorized effect fallbacks
  9543. * @param maxSimultaneousLights The maximum number of lights allowed
  9544. * @param rank the current rank of the Effect
  9545. * @returns The newly affected rank
  9546. */
  9547. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9548. /**
  9549. * Prepares the list of attributes required for morph targets according to the effect defines.
  9550. * @param attribs The current list of supported attribs
  9551. * @param mesh The mesh to prepare the morph targets attributes for
  9552. * @param defines The current Defines of the effect
  9553. */
  9554. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9555. /**
  9556. * Prepares the list of attributes required for bones according to the effect defines.
  9557. * @param attribs The current list of supported attribs
  9558. * @param mesh The mesh to prepare the bones attributes for
  9559. * @param defines The current Defines of the effect
  9560. * @param fallbacks The current efffect fallback strategy
  9561. */
  9562. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9563. /**
  9564. * Check and prepare the list of attributes required for instances according to the effect defines.
  9565. * @param attribs The current list of supported attribs
  9566. * @param defines The current MaterialDefines of the effect
  9567. */
  9568. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9569. /**
  9570. * Add the list of attributes required for instances to the attribs array.
  9571. * @param attribs The current list of supported attribs
  9572. */
  9573. static PushAttributesForInstances(attribs: string[]): void;
  9574. /**
  9575. * Binds the light shadow information to the effect for the given mesh.
  9576. * @param light The light containing the generator
  9577. * @param scene The scene the lights belongs to
  9578. * @param mesh The mesh we are binding the information to render
  9579. * @param lightIndex The light index in the effect used to render the mesh
  9580. * @param effect The effect we are binding the data to
  9581. */
  9582. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  9583. /**
  9584. * Binds the light information to the effect.
  9585. * @param light The light containing the generator
  9586. * @param effect The effect we are binding the data to
  9587. * @param lightIndex The light index in the effect used to render
  9588. */
  9589. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9590. /**
  9591. * Binds the lights information from the scene to the effect for the given mesh.
  9592. * @param scene The scene the lights belongs to
  9593. * @param mesh The mesh we are binding the information to render
  9594. * @param effect The effect we are binding the data to
  9595. * @param defines The generated defines for the effect
  9596. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9597. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9598. */
  9599. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  9600. private static _tempFogColor;
  9601. /**
  9602. * Binds the fog information from the scene to the effect for the given mesh.
  9603. * @param scene The scene the lights belongs to
  9604. * @param mesh The mesh we are binding the information to render
  9605. * @param effect The effect we are binding the data to
  9606. * @param linearSpace Defines if the fog effect is applied in linear space
  9607. */
  9608. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9609. /**
  9610. * Binds the bones information from the mesh to the effect.
  9611. * @param mesh The mesh we are binding the information to render
  9612. * @param effect The effect we are binding the data to
  9613. */
  9614. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9615. /**
  9616. * Binds the morph targets information from the mesh to the effect.
  9617. * @param abstractMesh The mesh we are binding the information to render
  9618. * @param effect The effect we are binding the data to
  9619. */
  9620. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9621. /**
  9622. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9623. * @param defines The generated defines used in the effect
  9624. * @param effect The effect we are binding the data to
  9625. * @param scene The scene we are willing to render with logarithmic scale for
  9626. */
  9627. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9628. /**
  9629. * Binds the clip plane information from the scene to the effect.
  9630. * @param scene The scene the clip plane information are extracted from
  9631. * @param effect The effect we are binding the data to
  9632. */
  9633. static BindClipPlane(effect: Effect, scene: Scene): void;
  9634. }
  9635. }
  9636. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  9637. /** @hidden */
  9638. export var kernelBlurVaryingDeclaration: {
  9639. name: string;
  9640. shader: string;
  9641. };
  9642. }
  9643. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  9644. /** @hidden */
  9645. export var kernelBlurFragment: {
  9646. name: string;
  9647. shader: string;
  9648. };
  9649. }
  9650. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  9651. /** @hidden */
  9652. export var kernelBlurFragment2: {
  9653. name: string;
  9654. shader: string;
  9655. };
  9656. }
  9657. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  9658. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  9659. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  9660. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  9661. /** @hidden */
  9662. export var kernelBlurPixelShader: {
  9663. name: string;
  9664. shader: string;
  9665. };
  9666. }
  9667. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  9668. /** @hidden */
  9669. export var kernelBlurVertex: {
  9670. name: string;
  9671. shader: string;
  9672. };
  9673. }
  9674. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  9675. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  9676. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  9677. /** @hidden */
  9678. export var kernelBlurVertexShader: {
  9679. name: string;
  9680. shader: string;
  9681. };
  9682. }
  9683. declare module "babylonjs/PostProcesses/blurPostProcess" {
  9684. import { Vector2 } from "babylonjs/Maths/math";
  9685. import { Nullable } from "babylonjs/types";
  9686. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  9687. import { Camera } from "babylonjs/Cameras/camera";
  9688. import { Effect } from "babylonjs/Materials/effect";
  9689. import { Engine } from "babylonjs/Engines/engine";
  9690. import "babylonjs/Shaders/kernelBlur.fragment";
  9691. import "babylonjs/Shaders/kernelBlur.vertex";
  9692. /**
  9693. * The Blur Post Process which blurs an image based on a kernel and direction.
  9694. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  9695. */
  9696. export class BlurPostProcess extends PostProcess {
  9697. /** The direction in which to blur the image. */
  9698. direction: Vector2;
  9699. private blockCompilation;
  9700. protected _kernel: number;
  9701. protected _idealKernel: number;
  9702. protected _packedFloat: boolean;
  9703. private _staticDefines;
  9704. /**
  9705. * Sets the length in pixels of the blur sample region
  9706. */
  9707. /**
  9708. * Gets the length in pixels of the blur sample region
  9709. */
  9710. kernel: number;
  9711. /**
  9712. * Sets wether or not the blur needs to unpack/repack floats
  9713. */
  9714. /**
  9715. * Gets wether or not the blur is unpacking/repacking floats
  9716. */
  9717. packedFloat: boolean;
  9718. /**
  9719. * Creates a new instance BlurPostProcess
  9720. * @param name The name of the effect.
  9721. * @param direction The direction in which to blur the image.
  9722. * @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.
  9723. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  9724. * @param camera The camera to apply the render pass to.
  9725. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  9726. * @param engine The engine which the post process will be applied. (default: current engine)
  9727. * @param reusable If the post process can be reused on the same frame. (default: false)
  9728. * @param textureType Type of textures used when performing the post process. (default: 0)
  9729. * @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)
  9730. */
  9731. constructor(name: string,
  9732. /** The direction in which to blur the image. */
  9733. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  9734. /**
  9735. * Updates the effect with the current post process compile time values and recompiles the shader.
  9736. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  9737. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  9738. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  9739. * @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
  9740. * @param onCompiled Called when the shader has been compiled.
  9741. * @param onError Called if there is an error when compiling a shader.
  9742. */
  9743. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9744. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9745. /**
  9746. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  9747. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  9748. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  9749. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  9750. * The gaps between physical kernels are compensated for in the weighting of the samples
  9751. * @param idealKernel Ideal blur kernel.
  9752. * @return Nearest best kernel.
  9753. */
  9754. protected _nearestBestKernel(idealKernel: number): number;
  9755. /**
  9756. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  9757. * @param x The point on the Gaussian distribution to sample.
  9758. * @return the value of the Gaussian function at x.
  9759. */
  9760. protected _gaussianWeight(x: number): number;
  9761. /**
  9762. * Generates a string that can be used as a floating point number in GLSL.
  9763. * @param x Value to print.
  9764. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  9765. * @return GLSL float string.
  9766. */
  9767. protected _glslFloat(x: number, decimalFigures?: number): string;
  9768. }
  9769. }
  9770. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9771. /** @hidden */
  9772. export var shadowMapPixelShader: {
  9773. name: string;
  9774. shader: string;
  9775. };
  9776. }
  9777. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9778. /** @hidden */
  9779. export var bonesDeclaration: {
  9780. name: string;
  9781. shader: string;
  9782. };
  9783. }
  9784. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9785. /** @hidden */
  9786. export var morphTargetsVertexGlobalDeclaration: {
  9787. name: string;
  9788. shader: string;
  9789. };
  9790. }
  9791. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9792. /** @hidden */
  9793. export var morphTargetsVertexDeclaration: {
  9794. name: string;
  9795. shader: string;
  9796. };
  9797. }
  9798. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9799. /** @hidden */
  9800. export var instancesDeclaration: {
  9801. name: string;
  9802. shader: string;
  9803. };
  9804. }
  9805. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9806. /** @hidden */
  9807. export var helperFunctions: {
  9808. name: string;
  9809. shader: string;
  9810. };
  9811. }
  9812. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9813. /** @hidden */
  9814. export var morphTargetsVertex: {
  9815. name: string;
  9816. shader: string;
  9817. };
  9818. }
  9819. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9820. /** @hidden */
  9821. export var instancesVertex: {
  9822. name: string;
  9823. shader: string;
  9824. };
  9825. }
  9826. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9827. /** @hidden */
  9828. export var bonesVertex: {
  9829. name: string;
  9830. shader: string;
  9831. };
  9832. }
  9833. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9834. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9835. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9836. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9837. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9838. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9839. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9840. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9841. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9842. /** @hidden */
  9843. export var shadowMapVertexShader: {
  9844. name: string;
  9845. shader: string;
  9846. };
  9847. }
  9848. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9849. /** @hidden */
  9850. export var depthBoxBlurPixelShader: {
  9851. name: string;
  9852. shader: string;
  9853. };
  9854. }
  9855. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  9856. import { Nullable } from "babylonjs/types";
  9857. import { Scene } from "babylonjs/scene";
  9858. import { Matrix } from "babylonjs/Maths/math";
  9859. import { SubMesh } from "babylonjs/Meshes/subMesh";
  9860. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9861. import { Mesh } from "babylonjs/Meshes/mesh";
  9862. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  9863. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9864. import { Effect } from "babylonjs/Materials/effect";
  9865. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  9866. import "babylonjs/Shaders/shadowMap.fragment";
  9867. import "babylonjs/Shaders/shadowMap.vertex";
  9868. import "babylonjs/Shaders/depthBoxBlur.fragment";
  9869. import { Observable } from "babylonjs/Misc/observable";
  9870. /**
  9871. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9872. */
  9873. export interface ICustomShaderOptions {
  9874. /**
  9875. * Gets or sets the custom shader name to use
  9876. */
  9877. shaderName: string;
  9878. /**
  9879. * The list of attribute names used in the shader
  9880. */
  9881. attributes?: string[];
  9882. /**
  9883. * The list of unifrom names used in the shader
  9884. */
  9885. uniforms?: string[];
  9886. /**
  9887. * The list of sampler names used in the shader
  9888. */
  9889. samplers?: string[];
  9890. /**
  9891. * The list of defines used in the shader
  9892. */
  9893. defines?: string[];
  9894. }
  9895. /**
  9896. * Interface to implement to create a shadow generator compatible with BJS.
  9897. */
  9898. export interface IShadowGenerator {
  9899. /**
  9900. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9901. * @returns The render target texture if present otherwise, null
  9902. */
  9903. getShadowMap(): Nullable<RenderTargetTexture>;
  9904. /**
  9905. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9906. * @returns The render target texture if the shadow map is present otherwise, null
  9907. */
  9908. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9909. /**
  9910. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9911. * @param subMesh The submesh we want to render in the shadow map
  9912. * @param useInstances Defines wether will draw in the map using instances
  9913. * @returns true if ready otherwise, false
  9914. */
  9915. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9916. /**
  9917. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9918. * @param defines Defines of the material we want to update
  9919. * @param lightIndex Index of the light in the enabled light list of the material
  9920. */
  9921. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9922. /**
  9923. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9924. * defined in the generator but impacting the effect).
  9925. * It implies the unifroms available on the materials are the standard BJS ones.
  9926. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9927. * @param effect The effect we are binfing the information for
  9928. */
  9929. bindShadowLight(lightIndex: string, effect: Effect): void;
  9930. /**
  9931. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9932. * (eq to shadow prjection matrix * light transform matrix)
  9933. * @returns The transform matrix used to create the shadow map
  9934. */
  9935. getTransformMatrix(): Matrix;
  9936. /**
  9937. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9938. * Cube and 2D textures for instance.
  9939. */
  9940. recreateShadowMap(): void;
  9941. /**
  9942. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9943. * @param onCompiled Callback triggered at the and of the effects compilation
  9944. * @param options Sets of optional options forcing the compilation with different modes
  9945. */
  9946. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9947. useInstances: boolean;
  9948. }>): void;
  9949. /**
  9950. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9951. * @param options Sets of optional options forcing the compilation with different modes
  9952. * @returns A promise that resolves when the compilation completes
  9953. */
  9954. forceCompilationAsync(options?: Partial<{
  9955. useInstances: boolean;
  9956. }>): Promise<void>;
  9957. /**
  9958. * Serializes the shadow generator setup to a json object.
  9959. * @returns The serialized JSON object
  9960. */
  9961. serialize(): any;
  9962. /**
  9963. * Disposes the Shadow map and related Textures and effects.
  9964. */
  9965. dispose(): void;
  9966. }
  9967. /**
  9968. * Default implementation IShadowGenerator.
  9969. * This is the main object responsible of generating shadows in the framework.
  9970. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9971. */
  9972. export class ShadowGenerator implements IShadowGenerator {
  9973. /**
  9974. * Shadow generator mode None: no filtering applied.
  9975. */
  9976. static readonly FILTER_NONE: number;
  9977. /**
  9978. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9979. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9980. */
  9981. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9982. /**
  9983. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9984. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9985. */
  9986. static readonly FILTER_POISSONSAMPLING: number;
  9987. /**
  9988. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9989. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9990. */
  9991. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9992. /**
  9993. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9994. * edge artifacts on steep falloff.
  9995. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9996. */
  9997. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9998. /**
  9999. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  10000. * edge artifacts on steep falloff.
  10001. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  10002. */
  10003. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  10004. /**
  10005. * Shadow generator mode PCF: Percentage Closer Filtering
  10006. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  10007. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  10008. */
  10009. static readonly FILTER_PCF: number;
  10010. /**
  10011. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  10012. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  10013. * Contact Hardening
  10014. */
  10015. static readonly FILTER_PCSS: number;
  10016. /**
  10017. * Reserved for PCF and PCSS
  10018. * Highest Quality.
  10019. *
  10020. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  10021. *
  10022. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  10023. */
  10024. static readonly QUALITY_HIGH: number;
  10025. /**
  10026. * Reserved for PCF and PCSS
  10027. * Good tradeoff for quality/perf cross devices
  10028. *
  10029. * Execute PCF on a 3*3 kernel.
  10030. *
  10031. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  10032. */
  10033. static readonly QUALITY_MEDIUM: number;
  10034. /**
  10035. * Reserved for PCF and PCSS
  10036. * The lowest quality but the fastest.
  10037. *
  10038. * Execute PCF on a 1*1 kernel.
  10039. *
  10040. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  10041. */
  10042. static readonly QUALITY_LOW: number;
  10043. /** Gets or sets the custom shader name to use */
  10044. customShaderOptions: ICustomShaderOptions;
  10045. /**
  10046. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  10047. */
  10048. onBeforeShadowMapRenderObservable: Observable<Effect>;
  10049. /**
  10050. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  10051. */
  10052. onAfterShadowMapRenderObservable: Observable<Effect>;
  10053. /**
  10054. * Observable triggered before a mesh is rendered in the shadow map.
  10055. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  10056. */
  10057. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  10058. /**
  10059. * Observable triggered after a mesh is rendered in the shadow map.
  10060. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  10061. */
  10062. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  10063. private _bias;
  10064. /**
  10065. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  10066. */
  10067. /**
  10068. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  10069. */
  10070. bias: number;
  10071. private _normalBias;
  10072. /**
  10073. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  10074. */
  10075. /**
  10076. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  10077. */
  10078. normalBias: number;
  10079. private _blurBoxOffset;
  10080. /**
  10081. * Gets the blur box offset: offset applied during the blur pass.
  10082. * Only useful if useKernelBlur = false
  10083. */
  10084. /**
  10085. * Sets the blur box offset: offset applied during the blur pass.
  10086. * Only useful if useKernelBlur = false
  10087. */
  10088. blurBoxOffset: number;
  10089. private _blurScale;
  10090. /**
  10091. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  10092. * 2 means half of the size.
  10093. */
  10094. /**
  10095. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  10096. * 2 means half of the size.
  10097. */
  10098. blurScale: number;
  10099. private _blurKernel;
  10100. /**
  10101. * Gets the blur kernel: kernel size of the blur pass.
  10102. * Only useful if useKernelBlur = true
  10103. */
  10104. /**
  10105. * Sets the blur kernel: kernel size of the blur pass.
  10106. * Only useful if useKernelBlur = true
  10107. */
  10108. blurKernel: number;
  10109. private _useKernelBlur;
  10110. /**
  10111. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  10112. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  10113. */
  10114. /**
  10115. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  10116. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  10117. */
  10118. useKernelBlur: boolean;
  10119. private _depthScale;
  10120. /**
  10121. * Gets the depth scale used in ESM mode.
  10122. */
  10123. /**
  10124. * Sets the depth scale used in ESM mode.
  10125. * This can override the scale stored on the light.
  10126. */
  10127. depthScale: number;
  10128. private _filter;
  10129. /**
  10130. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  10131. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  10132. */
  10133. /**
  10134. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  10135. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  10136. */
  10137. filter: number;
  10138. /**
  10139. * Gets if the current filter is set to Poisson Sampling.
  10140. */
  10141. /**
  10142. * Sets the current filter to Poisson Sampling.
  10143. */
  10144. usePoissonSampling: boolean;
  10145. /**
  10146. * Gets if the current filter is set to ESM.
  10147. */
  10148. /**
  10149. * Sets the current filter is to ESM.
  10150. */
  10151. useExponentialShadowMap: boolean;
  10152. /**
  10153. * Gets if the current filter is set to filtered ESM.
  10154. */
  10155. /**
  10156. * Gets if the current filter is set to filtered ESM.
  10157. */
  10158. useBlurExponentialShadowMap: boolean;
  10159. /**
  10160. * Gets if the current filter is set to "close ESM" (using the inverse of the
  10161. * exponential to prevent steep falloff artifacts).
  10162. */
  10163. /**
  10164. * Sets the current filter to "close ESM" (using the inverse of the
  10165. * exponential to prevent steep falloff artifacts).
  10166. */
  10167. useCloseExponentialShadowMap: boolean;
  10168. /**
  10169. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  10170. * exponential to prevent steep falloff artifacts).
  10171. */
  10172. /**
  10173. * Sets the current filter to filtered "close ESM" (using the inverse of the
  10174. * exponential to prevent steep falloff artifacts).
  10175. */
  10176. useBlurCloseExponentialShadowMap: boolean;
  10177. /**
  10178. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  10179. */
  10180. /**
  10181. * Sets the current filter to "PCF" (percentage closer filtering).
  10182. */
  10183. usePercentageCloserFiltering: boolean;
  10184. private _filteringQuality;
  10185. /**
  10186. * Gets the PCF or PCSS Quality.
  10187. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  10188. */
  10189. /**
  10190. * Sets the PCF or PCSS Quality.
  10191. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  10192. */
  10193. filteringQuality: number;
  10194. /**
  10195. * Gets if the current filter is set to "PCSS" (contact hardening).
  10196. */
  10197. /**
  10198. * Sets the current filter to "PCSS" (contact hardening).
  10199. */
  10200. useContactHardeningShadow: boolean;
  10201. private _contactHardeningLightSizeUVRatio;
  10202. /**
  10203. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  10204. * Using a ratio helps keeping shape stability independently of the map size.
  10205. *
  10206. * It does not account for the light projection as it was having too much
  10207. * instability during the light setup or during light position changes.
  10208. *
  10209. * Only valid if useContactHardeningShadow is true.
  10210. */
  10211. /**
  10212. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  10213. * Using a ratio helps keeping shape stability independently of the map size.
  10214. *
  10215. * It does not account for the light projection as it was having too much
  10216. * instability during the light setup or during light position changes.
  10217. *
  10218. * Only valid if useContactHardeningShadow is true.
  10219. */
  10220. contactHardeningLightSizeUVRatio: number;
  10221. private _darkness;
  10222. /** Gets or sets the actual darkness of a shadow */
  10223. darkness: number;
  10224. /**
  10225. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  10226. * 0 means strongest and 1 would means no shadow.
  10227. * @returns the darkness.
  10228. */
  10229. getDarkness(): number;
  10230. /**
  10231. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  10232. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  10233. * @returns the shadow generator allowing fluent coding.
  10234. */
  10235. setDarkness(darkness: number): ShadowGenerator;
  10236. private _transparencyShadow;
  10237. /** Gets or sets the ability to have transparent shadow */
  10238. transparencyShadow: boolean;
  10239. /**
  10240. * Sets the ability to have transparent shadow (boolean).
  10241. * @param transparent True if transparent else False
  10242. * @returns the shadow generator allowing fluent coding
  10243. */
  10244. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  10245. private _shadowMap;
  10246. private _shadowMap2;
  10247. /**
  10248. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  10249. * @returns The render target texture if present otherwise, null
  10250. */
  10251. getShadowMap(): Nullable<RenderTargetTexture>;
  10252. /**
  10253. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  10254. * @returns The render target texture if the shadow map is present otherwise, null
  10255. */
  10256. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  10257. /**
  10258. * Gets the class name of that object
  10259. * @returns "ShadowGenerator"
  10260. */
  10261. getClassName(): string;
  10262. /**
  10263. * Helper function to add a mesh and its descendants to the list of shadow casters.
  10264. * @param mesh Mesh to add
  10265. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  10266. * @returns the Shadow Generator itself
  10267. */
  10268. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  10269. /**
  10270. * Helper function to remove a mesh and its descendants from the list of shadow casters
  10271. * @param mesh Mesh to remove
  10272. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  10273. * @returns the Shadow Generator itself
  10274. */
  10275. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  10276. /**
  10277. * Controls the extent to which the shadows fade out at the edge of the frustum
  10278. * Used only by directionals and spots
  10279. */
  10280. frustumEdgeFalloff: number;
  10281. private _light;
  10282. /**
  10283. * Returns the associated light object.
  10284. * @returns the light generating the shadow
  10285. */
  10286. getLight(): IShadowLight;
  10287. /**
  10288. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  10289. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  10290. * It might on the other hand introduce peter panning.
  10291. */
  10292. forceBackFacesOnly: boolean;
  10293. private _scene;
  10294. private _lightDirection;
  10295. private _effect;
  10296. private _viewMatrix;
  10297. private _projectionMatrix;
  10298. private _transformMatrix;
  10299. private _cachedPosition;
  10300. private _cachedDirection;
  10301. private _cachedDefines;
  10302. private _currentRenderID;
  10303. private _boxBlurPostprocess;
  10304. private _kernelBlurXPostprocess;
  10305. private _kernelBlurYPostprocess;
  10306. private _blurPostProcesses;
  10307. private _mapSize;
  10308. private _currentFaceIndex;
  10309. private _currentFaceIndexCache;
  10310. private _textureType;
  10311. private _defaultTextureMatrix;
  10312. /** @hidden */
  10313. static _SceneComponentInitialization: (scene: Scene) => void;
  10314. /**
  10315. * Creates a ShadowGenerator object.
  10316. * A ShadowGenerator is the required tool to use the shadows.
  10317. * Each light casting shadows needs to use its own ShadowGenerator.
  10318. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  10319. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  10320. * @param light The light object generating the shadows.
  10321. * @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.
  10322. */
  10323. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  10324. private _initializeGenerator;
  10325. private _initializeShadowMap;
  10326. private _initializeBlurRTTAndPostProcesses;
  10327. private _renderForShadowMap;
  10328. private _renderSubMeshForShadowMap;
  10329. private _applyFilterValues;
  10330. /**
  10331. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  10332. * @param onCompiled Callback triggered at the and of the effects compilation
  10333. * @param options Sets of optional options forcing the compilation with different modes
  10334. */
  10335. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  10336. useInstances: boolean;
  10337. }>): void;
  10338. /**
  10339. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  10340. * @param options Sets of optional options forcing the compilation with different modes
  10341. * @returns A promise that resolves when the compilation completes
  10342. */
  10343. forceCompilationAsync(options?: Partial<{
  10344. useInstances: boolean;
  10345. }>): Promise<void>;
  10346. /**
  10347. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  10348. * @param subMesh The submesh we want to render in the shadow map
  10349. * @param useInstances Defines wether will draw in the map using instances
  10350. * @returns true if ready otherwise, false
  10351. */
  10352. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  10353. /**
  10354. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  10355. * @param defines Defines of the material we want to update
  10356. * @param lightIndex Index of the light in the enabled light list of the material
  10357. */
  10358. prepareDefines(defines: any, lightIndex: number): void;
  10359. /**
  10360. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  10361. * defined in the generator but impacting the effect).
  10362. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  10363. * @param effect The effect we are binfing the information for
  10364. */
  10365. bindShadowLight(lightIndex: string, effect: Effect): void;
  10366. /**
  10367. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  10368. * (eq to shadow prjection matrix * light transform matrix)
  10369. * @returns The transform matrix used to create the shadow map
  10370. */
  10371. getTransformMatrix(): Matrix;
  10372. /**
  10373. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  10374. * Cube and 2D textures for instance.
  10375. */
  10376. recreateShadowMap(): void;
  10377. private _disposeBlurPostProcesses;
  10378. private _disposeRTTandPostProcesses;
  10379. /**
  10380. * Disposes the ShadowGenerator.
  10381. * Returns nothing.
  10382. */
  10383. dispose(): void;
  10384. /**
  10385. * Serializes the shadow generator setup to a json object.
  10386. * @returns The serialized JSON object
  10387. */
  10388. serialize(): any;
  10389. /**
  10390. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  10391. * @param parsedShadowGenerator The JSON object to parse
  10392. * @param scene The scene to create the shadow map for
  10393. * @returns The parsed shadow generator
  10394. */
  10395. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  10396. }
  10397. }
  10398. declare module "babylonjs/Lights/light" {
  10399. import { Nullable } from "babylonjs/types";
  10400. import { Scene } from "babylonjs/scene";
  10401. import { Vector3, Color3 } from "babylonjs/Maths/math";
  10402. import { Node } from "babylonjs/node";
  10403. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10404. import { Effect } from "babylonjs/Materials/effect";
  10405. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  10406. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  10407. /**
  10408. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  10409. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  10410. * 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.
  10411. */
  10412. export abstract class Light extends Node {
  10413. /**
  10414. * Falloff Default: light is falling off following the material specification:
  10415. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  10416. */
  10417. static readonly FALLOFF_DEFAULT: number;
  10418. /**
  10419. * Falloff Physical: light is falling off following the inverse squared distance law.
  10420. */
  10421. static readonly FALLOFF_PHYSICAL: number;
  10422. /**
  10423. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  10424. * to enhance interoperability with other engines.
  10425. */
  10426. static readonly FALLOFF_GLTF: number;
  10427. /**
  10428. * Falloff Standard: light is falling off like in the standard material
  10429. * to enhance interoperability with other materials.
  10430. */
  10431. static readonly FALLOFF_STANDARD: number;
  10432. /**
  10433. * If every light affecting the material is in this lightmapMode,
  10434. * material.lightmapTexture adds or multiplies
  10435. * (depends on material.useLightmapAsShadowmap)
  10436. * after every other light calculations.
  10437. */
  10438. static readonly LIGHTMAP_DEFAULT: number;
  10439. /**
  10440. * material.lightmapTexture as only diffuse lighting from this light
  10441. * adds only specular lighting from this light
  10442. * adds dynamic shadows
  10443. */
  10444. static readonly LIGHTMAP_SPECULAR: number;
  10445. /**
  10446. * material.lightmapTexture as only lighting
  10447. * no light calculation from this light
  10448. * only adds dynamic shadows from this light
  10449. */
  10450. static readonly LIGHTMAP_SHADOWSONLY: number;
  10451. /**
  10452. * Each light type uses the default quantity according to its type:
  10453. * point/spot lights use luminous intensity
  10454. * directional lights use illuminance
  10455. */
  10456. static readonly INTENSITYMODE_AUTOMATIC: number;
  10457. /**
  10458. * lumen (lm)
  10459. */
  10460. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  10461. /**
  10462. * candela (lm/sr)
  10463. */
  10464. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  10465. /**
  10466. * lux (lm/m^2)
  10467. */
  10468. static readonly INTENSITYMODE_ILLUMINANCE: number;
  10469. /**
  10470. * nit (cd/m^2)
  10471. */
  10472. static readonly INTENSITYMODE_LUMINANCE: number;
  10473. /**
  10474. * Light type const id of the point light.
  10475. */
  10476. static readonly LIGHTTYPEID_POINTLIGHT: number;
  10477. /**
  10478. * Light type const id of the directional light.
  10479. */
  10480. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  10481. /**
  10482. * Light type const id of the spot light.
  10483. */
  10484. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  10485. /**
  10486. * Light type const id of the hemispheric light.
  10487. */
  10488. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  10489. /**
  10490. * Diffuse gives the basic color to an object.
  10491. */
  10492. diffuse: Color3;
  10493. /**
  10494. * Specular produces a highlight color on an object.
  10495. * Note: This is note affecting PBR materials.
  10496. */
  10497. specular: Color3;
  10498. /**
  10499. * Defines the falloff type for this light. This lets overrriding how punctual light are
  10500. * falling off base on range or angle.
  10501. * This can be set to any values in Light.FALLOFF_x.
  10502. *
  10503. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  10504. * other types of materials.
  10505. */
  10506. falloffType: number;
  10507. /**
  10508. * Strength of the light.
  10509. * Note: By default it is define in the framework own unit.
  10510. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  10511. */
  10512. intensity: number;
  10513. private _range;
  10514. protected _inverseSquaredRange: number;
  10515. /**
  10516. * Defines how far from the source the light is impacting in scene units.
  10517. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10518. */
  10519. /**
  10520. * Defines how far from the source the light is impacting in scene units.
  10521. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10522. */
  10523. range: number;
  10524. /**
  10525. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  10526. * of light.
  10527. */
  10528. private _photometricScale;
  10529. private _intensityMode;
  10530. /**
  10531. * Gets the photometric scale used to interpret the intensity.
  10532. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10533. */
  10534. /**
  10535. * Sets the photometric scale used to interpret the intensity.
  10536. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10537. */
  10538. intensityMode: number;
  10539. private _radius;
  10540. /**
  10541. * Gets the light radius used by PBR Materials to simulate soft area lights.
  10542. */
  10543. /**
  10544. * sets the light radius used by PBR Materials to simulate soft area lights.
  10545. */
  10546. radius: number;
  10547. private _renderPriority;
  10548. /**
  10549. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  10550. * exceeding the number allowed of the materials.
  10551. */
  10552. renderPriority: number;
  10553. private _shadowEnabled;
  10554. /**
  10555. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10556. * the current shadow generator.
  10557. */
  10558. /**
  10559. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10560. * the current shadow generator.
  10561. */
  10562. shadowEnabled: boolean;
  10563. private _includedOnlyMeshes;
  10564. /**
  10565. * Gets the only meshes impacted by this light.
  10566. */
  10567. /**
  10568. * Sets the only meshes impacted by this light.
  10569. */
  10570. includedOnlyMeshes: AbstractMesh[];
  10571. private _excludedMeshes;
  10572. /**
  10573. * Gets the meshes not impacted by this light.
  10574. */
  10575. /**
  10576. * Sets the meshes not impacted by this light.
  10577. */
  10578. excludedMeshes: AbstractMesh[];
  10579. private _excludeWithLayerMask;
  10580. /**
  10581. * Gets the layer id use to find what meshes are not impacted by the light.
  10582. * Inactive if 0
  10583. */
  10584. /**
  10585. * Sets the layer id use to find what meshes are not impacted by the light.
  10586. * Inactive if 0
  10587. */
  10588. excludeWithLayerMask: number;
  10589. private _includeOnlyWithLayerMask;
  10590. /**
  10591. * Gets the layer id use to find what meshes are impacted by the light.
  10592. * Inactive if 0
  10593. */
  10594. /**
  10595. * Sets the layer id use to find what meshes are impacted by the light.
  10596. * Inactive if 0
  10597. */
  10598. includeOnlyWithLayerMask: number;
  10599. private _lightmapMode;
  10600. /**
  10601. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10602. */
  10603. /**
  10604. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10605. */
  10606. lightmapMode: number;
  10607. /**
  10608. * Shadow generator associted to the light.
  10609. * @hidden Internal use only.
  10610. */
  10611. _shadowGenerator: Nullable<IShadowGenerator>;
  10612. /**
  10613. * @hidden Internal use only.
  10614. */
  10615. _excludedMeshesIds: string[];
  10616. /**
  10617. * @hidden Internal use only.
  10618. */
  10619. _includedOnlyMeshesIds: string[];
  10620. /**
  10621. * The current light unifom buffer.
  10622. * @hidden Internal use only.
  10623. */
  10624. _uniformBuffer: UniformBuffer;
  10625. /**
  10626. * Creates a Light object in the scene.
  10627. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10628. * @param name The firendly name of the light
  10629. * @param scene The scene the light belongs too
  10630. */
  10631. constructor(name: string, scene: Scene);
  10632. protected abstract _buildUniformLayout(): void;
  10633. /**
  10634. * Sets the passed Effect "effect" with the Light information.
  10635. * @param effect The effect to update
  10636. * @param lightIndex The index of the light in the effect to update
  10637. * @returns The light
  10638. */
  10639. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10640. /**
  10641. * Returns the string "Light".
  10642. * @returns the class name
  10643. */
  10644. getClassName(): string;
  10645. /** @hidden */
  10646. readonly _isLight: boolean;
  10647. /**
  10648. * Converts the light information to a readable string for debug purpose.
  10649. * @param fullDetails Supports for multiple levels of logging within scene loading
  10650. * @returns the human readable light info
  10651. */
  10652. toString(fullDetails?: boolean): string;
  10653. /** @hidden */
  10654. protected _syncParentEnabledState(): void;
  10655. /**
  10656. * Set the enabled state of this node.
  10657. * @param value - the new enabled state
  10658. */
  10659. setEnabled(value: boolean): void;
  10660. /**
  10661. * Returns the Light associated shadow generator if any.
  10662. * @return the associated shadow generator.
  10663. */
  10664. getShadowGenerator(): Nullable<IShadowGenerator>;
  10665. /**
  10666. * Returns a Vector3, the absolute light position in the World.
  10667. * @returns the world space position of the light
  10668. */
  10669. getAbsolutePosition(): Vector3;
  10670. /**
  10671. * Specifies if the light will affect the passed mesh.
  10672. * @param mesh The mesh to test against the light
  10673. * @return true the mesh is affected otherwise, false.
  10674. */
  10675. canAffectMesh(mesh: AbstractMesh): boolean;
  10676. /**
  10677. * Sort function to order lights for rendering.
  10678. * @param a First Light object to compare to second.
  10679. * @param b Second Light object to compare first.
  10680. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10681. */
  10682. static CompareLightsPriority(a: Light, b: Light): number;
  10683. /**
  10684. * Releases resources associated with this node.
  10685. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10686. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10687. */
  10688. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10689. /**
  10690. * Returns the light type ID (integer).
  10691. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10692. */
  10693. getTypeID(): number;
  10694. /**
  10695. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10696. * @returns the scaled intensity in intensity mode unit
  10697. */
  10698. getScaledIntensity(): number;
  10699. /**
  10700. * Returns a new Light object, named "name", from the current one.
  10701. * @param name The name of the cloned light
  10702. * @returns the new created light
  10703. */
  10704. clone(name: string): Nullable<Light>;
  10705. /**
  10706. * Serializes the current light into a Serialization object.
  10707. * @returns the serialized object.
  10708. */
  10709. serialize(): any;
  10710. /**
  10711. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10712. * This new light is named "name" and added to the passed scene.
  10713. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10714. * @param name The friendly name of the light
  10715. * @param scene The scene the new light will belong to
  10716. * @returns the constructor function
  10717. */
  10718. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10719. /**
  10720. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10721. * @param parsedLight The JSON representation of the light
  10722. * @param scene The scene to create the parsed light in
  10723. * @returns the created light after parsing
  10724. */
  10725. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10726. private _hookArrayForExcluded;
  10727. private _hookArrayForIncludedOnly;
  10728. private _resyncMeshes;
  10729. /**
  10730. * Forces the meshes to update their light related information in their rendering used effects
  10731. * @hidden Internal Use Only
  10732. */
  10733. _markMeshesAsLightDirty(): void;
  10734. /**
  10735. * Recomputes the cached photometric scale if needed.
  10736. */
  10737. private _computePhotometricScale;
  10738. /**
  10739. * Returns the Photometric Scale according to the light type and intensity mode.
  10740. */
  10741. private _getPhotometricScale;
  10742. /**
  10743. * Reorder the light in the scene according to their defined priority.
  10744. * @hidden Internal Use Only
  10745. */
  10746. _reorderLightsInScene(): void;
  10747. /**
  10748. * Prepares the list of defines specific to the light type.
  10749. * @param defines the list of defines
  10750. * @param lightIndex defines the index of the light for the effect
  10751. */
  10752. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10753. }
  10754. }
  10755. declare module "babylonjs/Actions/action" {
  10756. import { Observable } from "babylonjs/Misc/observable";
  10757. import { Condition } from "babylonjs/Actions/condition";
  10758. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10759. import { ActionManager } from "babylonjs/Actions/actionManager";
  10760. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10761. /**
  10762. * Interface used to define Action
  10763. */
  10764. export interface IAction {
  10765. /**
  10766. * Trigger for the action
  10767. */
  10768. trigger: number;
  10769. /** Options of the trigger */
  10770. triggerOptions: any;
  10771. /**
  10772. * Gets the trigger parameters
  10773. * @returns the trigger parameters
  10774. */
  10775. getTriggerParameter(): any;
  10776. /**
  10777. * Internal only - executes current action event
  10778. * @hidden
  10779. */
  10780. _executeCurrent(evt?: ActionEvent): void;
  10781. /**
  10782. * Serialize placeholder for child classes
  10783. * @param parent of child
  10784. * @returns the serialized object
  10785. */
  10786. serialize(parent: any): any;
  10787. /**
  10788. * Internal only
  10789. * @hidden
  10790. */
  10791. _prepare(): void;
  10792. /**
  10793. * Internal only - manager for action
  10794. * @hidden
  10795. */
  10796. _actionManager: AbstractActionManager;
  10797. /**
  10798. * Adds action to chain of actions, may be a DoNothingAction
  10799. * @param action defines the next action to execute
  10800. * @returns The action passed in
  10801. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10802. */
  10803. then(action: IAction): IAction;
  10804. }
  10805. /**
  10806. * The action to be carried out following a trigger
  10807. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10808. */
  10809. export class Action implements IAction {
  10810. /** the trigger, with or without parameters, for the action */
  10811. triggerOptions: any;
  10812. /**
  10813. * Trigger for the action
  10814. */
  10815. trigger: number;
  10816. /**
  10817. * Internal only - manager for action
  10818. * @hidden
  10819. */
  10820. _actionManager: ActionManager;
  10821. private _nextActiveAction;
  10822. private _child;
  10823. private _condition?;
  10824. private _triggerParameter;
  10825. /**
  10826. * An event triggered prior to action being executed.
  10827. */
  10828. onBeforeExecuteObservable: Observable<Action>;
  10829. /**
  10830. * Creates a new Action
  10831. * @param triggerOptions the trigger, with or without parameters, for the action
  10832. * @param condition an optional determinant of action
  10833. */
  10834. constructor(
  10835. /** the trigger, with or without parameters, for the action */
  10836. triggerOptions: any, condition?: Condition);
  10837. /**
  10838. * Internal only
  10839. * @hidden
  10840. */
  10841. _prepare(): void;
  10842. /**
  10843. * Gets the trigger parameters
  10844. * @returns the trigger parameters
  10845. */
  10846. getTriggerParameter(): any;
  10847. /**
  10848. * Internal only - executes current action event
  10849. * @hidden
  10850. */
  10851. _executeCurrent(evt?: ActionEvent): void;
  10852. /**
  10853. * Execute placeholder for child classes
  10854. * @param evt optional action event
  10855. */
  10856. execute(evt?: ActionEvent): void;
  10857. /**
  10858. * Skips to next active action
  10859. */
  10860. skipToNextActiveAction(): void;
  10861. /**
  10862. * Adds action to chain of actions, may be a DoNothingAction
  10863. * @param action defines the next action to execute
  10864. * @returns The action passed in
  10865. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10866. */
  10867. then(action: Action): Action;
  10868. /**
  10869. * Internal only
  10870. * @hidden
  10871. */
  10872. _getProperty(propertyPath: string): string;
  10873. /**
  10874. * Internal only
  10875. * @hidden
  10876. */
  10877. _getEffectiveTarget(target: any, propertyPath: string): any;
  10878. /**
  10879. * Serialize placeholder for child classes
  10880. * @param parent of child
  10881. * @returns the serialized object
  10882. */
  10883. serialize(parent: any): any;
  10884. /**
  10885. * Internal only called by serialize
  10886. * @hidden
  10887. */
  10888. protected _serialize(serializedAction: any, parent?: any): any;
  10889. /**
  10890. * Internal only
  10891. * @hidden
  10892. */
  10893. static _SerializeValueAsString: (value: any) => string;
  10894. /**
  10895. * Internal only
  10896. * @hidden
  10897. */
  10898. static _GetTargetProperty: (target: import("babylonjs/scene").Scene | import("babylonjs/node").Node) => {
  10899. name: string;
  10900. targetType: string;
  10901. value: string;
  10902. };
  10903. }
  10904. }
  10905. declare module "babylonjs/Actions/condition" {
  10906. import { ActionManager } from "babylonjs/Actions/actionManager";
  10907. /**
  10908. * A Condition applied to an Action
  10909. */
  10910. export class Condition {
  10911. /**
  10912. * Internal only - manager for action
  10913. * @hidden
  10914. */
  10915. _actionManager: ActionManager;
  10916. /**
  10917. * Internal only
  10918. * @hidden
  10919. */
  10920. _evaluationId: number;
  10921. /**
  10922. * Internal only
  10923. * @hidden
  10924. */
  10925. _currentResult: boolean;
  10926. /**
  10927. * Creates a new Condition
  10928. * @param actionManager the manager of the action the condition is applied to
  10929. */
  10930. constructor(actionManager: ActionManager);
  10931. /**
  10932. * Check if the current condition is valid
  10933. * @returns a boolean
  10934. */
  10935. isValid(): boolean;
  10936. /**
  10937. * Internal only
  10938. * @hidden
  10939. */
  10940. _getProperty(propertyPath: string): string;
  10941. /**
  10942. * Internal only
  10943. * @hidden
  10944. */
  10945. _getEffectiveTarget(target: any, propertyPath: string): any;
  10946. /**
  10947. * Serialize placeholder for child classes
  10948. * @returns the serialized object
  10949. */
  10950. serialize(): any;
  10951. /**
  10952. * Internal only
  10953. * @hidden
  10954. */
  10955. protected _serialize(serializedCondition: any): any;
  10956. }
  10957. /**
  10958. * Defines specific conditional operators as extensions of Condition
  10959. */
  10960. export class ValueCondition extends Condition {
  10961. /** path to specify the property of the target the conditional operator uses */
  10962. propertyPath: string;
  10963. /** the value compared by the conditional operator against the current value of the property */
  10964. value: any;
  10965. /** the conditional operator, default ValueCondition.IsEqual */
  10966. operator: number;
  10967. /**
  10968. * Internal only
  10969. * @hidden
  10970. */
  10971. private static _IsEqual;
  10972. /**
  10973. * Internal only
  10974. * @hidden
  10975. */
  10976. private static _IsDifferent;
  10977. /**
  10978. * Internal only
  10979. * @hidden
  10980. */
  10981. private static _IsGreater;
  10982. /**
  10983. * Internal only
  10984. * @hidden
  10985. */
  10986. private static _IsLesser;
  10987. /**
  10988. * returns the number for IsEqual
  10989. */
  10990. static readonly IsEqual: number;
  10991. /**
  10992. * Returns the number for IsDifferent
  10993. */
  10994. static readonly IsDifferent: number;
  10995. /**
  10996. * Returns the number for IsGreater
  10997. */
  10998. static readonly IsGreater: number;
  10999. /**
  11000. * Returns the number for IsLesser
  11001. */
  11002. static readonly IsLesser: number;
  11003. /**
  11004. * Internal only The action manager for the condition
  11005. * @hidden
  11006. */
  11007. _actionManager: ActionManager;
  11008. /**
  11009. * Internal only
  11010. * @hidden
  11011. */
  11012. private _target;
  11013. /**
  11014. * Internal only
  11015. * @hidden
  11016. */
  11017. private _effectiveTarget;
  11018. /**
  11019. * Internal only
  11020. * @hidden
  11021. */
  11022. private _property;
  11023. /**
  11024. * Creates a new ValueCondition
  11025. * @param actionManager manager for the action the condition applies to
  11026. * @param target for the action
  11027. * @param propertyPath path to specify the property of the target the conditional operator uses
  11028. * @param value the value compared by the conditional operator against the current value of the property
  11029. * @param operator the conditional operator, default ValueCondition.IsEqual
  11030. */
  11031. constructor(actionManager: ActionManager, target: any,
  11032. /** path to specify the property of the target the conditional operator uses */
  11033. propertyPath: string,
  11034. /** the value compared by the conditional operator against the current value of the property */
  11035. value: any,
  11036. /** the conditional operator, default ValueCondition.IsEqual */
  11037. operator?: number);
  11038. /**
  11039. * Compares the given value with the property value for the specified conditional operator
  11040. * @returns the result of the comparison
  11041. */
  11042. isValid(): boolean;
  11043. /**
  11044. * Serialize the ValueCondition into a JSON compatible object
  11045. * @returns serialization object
  11046. */
  11047. serialize(): any;
  11048. /**
  11049. * Gets the name of the conditional operator for the ValueCondition
  11050. * @param operator the conditional operator
  11051. * @returns the name
  11052. */
  11053. static GetOperatorName(operator: number): string;
  11054. }
  11055. /**
  11056. * Defines a predicate condition as an extension of Condition
  11057. */
  11058. export class PredicateCondition extends Condition {
  11059. /** defines the predicate function used to validate the condition */
  11060. predicate: () => boolean;
  11061. /**
  11062. * Internal only - manager for action
  11063. * @hidden
  11064. */
  11065. _actionManager: ActionManager;
  11066. /**
  11067. * Creates a new PredicateCondition
  11068. * @param actionManager manager for the action the condition applies to
  11069. * @param predicate defines the predicate function used to validate the condition
  11070. */
  11071. constructor(actionManager: ActionManager,
  11072. /** defines the predicate function used to validate the condition */
  11073. predicate: () => boolean);
  11074. /**
  11075. * @returns the validity of the predicate condition
  11076. */
  11077. isValid(): boolean;
  11078. }
  11079. /**
  11080. * Defines a state condition as an extension of Condition
  11081. */
  11082. export class StateCondition extends Condition {
  11083. /** Value to compare with target state */
  11084. value: string;
  11085. /**
  11086. * Internal only - manager for action
  11087. * @hidden
  11088. */
  11089. _actionManager: ActionManager;
  11090. /**
  11091. * Internal only
  11092. * @hidden
  11093. */
  11094. private _target;
  11095. /**
  11096. * Creates a new StateCondition
  11097. * @param actionManager manager for the action the condition applies to
  11098. * @param target of the condition
  11099. * @param value to compare with target state
  11100. */
  11101. constructor(actionManager: ActionManager, target: any,
  11102. /** Value to compare with target state */
  11103. value: string);
  11104. /**
  11105. * Gets a boolean indicating if the current condition is met
  11106. * @returns the validity of the state
  11107. */
  11108. isValid(): boolean;
  11109. /**
  11110. * Serialize the StateCondition into a JSON compatible object
  11111. * @returns serialization object
  11112. */
  11113. serialize(): any;
  11114. }
  11115. }
  11116. declare module "babylonjs/Actions/directActions" {
  11117. import { Action } from "babylonjs/Actions/action";
  11118. import { Condition } from "babylonjs/Actions/condition";
  11119. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  11120. /**
  11121. * This defines an action responsible to toggle a boolean once triggered.
  11122. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11123. */
  11124. export class SwitchBooleanAction extends Action {
  11125. /**
  11126. * The path to the boolean property in the target object
  11127. */
  11128. propertyPath: string;
  11129. private _target;
  11130. private _effectiveTarget;
  11131. private _property;
  11132. /**
  11133. * Instantiate the action
  11134. * @param triggerOptions defines the trigger options
  11135. * @param target defines the object containing the boolean
  11136. * @param propertyPath defines the path to the boolean property in the target object
  11137. * @param condition defines the trigger related conditions
  11138. */
  11139. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  11140. /** @hidden */
  11141. _prepare(): void;
  11142. /**
  11143. * Execute the action toggle the boolean value.
  11144. */
  11145. execute(): void;
  11146. /**
  11147. * Serializes the actions and its related information.
  11148. * @param parent defines the object to serialize in
  11149. * @returns the serialized object
  11150. */
  11151. serialize(parent: any): any;
  11152. }
  11153. /**
  11154. * This defines an action responsible to set a the state field of the target
  11155. * to a desired value once triggered.
  11156. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11157. */
  11158. export class SetStateAction extends Action {
  11159. /**
  11160. * The value to store in the state field.
  11161. */
  11162. value: string;
  11163. private _target;
  11164. /**
  11165. * Instantiate the action
  11166. * @param triggerOptions defines the trigger options
  11167. * @param target defines the object containing the state property
  11168. * @param value defines the value to store in the state field
  11169. * @param condition defines the trigger related conditions
  11170. */
  11171. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  11172. /**
  11173. * Execute the action and store the value on the target state property.
  11174. */
  11175. execute(): void;
  11176. /**
  11177. * Serializes the actions and its related information.
  11178. * @param parent defines the object to serialize in
  11179. * @returns the serialized object
  11180. */
  11181. serialize(parent: any): any;
  11182. }
  11183. /**
  11184. * This defines an action responsible to set a property of the target
  11185. * to a desired value once triggered.
  11186. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11187. */
  11188. export class SetValueAction extends Action {
  11189. /**
  11190. * The path of the property to set in the target.
  11191. */
  11192. propertyPath: string;
  11193. /**
  11194. * The value to set in the property
  11195. */
  11196. value: any;
  11197. private _target;
  11198. private _effectiveTarget;
  11199. private _property;
  11200. /**
  11201. * Instantiate the action
  11202. * @param triggerOptions defines the trigger options
  11203. * @param target defines the object containing the property
  11204. * @param propertyPath defines the path of the property to set in the target
  11205. * @param value defines the value to set in the property
  11206. * @param condition defines the trigger related conditions
  11207. */
  11208. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  11209. /** @hidden */
  11210. _prepare(): void;
  11211. /**
  11212. * Execute the action and set the targetted property to the desired value.
  11213. */
  11214. execute(): void;
  11215. /**
  11216. * Serializes the actions and its related information.
  11217. * @param parent defines the object to serialize in
  11218. * @returns the serialized object
  11219. */
  11220. serialize(parent: any): any;
  11221. }
  11222. /**
  11223. * This defines an action responsible to increment the target value
  11224. * to a desired value once triggered.
  11225. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11226. */
  11227. export class IncrementValueAction extends Action {
  11228. /**
  11229. * The path of the property to increment in the target.
  11230. */
  11231. propertyPath: string;
  11232. /**
  11233. * The value we should increment the property by.
  11234. */
  11235. value: any;
  11236. private _target;
  11237. private _effectiveTarget;
  11238. private _property;
  11239. /**
  11240. * Instantiate the action
  11241. * @param triggerOptions defines the trigger options
  11242. * @param target defines the object containing the property
  11243. * @param propertyPath defines the path of the property to increment in the target
  11244. * @param value defines the value value we should increment the property by
  11245. * @param condition defines the trigger related conditions
  11246. */
  11247. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  11248. /** @hidden */
  11249. _prepare(): void;
  11250. /**
  11251. * Execute the action and increment the target of the value amount.
  11252. */
  11253. execute(): void;
  11254. /**
  11255. * Serializes the actions and its related information.
  11256. * @param parent defines the object to serialize in
  11257. * @returns the serialized object
  11258. */
  11259. serialize(parent: any): any;
  11260. }
  11261. /**
  11262. * This defines an action responsible to start an animation once triggered.
  11263. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11264. */
  11265. export class PlayAnimationAction extends Action {
  11266. /**
  11267. * Where the animation should start (animation frame)
  11268. */
  11269. from: number;
  11270. /**
  11271. * Where the animation should stop (animation frame)
  11272. */
  11273. to: number;
  11274. /**
  11275. * Define if the animation should loop or stop after the first play.
  11276. */
  11277. loop?: boolean;
  11278. private _target;
  11279. /**
  11280. * Instantiate the action
  11281. * @param triggerOptions defines the trigger options
  11282. * @param target defines the target animation or animation name
  11283. * @param from defines from where the animation should start (animation frame)
  11284. * @param end defines where the animation should stop (animation frame)
  11285. * @param loop defines if the animation should loop or stop after the first play
  11286. * @param condition defines the trigger related conditions
  11287. */
  11288. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  11289. /** @hidden */
  11290. _prepare(): void;
  11291. /**
  11292. * Execute the action and play the animation.
  11293. */
  11294. execute(): void;
  11295. /**
  11296. * Serializes the actions and its related information.
  11297. * @param parent defines the object to serialize in
  11298. * @returns the serialized object
  11299. */
  11300. serialize(parent: any): any;
  11301. }
  11302. /**
  11303. * This defines an action responsible to stop an animation once triggered.
  11304. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11305. */
  11306. export class StopAnimationAction extends Action {
  11307. private _target;
  11308. /**
  11309. * Instantiate the action
  11310. * @param triggerOptions defines the trigger options
  11311. * @param target defines the target animation or animation name
  11312. * @param condition defines the trigger related conditions
  11313. */
  11314. constructor(triggerOptions: any, target: any, condition?: Condition);
  11315. /** @hidden */
  11316. _prepare(): void;
  11317. /**
  11318. * Execute the action and stop the animation.
  11319. */
  11320. execute(): void;
  11321. /**
  11322. * Serializes the actions and its related information.
  11323. * @param parent defines the object to serialize in
  11324. * @returns the serialized object
  11325. */
  11326. serialize(parent: any): any;
  11327. }
  11328. /**
  11329. * This defines an action responsible that does nothing once triggered.
  11330. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11331. */
  11332. export class DoNothingAction extends Action {
  11333. /**
  11334. * Instantiate the action
  11335. * @param triggerOptions defines the trigger options
  11336. * @param condition defines the trigger related conditions
  11337. */
  11338. constructor(triggerOptions?: any, condition?: Condition);
  11339. /**
  11340. * Execute the action and do nothing.
  11341. */
  11342. execute(): void;
  11343. /**
  11344. * Serializes the actions and its related information.
  11345. * @param parent defines the object to serialize in
  11346. * @returns the serialized object
  11347. */
  11348. serialize(parent: any): any;
  11349. }
  11350. /**
  11351. * This defines an action responsible to trigger several actions once triggered.
  11352. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11353. */
  11354. export class CombineAction extends Action {
  11355. /**
  11356. * The list of aggregated animations to run.
  11357. */
  11358. children: Action[];
  11359. /**
  11360. * Instantiate the action
  11361. * @param triggerOptions defines the trigger options
  11362. * @param children defines the list of aggregated animations to run
  11363. * @param condition defines the trigger related conditions
  11364. */
  11365. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  11366. /** @hidden */
  11367. _prepare(): void;
  11368. /**
  11369. * Execute the action and executes all the aggregated actions.
  11370. */
  11371. execute(evt: ActionEvent): void;
  11372. /**
  11373. * Serializes the actions and its related information.
  11374. * @param parent defines the object to serialize in
  11375. * @returns the serialized object
  11376. */
  11377. serialize(parent: any): any;
  11378. }
  11379. /**
  11380. * This defines an action responsible to run code (external event) once triggered.
  11381. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11382. */
  11383. export class ExecuteCodeAction extends Action {
  11384. /**
  11385. * The callback function to run.
  11386. */
  11387. func: (evt: ActionEvent) => void;
  11388. /**
  11389. * Instantiate the action
  11390. * @param triggerOptions defines the trigger options
  11391. * @param func defines the callback function to run
  11392. * @param condition defines the trigger related conditions
  11393. */
  11394. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  11395. /**
  11396. * Execute the action and run the attached code.
  11397. */
  11398. execute(evt: ActionEvent): void;
  11399. }
  11400. /**
  11401. * This defines an action responsible to set the parent property of the target once triggered.
  11402. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11403. */
  11404. export class SetParentAction extends Action {
  11405. private _parent;
  11406. private _target;
  11407. /**
  11408. * Instantiate the action
  11409. * @param triggerOptions defines the trigger options
  11410. * @param target defines the target containing the parent property
  11411. * @param parent defines from where the animation should start (animation frame)
  11412. * @param condition defines the trigger related conditions
  11413. */
  11414. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  11415. /** @hidden */
  11416. _prepare(): void;
  11417. /**
  11418. * Execute the action and set the parent property.
  11419. */
  11420. execute(): void;
  11421. /**
  11422. * Serializes the actions and its related information.
  11423. * @param parent defines the object to serialize in
  11424. * @returns the serialized object
  11425. */
  11426. serialize(parent: any): any;
  11427. }
  11428. }
  11429. declare module "babylonjs/Actions/actionManager" {
  11430. import { Nullable } from "babylonjs/types";
  11431. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11432. import { Scene } from "babylonjs/scene";
  11433. import { IAction } from "babylonjs/Actions/action";
  11434. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  11435. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  11436. /**
  11437. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  11438. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  11439. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11440. */
  11441. export class ActionManager extends AbstractActionManager {
  11442. /**
  11443. * Nothing
  11444. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11445. */
  11446. static readonly NothingTrigger: number;
  11447. /**
  11448. * On pick
  11449. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11450. */
  11451. static readonly OnPickTrigger: number;
  11452. /**
  11453. * On left pick
  11454. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11455. */
  11456. static readonly OnLeftPickTrigger: number;
  11457. /**
  11458. * On right pick
  11459. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11460. */
  11461. static readonly OnRightPickTrigger: number;
  11462. /**
  11463. * On center pick
  11464. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11465. */
  11466. static readonly OnCenterPickTrigger: number;
  11467. /**
  11468. * On pick down
  11469. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11470. */
  11471. static readonly OnPickDownTrigger: number;
  11472. /**
  11473. * On double pick
  11474. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11475. */
  11476. static readonly OnDoublePickTrigger: number;
  11477. /**
  11478. * On pick up
  11479. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11480. */
  11481. static readonly OnPickUpTrigger: number;
  11482. /**
  11483. * On pick out.
  11484. * This trigger will only be raised if you also declared a OnPickDown
  11485. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11486. */
  11487. static readonly OnPickOutTrigger: number;
  11488. /**
  11489. * On long press
  11490. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11491. */
  11492. static readonly OnLongPressTrigger: number;
  11493. /**
  11494. * On pointer over
  11495. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11496. */
  11497. static readonly OnPointerOverTrigger: number;
  11498. /**
  11499. * On pointer out
  11500. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11501. */
  11502. static readonly OnPointerOutTrigger: number;
  11503. /**
  11504. * On every frame
  11505. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11506. */
  11507. static readonly OnEveryFrameTrigger: number;
  11508. /**
  11509. * On intersection enter
  11510. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11511. */
  11512. static readonly OnIntersectionEnterTrigger: number;
  11513. /**
  11514. * On intersection exit
  11515. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11516. */
  11517. static readonly OnIntersectionExitTrigger: number;
  11518. /**
  11519. * On key down
  11520. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11521. */
  11522. static readonly OnKeyDownTrigger: number;
  11523. /**
  11524. * On key up
  11525. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11526. */
  11527. static readonly OnKeyUpTrigger: number;
  11528. private _scene;
  11529. /**
  11530. * Creates a new action manager
  11531. * @param scene defines the hosting scene
  11532. */
  11533. constructor(scene: Scene);
  11534. /**
  11535. * Releases all associated resources
  11536. */
  11537. dispose(): void;
  11538. /**
  11539. * Gets hosting scene
  11540. * @returns the hosting scene
  11541. */
  11542. getScene(): Scene;
  11543. /**
  11544. * Does this action manager handles actions of any of the given triggers
  11545. * @param triggers defines the triggers to be tested
  11546. * @return a boolean indicating whether one (or more) of the triggers is handled
  11547. */
  11548. hasSpecificTriggers(triggers: number[]): boolean;
  11549. /**
  11550. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  11551. * speed.
  11552. * @param triggerA defines the trigger to be tested
  11553. * @param triggerB defines the trigger to be tested
  11554. * @return a boolean indicating whether one (or more) of the triggers is handled
  11555. */
  11556. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  11557. /**
  11558. * Does this action manager handles actions of a given trigger
  11559. * @param trigger defines the trigger to be tested
  11560. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  11561. * @return whether the trigger is handled
  11562. */
  11563. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  11564. /**
  11565. * Does this action manager has pointer triggers
  11566. */
  11567. readonly hasPointerTriggers: boolean;
  11568. /**
  11569. * Does this action manager has pick triggers
  11570. */
  11571. readonly hasPickTriggers: boolean;
  11572. /**
  11573. * Registers an action to this action manager
  11574. * @param action defines the action to be registered
  11575. * @return the action amended (prepared) after registration
  11576. */
  11577. registerAction(action: IAction): Nullable<IAction>;
  11578. /**
  11579. * Unregisters an action to this action manager
  11580. * @param action defines the action to be unregistered
  11581. * @return a boolean indicating whether the action has been unregistered
  11582. */
  11583. unregisterAction(action: IAction): Boolean;
  11584. /**
  11585. * Process a specific trigger
  11586. * @param trigger defines the trigger to process
  11587. * @param evt defines the event details to be processed
  11588. */
  11589. processTrigger(trigger: number, evt?: IActionEvent): void;
  11590. /** @hidden */
  11591. _getEffectiveTarget(target: any, propertyPath: string): any;
  11592. /** @hidden */
  11593. _getProperty(propertyPath: string): string;
  11594. /**
  11595. * Serialize this manager to a JSON object
  11596. * @param name defines the property name to store this manager
  11597. * @returns a JSON representation of this manager
  11598. */
  11599. serialize(name: string): any;
  11600. /**
  11601. * Creates a new ActionManager from a JSON data
  11602. * @param parsedActions defines the JSON data to read from
  11603. * @param object defines the hosting mesh
  11604. * @param scene defines the hosting scene
  11605. */
  11606. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11607. /**
  11608. * Get a trigger name by index
  11609. * @param trigger defines the trigger index
  11610. * @returns a trigger name
  11611. */
  11612. static GetTriggerName(trigger: number): string;
  11613. }
  11614. }
  11615. declare module "babylonjs/Culling/ray" {
  11616. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  11617. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  11618. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11619. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11620. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  11621. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  11622. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  11623. /**
  11624. * Class representing a ray with position and direction
  11625. */
  11626. export class Ray {
  11627. /** origin point */
  11628. origin: Vector3;
  11629. /** direction */
  11630. direction: Vector3;
  11631. /** length of the ray */
  11632. length: number;
  11633. private static readonly TmpVector3;
  11634. private _tmpRay;
  11635. /**
  11636. * Creates a new ray
  11637. * @param origin origin point
  11638. * @param direction direction
  11639. * @param length length of the ray
  11640. */
  11641. constructor(
  11642. /** origin point */
  11643. origin: Vector3,
  11644. /** direction */
  11645. direction: Vector3,
  11646. /** length of the ray */
  11647. length?: number);
  11648. /**
  11649. * Checks if the ray intersects a box
  11650. * @param minimum bound of the box
  11651. * @param maximum bound of the box
  11652. * @param intersectionTreshold extra extend to be added to the box in all direction
  11653. * @returns if the box was hit
  11654. */
  11655. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11656. /**
  11657. * Checks if the ray intersects a box
  11658. * @param box the bounding box to check
  11659. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11660. * @returns if the box was hit
  11661. */
  11662. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11663. /**
  11664. * If the ray hits a sphere
  11665. * @param sphere the bounding sphere to check
  11666. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11667. * @returns true if it hits the sphere
  11668. */
  11669. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11670. /**
  11671. * If the ray hits a triange
  11672. * @param vertex0 triangle vertex
  11673. * @param vertex1 triangle vertex
  11674. * @param vertex2 triangle vertex
  11675. * @returns intersection information if hit
  11676. */
  11677. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11678. /**
  11679. * Checks if ray intersects a plane
  11680. * @param plane the plane to check
  11681. * @returns the distance away it was hit
  11682. */
  11683. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11684. /**
  11685. * Checks if ray intersects a mesh
  11686. * @param mesh the mesh to check
  11687. * @param fastCheck if only the bounding box should checked
  11688. * @returns picking info of the intersecton
  11689. */
  11690. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11691. /**
  11692. * Checks if ray intersects a mesh
  11693. * @param meshes the meshes to check
  11694. * @param fastCheck if only the bounding box should checked
  11695. * @param results array to store result in
  11696. * @returns Array of picking infos
  11697. */
  11698. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11699. private _comparePickingInfo;
  11700. private static smallnum;
  11701. private static rayl;
  11702. /**
  11703. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11704. * @param sega the first point of the segment to test the intersection against
  11705. * @param segb the second point of the segment to test the intersection against
  11706. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11707. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11708. */
  11709. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11710. /**
  11711. * Update the ray from viewport position
  11712. * @param x position
  11713. * @param y y position
  11714. * @param viewportWidth viewport width
  11715. * @param viewportHeight viewport height
  11716. * @param world world matrix
  11717. * @param view view matrix
  11718. * @param projection projection matrix
  11719. * @returns this ray updated
  11720. */
  11721. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11722. /**
  11723. * Creates a ray with origin and direction of 0,0,0
  11724. * @returns the new ray
  11725. */
  11726. static Zero(): Ray;
  11727. /**
  11728. * Creates a new ray from screen space and viewport
  11729. * @param x position
  11730. * @param y y position
  11731. * @param viewportWidth viewport width
  11732. * @param viewportHeight viewport height
  11733. * @param world world matrix
  11734. * @param view view matrix
  11735. * @param projection projection matrix
  11736. * @returns new ray
  11737. */
  11738. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11739. /**
  11740. * 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
  11741. * transformed to the given world matrix.
  11742. * @param origin The origin point
  11743. * @param end The end point
  11744. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11745. * @returns the new ray
  11746. */
  11747. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11748. /**
  11749. * Transforms a ray by a matrix
  11750. * @param ray ray to transform
  11751. * @param matrix matrix to apply
  11752. * @returns the resulting new ray
  11753. */
  11754. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11755. /**
  11756. * Transforms a ray by a matrix
  11757. * @param ray ray to transform
  11758. * @param matrix matrix to apply
  11759. * @param result ray to store result in
  11760. */
  11761. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11762. /**
  11763. * Unproject a ray from screen space to object space
  11764. * @param sourceX defines the screen space x coordinate to use
  11765. * @param sourceY defines the screen space y coordinate to use
  11766. * @param viewportWidth defines the current width of the viewport
  11767. * @param viewportHeight defines the current height of the viewport
  11768. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11769. * @param view defines the view matrix to use
  11770. * @param projection defines the projection matrix to use
  11771. */
  11772. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11773. }
  11774. /**
  11775. * Type used to define predicate used to select faces when a mesh intersection is detected
  11776. */
  11777. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11778. module "babylonjs/scene" {
  11779. interface Scene {
  11780. /** @hidden */
  11781. _tempPickingRay: Nullable<Ray>;
  11782. /** @hidden */
  11783. _cachedRayForTransform: Ray;
  11784. /** @hidden */
  11785. _pickWithRayInverseMatrix: Matrix;
  11786. /** @hidden */
  11787. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11788. /** @hidden */
  11789. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11790. }
  11791. }
  11792. }
  11793. declare module "babylonjs/sceneComponent" {
  11794. import { Scene } from "babylonjs/scene";
  11795. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11796. import { SubMesh } from "babylonjs/Meshes/subMesh";
  11797. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  11798. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  11799. import { Nullable } from "babylonjs/types";
  11800. import { Camera } from "babylonjs/Cameras/camera";
  11801. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  11802. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11803. import { AbstractScene } from "babylonjs/abstractScene";
  11804. /**
  11805. * Groups all the scene component constants in one place to ease maintenance.
  11806. * @hidden
  11807. */
  11808. export class SceneComponentConstants {
  11809. static readonly NAME_EFFECTLAYER: string;
  11810. static readonly NAME_LAYER: string;
  11811. static readonly NAME_LENSFLARESYSTEM: string;
  11812. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11813. static readonly NAME_PARTICLESYSTEM: string;
  11814. static readonly NAME_GAMEPAD: string;
  11815. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11816. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11817. static readonly NAME_DEPTHRENDERER: string;
  11818. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11819. static readonly NAME_SPRITE: string;
  11820. static readonly NAME_OUTLINERENDERER: string;
  11821. static readonly NAME_PROCEDURALTEXTURE: string;
  11822. static readonly NAME_SHADOWGENERATOR: string;
  11823. static readonly NAME_OCTREE: string;
  11824. static readonly NAME_PHYSICSENGINE: string;
  11825. static readonly NAME_AUDIO: string;
  11826. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11827. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11828. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11829. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11830. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11831. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11832. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11833. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11834. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11835. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11836. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11837. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11838. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11839. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11840. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11841. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11842. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11843. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11844. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11845. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11846. static readonly STEP_AFTERRENDER_AUDIO: number;
  11847. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11848. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11849. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11850. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11851. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11852. static readonly STEP_POINTERMOVE_SPRITE: number;
  11853. static readonly STEP_POINTERDOWN_SPRITE: number;
  11854. static readonly STEP_POINTERUP_SPRITE: number;
  11855. }
  11856. /**
  11857. * This represents a scene component.
  11858. *
  11859. * This is used to decouple the dependency the scene is having on the different workloads like
  11860. * layers, post processes...
  11861. */
  11862. export interface ISceneComponent {
  11863. /**
  11864. * The name of the component. Each component must have a unique name.
  11865. */
  11866. name: string;
  11867. /**
  11868. * The scene the component belongs to.
  11869. */
  11870. scene: Scene;
  11871. /**
  11872. * Register the component to one instance of a scene.
  11873. */
  11874. register(): void;
  11875. /**
  11876. * Rebuilds the elements related to this component in case of
  11877. * context lost for instance.
  11878. */
  11879. rebuild(): void;
  11880. /**
  11881. * Disposes the component and the associated ressources.
  11882. */
  11883. dispose(): void;
  11884. }
  11885. /**
  11886. * This represents a SERIALIZABLE scene component.
  11887. *
  11888. * This extends Scene Component to add Serialization methods on top.
  11889. */
  11890. export interface ISceneSerializableComponent extends ISceneComponent {
  11891. /**
  11892. * Adds all the elements from the container to the scene
  11893. * @param container the container holding the elements
  11894. */
  11895. addFromContainer(container: AbstractScene): void;
  11896. /**
  11897. * Removes all the elements in the container from the scene
  11898. * @param container contains the elements to remove
  11899. * @param dispose if the removed element should be disposed (default: false)
  11900. */
  11901. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11902. /**
  11903. * Serializes the component data to the specified json object
  11904. * @param serializationObject The object to serialize to
  11905. */
  11906. serialize(serializationObject: any): void;
  11907. }
  11908. /**
  11909. * Strong typing of a Mesh related stage step action
  11910. */
  11911. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11912. /**
  11913. * Strong typing of a Evaluate Sub Mesh related stage step action
  11914. */
  11915. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11916. /**
  11917. * Strong typing of a Active Mesh related stage step action
  11918. */
  11919. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11920. /**
  11921. * Strong typing of a Camera related stage step action
  11922. */
  11923. export type CameraStageAction = (camera: Camera) => void;
  11924. /**
  11925. * Strong typing of a Camera Frame buffer related stage step action
  11926. */
  11927. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11928. /**
  11929. * Strong typing of a Render Target related stage step action
  11930. */
  11931. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11932. /**
  11933. * Strong typing of a RenderingGroup related stage step action
  11934. */
  11935. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11936. /**
  11937. * Strong typing of a Mesh Render related stage step action
  11938. */
  11939. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11940. /**
  11941. * Strong typing of a simple stage step action
  11942. */
  11943. export type SimpleStageAction = () => void;
  11944. /**
  11945. * Strong typing of a render target action.
  11946. */
  11947. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11948. /**
  11949. * Strong typing of a pointer move action.
  11950. */
  11951. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11952. /**
  11953. * Strong typing of a pointer up/down action.
  11954. */
  11955. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11956. /**
  11957. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11958. * @hidden
  11959. */
  11960. export class Stage<T extends Function> extends Array<{
  11961. index: number;
  11962. component: ISceneComponent;
  11963. action: T;
  11964. }> {
  11965. /**
  11966. * Hide ctor from the rest of the world.
  11967. * @param items The items to add.
  11968. */
  11969. private constructor();
  11970. /**
  11971. * Creates a new Stage.
  11972. * @returns A new instance of a Stage
  11973. */
  11974. static Create<T extends Function>(): Stage<T>;
  11975. /**
  11976. * Registers a step in an ordered way in the targeted stage.
  11977. * @param index Defines the position to register the step in
  11978. * @param component Defines the component attached to the step
  11979. * @param action Defines the action to launch during the step
  11980. */
  11981. registerStep(index: number, component: ISceneComponent, action: T): void;
  11982. /**
  11983. * Clears all the steps from the stage.
  11984. */
  11985. clear(): void;
  11986. }
  11987. }
  11988. declare module "babylonjs/Sprites/spriteSceneComponent" {
  11989. import { Nullable } from "babylonjs/types";
  11990. import { Observable } from "babylonjs/Misc/observable";
  11991. import { Scene } from "babylonjs/scene";
  11992. import { Sprite } from "babylonjs/Sprites/sprite";
  11993. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11994. import { Ray } from "babylonjs/Culling/ray";
  11995. import { Camera } from "babylonjs/Cameras/camera";
  11996. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11997. import { ISceneComponent } from "babylonjs/sceneComponent";
  11998. module "babylonjs/scene" {
  11999. interface Scene {
  12000. /** @hidden */
  12001. _pointerOverSprite: Nullable<Sprite>;
  12002. /** @hidden */
  12003. _pickedDownSprite: Nullable<Sprite>;
  12004. /** @hidden */
  12005. _tempSpritePickingRay: Nullable<Ray>;
  12006. /**
  12007. * All of the sprite managers added to this scene
  12008. * @see http://doc.babylonjs.com/babylon101/sprites
  12009. */
  12010. spriteManagers: Array<ISpriteManager>;
  12011. /**
  12012. * An event triggered when sprites rendering is about to start
  12013. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  12014. */
  12015. onBeforeSpritesRenderingObservable: Observable<Scene>;
  12016. /**
  12017. * An event triggered when sprites rendering is done
  12018. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  12019. */
  12020. onAfterSpritesRenderingObservable: Observable<Scene>;
  12021. /** @hidden */
  12022. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  12023. /** Launch a ray to try to pick a sprite in the scene
  12024. * @param x position on screen
  12025. * @param y position on screen
  12026. * @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
  12027. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  12028. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  12029. * @returns a PickingInfo
  12030. */
  12031. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  12032. /** Use the given ray to pick a sprite in the scene
  12033. * @param ray The ray (in world space) to use to pick meshes
  12034. * @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
  12035. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  12036. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  12037. * @returns a PickingInfo
  12038. */
  12039. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  12040. /**
  12041. * Force the sprite under the pointer
  12042. * @param sprite defines the sprite to use
  12043. */
  12044. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  12045. /**
  12046. * Gets the sprite under the pointer
  12047. * @returns a Sprite or null if no sprite is under the pointer
  12048. */
  12049. getPointerOverSprite(): Nullable<Sprite>;
  12050. }
  12051. }
  12052. /**
  12053. * Defines the sprite scene component responsible to manage sprites
  12054. * in a given scene.
  12055. */
  12056. export class SpriteSceneComponent implements ISceneComponent {
  12057. /**
  12058. * The component name helpfull to identify the component in the list of scene components.
  12059. */
  12060. readonly name: string;
  12061. /**
  12062. * The scene the component belongs to.
  12063. */
  12064. scene: Scene;
  12065. /** @hidden */
  12066. private _spritePredicate;
  12067. /**
  12068. * Creates a new instance of the component for the given scene
  12069. * @param scene Defines the scene to register the component in
  12070. */
  12071. constructor(scene: Scene);
  12072. /**
  12073. * Registers the component in a given scene
  12074. */
  12075. register(): void;
  12076. /**
  12077. * Rebuilds the elements related to this component in case of
  12078. * context lost for instance.
  12079. */
  12080. rebuild(): void;
  12081. /**
  12082. * Disposes the component and the associated ressources.
  12083. */
  12084. dispose(): void;
  12085. private _pickSpriteButKeepRay;
  12086. private _pointerMove;
  12087. private _pointerDown;
  12088. private _pointerUp;
  12089. }
  12090. }
  12091. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  12092. /** @hidden */
  12093. export var fogFragmentDeclaration: {
  12094. name: string;
  12095. shader: string;
  12096. };
  12097. }
  12098. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  12099. /** @hidden */
  12100. export var fogFragment: {
  12101. name: string;
  12102. shader: string;
  12103. };
  12104. }
  12105. declare module "babylonjs/Shaders/sprites.fragment" {
  12106. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  12107. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  12108. /** @hidden */
  12109. export var spritesPixelShader: {
  12110. name: string;
  12111. shader: string;
  12112. };
  12113. }
  12114. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  12115. /** @hidden */
  12116. export var fogVertexDeclaration: {
  12117. name: string;
  12118. shader: string;
  12119. };
  12120. }
  12121. declare module "babylonjs/Shaders/sprites.vertex" {
  12122. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  12123. /** @hidden */
  12124. export var spritesVertexShader: {
  12125. name: string;
  12126. shader: string;
  12127. };
  12128. }
  12129. declare module "babylonjs/Sprites/spriteManager" {
  12130. import { IDisposable, Scene } from "babylonjs/scene";
  12131. import { Nullable } from "babylonjs/types";
  12132. import { Observable } from "babylonjs/Misc/observable";
  12133. import { Sprite } from "babylonjs/Sprites/sprite";
  12134. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  12135. import { Camera } from "babylonjs/Cameras/camera";
  12136. import { Texture } from "babylonjs/Materials/Textures/texture";
  12137. import "babylonjs/Shaders/sprites.fragment";
  12138. import "babylonjs/Shaders/sprites.vertex";
  12139. import { Ray } from "babylonjs/Culling/ray";
  12140. /**
  12141. * Defines the minimum interface to fullfil in order to be a sprite manager.
  12142. */
  12143. export interface ISpriteManager extends IDisposable {
  12144. /**
  12145. * Restricts the camera to viewing objects with the same layerMask.
  12146. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  12147. */
  12148. layerMask: number;
  12149. /**
  12150. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  12151. */
  12152. isPickable: boolean;
  12153. /**
  12154. * Specifies the rendering group id for this mesh (0 by default)
  12155. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  12156. */
  12157. renderingGroupId: number;
  12158. /**
  12159. * Defines the list of sprites managed by the manager.
  12160. */
  12161. sprites: Array<Sprite>;
  12162. /**
  12163. * Tests the intersection of a sprite with a specific ray.
  12164. * @param ray The ray we are sending to test the collision
  12165. * @param camera The camera space we are sending rays in
  12166. * @param predicate A predicate allowing excluding sprites from the list of object to test
  12167. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  12168. * @returns picking info or null.
  12169. */
  12170. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  12171. /**
  12172. * Renders the list of sprites on screen.
  12173. */
  12174. render(): void;
  12175. }
  12176. /**
  12177. * Class used to manage multiple sprites on the same spritesheet
  12178. * @see http://doc.babylonjs.com/babylon101/sprites
  12179. */
  12180. export class SpriteManager implements ISpriteManager {
  12181. /** defines the manager's name */
  12182. name: string;
  12183. /** Gets the list of sprites */
  12184. sprites: Sprite[];
  12185. /** Gets or sets the rendering group id (0 by default) */
  12186. renderingGroupId: number;
  12187. /** Gets or sets camera layer mask */
  12188. layerMask: number;
  12189. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  12190. fogEnabled: boolean;
  12191. /** Gets or sets a boolean indicating if the sprites are pickable */
  12192. isPickable: boolean;
  12193. /** Defines the default width of a cell in the spritesheet */
  12194. cellWidth: number;
  12195. /** Defines the default height of a cell in the spritesheet */
  12196. cellHeight: number;
  12197. /**
  12198. * An event triggered when the manager is disposed.
  12199. */
  12200. onDisposeObservable: Observable<SpriteManager>;
  12201. private _onDisposeObserver;
  12202. /**
  12203. * Callback called when the manager is disposed
  12204. */
  12205. onDispose: () => void;
  12206. private _capacity;
  12207. private _spriteTexture;
  12208. private _epsilon;
  12209. private _scene;
  12210. private _vertexData;
  12211. private _buffer;
  12212. private _vertexBuffers;
  12213. private _indexBuffer;
  12214. private _effectBase;
  12215. private _effectFog;
  12216. /**
  12217. * Gets or sets the spritesheet texture
  12218. */
  12219. texture: Texture;
  12220. /**
  12221. * Creates a new sprite manager
  12222. * @param name defines the manager's name
  12223. * @param imgUrl defines the sprite sheet url
  12224. * @param capacity defines the maximum allowed number of sprites
  12225. * @param cellSize defines the size of a sprite cell
  12226. * @param scene defines the hosting scene
  12227. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  12228. * @param samplingMode defines the smapling mode to use with spritesheet
  12229. */
  12230. constructor(
  12231. /** defines the manager's name */
  12232. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  12233. private _appendSpriteVertex;
  12234. /**
  12235. * Intersects the sprites with a ray
  12236. * @param ray defines the ray to intersect with
  12237. * @param camera defines the current active camera
  12238. * @param predicate defines a predicate used to select candidate sprites
  12239. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  12240. * @returns null if no hit or a PickingInfo
  12241. */
  12242. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  12243. /**
  12244. * Render all child sprites
  12245. */
  12246. render(): void;
  12247. /**
  12248. * Release associated resources
  12249. */
  12250. dispose(): void;
  12251. }
  12252. }
  12253. declare module "babylonjs/Sprites/sprite" {
  12254. import { Vector3, Color4 } from "babylonjs/Maths/math";
  12255. import { Nullable } from "babylonjs/types";
  12256. import { ActionManager } from "babylonjs/Actions/actionManager";
  12257. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  12258. /**
  12259. * Class used to represent a sprite
  12260. * @see http://doc.babylonjs.com/babylon101/sprites
  12261. */
  12262. export class Sprite {
  12263. /** defines the name */
  12264. name: string;
  12265. /** Gets or sets the current world position */
  12266. position: Vector3;
  12267. /** Gets or sets the main color */
  12268. color: Color4;
  12269. /** Gets or sets the width */
  12270. width: number;
  12271. /** Gets or sets the height */
  12272. height: number;
  12273. /** Gets or sets rotation angle */
  12274. angle: number;
  12275. /** Gets or sets the cell index in the sprite sheet */
  12276. cellIndex: number;
  12277. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  12278. invertU: number;
  12279. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  12280. invertV: number;
  12281. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  12282. disposeWhenFinishedAnimating: boolean;
  12283. /** Gets the list of attached animations */
  12284. animations: Animation[];
  12285. /** Gets or sets a boolean indicating if the sprite can be picked */
  12286. isPickable: boolean;
  12287. /**
  12288. * Gets or sets the associated action manager
  12289. */
  12290. actionManager: Nullable<ActionManager>;
  12291. private _animationStarted;
  12292. private _loopAnimation;
  12293. private _fromIndex;
  12294. private _toIndex;
  12295. private _delay;
  12296. private _direction;
  12297. private _manager;
  12298. private _time;
  12299. private _onAnimationEnd;
  12300. /**
  12301. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  12302. */
  12303. isVisible: boolean;
  12304. /**
  12305. * Gets or sets the sprite size
  12306. */
  12307. size: number;
  12308. /**
  12309. * Creates a new Sprite
  12310. * @param name defines the name
  12311. * @param manager defines the manager
  12312. */
  12313. constructor(
  12314. /** defines the name */
  12315. name: string, manager: ISpriteManager);
  12316. /**
  12317. * Starts an animation
  12318. * @param from defines the initial key
  12319. * @param to defines the end key
  12320. * @param loop defines if the animation must loop
  12321. * @param delay defines the start delay (in ms)
  12322. * @param onAnimationEnd defines a callback to call when animation ends
  12323. */
  12324. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  12325. /** Stops current animation (if any) */
  12326. stopAnimation(): void;
  12327. /** @hidden */
  12328. _animate(deltaTime: number): void;
  12329. /** Release associated resources */
  12330. dispose(): void;
  12331. }
  12332. }
  12333. declare module "babylonjs/Collisions/pickingInfo" {
  12334. import { Nullable } from "babylonjs/types";
  12335. import { Vector3, Vector2 } from "babylonjs/Maths/math";
  12336. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12337. import { Sprite } from "babylonjs/Sprites/sprite";
  12338. import { Ray } from "babylonjs/Culling/ray";
  12339. /**
  12340. * Information about the result of picking within a scene
  12341. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  12342. */
  12343. export class PickingInfo {
  12344. /** @hidden */
  12345. _pickingUnavailable: boolean;
  12346. /**
  12347. * If the pick collided with an object
  12348. */
  12349. hit: boolean;
  12350. /**
  12351. * Distance away where the pick collided
  12352. */
  12353. distance: number;
  12354. /**
  12355. * The location of pick collision
  12356. */
  12357. pickedPoint: Nullable<Vector3>;
  12358. /**
  12359. * The mesh corresponding the the pick collision
  12360. */
  12361. pickedMesh: Nullable<AbstractMesh>;
  12362. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  12363. bu: number;
  12364. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  12365. bv: number;
  12366. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  12367. faceId: number;
  12368. /** Id of the the submesh that was picked */
  12369. subMeshId: number;
  12370. /** If a sprite was picked, this will be the sprite the pick collided with */
  12371. pickedSprite: Nullable<Sprite>;
  12372. /**
  12373. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  12374. */
  12375. originMesh: Nullable<AbstractMesh>;
  12376. /**
  12377. * The ray that was used to perform the picking.
  12378. */
  12379. ray: Nullable<Ray>;
  12380. /**
  12381. * Gets the normal correspodning to the face the pick collided with
  12382. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  12383. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  12384. * @returns The normal correspodning to the face the pick collided with
  12385. */
  12386. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  12387. /**
  12388. * Gets the texture coordinates of where the pick occured
  12389. * @returns the vector containing the coordnates of the texture
  12390. */
  12391. getTextureCoordinates(): Nullable<Vector2>;
  12392. }
  12393. }
  12394. declare module "babylonjs/Events/pointerEvents" {
  12395. import { Nullable } from "babylonjs/types";
  12396. import { Vector2 } from "babylonjs/Maths/math";
  12397. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  12398. import { Ray } from "babylonjs/Culling/ray";
  12399. /**
  12400. * Gather the list of pointer event types as constants.
  12401. */
  12402. export class PointerEventTypes {
  12403. /**
  12404. * 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.
  12405. */
  12406. static readonly POINTERDOWN: number;
  12407. /**
  12408. * The pointerup event is fired when a pointer is no longer active.
  12409. */
  12410. static readonly POINTERUP: number;
  12411. /**
  12412. * The pointermove event is fired when a pointer changes coordinates.
  12413. */
  12414. static readonly POINTERMOVE: number;
  12415. /**
  12416. * The pointerwheel event is fired when a mouse wheel has been rotated.
  12417. */
  12418. static readonly POINTERWHEEL: number;
  12419. /**
  12420. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  12421. */
  12422. static readonly POINTERPICK: number;
  12423. /**
  12424. * The pointertap event is fired when a the object has been touched and released without drag.
  12425. */
  12426. static readonly POINTERTAP: number;
  12427. /**
  12428. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  12429. */
  12430. static readonly POINTERDOUBLETAP: number;
  12431. }
  12432. /**
  12433. * Base class of pointer info types.
  12434. */
  12435. export class PointerInfoBase {
  12436. /**
  12437. * Defines the type of event (PointerEventTypes)
  12438. */
  12439. type: number;
  12440. /**
  12441. * Defines the related dom event
  12442. */
  12443. event: PointerEvent | MouseWheelEvent;
  12444. /**
  12445. * Instantiates the base class of pointers info.
  12446. * @param type Defines the type of event (PointerEventTypes)
  12447. * @param event Defines the related dom event
  12448. */
  12449. constructor(
  12450. /**
  12451. * Defines the type of event (PointerEventTypes)
  12452. */
  12453. type: number,
  12454. /**
  12455. * Defines the related dom event
  12456. */
  12457. event: PointerEvent | MouseWheelEvent);
  12458. }
  12459. /**
  12460. * This class is used to store pointer related info for the onPrePointerObservable event.
  12461. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  12462. */
  12463. export class PointerInfoPre extends PointerInfoBase {
  12464. /**
  12465. * Ray from a pointer if availible (eg. 6dof controller)
  12466. */
  12467. ray: Nullable<Ray>;
  12468. /**
  12469. * Defines the local position of the pointer on the canvas.
  12470. */
  12471. localPosition: Vector2;
  12472. /**
  12473. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  12474. */
  12475. skipOnPointerObservable: boolean;
  12476. /**
  12477. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  12478. * @param type Defines the type of event (PointerEventTypes)
  12479. * @param event Defines the related dom event
  12480. * @param localX Defines the local x coordinates of the pointer when the event occured
  12481. * @param localY Defines the local y coordinates of the pointer when the event occured
  12482. */
  12483. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  12484. }
  12485. /**
  12486. * This type contains all the data related to a pointer event in Babylon.js.
  12487. * 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.
  12488. */
  12489. export class PointerInfo extends PointerInfoBase {
  12490. /**
  12491. * Defines the picking info associated to the info (if any)\
  12492. */
  12493. pickInfo: Nullable<PickingInfo>;
  12494. /**
  12495. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  12496. * @param type Defines the type of event (PointerEventTypes)
  12497. * @param event Defines the related dom event
  12498. * @param pickInfo Defines the picking info associated to the info (if any)\
  12499. */
  12500. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  12501. /**
  12502. * Defines the picking info associated to the info (if any)\
  12503. */
  12504. pickInfo: Nullable<PickingInfo>);
  12505. }
  12506. /**
  12507. * Data relating to a touch event on the screen.
  12508. */
  12509. export interface PointerTouch {
  12510. /**
  12511. * X coordinate of touch.
  12512. */
  12513. x: number;
  12514. /**
  12515. * Y coordinate of touch.
  12516. */
  12517. y: number;
  12518. /**
  12519. * Id of touch. Unique for each finger.
  12520. */
  12521. pointerId: number;
  12522. /**
  12523. * Event type passed from DOM.
  12524. */
  12525. type: any;
  12526. }
  12527. }
  12528. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  12529. import { Observable } from "babylonjs/Misc/observable";
  12530. import { Nullable } from "babylonjs/types";
  12531. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12532. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12533. /**
  12534. * Manage the mouse inputs to control the movement of a free camera.
  12535. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12536. */
  12537. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  12538. /**
  12539. * Define if touch is enabled in the mouse input
  12540. */
  12541. touchEnabled: boolean;
  12542. /**
  12543. * Defines the camera the input is attached to.
  12544. */
  12545. camera: FreeCamera;
  12546. /**
  12547. * Defines the buttons associated with the input to handle camera move.
  12548. */
  12549. buttons: number[];
  12550. /**
  12551. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  12552. */
  12553. angularSensibility: number;
  12554. private _pointerInput;
  12555. private _onMouseMove;
  12556. private _observer;
  12557. private previousPosition;
  12558. /**
  12559. * Observable for when a pointer move event occurs containing the move offset
  12560. */
  12561. onPointerMovedObservable: Observable<{
  12562. offsetX: number;
  12563. offsetY: number;
  12564. }>;
  12565. /**
  12566. * @hidden
  12567. * If the camera should be rotated automatically based on pointer movement
  12568. */
  12569. _allowCameraRotation: boolean;
  12570. /**
  12571. * Manage the mouse inputs to control the movement of a free camera.
  12572. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12573. * @param touchEnabled Defines if touch is enabled or not
  12574. */
  12575. constructor(
  12576. /**
  12577. * Define if touch is enabled in the mouse input
  12578. */
  12579. touchEnabled?: boolean);
  12580. /**
  12581. * Attach the input controls to a specific dom element to get the input from.
  12582. * @param element Defines the element the controls should be listened from
  12583. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12584. */
  12585. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12586. /**
  12587. * Called on JS contextmenu event.
  12588. * Override this method to provide functionality.
  12589. */
  12590. protected onContextMenu(evt: PointerEvent): void;
  12591. /**
  12592. * Detach the current controls from the specified dom element.
  12593. * @param element Defines the element to stop listening the inputs from
  12594. */
  12595. detachControl(element: Nullable<HTMLElement>): void;
  12596. /**
  12597. * Gets the class name of the current intput.
  12598. * @returns the class name
  12599. */
  12600. getClassName(): string;
  12601. /**
  12602. * Get the friendly name associated with the input class.
  12603. * @returns the input friendly name
  12604. */
  12605. getSimpleName(): string;
  12606. }
  12607. }
  12608. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  12609. import { Nullable } from "babylonjs/types";
  12610. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12611. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12612. /**
  12613. * Manage the touch inputs to control the movement of a free camera.
  12614. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12615. */
  12616. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12617. /**
  12618. * Defines the camera the input is attached to.
  12619. */
  12620. camera: FreeCamera;
  12621. /**
  12622. * Defines the touch sensibility for rotation.
  12623. * The higher the faster.
  12624. */
  12625. touchAngularSensibility: number;
  12626. /**
  12627. * Defines the touch sensibility for move.
  12628. * The higher the faster.
  12629. */
  12630. touchMoveSensibility: number;
  12631. private _offsetX;
  12632. private _offsetY;
  12633. private _pointerPressed;
  12634. private _pointerInput;
  12635. private _observer;
  12636. private _onLostFocus;
  12637. /**
  12638. * Attach the input controls to a specific dom element to get the input from.
  12639. * @param element Defines the element the controls should be listened from
  12640. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12641. */
  12642. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12643. /**
  12644. * Detach the current controls from the specified dom element.
  12645. * @param element Defines the element to stop listening the inputs from
  12646. */
  12647. detachControl(element: Nullable<HTMLElement>): void;
  12648. /**
  12649. * Update the current camera state depending on the inputs that have been used this frame.
  12650. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12651. */
  12652. checkInputs(): void;
  12653. /**
  12654. * Gets the class name of the current intput.
  12655. * @returns the class name
  12656. */
  12657. getClassName(): string;
  12658. /**
  12659. * Get the friendly name associated with the input class.
  12660. * @returns the input friendly name
  12661. */
  12662. getSimpleName(): string;
  12663. }
  12664. }
  12665. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  12666. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12667. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  12668. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  12669. import { Nullable } from "babylonjs/types";
  12670. /**
  12671. * Default Inputs manager for the FreeCamera.
  12672. * It groups all the default supported inputs for ease of use.
  12673. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12674. */
  12675. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12676. /**
  12677. * @hidden
  12678. */
  12679. _mouseInput: Nullable<FreeCameraMouseInput>;
  12680. /**
  12681. * Instantiates a new FreeCameraInputsManager.
  12682. * @param camera Defines the camera the inputs belong to
  12683. */
  12684. constructor(camera: FreeCamera);
  12685. /**
  12686. * Add keyboard input support to the input manager.
  12687. * @returns the current input manager
  12688. */
  12689. addKeyboard(): FreeCameraInputsManager;
  12690. /**
  12691. * Add mouse input support to the input manager.
  12692. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12693. * @returns the current input manager
  12694. */
  12695. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12696. /**
  12697. * Removes the mouse input support from the manager
  12698. * @returns the current input manager
  12699. */
  12700. removeMouse(): FreeCameraInputsManager;
  12701. /**
  12702. * Add touch input support to the input manager.
  12703. * @returns the current input manager
  12704. */
  12705. addTouch(): FreeCameraInputsManager;
  12706. /**
  12707. * Remove all attached input methods from a camera
  12708. */
  12709. clear(): void;
  12710. }
  12711. }
  12712. declare module "babylonjs/Cameras/freeCamera" {
  12713. import { Vector3 } from "babylonjs/Maths/math";
  12714. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12715. import { Scene } from "babylonjs/scene";
  12716. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12717. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  12718. /**
  12719. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12720. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12721. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12722. */
  12723. export class FreeCamera extends TargetCamera {
  12724. /**
  12725. * Define the collision ellipsoid of the camera.
  12726. * This is helpful to simulate a camera body like the player body around the camera
  12727. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12728. */
  12729. ellipsoid: Vector3;
  12730. /**
  12731. * Define an offset for the position of the ellipsoid around the camera.
  12732. * This can be helpful to determine the center of the body near the gravity center of the body
  12733. * instead of its head.
  12734. */
  12735. ellipsoidOffset: Vector3;
  12736. /**
  12737. * Enable or disable collisions of the camera with the rest of the scene objects.
  12738. */
  12739. checkCollisions: boolean;
  12740. /**
  12741. * Enable or disable gravity on the camera.
  12742. */
  12743. applyGravity: boolean;
  12744. /**
  12745. * Define the input manager associated to the camera.
  12746. */
  12747. inputs: FreeCameraInputsManager;
  12748. /**
  12749. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12750. * Higher values reduce sensitivity.
  12751. */
  12752. /**
  12753. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12754. * Higher values reduce sensitivity.
  12755. */
  12756. angularSensibility: number;
  12757. /**
  12758. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12759. */
  12760. keysUp: number[];
  12761. /**
  12762. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12763. */
  12764. keysDown: number[];
  12765. /**
  12766. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12767. */
  12768. keysLeft: number[];
  12769. /**
  12770. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12771. */
  12772. keysRight: number[];
  12773. /**
  12774. * Event raised when the camera collide with a mesh in the scene.
  12775. */
  12776. onCollide: (collidedMesh: AbstractMesh) => void;
  12777. private _collider;
  12778. private _needMoveForGravity;
  12779. private _oldPosition;
  12780. private _diffPosition;
  12781. private _newPosition;
  12782. /** @hidden */
  12783. _localDirection: Vector3;
  12784. /** @hidden */
  12785. _transformedDirection: Vector3;
  12786. /**
  12787. * Instantiates a Free Camera.
  12788. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12789. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12790. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12791. * @param name Define the name of the camera in the scene
  12792. * @param position Define the start position of the camera in the scene
  12793. * @param scene Define the scene the camera belongs to
  12794. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12795. */
  12796. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12797. /**
  12798. * Attached controls to the current camera.
  12799. * @param element Defines the element the controls should be listened from
  12800. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12801. */
  12802. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12803. /**
  12804. * Detach the current controls from the camera.
  12805. * The camera will stop reacting to inputs.
  12806. * @param element Defines the element to stop listening the inputs from
  12807. */
  12808. detachControl(element: HTMLElement): void;
  12809. private _collisionMask;
  12810. /**
  12811. * Define a collision mask to limit the list of object the camera can collide with
  12812. */
  12813. collisionMask: number;
  12814. /** @hidden */
  12815. _collideWithWorld(displacement: Vector3): void;
  12816. private _onCollisionPositionChange;
  12817. /** @hidden */
  12818. _checkInputs(): void;
  12819. /** @hidden */
  12820. _decideIfNeedsToMove(): boolean;
  12821. /** @hidden */
  12822. _updatePosition(): void;
  12823. /**
  12824. * Destroy the camera and release the current resources hold by it.
  12825. */
  12826. dispose(): void;
  12827. /**
  12828. * Gets the current object class name.
  12829. * @return the class name
  12830. */
  12831. getClassName(): string;
  12832. }
  12833. }
  12834. declare module "babylonjs/Gamepads/gamepad" {
  12835. import { Observable } from "babylonjs/Misc/observable";
  12836. /**
  12837. * Represents a gamepad control stick position
  12838. */
  12839. export class StickValues {
  12840. /**
  12841. * The x component of the control stick
  12842. */
  12843. x: number;
  12844. /**
  12845. * The y component of the control stick
  12846. */
  12847. y: number;
  12848. /**
  12849. * Initializes the gamepad x and y control stick values
  12850. * @param x The x component of the gamepad control stick value
  12851. * @param y The y component of the gamepad control stick value
  12852. */
  12853. constructor(
  12854. /**
  12855. * The x component of the control stick
  12856. */
  12857. x: number,
  12858. /**
  12859. * The y component of the control stick
  12860. */
  12861. y: number);
  12862. }
  12863. /**
  12864. * An interface which manages callbacks for gamepad button changes
  12865. */
  12866. export interface GamepadButtonChanges {
  12867. /**
  12868. * Called when a gamepad has been changed
  12869. */
  12870. changed: boolean;
  12871. /**
  12872. * Called when a gamepad press event has been triggered
  12873. */
  12874. pressChanged: boolean;
  12875. /**
  12876. * Called when a touch event has been triggered
  12877. */
  12878. touchChanged: boolean;
  12879. /**
  12880. * Called when a value has changed
  12881. */
  12882. valueChanged: boolean;
  12883. }
  12884. /**
  12885. * Represents a gamepad
  12886. */
  12887. export class Gamepad {
  12888. /**
  12889. * The id of the gamepad
  12890. */
  12891. id: string;
  12892. /**
  12893. * The index of the gamepad
  12894. */
  12895. index: number;
  12896. /**
  12897. * The browser gamepad
  12898. */
  12899. browserGamepad: any;
  12900. /**
  12901. * Specifies what type of gamepad this represents
  12902. */
  12903. type: number;
  12904. private _leftStick;
  12905. private _rightStick;
  12906. /** @hidden */
  12907. _isConnected: boolean;
  12908. private _leftStickAxisX;
  12909. private _leftStickAxisY;
  12910. private _rightStickAxisX;
  12911. private _rightStickAxisY;
  12912. /**
  12913. * Triggered when the left control stick has been changed
  12914. */
  12915. private _onleftstickchanged;
  12916. /**
  12917. * Triggered when the right control stick has been changed
  12918. */
  12919. private _onrightstickchanged;
  12920. /**
  12921. * Represents a gamepad controller
  12922. */
  12923. static GAMEPAD: number;
  12924. /**
  12925. * Represents a generic controller
  12926. */
  12927. static GENERIC: number;
  12928. /**
  12929. * Represents an XBox controller
  12930. */
  12931. static XBOX: number;
  12932. /**
  12933. * Represents a pose-enabled controller
  12934. */
  12935. static POSE_ENABLED: number;
  12936. /**
  12937. * Specifies whether the left control stick should be Y-inverted
  12938. */
  12939. protected _invertLeftStickY: boolean;
  12940. /**
  12941. * Specifies if the gamepad has been connected
  12942. */
  12943. readonly isConnected: boolean;
  12944. /**
  12945. * Initializes the gamepad
  12946. * @param id The id of the gamepad
  12947. * @param index The index of the gamepad
  12948. * @param browserGamepad The browser gamepad
  12949. * @param leftStickX The x component of the left joystick
  12950. * @param leftStickY The y component of the left joystick
  12951. * @param rightStickX The x component of the right joystick
  12952. * @param rightStickY The y component of the right joystick
  12953. */
  12954. constructor(
  12955. /**
  12956. * The id of the gamepad
  12957. */
  12958. id: string,
  12959. /**
  12960. * The index of the gamepad
  12961. */
  12962. index: number,
  12963. /**
  12964. * The browser gamepad
  12965. */
  12966. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12967. /**
  12968. * Callback triggered when the left joystick has changed
  12969. * @param callback
  12970. */
  12971. onleftstickchanged(callback: (values: StickValues) => void): void;
  12972. /**
  12973. * Callback triggered when the right joystick has changed
  12974. * @param callback
  12975. */
  12976. onrightstickchanged(callback: (values: StickValues) => void): void;
  12977. /**
  12978. * Gets the left joystick
  12979. */
  12980. /**
  12981. * Sets the left joystick values
  12982. */
  12983. leftStick: StickValues;
  12984. /**
  12985. * Gets the right joystick
  12986. */
  12987. /**
  12988. * Sets the right joystick value
  12989. */
  12990. rightStick: StickValues;
  12991. /**
  12992. * Updates the gamepad joystick positions
  12993. */
  12994. update(): void;
  12995. /**
  12996. * Disposes the gamepad
  12997. */
  12998. dispose(): void;
  12999. }
  13000. /**
  13001. * Represents a generic gamepad
  13002. */
  13003. export class GenericPad extends Gamepad {
  13004. private _buttons;
  13005. private _onbuttondown;
  13006. private _onbuttonup;
  13007. /**
  13008. * Observable triggered when a button has been pressed
  13009. */
  13010. onButtonDownObservable: Observable<number>;
  13011. /**
  13012. * Observable triggered when a button has been released
  13013. */
  13014. onButtonUpObservable: Observable<number>;
  13015. /**
  13016. * Callback triggered when a button has been pressed
  13017. * @param callback Called when a button has been pressed
  13018. */
  13019. onbuttondown(callback: (buttonPressed: number) => void): void;
  13020. /**
  13021. * Callback triggered when a button has been released
  13022. * @param callback Called when a button has been released
  13023. */
  13024. onbuttonup(callback: (buttonReleased: number) => void): void;
  13025. /**
  13026. * Initializes the generic gamepad
  13027. * @param id The id of the generic gamepad
  13028. * @param index The index of the generic gamepad
  13029. * @param browserGamepad The browser gamepad
  13030. */
  13031. constructor(id: string, index: number, browserGamepad: any);
  13032. private _setButtonValue;
  13033. /**
  13034. * Updates the generic gamepad
  13035. */
  13036. update(): void;
  13037. /**
  13038. * Disposes the generic gamepad
  13039. */
  13040. dispose(): void;
  13041. }
  13042. }
  13043. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  13044. import { Observable } from "babylonjs/Misc/observable";
  13045. import { Nullable } from "babylonjs/types";
  13046. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  13047. import { TransformNode } from "babylonjs/Meshes/transformNode";
  13048. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13049. import { Ray } from "babylonjs/Culling/ray";
  13050. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  13051. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  13052. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  13053. /**
  13054. * Defines the types of pose enabled controllers that are supported
  13055. */
  13056. export enum PoseEnabledControllerType {
  13057. /**
  13058. * HTC Vive
  13059. */
  13060. VIVE = 0,
  13061. /**
  13062. * Oculus Rift
  13063. */
  13064. OCULUS = 1,
  13065. /**
  13066. * Windows mixed reality
  13067. */
  13068. WINDOWS = 2,
  13069. /**
  13070. * Samsung gear VR
  13071. */
  13072. GEAR_VR = 3,
  13073. /**
  13074. * Google Daydream
  13075. */
  13076. DAYDREAM = 4,
  13077. /**
  13078. * Generic
  13079. */
  13080. GENERIC = 5
  13081. }
  13082. /**
  13083. * Defines the MutableGamepadButton interface for the state of a gamepad button
  13084. */
  13085. export interface MutableGamepadButton {
  13086. /**
  13087. * Value of the button/trigger
  13088. */
  13089. value: number;
  13090. /**
  13091. * If the button/trigger is currently touched
  13092. */
  13093. touched: boolean;
  13094. /**
  13095. * If the button/trigger is currently pressed
  13096. */
  13097. pressed: boolean;
  13098. }
  13099. /**
  13100. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  13101. * @hidden
  13102. */
  13103. export interface ExtendedGamepadButton extends GamepadButton {
  13104. /**
  13105. * If the button/trigger is currently pressed
  13106. */
  13107. readonly pressed: boolean;
  13108. /**
  13109. * If the button/trigger is currently touched
  13110. */
  13111. readonly touched: boolean;
  13112. /**
  13113. * Value of the button/trigger
  13114. */
  13115. readonly value: number;
  13116. }
  13117. /** @hidden */
  13118. export interface _GamePadFactory {
  13119. /**
  13120. * Returns wether or not the current gamepad can be created for this type of controller.
  13121. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  13122. * @returns true if it can be created, otherwise false
  13123. */
  13124. canCreate(gamepadInfo: any): boolean;
  13125. /**
  13126. * Creates a new instance of the Gamepad.
  13127. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  13128. * @returns the new gamepad instance
  13129. */
  13130. create(gamepadInfo: any): Gamepad;
  13131. }
  13132. /**
  13133. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  13134. */
  13135. export class PoseEnabledControllerHelper {
  13136. /** @hidden */
  13137. static _ControllerFactories: _GamePadFactory[];
  13138. /** @hidden */
  13139. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  13140. /**
  13141. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  13142. * @param vrGamepad the gamepad to initialized
  13143. * @returns a vr controller of the type the gamepad identified as
  13144. */
  13145. static InitiateController(vrGamepad: any): Gamepad;
  13146. }
  13147. /**
  13148. * Defines the PoseEnabledController object that contains state of a vr capable controller
  13149. */
  13150. export class PoseEnabledController extends Gamepad implements PoseControlled {
  13151. private _deviceRoomPosition;
  13152. private _deviceRoomRotationQuaternion;
  13153. /**
  13154. * The device position in babylon space
  13155. */
  13156. devicePosition: Vector3;
  13157. /**
  13158. * The device rotation in babylon space
  13159. */
  13160. deviceRotationQuaternion: Quaternion;
  13161. /**
  13162. * The scale factor of the device in babylon space
  13163. */
  13164. deviceScaleFactor: number;
  13165. /**
  13166. * (Likely devicePosition should be used instead) The device position in its room space
  13167. */
  13168. position: Vector3;
  13169. /**
  13170. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  13171. */
  13172. rotationQuaternion: Quaternion;
  13173. /**
  13174. * The type of controller (Eg. Windows mixed reality)
  13175. */
  13176. controllerType: PoseEnabledControllerType;
  13177. protected _calculatedPosition: Vector3;
  13178. private _calculatedRotation;
  13179. /**
  13180. * The raw pose from the device
  13181. */
  13182. rawPose: DevicePose;
  13183. private _trackPosition;
  13184. private _maxRotationDistFromHeadset;
  13185. private _draggedRoomRotation;
  13186. /**
  13187. * @hidden
  13188. */
  13189. _disableTrackPosition(fixedPosition: Vector3): void;
  13190. /**
  13191. * Internal, the mesh attached to the controller
  13192. * @hidden
  13193. */
  13194. _mesh: Nullable<AbstractMesh>;
  13195. private _poseControlledCamera;
  13196. private _leftHandSystemQuaternion;
  13197. /**
  13198. * Internal, matrix used to convert room space to babylon space
  13199. * @hidden
  13200. */
  13201. _deviceToWorld: Matrix;
  13202. /**
  13203. * Node to be used when casting a ray from the controller
  13204. * @hidden
  13205. */
  13206. _pointingPoseNode: Nullable<TransformNode>;
  13207. /**
  13208. * Name of the child mesh that can be used to cast a ray from the controller
  13209. */
  13210. static readonly POINTING_POSE: string;
  13211. /**
  13212. * Creates a new PoseEnabledController from a gamepad
  13213. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  13214. */
  13215. constructor(browserGamepad: any);
  13216. private _workingMatrix;
  13217. /**
  13218. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  13219. */
  13220. update(): void;
  13221. /**
  13222. * Updates only the pose device and mesh without doing any button event checking
  13223. */
  13224. protected _updatePoseAndMesh(): void;
  13225. /**
  13226. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  13227. * @param poseData raw pose fromthe device
  13228. */
  13229. updateFromDevice(poseData: DevicePose): void;
  13230. /**
  13231. * @hidden
  13232. */
  13233. _meshAttachedObservable: Observable<AbstractMesh>;
  13234. /**
  13235. * Attaches a mesh to the controller
  13236. * @param mesh the mesh to be attached
  13237. */
  13238. attachToMesh(mesh: AbstractMesh): void;
  13239. /**
  13240. * Attaches the controllers mesh to a camera
  13241. * @param camera the camera the mesh should be attached to
  13242. */
  13243. attachToPoseControlledCamera(camera: TargetCamera): void;
  13244. /**
  13245. * Disposes of the controller
  13246. */
  13247. dispose(): void;
  13248. /**
  13249. * The mesh that is attached to the controller
  13250. */
  13251. readonly mesh: Nullable<AbstractMesh>;
  13252. /**
  13253. * Gets the ray of the controller in the direction the controller is pointing
  13254. * @param length the length the resulting ray should be
  13255. * @returns a ray in the direction the controller is pointing
  13256. */
  13257. getForwardRay(length?: number): Ray;
  13258. }
  13259. }
  13260. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  13261. import { Observable } from "babylonjs/Misc/observable";
  13262. import { Scene } from "babylonjs/scene";
  13263. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13264. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  13265. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  13266. /**
  13267. * Defines the WebVRController object that represents controllers tracked in 3D space
  13268. */
  13269. export abstract class WebVRController extends PoseEnabledController {
  13270. /**
  13271. * Internal, the default controller model for the controller
  13272. */
  13273. protected _defaultModel: AbstractMesh;
  13274. /**
  13275. * Fired when the trigger state has changed
  13276. */
  13277. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  13278. /**
  13279. * Fired when the main button state has changed
  13280. */
  13281. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  13282. /**
  13283. * Fired when the secondary button state has changed
  13284. */
  13285. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  13286. /**
  13287. * Fired when the pad state has changed
  13288. */
  13289. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  13290. /**
  13291. * Fired when controllers stick values have changed
  13292. */
  13293. onPadValuesChangedObservable: Observable<StickValues>;
  13294. /**
  13295. * Array of button availible on the controller
  13296. */
  13297. protected _buttons: Array<MutableGamepadButton>;
  13298. private _onButtonStateChange;
  13299. /**
  13300. * Fired when a controller button's state has changed
  13301. * @param callback the callback containing the button that was modified
  13302. */
  13303. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  13304. /**
  13305. * X and Y axis corrisponding to the controllers joystick
  13306. */
  13307. pad: StickValues;
  13308. /**
  13309. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  13310. */
  13311. hand: string;
  13312. /**
  13313. * The default controller model for the controller
  13314. */
  13315. readonly defaultModel: AbstractMesh;
  13316. /**
  13317. * Creates a new WebVRController from a gamepad
  13318. * @param vrGamepad the gamepad that the WebVRController should be created from
  13319. */
  13320. constructor(vrGamepad: any);
  13321. /**
  13322. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  13323. */
  13324. update(): void;
  13325. /**
  13326. * Function to be called when a button is modified
  13327. */
  13328. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  13329. /**
  13330. * Loads a mesh and attaches it to the controller
  13331. * @param scene the scene the mesh should be added to
  13332. * @param meshLoaded callback for when the mesh has been loaded
  13333. */
  13334. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  13335. private _setButtonValue;
  13336. private _changes;
  13337. private _checkChanges;
  13338. /**
  13339. * Disposes of th webVRCOntroller
  13340. */
  13341. dispose(): void;
  13342. }
  13343. }
  13344. declare module "babylonjs/Lights/hemisphericLight" {
  13345. import { Nullable } from "babylonjs/types";
  13346. import { Scene } from "babylonjs/scene";
  13347. import { Matrix, Vector3, Color3 } from "babylonjs/Maths/math";
  13348. import { Effect } from "babylonjs/Materials/effect";
  13349. import { Light } from "babylonjs/Lights/light";
  13350. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  13351. /**
  13352. * The HemisphericLight simulates the ambient environment light,
  13353. * so the passed direction is the light reflection direction, not the incoming direction.
  13354. */
  13355. export class HemisphericLight extends Light {
  13356. /**
  13357. * The groundColor is the light in the opposite direction to the one specified during creation.
  13358. * 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.
  13359. */
  13360. groundColor: Color3;
  13361. /**
  13362. * The light reflection direction, not the incoming direction.
  13363. */
  13364. direction: Vector3;
  13365. /**
  13366. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  13367. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  13368. * The HemisphericLight can't cast shadows.
  13369. * Documentation : https://doc.babylonjs.com/babylon101/lights
  13370. * @param name The friendly name of the light
  13371. * @param direction The direction of the light reflection
  13372. * @param scene The scene the light belongs to
  13373. */
  13374. constructor(name: string, direction: Vector3, scene: Scene);
  13375. protected _buildUniformLayout(): void;
  13376. /**
  13377. * Returns the string "HemisphericLight".
  13378. * @return The class name
  13379. */
  13380. getClassName(): string;
  13381. /**
  13382. * Sets the HemisphericLight direction towards the passed target (Vector3).
  13383. * Returns the updated direction.
  13384. * @param target The target the direction should point to
  13385. * @return The computed direction
  13386. */
  13387. setDirectionToTarget(target: Vector3): Vector3;
  13388. /**
  13389. * Returns the shadow generator associated to the light.
  13390. * @returns Always null for hemispheric lights because it does not support shadows.
  13391. */
  13392. getShadowGenerator(): Nullable<IShadowGenerator>;
  13393. /**
  13394. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  13395. * @param effect The effect to update
  13396. * @param lightIndex The index of the light in the effect to update
  13397. * @returns The hemispheric light
  13398. */
  13399. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  13400. /**
  13401. * Computes the world matrix of the node
  13402. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  13403. * @param useWasUpdatedFlag defines a reserved property
  13404. * @returns the world matrix
  13405. */
  13406. computeWorldMatrix(): Matrix;
  13407. /**
  13408. * Returns the integer 3.
  13409. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  13410. */
  13411. getTypeID(): number;
  13412. /**
  13413. * Prepares the list of defines specific to the light type.
  13414. * @param defines the list of defines
  13415. * @param lightIndex defines the index of the light for the effect
  13416. */
  13417. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  13418. }
  13419. }
  13420. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  13421. /** @hidden */
  13422. export var vrMultiviewToSingleviewPixelShader: {
  13423. name: string;
  13424. shader: string;
  13425. };
  13426. }
  13427. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  13428. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  13429. import { Scene } from "babylonjs/scene";
  13430. /**
  13431. * Renders to multiple views with a single draw call
  13432. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  13433. */
  13434. export class MultiviewRenderTarget extends RenderTargetTexture {
  13435. /**
  13436. * Creates a multiview render target
  13437. * @param scene scene used with the render target
  13438. * @param size the size of the render target (used for each view)
  13439. */
  13440. constructor(scene: Scene, size?: number | {
  13441. width: number;
  13442. height: number;
  13443. } | {
  13444. ratio: number;
  13445. });
  13446. /**
  13447. * @hidden
  13448. * @param faceIndex the face index, if its a cube texture
  13449. */
  13450. _bindFrameBuffer(faceIndex?: number): void;
  13451. /**
  13452. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  13453. * @returns the view count
  13454. */
  13455. getViewCount(): number;
  13456. }
  13457. }
  13458. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  13459. import { Camera } from "babylonjs/Cameras/camera";
  13460. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  13461. import { Nullable } from "babylonjs/types";
  13462. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  13463. import { Matrix } from "babylonjs/Maths/math";
  13464. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  13465. module "babylonjs/Engines/engine" {
  13466. interface Engine {
  13467. /**
  13468. * Creates a new multiview render target
  13469. * @param width defines the width of the texture
  13470. * @param height defines the height of the texture
  13471. * @returns the created multiview texture
  13472. */
  13473. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  13474. /**
  13475. * Binds a multiview framebuffer to be drawn to
  13476. * @param multiviewTexture texture to bind
  13477. */
  13478. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  13479. }
  13480. }
  13481. module "babylonjs/Cameras/camera" {
  13482. interface Camera {
  13483. /**
  13484. * @hidden
  13485. * 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)
  13486. */
  13487. _useMultiviewToSingleView: boolean;
  13488. /**
  13489. * @hidden
  13490. * 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)
  13491. */
  13492. _multiviewTexture: Nullable<RenderTargetTexture>;
  13493. /**
  13494. * @hidden
  13495. * ensures the multiview texture of the camera exists and has the specified width/height
  13496. * @param width height to set on the multiview texture
  13497. * @param height width to set on the multiview texture
  13498. */
  13499. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  13500. }
  13501. }
  13502. module "babylonjs/scene" {
  13503. interface Scene {
  13504. /** @hidden */
  13505. _transformMatrixR: Matrix;
  13506. /** @hidden */
  13507. _multiviewSceneUbo: Nullable<UniformBuffer>;
  13508. /** @hidden */
  13509. _createMultiviewUbo(): void;
  13510. /** @hidden */
  13511. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  13512. /** @hidden */
  13513. _renderMultiviewToSingleView(camera: Camera): void;
  13514. }
  13515. }
  13516. }
  13517. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  13518. import { Camera } from "babylonjs/Cameras/camera";
  13519. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  13520. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  13521. import "babylonjs/Engines/Extensions/engine.multiview";
  13522. /**
  13523. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  13524. * This will not be used for webXR as it supports displaying texture arrays directly
  13525. */
  13526. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  13527. /**
  13528. * Initializes a VRMultiviewToSingleview
  13529. * @param name name of the post process
  13530. * @param camera camera to be applied to
  13531. * @param scaleFactor scaling factor to the size of the output texture
  13532. */
  13533. constructor(name: string, camera: Camera, scaleFactor: number);
  13534. }
  13535. }
  13536. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  13537. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  13538. import { Nullable } from "babylonjs/types";
  13539. import { Size } from "babylonjs/Maths/math";
  13540. import { Observable } from "babylonjs/Misc/observable";
  13541. module "babylonjs/Engines/engine" {
  13542. /**
  13543. * Defines the interface used by display changed events
  13544. */
  13545. interface IDisplayChangedEventArgs {
  13546. /** Gets the vrDisplay object (if any) */
  13547. vrDisplay: Nullable<any>;
  13548. /** Gets a boolean indicating if webVR is supported */
  13549. vrSupported: boolean;
  13550. }
  13551. interface Engine {
  13552. /** @hidden */
  13553. _vrDisplay: any;
  13554. /** @hidden */
  13555. _vrSupported: boolean;
  13556. /** @hidden */
  13557. _oldSize: Size;
  13558. /** @hidden */
  13559. _oldHardwareScaleFactor: number;
  13560. /** @hidden */
  13561. _vrExclusivePointerMode: boolean;
  13562. /** @hidden */
  13563. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  13564. /** @hidden */
  13565. _onVRDisplayPointerRestricted: () => void;
  13566. /** @hidden */
  13567. _onVRDisplayPointerUnrestricted: () => void;
  13568. /** @hidden */
  13569. _onVrDisplayConnect: Nullable<(display: any) => void>;
  13570. /** @hidden */
  13571. _onVrDisplayDisconnect: Nullable<() => void>;
  13572. /** @hidden */
  13573. _onVrDisplayPresentChange: Nullable<() => void>;
  13574. /**
  13575. * Observable signaled when VR display mode changes
  13576. */
  13577. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  13578. /**
  13579. * Observable signaled when VR request present is complete
  13580. */
  13581. onVRRequestPresentComplete: Observable<boolean>;
  13582. /**
  13583. * Observable signaled when VR request present starts
  13584. */
  13585. onVRRequestPresentStart: Observable<Engine>;
  13586. /**
  13587. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  13588. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  13589. */
  13590. isInVRExclusivePointerMode: boolean;
  13591. /**
  13592. * Gets a boolean indicating if a webVR device was detected
  13593. * @returns true if a webVR device was detected
  13594. */
  13595. isVRDevicePresent(): boolean;
  13596. /**
  13597. * Gets the current webVR device
  13598. * @returns the current webVR device (or null)
  13599. */
  13600. getVRDevice(): any;
  13601. /**
  13602. * Initializes a webVR display and starts listening to display change events
  13603. * The onVRDisplayChangedObservable will be notified upon these changes
  13604. * @returns A promise containing a VRDisplay and if vr is supported
  13605. */
  13606. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  13607. /** @hidden */
  13608. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  13609. /**
  13610. * Call this function to switch to webVR mode
  13611. * Will do nothing if webVR is not supported or if there is no webVR device
  13612. * @see http://doc.babylonjs.com/how_to/webvr_camera
  13613. */
  13614. enableVR(): void;
  13615. /** @hidden */
  13616. _onVRFullScreenTriggered(): void;
  13617. }
  13618. }
  13619. }
  13620. declare module "babylonjs/Cameras/VR/webVRCamera" {
  13621. import { Nullable } from "babylonjs/types";
  13622. import { Observable } from "babylonjs/Misc/observable";
  13623. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  13624. import { Scene } from "babylonjs/scene";
  13625. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  13626. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  13627. import { Node } from "babylonjs/node";
  13628. import { Ray } from "babylonjs/Culling/ray";
  13629. import "babylonjs/Cameras/RigModes/webVRRigMode";
  13630. import "babylonjs/Engines/Extensions/engine.webVR";
  13631. /**
  13632. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  13633. * IMPORTANT!! The data is right-hand data.
  13634. * @export
  13635. * @interface DevicePose
  13636. */
  13637. export interface DevicePose {
  13638. /**
  13639. * The position of the device, values in array are [x,y,z].
  13640. */
  13641. readonly position: Nullable<Float32Array>;
  13642. /**
  13643. * The linearVelocity of the device, values in array are [x,y,z].
  13644. */
  13645. readonly linearVelocity: Nullable<Float32Array>;
  13646. /**
  13647. * The linearAcceleration of the device, values in array are [x,y,z].
  13648. */
  13649. readonly linearAcceleration: Nullable<Float32Array>;
  13650. /**
  13651. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  13652. */
  13653. readonly orientation: Nullable<Float32Array>;
  13654. /**
  13655. * The angularVelocity of the device, values in array are [x,y,z].
  13656. */
  13657. readonly angularVelocity: Nullable<Float32Array>;
  13658. /**
  13659. * The angularAcceleration of the device, values in array are [x,y,z].
  13660. */
  13661. readonly angularAcceleration: Nullable<Float32Array>;
  13662. }
  13663. /**
  13664. * Interface representing a pose controlled object in Babylon.
  13665. * A pose controlled object has both regular pose values as well as pose values
  13666. * from an external device such as a VR head mounted display
  13667. */
  13668. export interface PoseControlled {
  13669. /**
  13670. * The position of the object in babylon space.
  13671. */
  13672. position: Vector3;
  13673. /**
  13674. * The rotation quaternion of the object in babylon space.
  13675. */
  13676. rotationQuaternion: Quaternion;
  13677. /**
  13678. * The position of the device in babylon space.
  13679. */
  13680. devicePosition?: Vector3;
  13681. /**
  13682. * The rotation quaternion of the device in babylon space.
  13683. */
  13684. deviceRotationQuaternion: Quaternion;
  13685. /**
  13686. * The raw pose coming from the device.
  13687. */
  13688. rawPose: Nullable<DevicePose>;
  13689. /**
  13690. * The scale of the device to be used when translating from device space to babylon space.
  13691. */
  13692. deviceScaleFactor: number;
  13693. /**
  13694. * Updates the poseControlled values based on the input device pose.
  13695. * @param poseData the pose data to update the object with
  13696. */
  13697. updateFromDevice(poseData: DevicePose): void;
  13698. }
  13699. /**
  13700. * Set of options to customize the webVRCamera
  13701. */
  13702. export interface WebVROptions {
  13703. /**
  13704. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  13705. */
  13706. trackPosition?: boolean;
  13707. /**
  13708. * Sets the scale of the vrDevice in babylon space. (default: 1)
  13709. */
  13710. positionScale?: number;
  13711. /**
  13712. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  13713. */
  13714. displayName?: string;
  13715. /**
  13716. * Should the native controller meshes be initialized. (default: true)
  13717. */
  13718. controllerMeshes?: boolean;
  13719. /**
  13720. * Creating a default HemiLight only on controllers. (default: true)
  13721. */
  13722. defaultLightingOnControllers?: boolean;
  13723. /**
  13724. * If you don't want to use the default VR button of the helper. (default: false)
  13725. */
  13726. useCustomVRButton?: boolean;
  13727. /**
  13728. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  13729. */
  13730. customVRButton?: HTMLButtonElement;
  13731. /**
  13732. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  13733. */
  13734. rayLength?: number;
  13735. /**
  13736. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  13737. */
  13738. defaultHeight?: number;
  13739. /**
  13740. * If multiview should be used if availible (default: false)
  13741. */
  13742. useMultiview?: boolean;
  13743. }
  13744. /**
  13745. * This represents a WebVR camera.
  13746. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  13747. * @example http://doc.babylonjs.com/how_to/webvr_camera
  13748. */
  13749. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  13750. private webVROptions;
  13751. /**
  13752. * @hidden
  13753. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  13754. */
  13755. _vrDevice: any;
  13756. /**
  13757. * The rawPose of the vrDevice.
  13758. */
  13759. rawPose: Nullable<DevicePose>;
  13760. private _onVREnabled;
  13761. private _specsVersion;
  13762. private _attached;
  13763. private _frameData;
  13764. protected _descendants: Array<Node>;
  13765. private _deviceRoomPosition;
  13766. /** @hidden */
  13767. _deviceRoomRotationQuaternion: Quaternion;
  13768. private _standingMatrix;
  13769. /**
  13770. * Represents device position in babylon space.
  13771. */
  13772. devicePosition: Vector3;
  13773. /**
  13774. * Represents device rotation in babylon space.
  13775. */
  13776. deviceRotationQuaternion: Quaternion;
  13777. /**
  13778. * The scale of the device to be used when translating from device space to babylon space.
  13779. */
  13780. deviceScaleFactor: number;
  13781. private _deviceToWorld;
  13782. private _worldToDevice;
  13783. /**
  13784. * References to the webVR controllers for the vrDevice.
  13785. */
  13786. controllers: Array<WebVRController>;
  13787. /**
  13788. * Emits an event when a controller is attached.
  13789. */
  13790. onControllersAttachedObservable: Observable<WebVRController[]>;
  13791. /**
  13792. * Emits an event when a controller's mesh has been loaded;
  13793. */
  13794. onControllerMeshLoadedObservable: Observable<WebVRController>;
  13795. /**
  13796. * Emits an event when the HMD's pose has been updated.
  13797. */
  13798. onPoseUpdatedFromDeviceObservable: Observable<any>;
  13799. private _poseSet;
  13800. /**
  13801. * If the rig cameras be used as parent instead of this camera.
  13802. */
  13803. rigParenting: boolean;
  13804. private _lightOnControllers;
  13805. private _defaultHeight?;
  13806. /**
  13807. * Instantiates a WebVRFreeCamera.
  13808. * @param name The name of the WebVRFreeCamera
  13809. * @param position The starting anchor position for the camera
  13810. * @param scene The scene the camera belongs to
  13811. * @param webVROptions a set of customizable options for the webVRCamera
  13812. */
  13813. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  13814. /**
  13815. * Gets the device distance from the ground in meters.
  13816. * @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.
  13817. */
  13818. deviceDistanceToRoomGround(): number;
  13819. /**
  13820. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13821. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  13822. */
  13823. useStandingMatrix(callback?: (bool: boolean) => void): void;
  13824. /**
  13825. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13826. * @returns A promise with a boolean set to if the standing matrix is supported.
  13827. */
  13828. useStandingMatrixAsync(): Promise<boolean>;
  13829. /**
  13830. * Disposes the camera
  13831. */
  13832. dispose(): void;
  13833. /**
  13834. * Gets a vrController by name.
  13835. * @param name The name of the controller to retreive
  13836. * @returns the controller matching the name specified or null if not found
  13837. */
  13838. getControllerByName(name: string): Nullable<WebVRController>;
  13839. private _leftController;
  13840. /**
  13841. * The controller corrisponding to the users left hand.
  13842. */
  13843. readonly leftController: Nullable<WebVRController>;
  13844. private _rightController;
  13845. /**
  13846. * The controller corrisponding to the users right hand.
  13847. */
  13848. readonly rightController: Nullable<WebVRController>;
  13849. /**
  13850. * Casts a ray forward from the vrCamera's gaze.
  13851. * @param length Length of the ray (default: 100)
  13852. * @returns the ray corrisponding to the gaze
  13853. */
  13854. getForwardRay(length?: number): Ray;
  13855. /**
  13856. * @hidden
  13857. * Updates the camera based on device's frame data
  13858. */
  13859. _checkInputs(): void;
  13860. /**
  13861. * Updates the poseControlled values based on the input device pose.
  13862. * @param poseData Pose coming from the device
  13863. */
  13864. updateFromDevice(poseData: DevicePose): void;
  13865. private _htmlElementAttached;
  13866. private _detachIfAttached;
  13867. /**
  13868. * WebVR's attach control will start broadcasting frames to the device.
  13869. * Note that in certain browsers (chrome for example) this function must be called
  13870. * within a user-interaction callback. Example:
  13871. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  13872. *
  13873. * @param element html element to attach the vrDevice to
  13874. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  13875. */
  13876. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  13877. /**
  13878. * Detaches the camera from the html element and disables VR
  13879. *
  13880. * @param element html element to detach from
  13881. */
  13882. detachControl(element: HTMLElement): void;
  13883. /**
  13884. * @returns the name of this class
  13885. */
  13886. getClassName(): string;
  13887. /**
  13888. * Calls resetPose on the vrDisplay
  13889. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  13890. */
  13891. resetToCurrentRotation(): void;
  13892. /**
  13893. * @hidden
  13894. * Updates the rig cameras (left and right eye)
  13895. */
  13896. _updateRigCameras(): void;
  13897. private _workingVector;
  13898. private _oneVector;
  13899. private _workingMatrix;
  13900. private updateCacheCalled;
  13901. private _correctPositionIfNotTrackPosition;
  13902. /**
  13903. * @hidden
  13904. * Updates the cached values of the camera
  13905. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  13906. */
  13907. _updateCache(ignoreParentClass?: boolean): void;
  13908. /**
  13909. * @hidden
  13910. * Get current device position in babylon world
  13911. */
  13912. _computeDevicePosition(): void;
  13913. /**
  13914. * Updates the current device position and rotation in the babylon world
  13915. */
  13916. update(): void;
  13917. /**
  13918. * @hidden
  13919. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  13920. * @returns an identity matrix
  13921. */
  13922. _getViewMatrix(): Matrix;
  13923. private _tmpMatrix;
  13924. /**
  13925. * This function is called by the two RIG cameras.
  13926. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  13927. * @hidden
  13928. */
  13929. _getWebVRViewMatrix(): Matrix;
  13930. /** @hidden */
  13931. _getWebVRProjectionMatrix(): Matrix;
  13932. private _onGamepadConnectedObserver;
  13933. private _onGamepadDisconnectedObserver;
  13934. private _updateCacheWhenTrackingDisabledObserver;
  13935. /**
  13936. * Initializes the controllers and their meshes
  13937. */
  13938. initControllers(): void;
  13939. }
  13940. }
  13941. declare module "babylonjs/PostProcesses/postProcess" {
  13942. import { Nullable } from "babylonjs/types";
  13943. import { SmartArray } from "babylonjs/Misc/smartArray";
  13944. import { Observable } from "babylonjs/Misc/observable";
  13945. import { Color4, Vector2 } from "babylonjs/Maths/math";
  13946. import { Camera } from "babylonjs/Cameras/camera";
  13947. import { Effect } from "babylonjs/Materials/effect";
  13948. import "babylonjs/Shaders/postprocess.vertex";
  13949. import { IInspectable } from "babylonjs/Misc/iInspectable";
  13950. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  13951. import { Engine } from "babylonjs/Engines/engine";
  13952. /**
  13953. * Size options for a post process
  13954. */
  13955. export type PostProcessOptions = {
  13956. width: number;
  13957. height: number;
  13958. };
  13959. /**
  13960. * PostProcess can be used to apply a shader to a texture after it has been rendered
  13961. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  13962. */
  13963. export class PostProcess {
  13964. /** Name of the PostProcess. */
  13965. name: string;
  13966. /**
  13967. * Gets or sets the unique id of the post process
  13968. */
  13969. uniqueId: number;
  13970. /**
  13971. * Width of the texture to apply the post process on
  13972. */
  13973. width: number;
  13974. /**
  13975. * Height of the texture to apply the post process on
  13976. */
  13977. height: number;
  13978. /**
  13979. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  13980. * @hidden
  13981. */
  13982. _outputTexture: Nullable<InternalTexture>;
  13983. /**
  13984. * Sampling mode used by the shader
  13985. * See https://doc.babylonjs.com/classes/3.1/texture
  13986. */
  13987. renderTargetSamplingMode: number;
  13988. /**
  13989. * Clear color to use when screen clearing
  13990. */
  13991. clearColor: Color4;
  13992. /**
  13993. * If the buffer needs to be cleared before applying the post process. (default: true)
  13994. * Should be set to false if shader will overwrite all previous pixels.
  13995. */
  13996. autoClear: boolean;
  13997. /**
  13998. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  13999. */
  14000. alphaMode: number;
  14001. /**
  14002. * Sets the setAlphaBlendConstants of the babylon engine
  14003. */
  14004. alphaConstants: Color4;
  14005. /**
  14006. * Animations to be used for the post processing
  14007. */
  14008. animations: import("babylonjs/Animations/animation").Animation[];
  14009. /**
  14010. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  14011. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  14012. */
  14013. enablePixelPerfectMode: boolean;
  14014. /**
  14015. * Force the postprocess to be applied without taking in account viewport
  14016. */
  14017. forceFullscreenViewport: boolean;
  14018. /**
  14019. * List of inspectable custom properties (used by the Inspector)
  14020. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  14021. */
  14022. inspectableCustomProperties: IInspectable[];
  14023. /**
  14024. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  14025. *
  14026. * | Value | Type | Description |
  14027. * | ----- | ----------------------------------- | ----------- |
  14028. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  14029. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  14030. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  14031. *
  14032. */
  14033. scaleMode: number;
  14034. /**
  14035. * Force textures to be a power of two (default: false)
  14036. */
  14037. alwaysForcePOT: boolean;
  14038. private _samples;
  14039. /**
  14040. * Number of sample textures (default: 1)
  14041. */
  14042. samples: number;
  14043. /**
  14044. * Modify the scale of the post process to be the same as the viewport (default: false)
  14045. */
  14046. adaptScaleToCurrentViewport: boolean;
  14047. private _camera;
  14048. private _scene;
  14049. private _engine;
  14050. private _options;
  14051. private _reusable;
  14052. private _textureType;
  14053. /**
  14054. * Smart array of input and output textures for the post process.
  14055. * @hidden
  14056. */
  14057. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  14058. /**
  14059. * The index in _textures that corresponds to the output texture.
  14060. * @hidden
  14061. */
  14062. _currentRenderTextureInd: number;
  14063. private _effect;
  14064. private _samplers;
  14065. private _fragmentUrl;
  14066. private _vertexUrl;
  14067. private _parameters;
  14068. private _scaleRatio;
  14069. protected _indexParameters: any;
  14070. private _shareOutputWithPostProcess;
  14071. private _texelSize;
  14072. private _forcedOutputTexture;
  14073. /**
  14074. * Returns the fragment url or shader name used in the post process.
  14075. * @returns the fragment url or name in the shader store.
  14076. */
  14077. getEffectName(): string;
  14078. /**
  14079. * An event triggered when the postprocess is activated.
  14080. */
  14081. onActivateObservable: Observable<Camera>;
  14082. private _onActivateObserver;
  14083. /**
  14084. * A function that is added to the onActivateObservable
  14085. */
  14086. onActivate: Nullable<(camera: Camera) => void>;
  14087. /**
  14088. * An event triggered when the postprocess changes its size.
  14089. */
  14090. onSizeChangedObservable: Observable<PostProcess>;
  14091. private _onSizeChangedObserver;
  14092. /**
  14093. * A function that is added to the onSizeChangedObservable
  14094. */
  14095. onSizeChanged: (postProcess: PostProcess) => void;
  14096. /**
  14097. * An event triggered when the postprocess applies its effect.
  14098. */
  14099. onApplyObservable: Observable<Effect>;
  14100. private _onApplyObserver;
  14101. /**
  14102. * A function that is added to the onApplyObservable
  14103. */
  14104. onApply: (effect: Effect) => void;
  14105. /**
  14106. * An event triggered before rendering the postprocess
  14107. */
  14108. onBeforeRenderObservable: Observable<Effect>;
  14109. private _onBeforeRenderObserver;
  14110. /**
  14111. * A function that is added to the onBeforeRenderObservable
  14112. */
  14113. onBeforeRender: (effect: Effect) => void;
  14114. /**
  14115. * An event triggered after rendering the postprocess
  14116. */
  14117. onAfterRenderObservable: Observable<Effect>;
  14118. private _onAfterRenderObserver;
  14119. /**
  14120. * A function that is added to the onAfterRenderObservable
  14121. */
  14122. onAfterRender: (efect: Effect) => void;
  14123. /**
  14124. * 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
  14125. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  14126. */
  14127. inputTexture: InternalTexture;
  14128. /**
  14129. * Gets the camera which post process is applied to.
  14130. * @returns The camera the post process is applied to.
  14131. */
  14132. getCamera(): Camera;
  14133. /**
  14134. * Gets the texel size of the postprocess.
  14135. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  14136. */
  14137. readonly texelSize: Vector2;
  14138. /**
  14139. * Creates a new instance PostProcess
  14140. * @param name The name of the PostProcess.
  14141. * @param fragmentUrl The url of the fragment shader to be used.
  14142. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  14143. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  14144. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  14145. * @param camera The camera to apply the render pass to.
  14146. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  14147. * @param engine The engine which the post process will be applied. (default: current engine)
  14148. * @param reusable If the post process can be reused on the same frame. (default: false)
  14149. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  14150. * @param textureType Type of textures used when performing the post process. (default: 0)
  14151. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  14152. * @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
  14153. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  14154. */
  14155. constructor(
  14156. /** Name of the PostProcess. */
  14157. 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);
  14158. /**
  14159. * Gets a string idenfifying the name of the class
  14160. * @returns "PostProcess" string
  14161. */
  14162. getClassName(): string;
  14163. /**
  14164. * Gets the engine which this post process belongs to.
  14165. * @returns The engine the post process was enabled with.
  14166. */
  14167. getEngine(): Engine;
  14168. /**
  14169. * The effect that is created when initializing the post process.
  14170. * @returns The created effect corrisponding the the postprocess.
  14171. */
  14172. getEffect(): Effect;
  14173. /**
  14174. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  14175. * @param postProcess The post process to share the output with.
  14176. * @returns This post process.
  14177. */
  14178. shareOutputWith(postProcess: PostProcess): PostProcess;
  14179. /**
  14180. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  14181. * This should be called if the post process that shares output with this post process is disabled/disposed.
  14182. */
  14183. useOwnOutput(): void;
  14184. /**
  14185. * Updates the effect with the current post process compile time values and recompiles the shader.
  14186. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  14187. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  14188. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  14189. * @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
  14190. * @param onCompiled Called when the shader has been compiled.
  14191. * @param onError Called if there is an error when compiling a shader.
  14192. */
  14193. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  14194. /**
  14195. * The post process is reusable if it can be used multiple times within one frame.
  14196. * @returns If the post process is reusable
  14197. */
  14198. isReusable(): boolean;
  14199. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  14200. markTextureDirty(): void;
  14201. /**
  14202. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  14203. * 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.
  14204. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  14205. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  14206. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  14207. * @returns The target texture that was bound to be written to.
  14208. */
  14209. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  14210. /**
  14211. * If the post process is supported.
  14212. */
  14213. readonly isSupported: boolean;
  14214. /**
  14215. * The aspect ratio of the output texture.
  14216. */
  14217. readonly aspectRatio: number;
  14218. /**
  14219. * Get a value indicating if the post-process is ready to be used
  14220. * @returns true if the post-process is ready (shader is compiled)
  14221. */
  14222. isReady(): boolean;
  14223. /**
  14224. * Binds all textures and uniforms to the shader, this will be run on every pass.
  14225. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  14226. */
  14227. apply(): Nullable<Effect>;
  14228. private _disposeTextures;
  14229. /**
  14230. * Disposes the post process.
  14231. * @param camera The camera to dispose the post process on.
  14232. */
  14233. dispose(camera?: Camera): void;
  14234. }
  14235. }
  14236. declare module "babylonjs/PostProcesses/postProcessManager" {
  14237. import { Nullable } from "babylonjs/types";
  14238. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  14239. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  14240. import { Scene } from "babylonjs/scene";
  14241. /**
  14242. * PostProcessManager is used to manage one or more post processes or post process pipelines
  14243. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  14244. */
  14245. export class PostProcessManager {
  14246. private _scene;
  14247. private _indexBuffer;
  14248. private _vertexBuffers;
  14249. /**
  14250. * Creates a new instance PostProcess
  14251. * @param scene The scene that the post process is associated with.
  14252. */
  14253. constructor(scene: Scene);
  14254. private _prepareBuffers;
  14255. private _buildIndexBuffer;
  14256. /**
  14257. * Rebuilds the vertex buffers of the manager.
  14258. * @hidden
  14259. */
  14260. _rebuild(): void;
  14261. /**
  14262. * Prepares a frame to be run through a post process.
  14263. * @param sourceTexture The input texture to the post procesess. (default: null)
  14264. * @param postProcesses An array of post processes to be run. (default: null)
  14265. * @returns True if the post processes were able to be run.
  14266. * @hidden
  14267. */
  14268. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  14269. /**
  14270. * Manually render a set of post processes to a texture.
  14271. * @param postProcesses An array of post processes to be run.
  14272. * @param targetTexture The target texture to render to.
  14273. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  14274. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  14275. * @param lodLevel defines which lod of the texture to render to
  14276. */
  14277. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  14278. /**
  14279. * Finalize the result of the output of the postprocesses.
  14280. * @param doNotPresent If true the result will not be displayed to the screen.
  14281. * @param targetTexture The target texture to render to.
  14282. * @param faceIndex The index of the face to bind the target texture to.
  14283. * @param postProcesses The array of post processes to render.
  14284. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  14285. * @hidden
  14286. */
  14287. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  14288. /**
  14289. * Disposes of the post process manager.
  14290. */
  14291. dispose(): void;
  14292. }
  14293. }
  14294. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  14295. import { Scene } from "babylonjs/scene";
  14296. import { ISceneComponent } from "babylonjs/sceneComponent";
  14297. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  14298. module "babylonjs/abstractScene" {
  14299. interface AbstractScene {
  14300. /**
  14301. * The list of procedural textures added to the scene
  14302. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14303. */
  14304. proceduralTextures: Array<ProceduralTexture>;
  14305. }
  14306. }
  14307. /**
  14308. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  14309. * in a given scene.
  14310. */
  14311. export class ProceduralTextureSceneComponent implements ISceneComponent {
  14312. /**
  14313. * The component name helpfull to identify the component in the list of scene components.
  14314. */
  14315. readonly name: string;
  14316. /**
  14317. * The scene the component belongs to.
  14318. */
  14319. scene: Scene;
  14320. /**
  14321. * Creates a new instance of the component for the given scene
  14322. * @param scene Defines the scene to register the component in
  14323. */
  14324. constructor(scene: Scene);
  14325. /**
  14326. * Registers the component in a given scene
  14327. */
  14328. register(): void;
  14329. /**
  14330. * Rebuilds the elements related to this component in case of
  14331. * context lost for instance.
  14332. */
  14333. rebuild(): void;
  14334. /**
  14335. * Disposes the component and the associated ressources.
  14336. */
  14337. dispose(): void;
  14338. private _beforeClear;
  14339. }
  14340. }
  14341. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  14342. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  14343. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  14344. module "babylonjs/Engines/engine" {
  14345. interface Engine {
  14346. /**
  14347. * Creates a new render target cube texture
  14348. * @param size defines the size of the texture
  14349. * @param options defines the options used to create the texture
  14350. * @returns a new render target cube texture stored in an InternalTexture
  14351. */
  14352. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  14353. }
  14354. }
  14355. }
  14356. declare module "babylonjs/Shaders/procedural.vertex" {
  14357. /** @hidden */
  14358. export var proceduralVertexShader: {
  14359. name: string;
  14360. shader: string;
  14361. };
  14362. }
  14363. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  14364. import { Observable } from "babylonjs/Misc/observable";
  14365. import { Nullable } from "babylonjs/types";
  14366. import { Scene } from "babylonjs/scene";
  14367. import { Matrix, Vector3, Vector2, Color3, Color4 } from "babylonjs/Maths/math";
  14368. import { Effect } from "babylonjs/Materials/effect";
  14369. import { Texture } from "babylonjs/Materials/Textures/texture";
  14370. import "babylonjs/Engines/Extensions/engine.renderTarget";
  14371. import "babylonjs/Shaders/procedural.vertex";
  14372. /**
  14373. * 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.
  14374. * This is the base class of any Procedural texture and contains most of the shareable code.
  14375. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14376. */
  14377. export class ProceduralTexture extends Texture {
  14378. isCube: boolean;
  14379. /**
  14380. * Define if the texture is enabled or not (disabled texture will not render)
  14381. */
  14382. isEnabled: boolean;
  14383. /**
  14384. * Define if the texture must be cleared before rendering (default is true)
  14385. */
  14386. autoClear: boolean;
  14387. /**
  14388. * Callback called when the texture is generated
  14389. */
  14390. onGenerated: () => void;
  14391. /**
  14392. * Event raised when the texture is generated
  14393. */
  14394. onGeneratedObservable: Observable<ProceduralTexture>;
  14395. /** @hidden */
  14396. _generateMipMaps: boolean;
  14397. /** @hidden **/
  14398. _effect: Effect;
  14399. /** @hidden */
  14400. _textures: {
  14401. [key: string]: Texture;
  14402. };
  14403. private _size;
  14404. private _currentRefreshId;
  14405. private _refreshRate;
  14406. private _vertexBuffers;
  14407. private _indexBuffer;
  14408. private _uniforms;
  14409. private _samplers;
  14410. private _fragment;
  14411. private _floats;
  14412. private _ints;
  14413. private _floatsArrays;
  14414. private _colors3;
  14415. private _colors4;
  14416. private _vectors2;
  14417. private _vectors3;
  14418. private _matrices;
  14419. private _fallbackTexture;
  14420. private _fallbackTextureUsed;
  14421. private _engine;
  14422. private _cachedDefines;
  14423. private _contentUpdateId;
  14424. private _contentData;
  14425. /**
  14426. * Instantiates a new procedural texture.
  14427. * 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.
  14428. * This is the base class of any Procedural texture and contains most of the shareable code.
  14429. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14430. * @param name Define the name of the texture
  14431. * @param size Define the size of the texture to create
  14432. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  14433. * @param scene Define the scene the texture belongs to
  14434. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  14435. * @param generateMipMaps Define if the texture should creates mip maps or not
  14436. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  14437. */
  14438. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  14439. /**
  14440. * The effect that is created when initializing the post process.
  14441. * @returns The created effect corrisponding the the postprocess.
  14442. */
  14443. getEffect(): Effect;
  14444. /**
  14445. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  14446. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  14447. */
  14448. getContent(): Nullable<ArrayBufferView>;
  14449. private _createIndexBuffer;
  14450. /** @hidden */
  14451. _rebuild(): void;
  14452. /**
  14453. * Resets the texture in order to recreate its associated resources.
  14454. * This can be called in case of context loss
  14455. */
  14456. reset(): void;
  14457. protected _getDefines(): string;
  14458. /**
  14459. * Is the texture ready to be used ? (rendered at least once)
  14460. * @returns true if ready, otherwise, false.
  14461. */
  14462. isReady(): boolean;
  14463. /**
  14464. * Resets the refresh counter of the texture and start bak from scratch.
  14465. * Could be useful to regenerate the texture if it is setup to render only once.
  14466. */
  14467. resetRefreshCounter(): void;
  14468. /**
  14469. * Set the fragment shader to use in order to render the texture.
  14470. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  14471. */
  14472. setFragment(fragment: any): void;
  14473. /**
  14474. * Define the refresh rate of the texture or the rendering frequency.
  14475. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  14476. */
  14477. refreshRate: number;
  14478. /** @hidden */
  14479. _shouldRender(): boolean;
  14480. /**
  14481. * Get the size the texture is rendering at.
  14482. * @returns the size (texture is always squared)
  14483. */
  14484. getRenderSize(): number;
  14485. /**
  14486. * Resize the texture to new value.
  14487. * @param size Define the new size the texture should have
  14488. * @param generateMipMaps Define whether the new texture should create mip maps
  14489. */
  14490. resize(size: number, generateMipMaps: boolean): void;
  14491. private _checkUniform;
  14492. /**
  14493. * Set a texture in the shader program used to render.
  14494. * @param name Define the name of the uniform samplers as defined in the shader
  14495. * @param texture Define the texture to bind to this sampler
  14496. * @return the texture itself allowing "fluent" like uniform updates
  14497. */
  14498. setTexture(name: string, texture: Texture): ProceduralTexture;
  14499. /**
  14500. * Set a float in the shader.
  14501. * @param name Define the name of the uniform as defined in the shader
  14502. * @param value Define the value to give to the uniform
  14503. * @return the texture itself allowing "fluent" like uniform updates
  14504. */
  14505. setFloat(name: string, value: number): ProceduralTexture;
  14506. /**
  14507. * Set a int in the shader.
  14508. * @param name Define the name of the uniform as defined in the shader
  14509. * @param value Define the value to give to the uniform
  14510. * @return the texture itself allowing "fluent" like uniform updates
  14511. */
  14512. setInt(name: string, value: number): ProceduralTexture;
  14513. /**
  14514. * Set an array of floats in the shader.
  14515. * @param name Define the name of the uniform as defined in the shader
  14516. * @param value Define the value to give to the uniform
  14517. * @return the texture itself allowing "fluent" like uniform updates
  14518. */
  14519. setFloats(name: string, value: number[]): ProceduralTexture;
  14520. /**
  14521. * Set a vec3 in the shader from a Color3.
  14522. * @param name Define the name of the uniform as defined in the shader
  14523. * @param value Define the value to give to the uniform
  14524. * @return the texture itself allowing "fluent" like uniform updates
  14525. */
  14526. setColor3(name: string, value: Color3): ProceduralTexture;
  14527. /**
  14528. * Set a vec4 in the shader from a Color4.
  14529. * @param name Define the name of the uniform as defined in the shader
  14530. * @param value Define the value to give to the uniform
  14531. * @return the texture itself allowing "fluent" like uniform updates
  14532. */
  14533. setColor4(name: string, value: Color4): ProceduralTexture;
  14534. /**
  14535. * Set a vec2 in the shader from a Vector2.
  14536. * @param name Define the name of the uniform as defined in the shader
  14537. * @param value Define the value to give to the uniform
  14538. * @return the texture itself allowing "fluent" like uniform updates
  14539. */
  14540. setVector2(name: string, value: Vector2): ProceduralTexture;
  14541. /**
  14542. * Set a vec3 in the shader from a Vector3.
  14543. * @param name Define the name of the uniform as defined in the shader
  14544. * @param value Define the value to give to the uniform
  14545. * @return the texture itself allowing "fluent" like uniform updates
  14546. */
  14547. setVector3(name: string, value: Vector3): ProceduralTexture;
  14548. /**
  14549. * Set a mat4 in the shader from a MAtrix.
  14550. * @param name Define the name of the uniform as defined in the shader
  14551. * @param value Define the value to give to the uniform
  14552. * @return the texture itself allowing "fluent" like uniform updates
  14553. */
  14554. setMatrix(name: string, value: Matrix): ProceduralTexture;
  14555. /**
  14556. * Render the texture to its associated render target.
  14557. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  14558. */
  14559. render(useCameraPostProcess?: boolean): void;
  14560. /**
  14561. * Clone the texture.
  14562. * @returns the cloned texture
  14563. */
  14564. clone(): ProceduralTexture;
  14565. /**
  14566. * Dispose the texture and release its asoociated resources.
  14567. */
  14568. dispose(): void;
  14569. }
  14570. }
  14571. declare module "babylonjs/Particles/baseParticleSystem" {
  14572. import { Nullable } from "babylonjs/types";
  14573. import { Color4, Vector2, Vector3 } from "babylonjs/Maths/math";
  14574. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14575. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  14576. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  14577. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  14578. import { Scene } from "babylonjs/scene";
  14579. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/tools";
  14580. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  14581. import { Texture } from "babylonjs/Materials/Textures/texture";
  14582. import { Animation } from "babylonjs/Animations/animation";
  14583. /**
  14584. * This represents the base class for particle system in Babylon.
  14585. * 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.
  14586. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14587. * @example https://doc.babylonjs.com/babylon101/particles
  14588. */
  14589. export class BaseParticleSystem {
  14590. /**
  14591. * Source color is added to the destination color without alpha affecting the result
  14592. */
  14593. static BLENDMODE_ONEONE: number;
  14594. /**
  14595. * Blend current color and particle color using particle’s alpha
  14596. */
  14597. static BLENDMODE_STANDARD: number;
  14598. /**
  14599. * Add current color and particle color multiplied by particle’s alpha
  14600. */
  14601. static BLENDMODE_ADD: number;
  14602. /**
  14603. * Multiply current color with particle color
  14604. */
  14605. static BLENDMODE_MULTIPLY: number;
  14606. /**
  14607. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  14608. */
  14609. static BLENDMODE_MULTIPLYADD: number;
  14610. /**
  14611. * List of animations used by the particle system.
  14612. */
  14613. animations: Animation[];
  14614. /**
  14615. * The id of the Particle system.
  14616. */
  14617. id: string;
  14618. /**
  14619. * The friendly name of the Particle system.
  14620. */
  14621. name: string;
  14622. /**
  14623. * The rendering group used by the Particle system to chose when to render.
  14624. */
  14625. renderingGroupId: number;
  14626. /**
  14627. * The emitter represents the Mesh or position we are attaching the particle system to.
  14628. */
  14629. emitter: Nullable<AbstractMesh | Vector3>;
  14630. /**
  14631. * The maximum number of particles to emit per frame
  14632. */
  14633. emitRate: number;
  14634. /**
  14635. * If you want to launch only a few particles at once, that can be done, as well.
  14636. */
  14637. manualEmitCount: number;
  14638. /**
  14639. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14640. */
  14641. updateSpeed: number;
  14642. /**
  14643. * The amount of time the particle system is running (depends of the overall update speed).
  14644. */
  14645. targetStopDuration: number;
  14646. /**
  14647. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14648. */
  14649. disposeOnStop: boolean;
  14650. /**
  14651. * Minimum power of emitting particles.
  14652. */
  14653. minEmitPower: number;
  14654. /**
  14655. * Maximum power of emitting particles.
  14656. */
  14657. maxEmitPower: number;
  14658. /**
  14659. * Minimum life time of emitting particles.
  14660. */
  14661. minLifeTime: number;
  14662. /**
  14663. * Maximum life time of emitting particles.
  14664. */
  14665. maxLifeTime: number;
  14666. /**
  14667. * Minimum Size of emitting particles.
  14668. */
  14669. minSize: number;
  14670. /**
  14671. * Maximum Size of emitting particles.
  14672. */
  14673. maxSize: number;
  14674. /**
  14675. * Minimum scale of emitting particles on X axis.
  14676. */
  14677. minScaleX: number;
  14678. /**
  14679. * Maximum scale of emitting particles on X axis.
  14680. */
  14681. maxScaleX: number;
  14682. /**
  14683. * Minimum scale of emitting particles on Y axis.
  14684. */
  14685. minScaleY: number;
  14686. /**
  14687. * Maximum scale of emitting particles on Y axis.
  14688. */
  14689. maxScaleY: number;
  14690. /**
  14691. * Gets or sets the minimal initial rotation in radians.
  14692. */
  14693. minInitialRotation: number;
  14694. /**
  14695. * Gets or sets the maximal initial rotation in radians.
  14696. */
  14697. maxInitialRotation: number;
  14698. /**
  14699. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14700. */
  14701. minAngularSpeed: number;
  14702. /**
  14703. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14704. */
  14705. maxAngularSpeed: number;
  14706. /**
  14707. * The texture used to render each particle. (this can be a spritesheet)
  14708. */
  14709. particleTexture: Nullable<Texture>;
  14710. /**
  14711. * The layer mask we are rendering the particles through.
  14712. */
  14713. layerMask: number;
  14714. /**
  14715. * This can help using your own shader to render the particle system.
  14716. * The according effect will be created
  14717. */
  14718. customShader: any;
  14719. /**
  14720. * By default particle system starts as soon as they are created. This prevents the
  14721. * automatic start to happen and let you decide when to start emitting particles.
  14722. */
  14723. preventAutoStart: boolean;
  14724. private _noiseTexture;
  14725. /**
  14726. * Gets or sets a texture used to add random noise to particle positions
  14727. */
  14728. noiseTexture: Nullable<ProceduralTexture>;
  14729. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14730. noiseStrength: Vector3;
  14731. /**
  14732. * Callback triggered when the particle animation is ending.
  14733. */
  14734. onAnimationEnd: Nullable<() => void>;
  14735. /**
  14736. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  14737. */
  14738. blendMode: number;
  14739. /**
  14740. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  14741. * to override the particles.
  14742. */
  14743. forceDepthWrite: boolean;
  14744. /** 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 */
  14745. preWarmCycles: number;
  14746. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  14747. preWarmStepOffset: number;
  14748. /**
  14749. * 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)
  14750. */
  14751. spriteCellChangeSpeed: number;
  14752. /**
  14753. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14754. */
  14755. startSpriteCellID: number;
  14756. /**
  14757. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14758. */
  14759. endSpriteCellID: number;
  14760. /**
  14761. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14762. */
  14763. spriteCellWidth: number;
  14764. /**
  14765. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14766. */
  14767. spriteCellHeight: number;
  14768. /**
  14769. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14770. */
  14771. spriteRandomStartCell: boolean;
  14772. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14773. translationPivot: Vector2;
  14774. /** @hidden */
  14775. protected _isAnimationSheetEnabled: boolean;
  14776. /**
  14777. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14778. */
  14779. beginAnimationOnStart: boolean;
  14780. /**
  14781. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14782. */
  14783. beginAnimationFrom: number;
  14784. /**
  14785. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14786. */
  14787. beginAnimationTo: number;
  14788. /**
  14789. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14790. */
  14791. beginAnimationLoop: boolean;
  14792. /**
  14793. * Gets or sets a world offset applied to all particles
  14794. */
  14795. worldOffset: Vector3;
  14796. /**
  14797. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  14798. */
  14799. isAnimationSheetEnabled: boolean;
  14800. /**
  14801. * Get hosting scene
  14802. * @returns the scene
  14803. */
  14804. getScene(): Scene;
  14805. /**
  14806. * You can use gravity if you want to give an orientation to your particles.
  14807. */
  14808. gravity: Vector3;
  14809. protected _colorGradients: Nullable<Array<ColorGradient>>;
  14810. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  14811. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  14812. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  14813. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  14814. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  14815. protected _dragGradients: Nullable<Array<FactorGradient>>;
  14816. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  14817. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  14818. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  14819. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  14820. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  14821. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  14822. /**
  14823. * Defines the delay in milliseconds before starting the system (0 by default)
  14824. */
  14825. startDelay: number;
  14826. /**
  14827. * Gets the current list of drag gradients.
  14828. * You must use addDragGradient and removeDragGradient to udpate this list
  14829. * @returns the list of drag gradients
  14830. */
  14831. getDragGradients(): Nullable<Array<FactorGradient>>;
  14832. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14833. limitVelocityDamping: number;
  14834. /**
  14835. * Gets the current list of limit velocity gradients.
  14836. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14837. * @returns the list of limit velocity gradients
  14838. */
  14839. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14840. /**
  14841. * Gets the current list of color gradients.
  14842. * You must use addColorGradient and removeColorGradient to udpate this list
  14843. * @returns the list of color gradients
  14844. */
  14845. getColorGradients(): Nullable<Array<ColorGradient>>;
  14846. /**
  14847. * Gets the current list of size gradients.
  14848. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14849. * @returns the list of size gradients
  14850. */
  14851. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14852. /**
  14853. * Gets the current list of color remap gradients.
  14854. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14855. * @returns the list of color remap gradients
  14856. */
  14857. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14858. /**
  14859. * Gets the current list of alpha remap gradients.
  14860. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14861. * @returns the list of alpha remap gradients
  14862. */
  14863. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14864. /**
  14865. * Gets the current list of life time gradients.
  14866. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14867. * @returns the list of life time gradients
  14868. */
  14869. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14870. /**
  14871. * Gets the current list of angular speed gradients.
  14872. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14873. * @returns the list of angular speed gradients
  14874. */
  14875. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14876. /**
  14877. * Gets the current list of velocity gradients.
  14878. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14879. * @returns the list of velocity gradients
  14880. */
  14881. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14882. /**
  14883. * Gets the current list of start size gradients.
  14884. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14885. * @returns the list of start size gradients
  14886. */
  14887. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14888. /**
  14889. * Gets the current list of emit rate gradients.
  14890. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14891. * @returns the list of emit rate gradients
  14892. */
  14893. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14894. /**
  14895. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14896. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14897. */
  14898. direction1: Vector3;
  14899. /**
  14900. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14901. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14902. */
  14903. direction2: Vector3;
  14904. /**
  14905. * 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.
  14906. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14907. */
  14908. minEmitBox: Vector3;
  14909. /**
  14910. * 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.
  14911. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14912. */
  14913. maxEmitBox: Vector3;
  14914. /**
  14915. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14916. */
  14917. color1: Color4;
  14918. /**
  14919. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14920. */
  14921. color2: Color4;
  14922. /**
  14923. * Color the particle will have at the end of its lifetime
  14924. */
  14925. colorDead: Color4;
  14926. /**
  14927. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  14928. */
  14929. textureMask: Color4;
  14930. /**
  14931. * The particle emitter type defines the emitter used by the particle system.
  14932. * It can be for example box, sphere, or cone...
  14933. */
  14934. particleEmitterType: IParticleEmitterType;
  14935. /** @hidden */
  14936. _isSubEmitter: boolean;
  14937. /**
  14938. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14939. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14940. */
  14941. billboardMode: number;
  14942. protected _isBillboardBased: boolean;
  14943. /**
  14944. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  14945. */
  14946. isBillboardBased: boolean;
  14947. /**
  14948. * The scene the particle system belongs to.
  14949. */
  14950. protected _scene: Scene;
  14951. /**
  14952. * Local cache of defines for image processing.
  14953. */
  14954. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  14955. /**
  14956. * Default configuration related to image processing available in the standard Material.
  14957. */
  14958. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  14959. /**
  14960. * Gets the image processing configuration used either in this material.
  14961. */
  14962. /**
  14963. * Sets the Default image processing configuration used either in the this material.
  14964. *
  14965. * If sets to null, the scene one is in use.
  14966. */
  14967. imageProcessingConfiguration: ImageProcessingConfiguration;
  14968. /**
  14969. * Attaches a new image processing configuration to the Standard Material.
  14970. * @param configuration
  14971. */
  14972. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  14973. /** @hidden */
  14974. protected _reset(): void;
  14975. /** @hidden */
  14976. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  14977. /**
  14978. * Instantiates a particle system.
  14979. * 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.
  14980. * @param name The name of the particle system
  14981. */
  14982. constructor(name: string);
  14983. /**
  14984. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14985. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14986. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14987. * @returns the emitter
  14988. */
  14989. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14990. /**
  14991. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14992. * @param radius The radius of the hemisphere to emit from
  14993. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14994. * @returns the emitter
  14995. */
  14996. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  14997. /**
  14998. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14999. * @param radius The radius of the sphere to emit from
  15000. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  15001. * @returns the emitter
  15002. */
  15003. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  15004. /**
  15005. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  15006. * @param radius The radius of the sphere to emit from
  15007. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  15008. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  15009. * @returns the emitter
  15010. */
  15011. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  15012. /**
  15013. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  15014. * @param radius The radius of the emission cylinder
  15015. * @param height The height of the emission cylinder
  15016. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  15017. * @param directionRandomizer How much to randomize the particle direction [0-1]
  15018. * @returns the emitter
  15019. */
  15020. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  15021. /**
  15022. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  15023. * @param radius The radius of the cylinder to emit from
  15024. * @param height The height of the emission cylinder
  15025. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15026. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  15027. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  15028. * @returns the emitter
  15029. */
  15030. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  15031. /**
  15032. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  15033. * @param radius The radius of the cone to emit from
  15034. * @param angle The base angle of the cone
  15035. * @returns the emitter
  15036. */
  15037. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  15038. /**
  15039. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  15040. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  15041. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  15042. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  15043. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  15044. * @returns the emitter
  15045. */
  15046. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  15047. }
  15048. }
  15049. declare module "babylonjs/Particles/subEmitter" {
  15050. import { Scene } from "babylonjs/scene";
  15051. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  15052. /**
  15053. * Type of sub emitter
  15054. */
  15055. export enum SubEmitterType {
  15056. /**
  15057. * Attached to the particle over it's lifetime
  15058. */
  15059. ATTACHED = 0,
  15060. /**
  15061. * Created when the particle dies
  15062. */
  15063. END = 1
  15064. }
  15065. /**
  15066. * Sub emitter class used to emit particles from an existing particle
  15067. */
  15068. export class SubEmitter {
  15069. /**
  15070. * the particle system to be used by the sub emitter
  15071. */
  15072. particleSystem: ParticleSystem;
  15073. /**
  15074. * Type of the submitter (Default: END)
  15075. */
  15076. type: SubEmitterType;
  15077. /**
  15078. * 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)
  15079. * Note: This only is supported when using an emitter of type Mesh
  15080. */
  15081. inheritDirection: boolean;
  15082. /**
  15083. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  15084. */
  15085. inheritedVelocityAmount: number;
  15086. /**
  15087. * Creates a sub emitter
  15088. * @param particleSystem the particle system to be used by the sub emitter
  15089. */
  15090. constructor(
  15091. /**
  15092. * the particle system to be used by the sub emitter
  15093. */
  15094. particleSystem: ParticleSystem);
  15095. /**
  15096. * Clones the sub emitter
  15097. * @returns the cloned sub emitter
  15098. */
  15099. clone(): SubEmitter;
  15100. /**
  15101. * Serialize current object to a JSON object
  15102. * @returns the serialized object
  15103. */
  15104. serialize(): any;
  15105. /** @hidden */
  15106. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  15107. /**
  15108. * Creates a new SubEmitter from a serialized JSON version
  15109. * @param serializationObject defines the JSON object to read from
  15110. * @param scene defines the hosting scene
  15111. * @param rootUrl defines the rootUrl for data loading
  15112. * @returns a new SubEmitter
  15113. */
  15114. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  15115. /** Release associated resources */
  15116. dispose(): void;
  15117. }
  15118. }
  15119. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  15120. /** @hidden */
  15121. export var clipPlaneFragmentDeclaration: {
  15122. name: string;
  15123. shader: string;
  15124. };
  15125. }
  15126. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  15127. /** @hidden */
  15128. export var imageProcessingDeclaration: {
  15129. name: string;
  15130. shader: string;
  15131. };
  15132. }
  15133. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  15134. /** @hidden */
  15135. export var imageProcessingFunctions: {
  15136. name: string;
  15137. shader: string;
  15138. };
  15139. }
  15140. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  15141. /** @hidden */
  15142. export var clipPlaneFragment: {
  15143. name: string;
  15144. shader: string;
  15145. };
  15146. }
  15147. declare module "babylonjs/Shaders/particles.fragment" {
  15148. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  15149. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  15150. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  15151. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  15152. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  15153. /** @hidden */
  15154. export var particlesPixelShader: {
  15155. name: string;
  15156. shader: string;
  15157. };
  15158. }
  15159. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  15160. /** @hidden */
  15161. export var clipPlaneVertexDeclaration: {
  15162. name: string;
  15163. shader: string;
  15164. };
  15165. }
  15166. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  15167. /** @hidden */
  15168. export var clipPlaneVertex: {
  15169. name: string;
  15170. shader: string;
  15171. };
  15172. }
  15173. declare module "babylonjs/Shaders/particles.vertex" {
  15174. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  15175. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  15176. /** @hidden */
  15177. export var particlesVertexShader: {
  15178. name: string;
  15179. shader: string;
  15180. };
  15181. }
  15182. declare module "babylonjs/Particles/particleSystem" {
  15183. import { Nullable } from "babylonjs/types";
  15184. import { IAnimatable, FactorGradient, Color3Gradient } from "babylonjs/Misc/tools";
  15185. import { Observable } from "babylonjs/Misc/observable";
  15186. import { Color4, Color3, Vector3, Matrix } from "babylonjs/Maths/math";
  15187. import { Effect } from "babylonjs/Materials/effect";
  15188. import { Scene, IDisposable } from "babylonjs/scene";
  15189. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  15190. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  15191. import { Particle } from "babylonjs/Particles/particle";
  15192. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  15193. import "babylonjs/Shaders/particles.fragment";
  15194. import "babylonjs/Shaders/particles.vertex";
  15195. /**
  15196. * This represents a particle system in Babylon.
  15197. * 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.
  15198. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  15199. * @example https://doc.babylonjs.com/babylon101/particles
  15200. */
  15201. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  15202. /**
  15203. * Billboard mode will only apply to Y axis
  15204. */
  15205. static readonly BILLBOARDMODE_Y: number;
  15206. /**
  15207. * Billboard mode will apply to all axes
  15208. */
  15209. static readonly BILLBOARDMODE_ALL: number;
  15210. /**
  15211. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  15212. */
  15213. static readonly BILLBOARDMODE_STRETCHED: number;
  15214. /**
  15215. * This function can be defined to provide custom update for active particles.
  15216. * This function will be called instead of regular update (age, position, color, etc.).
  15217. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  15218. */
  15219. updateFunction: (particles: Particle[]) => void;
  15220. private _emitterWorldMatrix;
  15221. /**
  15222. * This function can be defined to specify initial direction for every new particle.
  15223. * It by default use the emitterType defined function
  15224. */
  15225. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  15226. /**
  15227. * This function can be defined to specify initial position for every new particle.
  15228. * It by default use the emitterType defined function
  15229. */
  15230. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  15231. /**
  15232. * @hidden
  15233. */
  15234. _inheritedVelocityOffset: Vector3;
  15235. /**
  15236. * An event triggered when the system is disposed
  15237. */
  15238. onDisposeObservable: Observable<ParticleSystem>;
  15239. private _onDisposeObserver;
  15240. /**
  15241. * Sets a callback that will be triggered when the system is disposed
  15242. */
  15243. onDispose: () => void;
  15244. private _particles;
  15245. private _epsilon;
  15246. private _capacity;
  15247. private _stockParticles;
  15248. private _newPartsExcess;
  15249. private _vertexData;
  15250. private _vertexBuffer;
  15251. private _vertexBuffers;
  15252. private _spriteBuffer;
  15253. private _indexBuffer;
  15254. private _effect;
  15255. private _customEffect;
  15256. private _cachedDefines;
  15257. private _scaledColorStep;
  15258. private _colorDiff;
  15259. private _scaledDirection;
  15260. private _scaledGravity;
  15261. private _currentRenderId;
  15262. private _alive;
  15263. private _useInstancing;
  15264. private _started;
  15265. private _stopped;
  15266. private _actualFrame;
  15267. private _scaledUpdateSpeed;
  15268. private _vertexBufferSize;
  15269. /** @hidden */
  15270. _currentEmitRateGradient: Nullable<FactorGradient>;
  15271. /** @hidden */
  15272. _currentEmitRate1: number;
  15273. /** @hidden */
  15274. _currentEmitRate2: number;
  15275. /** @hidden */
  15276. _currentStartSizeGradient: Nullable<FactorGradient>;
  15277. /** @hidden */
  15278. _currentStartSize1: number;
  15279. /** @hidden */
  15280. _currentStartSize2: number;
  15281. private readonly _rawTextureWidth;
  15282. private _rampGradientsTexture;
  15283. private _useRampGradients;
  15284. /** Gets or sets a boolean indicating that ramp gradients must be used
  15285. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  15286. */
  15287. useRampGradients: boolean;
  15288. /**
  15289. * 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.
  15290. * 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: [])
  15291. */
  15292. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  15293. private _subEmitters;
  15294. /**
  15295. * @hidden
  15296. * If the particle systems emitter should be disposed when the particle system is disposed
  15297. */
  15298. _disposeEmitterOnDispose: boolean;
  15299. /**
  15300. * The current active Sub-systems, this property is used by the root particle system only.
  15301. */
  15302. activeSubSystems: Array<ParticleSystem>;
  15303. private _rootParticleSystem;
  15304. /**
  15305. * Gets the current list of active particles
  15306. */
  15307. readonly particles: Particle[];
  15308. /**
  15309. * Returns the string "ParticleSystem"
  15310. * @returns a string containing the class name
  15311. */
  15312. getClassName(): string;
  15313. /**
  15314. * Instantiates a particle system.
  15315. * 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.
  15316. * @param name The name of the particle system
  15317. * @param capacity The max number of particles alive at the same time
  15318. * @param scene The scene the particle system belongs to
  15319. * @param customEffect a custom effect used to change the way particles are rendered by default
  15320. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  15321. * @param epsilon Offset used to render the particles
  15322. */
  15323. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  15324. private _addFactorGradient;
  15325. private _removeFactorGradient;
  15326. /**
  15327. * Adds a new life time gradient
  15328. * @param gradient defines the gradient to use (between 0 and 1)
  15329. * @param factor defines the life time factor to affect to the specified gradient
  15330. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15331. * @returns the current particle system
  15332. */
  15333. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15334. /**
  15335. * Remove a specific life time gradient
  15336. * @param gradient defines the gradient to remove
  15337. * @returns the current particle system
  15338. */
  15339. removeLifeTimeGradient(gradient: number): IParticleSystem;
  15340. /**
  15341. * Adds a new size gradient
  15342. * @param gradient defines the gradient to use (between 0 and 1)
  15343. * @param factor defines the size factor to affect to the specified gradient
  15344. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15345. * @returns the current particle system
  15346. */
  15347. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15348. /**
  15349. * Remove a specific size gradient
  15350. * @param gradient defines the gradient to remove
  15351. * @returns the current particle system
  15352. */
  15353. removeSizeGradient(gradient: number): IParticleSystem;
  15354. /**
  15355. * Adds a new color remap gradient
  15356. * @param gradient defines the gradient to use (between 0 and 1)
  15357. * @param min defines the color remap minimal range
  15358. * @param max defines the color remap maximal range
  15359. * @returns the current particle system
  15360. */
  15361. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15362. /**
  15363. * Remove a specific color remap gradient
  15364. * @param gradient defines the gradient to remove
  15365. * @returns the current particle system
  15366. */
  15367. removeColorRemapGradient(gradient: number): IParticleSystem;
  15368. /**
  15369. * Adds a new alpha remap gradient
  15370. * @param gradient defines the gradient to use (between 0 and 1)
  15371. * @param min defines the alpha remap minimal range
  15372. * @param max defines the alpha remap maximal range
  15373. * @returns the current particle system
  15374. */
  15375. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15376. /**
  15377. * Remove a specific alpha remap gradient
  15378. * @param gradient defines the gradient to remove
  15379. * @returns the current particle system
  15380. */
  15381. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  15382. /**
  15383. * Adds a new angular speed gradient
  15384. * @param gradient defines the gradient to use (between 0 and 1)
  15385. * @param factor defines the angular speed to affect to the specified gradient
  15386. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15387. * @returns the current particle system
  15388. */
  15389. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15390. /**
  15391. * Remove a specific angular speed gradient
  15392. * @param gradient defines the gradient to remove
  15393. * @returns the current particle system
  15394. */
  15395. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  15396. /**
  15397. * Adds a new velocity gradient
  15398. * @param gradient defines the gradient to use (between 0 and 1)
  15399. * @param factor defines the velocity to affect to the specified gradient
  15400. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15401. * @returns the current particle system
  15402. */
  15403. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15404. /**
  15405. * Remove a specific velocity gradient
  15406. * @param gradient defines the gradient to remove
  15407. * @returns the current particle system
  15408. */
  15409. removeVelocityGradient(gradient: number): IParticleSystem;
  15410. /**
  15411. * Adds a new limit velocity gradient
  15412. * @param gradient defines the gradient to use (between 0 and 1)
  15413. * @param factor defines the limit velocity value to affect to the specified gradient
  15414. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15415. * @returns the current particle system
  15416. */
  15417. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15418. /**
  15419. * Remove a specific limit velocity gradient
  15420. * @param gradient defines the gradient to remove
  15421. * @returns the current particle system
  15422. */
  15423. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  15424. /**
  15425. * Adds a new drag gradient
  15426. * @param gradient defines the gradient to use (between 0 and 1)
  15427. * @param factor defines the drag value to affect to the specified gradient
  15428. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15429. * @returns the current particle system
  15430. */
  15431. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15432. /**
  15433. * Remove a specific drag gradient
  15434. * @param gradient defines the gradient to remove
  15435. * @returns the current particle system
  15436. */
  15437. removeDragGradient(gradient: number): IParticleSystem;
  15438. /**
  15439. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  15440. * @param gradient defines the gradient to use (between 0 and 1)
  15441. * @param factor defines the emit rate value to affect to the specified gradient
  15442. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15443. * @returns the current particle system
  15444. */
  15445. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15446. /**
  15447. * Remove a specific emit rate gradient
  15448. * @param gradient defines the gradient to remove
  15449. * @returns the current particle system
  15450. */
  15451. removeEmitRateGradient(gradient: number): IParticleSystem;
  15452. /**
  15453. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  15454. * @param gradient defines the gradient to use (between 0 and 1)
  15455. * @param factor defines the start size value to affect to the specified gradient
  15456. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15457. * @returns the current particle system
  15458. */
  15459. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15460. /**
  15461. * Remove a specific start size gradient
  15462. * @param gradient defines the gradient to remove
  15463. * @returns the current particle system
  15464. */
  15465. removeStartSizeGradient(gradient: number): IParticleSystem;
  15466. private _createRampGradientTexture;
  15467. /**
  15468. * Gets the current list of ramp gradients.
  15469. * You must use addRampGradient and removeRampGradient to udpate this list
  15470. * @returns the list of ramp gradients
  15471. */
  15472. getRampGradients(): Nullable<Array<Color3Gradient>>;
  15473. /**
  15474. * Adds a new ramp gradient used to remap particle colors
  15475. * @param gradient defines the gradient to use (between 0 and 1)
  15476. * @param color defines the color to affect to the specified gradient
  15477. * @returns the current particle system
  15478. */
  15479. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  15480. /**
  15481. * Remove a specific ramp gradient
  15482. * @param gradient defines the gradient to remove
  15483. * @returns the current particle system
  15484. */
  15485. removeRampGradient(gradient: number): ParticleSystem;
  15486. /**
  15487. * Adds a new color gradient
  15488. * @param gradient defines the gradient to use (between 0 and 1)
  15489. * @param color1 defines the color to affect to the specified gradient
  15490. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  15491. * @returns this particle system
  15492. */
  15493. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  15494. /**
  15495. * Remove a specific color gradient
  15496. * @param gradient defines the gradient to remove
  15497. * @returns this particle system
  15498. */
  15499. removeColorGradient(gradient: number): IParticleSystem;
  15500. private _fetchR;
  15501. protected _reset(): void;
  15502. private _resetEffect;
  15503. private _createVertexBuffers;
  15504. private _createIndexBuffer;
  15505. /**
  15506. * Gets the maximum number of particles active at the same time.
  15507. * @returns The max number of active particles.
  15508. */
  15509. getCapacity(): number;
  15510. /**
  15511. * Gets whether there are still active particles in the system.
  15512. * @returns True if it is alive, otherwise false.
  15513. */
  15514. isAlive(): boolean;
  15515. /**
  15516. * Gets if the system has been started. (Note: this will still be true after stop is called)
  15517. * @returns True if it has been started, otherwise false.
  15518. */
  15519. isStarted(): boolean;
  15520. private _prepareSubEmitterInternalArray;
  15521. /**
  15522. * Starts the particle system and begins to emit
  15523. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  15524. */
  15525. start(delay?: number): void;
  15526. /**
  15527. * Stops the particle system.
  15528. * @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.
  15529. */
  15530. stop(stopSubEmitters?: boolean): void;
  15531. /**
  15532. * Remove all active particles
  15533. */
  15534. reset(): void;
  15535. /**
  15536. * @hidden (for internal use only)
  15537. */
  15538. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  15539. /**
  15540. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  15541. * Its lifetime will start back at 0.
  15542. */
  15543. recycleParticle: (particle: Particle) => void;
  15544. private _stopSubEmitters;
  15545. private _createParticle;
  15546. private _removeFromRoot;
  15547. private _emitFromParticle;
  15548. private _update;
  15549. /** @hidden */
  15550. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  15551. /** @hidden */
  15552. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  15553. /** @hidden */
  15554. private _getEffect;
  15555. /**
  15556. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  15557. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  15558. */
  15559. animate(preWarmOnly?: boolean): void;
  15560. private _appendParticleVertices;
  15561. /**
  15562. * Rebuilds the particle system.
  15563. */
  15564. rebuild(): void;
  15565. /**
  15566. * Is this system ready to be used/rendered
  15567. * @return true if the system is ready
  15568. */
  15569. isReady(): boolean;
  15570. private _render;
  15571. /**
  15572. * Renders the particle system in its current state.
  15573. * @returns the current number of particles
  15574. */
  15575. render(): number;
  15576. /**
  15577. * Disposes the particle system and free the associated resources
  15578. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  15579. */
  15580. dispose(disposeTexture?: boolean): void;
  15581. /**
  15582. * Clones the particle system.
  15583. * @param name The name of the cloned object
  15584. * @param newEmitter The new emitter to use
  15585. * @returns the cloned particle system
  15586. */
  15587. clone(name: string, newEmitter: any): ParticleSystem;
  15588. /**
  15589. * Serializes the particle system to a JSON object.
  15590. * @returns the JSON object
  15591. */
  15592. serialize(): any;
  15593. /** @hidden */
  15594. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  15595. /** @hidden */
  15596. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  15597. /**
  15598. * Parses a JSON object to create a particle system.
  15599. * @param parsedParticleSystem The JSON object to parse
  15600. * @param scene The scene to create the particle system in
  15601. * @param rootUrl The root url to use to load external dependencies like texture
  15602. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  15603. * @returns the Parsed particle system
  15604. */
  15605. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  15606. }
  15607. }
  15608. declare module "babylonjs/Particles/particle" {
  15609. import { Nullable } from "babylonjs/types";
  15610. import { Color4, Vector2, Vector3, Vector4 } from "babylonjs/Maths/math";
  15611. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  15612. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  15613. import { ColorGradient, FactorGradient } from "babylonjs/Misc/tools";
  15614. /**
  15615. * A particle represents one of the element emitted by a particle system.
  15616. * This is mainly define by its coordinates, direction, velocity and age.
  15617. */
  15618. export class Particle {
  15619. /**
  15620. * The particle system the particle belongs to.
  15621. */
  15622. particleSystem: ParticleSystem;
  15623. private static _Count;
  15624. /**
  15625. * Unique ID of the particle
  15626. */
  15627. id: number;
  15628. /**
  15629. * The world position of the particle in the scene.
  15630. */
  15631. position: Vector3;
  15632. /**
  15633. * The world direction of the particle in the scene.
  15634. */
  15635. direction: Vector3;
  15636. /**
  15637. * The color of the particle.
  15638. */
  15639. color: Color4;
  15640. /**
  15641. * The color change of the particle per step.
  15642. */
  15643. colorStep: Color4;
  15644. /**
  15645. * Defines how long will the life of the particle be.
  15646. */
  15647. lifeTime: number;
  15648. /**
  15649. * The current age of the particle.
  15650. */
  15651. age: number;
  15652. /**
  15653. * The current size of the particle.
  15654. */
  15655. size: number;
  15656. /**
  15657. * The current scale of the particle.
  15658. */
  15659. scale: Vector2;
  15660. /**
  15661. * The current angle of the particle.
  15662. */
  15663. angle: number;
  15664. /**
  15665. * Defines how fast is the angle changing.
  15666. */
  15667. angularSpeed: number;
  15668. /**
  15669. * Defines the cell index used by the particle to be rendered from a sprite.
  15670. */
  15671. cellIndex: number;
  15672. /**
  15673. * The information required to support color remapping
  15674. */
  15675. remapData: Vector4;
  15676. /** @hidden */
  15677. _randomCellOffset?: number;
  15678. /** @hidden */
  15679. _initialDirection: Nullable<Vector3>;
  15680. /** @hidden */
  15681. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  15682. /** @hidden */
  15683. _initialStartSpriteCellID: number;
  15684. /** @hidden */
  15685. _initialEndSpriteCellID: number;
  15686. /** @hidden */
  15687. _currentColorGradient: Nullable<ColorGradient>;
  15688. /** @hidden */
  15689. _currentColor1: Color4;
  15690. /** @hidden */
  15691. _currentColor2: Color4;
  15692. /** @hidden */
  15693. _currentSizeGradient: Nullable<FactorGradient>;
  15694. /** @hidden */
  15695. _currentSize1: number;
  15696. /** @hidden */
  15697. _currentSize2: number;
  15698. /** @hidden */
  15699. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  15700. /** @hidden */
  15701. _currentAngularSpeed1: number;
  15702. /** @hidden */
  15703. _currentAngularSpeed2: number;
  15704. /** @hidden */
  15705. _currentVelocityGradient: Nullable<FactorGradient>;
  15706. /** @hidden */
  15707. _currentVelocity1: number;
  15708. /** @hidden */
  15709. _currentVelocity2: number;
  15710. /** @hidden */
  15711. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  15712. /** @hidden */
  15713. _currentLimitVelocity1: number;
  15714. /** @hidden */
  15715. _currentLimitVelocity2: number;
  15716. /** @hidden */
  15717. _currentDragGradient: Nullable<FactorGradient>;
  15718. /** @hidden */
  15719. _currentDrag1: number;
  15720. /** @hidden */
  15721. _currentDrag2: number;
  15722. /** @hidden */
  15723. _randomNoiseCoordinates1: Vector3;
  15724. /** @hidden */
  15725. _randomNoiseCoordinates2: Vector3;
  15726. /**
  15727. * Creates a new instance Particle
  15728. * @param particleSystem the particle system the particle belongs to
  15729. */
  15730. constructor(
  15731. /**
  15732. * The particle system the particle belongs to.
  15733. */
  15734. particleSystem: ParticleSystem);
  15735. private updateCellInfoFromSystem;
  15736. /**
  15737. * Defines how the sprite cell index is updated for the particle
  15738. */
  15739. updateCellIndex(): void;
  15740. /** @hidden */
  15741. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  15742. /** @hidden */
  15743. _inheritParticleInfoToSubEmitters(): void;
  15744. /** @hidden */
  15745. _reset(): void;
  15746. /**
  15747. * Copy the properties of particle to another one.
  15748. * @param other the particle to copy the information to.
  15749. */
  15750. copyTo(other: Particle): void;
  15751. }
  15752. }
  15753. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  15754. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15755. import { Effect } from "babylonjs/Materials/effect";
  15756. import { Particle } from "babylonjs/Particles/particle";
  15757. /**
  15758. * Particle emitter represents a volume emitting particles.
  15759. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  15760. */
  15761. export interface IParticleEmitterType {
  15762. /**
  15763. * Called by the particle System when the direction is computed for the created particle.
  15764. * @param worldMatrix is the world matrix of the particle system
  15765. * @param directionToUpdate is the direction vector to update with the result
  15766. * @param particle is the particle we are computed the direction for
  15767. */
  15768. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15769. /**
  15770. * Called by the particle System when the position is computed for the created particle.
  15771. * @param worldMatrix is the world matrix of the particle system
  15772. * @param positionToUpdate is the position vector to update with the result
  15773. * @param particle is the particle we are computed the position for
  15774. */
  15775. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15776. /**
  15777. * Clones the current emitter and returns a copy of it
  15778. * @returns the new emitter
  15779. */
  15780. clone(): IParticleEmitterType;
  15781. /**
  15782. * Called by the GPUParticleSystem to setup the update shader
  15783. * @param effect defines the update shader
  15784. */
  15785. applyToShader(effect: Effect): void;
  15786. /**
  15787. * Returns a string to use to update the GPU particles update shader
  15788. * @returns the effect defines string
  15789. */
  15790. getEffectDefines(): string;
  15791. /**
  15792. * Returns a string representing the class name
  15793. * @returns a string containing the class name
  15794. */
  15795. getClassName(): string;
  15796. /**
  15797. * Serializes the particle system to a JSON object.
  15798. * @returns the JSON object
  15799. */
  15800. serialize(): any;
  15801. /**
  15802. * Parse properties from a JSON object
  15803. * @param serializationObject defines the JSON object
  15804. */
  15805. parse(serializationObject: any): void;
  15806. }
  15807. }
  15808. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  15809. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15810. import { Effect } from "babylonjs/Materials/effect";
  15811. import { Particle } from "babylonjs/Particles/particle";
  15812. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15813. /**
  15814. * Particle emitter emitting particles from the inside of a box.
  15815. * It emits the particles randomly between 2 given directions.
  15816. */
  15817. export class BoxParticleEmitter implements IParticleEmitterType {
  15818. /**
  15819. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15820. */
  15821. direction1: Vector3;
  15822. /**
  15823. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15824. */
  15825. direction2: Vector3;
  15826. /**
  15827. * 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.
  15828. */
  15829. minEmitBox: Vector3;
  15830. /**
  15831. * 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.
  15832. */
  15833. maxEmitBox: Vector3;
  15834. /**
  15835. * Creates a new instance BoxParticleEmitter
  15836. */
  15837. constructor();
  15838. /**
  15839. * Called by the particle System when the direction is computed for the created particle.
  15840. * @param worldMatrix is the world matrix of the particle system
  15841. * @param directionToUpdate is the direction vector to update with the result
  15842. * @param particle is the particle we are computed the direction for
  15843. */
  15844. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15845. /**
  15846. * Called by the particle System when the position is computed for the created particle.
  15847. * @param worldMatrix is the world matrix of the particle system
  15848. * @param positionToUpdate is the position vector to update with the result
  15849. * @param particle is the particle we are computed the position for
  15850. */
  15851. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15852. /**
  15853. * Clones the current emitter and returns a copy of it
  15854. * @returns the new emitter
  15855. */
  15856. clone(): BoxParticleEmitter;
  15857. /**
  15858. * Called by the GPUParticleSystem to setup the update shader
  15859. * @param effect defines the update shader
  15860. */
  15861. applyToShader(effect: Effect): void;
  15862. /**
  15863. * Returns a string to use to update the GPU particles update shader
  15864. * @returns a string containng the defines string
  15865. */
  15866. getEffectDefines(): string;
  15867. /**
  15868. * Returns the string "BoxParticleEmitter"
  15869. * @returns a string containing the class name
  15870. */
  15871. getClassName(): string;
  15872. /**
  15873. * Serializes the particle system to a JSON object.
  15874. * @returns the JSON object
  15875. */
  15876. serialize(): any;
  15877. /**
  15878. * Parse properties from a JSON object
  15879. * @param serializationObject defines the JSON object
  15880. */
  15881. parse(serializationObject: any): void;
  15882. }
  15883. }
  15884. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  15885. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15886. import { Effect } from "babylonjs/Materials/effect";
  15887. import { Particle } from "babylonjs/Particles/particle";
  15888. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15889. /**
  15890. * Particle emitter emitting particles from the inside of a cone.
  15891. * It emits the particles alongside the cone volume from the base to the particle.
  15892. * The emission direction might be randomized.
  15893. */
  15894. export class ConeParticleEmitter implements IParticleEmitterType {
  15895. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15896. directionRandomizer: number;
  15897. private _radius;
  15898. private _angle;
  15899. private _height;
  15900. /**
  15901. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  15902. */
  15903. radiusRange: number;
  15904. /**
  15905. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  15906. */
  15907. heightRange: number;
  15908. /**
  15909. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  15910. */
  15911. emitFromSpawnPointOnly: boolean;
  15912. /**
  15913. * Gets or sets the radius of the emission cone
  15914. */
  15915. radius: number;
  15916. /**
  15917. * Gets or sets the angle of the emission cone
  15918. */
  15919. angle: number;
  15920. private _buildHeight;
  15921. /**
  15922. * Creates a new instance ConeParticleEmitter
  15923. * @param radius the radius of the emission cone (1 by default)
  15924. * @param angle the cone base angle (PI by default)
  15925. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  15926. */
  15927. constructor(radius?: number, angle?: number,
  15928. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15929. directionRandomizer?: number);
  15930. /**
  15931. * Called by the particle System when the direction is computed for the created particle.
  15932. * @param worldMatrix is the world matrix of the particle system
  15933. * @param directionToUpdate is the direction vector to update with the result
  15934. * @param particle is the particle we are computed the direction for
  15935. */
  15936. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15937. /**
  15938. * Called by the particle System when the position is computed for the created particle.
  15939. * @param worldMatrix is the world matrix of the particle system
  15940. * @param positionToUpdate is the position vector to update with the result
  15941. * @param particle is the particle we are computed the position for
  15942. */
  15943. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15944. /**
  15945. * Clones the current emitter and returns a copy of it
  15946. * @returns the new emitter
  15947. */
  15948. clone(): ConeParticleEmitter;
  15949. /**
  15950. * Called by the GPUParticleSystem to setup the update shader
  15951. * @param effect defines the update shader
  15952. */
  15953. applyToShader(effect: Effect): void;
  15954. /**
  15955. * Returns a string to use to update the GPU particles update shader
  15956. * @returns a string containng the defines string
  15957. */
  15958. getEffectDefines(): string;
  15959. /**
  15960. * Returns the string "ConeParticleEmitter"
  15961. * @returns a string containing the class name
  15962. */
  15963. getClassName(): string;
  15964. /**
  15965. * Serializes the particle system to a JSON object.
  15966. * @returns the JSON object
  15967. */
  15968. serialize(): any;
  15969. /**
  15970. * Parse properties from a JSON object
  15971. * @param serializationObject defines the JSON object
  15972. */
  15973. parse(serializationObject: any): void;
  15974. }
  15975. }
  15976. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  15977. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15978. import { Effect } from "babylonjs/Materials/effect";
  15979. import { Particle } from "babylonjs/Particles/particle";
  15980. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15981. /**
  15982. * Particle emitter emitting particles from the inside of a cylinder.
  15983. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  15984. */
  15985. export class CylinderParticleEmitter implements IParticleEmitterType {
  15986. /**
  15987. * The radius of the emission cylinder.
  15988. */
  15989. radius: number;
  15990. /**
  15991. * The height of the emission cylinder.
  15992. */
  15993. height: number;
  15994. /**
  15995. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15996. */
  15997. radiusRange: number;
  15998. /**
  15999. * How much to randomize the particle direction [0-1].
  16000. */
  16001. directionRandomizer: number;
  16002. /**
  16003. * Creates a new instance CylinderParticleEmitter
  16004. * @param radius the radius of the emission cylinder (1 by default)
  16005. * @param height the height of the emission cylinder (1 by default)
  16006. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16007. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16008. */
  16009. constructor(
  16010. /**
  16011. * The radius of the emission cylinder.
  16012. */
  16013. radius?: number,
  16014. /**
  16015. * The height of the emission cylinder.
  16016. */
  16017. height?: number,
  16018. /**
  16019. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16020. */
  16021. radiusRange?: number,
  16022. /**
  16023. * How much to randomize the particle direction [0-1].
  16024. */
  16025. directionRandomizer?: number);
  16026. /**
  16027. * Called by the particle System when the direction is computed for the created particle.
  16028. * @param worldMatrix is the world matrix of the particle system
  16029. * @param directionToUpdate is the direction vector to update with the result
  16030. * @param particle is the particle we are computed the direction for
  16031. */
  16032. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16033. /**
  16034. * Called by the particle System when the position is computed for the created particle.
  16035. * @param worldMatrix is the world matrix of the particle system
  16036. * @param positionToUpdate is the position vector to update with the result
  16037. * @param particle is the particle we are computed the position for
  16038. */
  16039. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  16040. /**
  16041. * Clones the current emitter and returns a copy of it
  16042. * @returns the new emitter
  16043. */
  16044. clone(): CylinderParticleEmitter;
  16045. /**
  16046. * Called by the GPUParticleSystem to setup the update shader
  16047. * @param effect defines the update shader
  16048. */
  16049. applyToShader(effect: Effect): void;
  16050. /**
  16051. * Returns a string to use to update the GPU particles update shader
  16052. * @returns a string containng the defines string
  16053. */
  16054. getEffectDefines(): string;
  16055. /**
  16056. * Returns the string "CylinderParticleEmitter"
  16057. * @returns a string containing the class name
  16058. */
  16059. getClassName(): string;
  16060. /**
  16061. * Serializes the particle system to a JSON object.
  16062. * @returns the JSON object
  16063. */
  16064. serialize(): any;
  16065. /**
  16066. * Parse properties from a JSON object
  16067. * @param serializationObject defines the JSON object
  16068. */
  16069. parse(serializationObject: any): void;
  16070. }
  16071. /**
  16072. * Particle emitter emitting particles from the inside of a cylinder.
  16073. * It emits the particles randomly between two vectors.
  16074. */
  16075. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  16076. /**
  16077. * The min limit of the emission direction.
  16078. */
  16079. direction1: Vector3;
  16080. /**
  16081. * The max limit of the emission direction.
  16082. */
  16083. direction2: Vector3;
  16084. /**
  16085. * Creates a new instance CylinderDirectedParticleEmitter
  16086. * @param radius the radius of the emission cylinder (1 by default)
  16087. * @param height the height of the emission cylinder (1 by default)
  16088. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16089. * @param direction1 the min limit of the emission direction (up vector by default)
  16090. * @param direction2 the max limit of the emission direction (up vector by default)
  16091. */
  16092. constructor(radius?: number, height?: number, radiusRange?: number,
  16093. /**
  16094. * The min limit of the emission direction.
  16095. */
  16096. direction1?: Vector3,
  16097. /**
  16098. * The max limit of the emission direction.
  16099. */
  16100. direction2?: Vector3);
  16101. /**
  16102. * Called by the particle System when the direction is computed for the created particle.
  16103. * @param worldMatrix is the world matrix of the particle system
  16104. * @param directionToUpdate is the direction vector to update with the result
  16105. * @param particle is the particle we are computed the direction for
  16106. */
  16107. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16108. /**
  16109. * Clones the current emitter and returns a copy of it
  16110. * @returns the new emitter
  16111. */
  16112. clone(): CylinderDirectedParticleEmitter;
  16113. /**
  16114. * Called by the GPUParticleSystem to setup the update shader
  16115. * @param effect defines the update shader
  16116. */
  16117. applyToShader(effect: Effect): void;
  16118. /**
  16119. * Returns a string to use to update the GPU particles update shader
  16120. * @returns a string containng the defines string
  16121. */
  16122. getEffectDefines(): string;
  16123. /**
  16124. * Returns the string "CylinderDirectedParticleEmitter"
  16125. * @returns a string containing the class name
  16126. */
  16127. getClassName(): string;
  16128. /**
  16129. * Serializes the particle system to a JSON object.
  16130. * @returns the JSON object
  16131. */
  16132. serialize(): any;
  16133. /**
  16134. * Parse properties from a JSON object
  16135. * @param serializationObject defines the JSON object
  16136. */
  16137. parse(serializationObject: any): void;
  16138. }
  16139. }
  16140. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  16141. import { Vector3, Matrix } from "babylonjs/Maths/math";
  16142. import { Effect } from "babylonjs/Materials/effect";
  16143. import { Particle } from "babylonjs/Particles/particle";
  16144. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16145. /**
  16146. * Particle emitter emitting particles from the inside of a hemisphere.
  16147. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  16148. */
  16149. export class HemisphericParticleEmitter implements IParticleEmitterType {
  16150. /**
  16151. * The radius of the emission hemisphere.
  16152. */
  16153. radius: number;
  16154. /**
  16155. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16156. */
  16157. radiusRange: number;
  16158. /**
  16159. * How much to randomize the particle direction [0-1].
  16160. */
  16161. directionRandomizer: number;
  16162. /**
  16163. * Creates a new instance HemisphericParticleEmitter
  16164. * @param radius the radius of the emission hemisphere (1 by default)
  16165. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16166. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16167. */
  16168. constructor(
  16169. /**
  16170. * The radius of the emission hemisphere.
  16171. */
  16172. radius?: number,
  16173. /**
  16174. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16175. */
  16176. radiusRange?: number,
  16177. /**
  16178. * How much to randomize the particle direction [0-1].
  16179. */
  16180. directionRandomizer?: number);
  16181. /**
  16182. * Called by the particle System when the direction is computed for the created particle.
  16183. * @param worldMatrix is the world matrix of the particle system
  16184. * @param directionToUpdate is the direction vector to update with the result
  16185. * @param particle is the particle we are computed the direction for
  16186. */
  16187. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16188. /**
  16189. * Called by the particle System when the position is computed for the created particle.
  16190. * @param worldMatrix is the world matrix of the particle system
  16191. * @param positionToUpdate is the position vector to update with the result
  16192. * @param particle is the particle we are computed the position for
  16193. */
  16194. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  16195. /**
  16196. * Clones the current emitter and returns a copy of it
  16197. * @returns the new emitter
  16198. */
  16199. clone(): HemisphericParticleEmitter;
  16200. /**
  16201. * Called by the GPUParticleSystem to setup the update shader
  16202. * @param effect defines the update shader
  16203. */
  16204. applyToShader(effect: Effect): void;
  16205. /**
  16206. * Returns a string to use to update the GPU particles update shader
  16207. * @returns a string containng the defines string
  16208. */
  16209. getEffectDefines(): string;
  16210. /**
  16211. * Returns the string "HemisphericParticleEmitter"
  16212. * @returns a string containing the class name
  16213. */
  16214. getClassName(): string;
  16215. /**
  16216. * Serializes the particle system to a JSON object.
  16217. * @returns the JSON object
  16218. */
  16219. serialize(): any;
  16220. /**
  16221. * Parse properties from a JSON object
  16222. * @param serializationObject defines the JSON object
  16223. */
  16224. parse(serializationObject: any): void;
  16225. }
  16226. }
  16227. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  16228. import { Vector3, Matrix } from "babylonjs/Maths/math";
  16229. import { Effect } from "babylonjs/Materials/effect";
  16230. import { Particle } from "babylonjs/Particles/particle";
  16231. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16232. /**
  16233. * Particle emitter emitting particles from a point.
  16234. * It emits the particles randomly between 2 given directions.
  16235. */
  16236. export class PointParticleEmitter implements IParticleEmitterType {
  16237. /**
  16238. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16239. */
  16240. direction1: Vector3;
  16241. /**
  16242. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16243. */
  16244. direction2: Vector3;
  16245. /**
  16246. * Creates a new instance PointParticleEmitter
  16247. */
  16248. constructor();
  16249. /**
  16250. * Called by the particle System when the direction is computed for the created particle.
  16251. * @param worldMatrix is the world matrix of the particle system
  16252. * @param directionToUpdate is the direction vector to update with the result
  16253. * @param particle is the particle we are computed the direction for
  16254. */
  16255. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16256. /**
  16257. * Called by the particle System when the position is computed for the created particle.
  16258. * @param worldMatrix is the world matrix of the particle system
  16259. * @param positionToUpdate is the position vector to update with the result
  16260. * @param particle is the particle we are computed the position for
  16261. */
  16262. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  16263. /**
  16264. * Clones the current emitter and returns a copy of it
  16265. * @returns the new emitter
  16266. */
  16267. clone(): PointParticleEmitter;
  16268. /**
  16269. * Called by the GPUParticleSystem to setup the update shader
  16270. * @param effect defines the update shader
  16271. */
  16272. applyToShader(effect: Effect): void;
  16273. /**
  16274. * Returns a string to use to update the GPU particles update shader
  16275. * @returns a string containng the defines string
  16276. */
  16277. getEffectDefines(): string;
  16278. /**
  16279. * Returns the string "PointParticleEmitter"
  16280. * @returns a string containing the class name
  16281. */
  16282. getClassName(): string;
  16283. /**
  16284. * Serializes the particle system to a JSON object.
  16285. * @returns the JSON object
  16286. */
  16287. serialize(): any;
  16288. /**
  16289. * Parse properties from a JSON object
  16290. * @param serializationObject defines the JSON object
  16291. */
  16292. parse(serializationObject: any): void;
  16293. }
  16294. }
  16295. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  16296. import { Vector3, Matrix } from "babylonjs/Maths/math";
  16297. import { Effect } from "babylonjs/Materials/effect";
  16298. import { Particle } from "babylonjs/Particles/particle";
  16299. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16300. /**
  16301. * Particle emitter emitting particles from the inside of a sphere.
  16302. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  16303. */
  16304. export class SphereParticleEmitter implements IParticleEmitterType {
  16305. /**
  16306. * The radius of the emission sphere.
  16307. */
  16308. radius: number;
  16309. /**
  16310. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16311. */
  16312. radiusRange: number;
  16313. /**
  16314. * How much to randomize the particle direction [0-1].
  16315. */
  16316. directionRandomizer: number;
  16317. /**
  16318. * Creates a new instance SphereParticleEmitter
  16319. * @param radius the radius of the emission sphere (1 by default)
  16320. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16321. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16322. */
  16323. constructor(
  16324. /**
  16325. * The radius of the emission sphere.
  16326. */
  16327. radius?: number,
  16328. /**
  16329. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16330. */
  16331. radiusRange?: number,
  16332. /**
  16333. * How much to randomize the particle direction [0-1].
  16334. */
  16335. directionRandomizer?: number);
  16336. /**
  16337. * Called by the particle System when the direction is computed for the created particle.
  16338. * @param worldMatrix is the world matrix of the particle system
  16339. * @param directionToUpdate is the direction vector to update with the result
  16340. * @param particle is the particle we are computed the direction for
  16341. */
  16342. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16343. /**
  16344. * Called by the particle System when the position is computed for the created particle.
  16345. * @param worldMatrix is the world matrix of the particle system
  16346. * @param positionToUpdate is the position vector to update with the result
  16347. * @param particle is the particle we are computed the position for
  16348. */
  16349. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  16350. /**
  16351. * Clones the current emitter and returns a copy of it
  16352. * @returns the new emitter
  16353. */
  16354. clone(): SphereParticleEmitter;
  16355. /**
  16356. * Called by the GPUParticleSystem to setup the update shader
  16357. * @param effect defines the update shader
  16358. */
  16359. applyToShader(effect: Effect): void;
  16360. /**
  16361. * Returns a string to use to update the GPU particles update shader
  16362. * @returns a string containng the defines string
  16363. */
  16364. getEffectDefines(): string;
  16365. /**
  16366. * Returns the string "SphereParticleEmitter"
  16367. * @returns a string containing the class name
  16368. */
  16369. getClassName(): string;
  16370. /**
  16371. * Serializes the particle system to a JSON object.
  16372. * @returns the JSON object
  16373. */
  16374. serialize(): any;
  16375. /**
  16376. * Parse properties from a JSON object
  16377. * @param serializationObject defines the JSON object
  16378. */
  16379. parse(serializationObject: any): void;
  16380. }
  16381. /**
  16382. * Particle emitter emitting particles from the inside of a sphere.
  16383. * It emits the particles randomly between two vectors.
  16384. */
  16385. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  16386. /**
  16387. * The min limit of the emission direction.
  16388. */
  16389. direction1: Vector3;
  16390. /**
  16391. * The max limit of the emission direction.
  16392. */
  16393. direction2: Vector3;
  16394. /**
  16395. * Creates a new instance SphereDirectedParticleEmitter
  16396. * @param radius the radius of the emission sphere (1 by default)
  16397. * @param direction1 the min limit of the emission direction (up vector by default)
  16398. * @param direction2 the max limit of the emission direction (up vector by default)
  16399. */
  16400. constructor(radius?: number,
  16401. /**
  16402. * The min limit of the emission direction.
  16403. */
  16404. direction1?: Vector3,
  16405. /**
  16406. * The max limit of the emission direction.
  16407. */
  16408. direction2?: Vector3);
  16409. /**
  16410. * Called by the particle System when the direction is computed for the created particle.
  16411. * @param worldMatrix is the world matrix of the particle system
  16412. * @param directionToUpdate is the direction vector to update with the result
  16413. * @param particle is the particle we are computed the direction for
  16414. */
  16415. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16416. /**
  16417. * Clones the current emitter and returns a copy of it
  16418. * @returns the new emitter
  16419. */
  16420. clone(): SphereDirectedParticleEmitter;
  16421. /**
  16422. * Called by the GPUParticleSystem to setup the update shader
  16423. * @param effect defines the update shader
  16424. */
  16425. applyToShader(effect: Effect): void;
  16426. /**
  16427. * Returns a string to use to update the GPU particles update shader
  16428. * @returns a string containng the defines string
  16429. */
  16430. getEffectDefines(): string;
  16431. /**
  16432. * Returns the string "SphereDirectedParticleEmitter"
  16433. * @returns a string containing the class name
  16434. */
  16435. getClassName(): string;
  16436. /**
  16437. * Serializes the particle system to a JSON object.
  16438. * @returns the JSON object
  16439. */
  16440. serialize(): any;
  16441. /**
  16442. * Parse properties from a JSON object
  16443. * @param serializationObject defines the JSON object
  16444. */
  16445. parse(serializationObject: any): void;
  16446. }
  16447. }
  16448. declare module "babylonjs/Particles/EmitterTypes/index" {
  16449. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  16450. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  16451. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  16452. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  16453. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16454. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  16455. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  16456. }
  16457. declare module "babylonjs/Particles/IParticleSystem" {
  16458. import { Nullable } from "babylonjs/types";
  16459. import { Color4, Color3, Vector2, Vector3 } from "babylonjs/Maths/math";
  16460. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16461. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  16462. import { Texture } from "babylonjs/Materials/Textures/texture";
  16463. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  16464. import { Scene } from "babylonjs/scene";
  16465. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/tools";
  16466. import { Animation } from "babylonjs/Animations/animation";
  16467. /**
  16468. * Interface representing a particle system in Babylon.js.
  16469. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  16470. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  16471. */
  16472. export interface IParticleSystem {
  16473. /**
  16474. * List of animations used by the particle system.
  16475. */
  16476. animations: Animation[];
  16477. /**
  16478. * The id of the Particle system.
  16479. */
  16480. id: string;
  16481. /**
  16482. * The name of the Particle system.
  16483. */
  16484. name: string;
  16485. /**
  16486. * The emitter represents the Mesh or position we are attaching the particle system to.
  16487. */
  16488. emitter: Nullable<AbstractMesh | Vector3>;
  16489. /**
  16490. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  16491. */
  16492. isBillboardBased: boolean;
  16493. /**
  16494. * The rendering group used by the Particle system to chose when to render.
  16495. */
  16496. renderingGroupId: number;
  16497. /**
  16498. * The layer mask we are rendering the particles through.
  16499. */
  16500. layerMask: number;
  16501. /**
  16502. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16503. */
  16504. updateSpeed: number;
  16505. /**
  16506. * The amount of time the particle system is running (depends of the overall update speed).
  16507. */
  16508. targetStopDuration: number;
  16509. /**
  16510. * The texture used to render each particle. (this can be a spritesheet)
  16511. */
  16512. particleTexture: Nullable<Texture>;
  16513. /**
  16514. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  16515. */
  16516. blendMode: number;
  16517. /**
  16518. * Minimum life time of emitting particles.
  16519. */
  16520. minLifeTime: number;
  16521. /**
  16522. * Maximum life time of emitting particles.
  16523. */
  16524. maxLifeTime: number;
  16525. /**
  16526. * Minimum Size of emitting particles.
  16527. */
  16528. minSize: number;
  16529. /**
  16530. * Maximum Size of emitting particles.
  16531. */
  16532. maxSize: number;
  16533. /**
  16534. * Minimum scale of emitting particles on X axis.
  16535. */
  16536. minScaleX: number;
  16537. /**
  16538. * Maximum scale of emitting particles on X axis.
  16539. */
  16540. maxScaleX: number;
  16541. /**
  16542. * Minimum scale of emitting particles on Y axis.
  16543. */
  16544. minScaleY: number;
  16545. /**
  16546. * Maximum scale of emitting particles on Y axis.
  16547. */
  16548. maxScaleY: number;
  16549. /**
  16550. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16551. */
  16552. color1: Color4;
  16553. /**
  16554. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16555. */
  16556. color2: Color4;
  16557. /**
  16558. * Color the particle will have at the end of its lifetime.
  16559. */
  16560. colorDead: Color4;
  16561. /**
  16562. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  16563. */
  16564. emitRate: number;
  16565. /**
  16566. * You can use gravity if you want to give an orientation to your particles.
  16567. */
  16568. gravity: Vector3;
  16569. /**
  16570. * Minimum power of emitting particles.
  16571. */
  16572. minEmitPower: number;
  16573. /**
  16574. * Maximum power of emitting particles.
  16575. */
  16576. maxEmitPower: number;
  16577. /**
  16578. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16579. */
  16580. minAngularSpeed: number;
  16581. /**
  16582. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16583. */
  16584. maxAngularSpeed: number;
  16585. /**
  16586. * Gets or sets the minimal initial rotation in radians.
  16587. */
  16588. minInitialRotation: number;
  16589. /**
  16590. * Gets or sets the maximal initial rotation in radians.
  16591. */
  16592. maxInitialRotation: number;
  16593. /**
  16594. * The particle emitter type defines the emitter used by the particle system.
  16595. * It can be for example box, sphere, or cone...
  16596. */
  16597. particleEmitterType: Nullable<IParticleEmitterType>;
  16598. /**
  16599. * Defines the delay in milliseconds before starting the system (0 by default)
  16600. */
  16601. startDelay: number;
  16602. /**
  16603. * 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
  16604. */
  16605. preWarmCycles: number;
  16606. /**
  16607. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  16608. */
  16609. preWarmStepOffset: number;
  16610. /**
  16611. * 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)
  16612. */
  16613. spriteCellChangeSpeed: number;
  16614. /**
  16615. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16616. */
  16617. startSpriteCellID: number;
  16618. /**
  16619. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16620. */
  16621. endSpriteCellID: number;
  16622. /**
  16623. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16624. */
  16625. spriteCellWidth: number;
  16626. /**
  16627. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16628. */
  16629. spriteCellHeight: number;
  16630. /**
  16631. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16632. */
  16633. spriteRandomStartCell: boolean;
  16634. /**
  16635. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  16636. */
  16637. isAnimationSheetEnabled: boolean;
  16638. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16639. translationPivot: Vector2;
  16640. /**
  16641. * Gets or sets a texture used to add random noise to particle positions
  16642. */
  16643. noiseTexture: Nullable<BaseTexture>;
  16644. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16645. noiseStrength: Vector3;
  16646. /**
  16647. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16648. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16649. */
  16650. billboardMode: number;
  16651. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16652. limitVelocityDamping: number;
  16653. /**
  16654. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16655. */
  16656. beginAnimationOnStart: boolean;
  16657. /**
  16658. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16659. */
  16660. beginAnimationFrom: number;
  16661. /**
  16662. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16663. */
  16664. beginAnimationTo: number;
  16665. /**
  16666. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16667. */
  16668. beginAnimationLoop: boolean;
  16669. /**
  16670. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16671. */
  16672. disposeOnStop: boolean;
  16673. /**
  16674. * Gets the maximum number of particles active at the same time.
  16675. * @returns The max number of active particles.
  16676. */
  16677. getCapacity(): number;
  16678. /**
  16679. * Gets if the system has been started. (Note: this will still be true after stop is called)
  16680. * @returns True if it has been started, otherwise false.
  16681. */
  16682. isStarted(): boolean;
  16683. /**
  16684. * Animates the particle system for this frame.
  16685. */
  16686. animate(): void;
  16687. /**
  16688. * Renders the particle system in its current state.
  16689. * @returns the current number of particles
  16690. */
  16691. render(): number;
  16692. /**
  16693. * Dispose the particle system and frees its associated resources.
  16694. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  16695. */
  16696. dispose(disposeTexture?: boolean): void;
  16697. /**
  16698. * Clones the particle system.
  16699. * @param name The name of the cloned object
  16700. * @param newEmitter The new emitter to use
  16701. * @returns the cloned particle system
  16702. */
  16703. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  16704. /**
  16705. * Serializes the particle system to a JSON object.
  16706. * @returns the JSON object
  16707. */
  16708. serialize(): any;
  16709. /**
  16710. * Rebuild the particle system
  16711. */
  16712. rebuild(): void;
  16713. /**
  16714. * Starts the particle system and begins to emit
  16715. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  16716. */
  16717. start(delay?: number): void;
  16718. /**
  16719. * Stops the particle system.
  16720. */
  16721. stop(): void;
  16722. /**
  16723. * Remove all active particles
  16724. */
  16725. reset(): void;
  16726. /**
  16727. * Is this system ready to be used/rendered
  16728. * @return true if the system is ready
  16729. */
  16730. isReady(): boolean;
  16731. /**
  16732. * Adds a new color gradient
  16733. * @param gradient defines the gradient to use (between 0 and 1)
  16734. * @param color1 defines the color to affect to the specified gradient
  16735. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  16736. * @returns the current particle system
  16737. */
  16738. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  16739. /**
  16740. * Remove a specific color gradient
  16741. * @param gradient defines the gradient to remove
  16742. * @returns the current particle system
  16743. */
  16744. removeColorGradient(gradient: number): IParticleSystem;
  16745. /**
  16746. * Adds a new size gradient
  16747. * @param gradient defines the gradient to use (between 0 and 1)
  16748. * @param factor defines the size factor to affect to the specified gradient
  16749. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16750. * @returns the current particle system
  16751. */
  16752. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16753. /**
  16754. * Remove a specific size gradient
  16755. * @param gradient defines the gradient to remove
  16756. * @returns the current particle system
  16757. */
  16758. removeSizeGradient(gradient: number): IParticleSystem;
  16759. /**
  16760. * Gets the current list of color gradients.
  16761. * You must use addColorGradient and removeColorGradient to udpate this list
  16762. * @returns the list of color gradients
  16763. */
  16764. getColorGradients(): Nullable<Array<ColorGradient>>;
  16765. /**
  16766. * Gets the current list of size gradients.
  16767. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16768. * @returns the list of size gradients
  16769. */
  16770. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16771. /**
  16772. * Gets the current list of angular speed gradients.
  16773. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16774. * @returns the list of angular speed gradients
  16775. */
  16776. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16777. /**
  16778. * Adds a new angular speed gradient
  16779. * @param gradient defines the gradient to use (between 0 and 1)
  16780. * @param factor defines the angular speed to affect to the specified gradient
  16781. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16782. * @returns the current particle system
  16783. */
  16784. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16785. /**
  16786. * Remove a specific angular speed gradient
  16787. * @param gradient defines the gradient to remove
  16788. * @returns the current particle system
  16789. */
  16790. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  16791. /**
  16792. * Gets the current list of velocity gradients.
  16793. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16794. * @returns the list of velocity gradients
  16795. */
  16796. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16797. /**
  16798. * Adds a new velocity gradient
  16799. * @param gradient defines the gradient to use (between 0 and 1)
  16800. * @param factor defines the velocity to affect to the specified gradient
  16801. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16802. * @returns the current particle system
  16803. */
  16804. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16805. /**
  16806. * Remove a specific velocity gradient
  16807. * @param gradient defines the gradient to remove
  16808. * @returns the current particle system
  16809. */
  16810. removeVelocityGradient(gradient: number): IParticleSystem;
  16811. /**
  16812. * Gets the current list of limit velocity gradients.
  16813. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16814. * @returns the list of limit velocity gradients
  16815. */
  16816. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16817. /**
  16818. * Adds a new limit velocity gradient
  16819. * @param gradient defines the gradient to use (between 0 and 1)
  16820. * @param factor defines the limit velocity to affect to the specified gradient
  16821. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16822. * @returns the current particle system
  16823. */
  16824. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16825. /**
  16826. * Remove a specific limit velocity gradient
  16827. * @param gradient defines the gradient to remove
  16828. * @returns the current particle system
  16829. */
  16830. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  16831. /**
  16832. * Adds a new drag gradient
  16833. * @param gradient defines the gradient to use (between 0 and 1)
  16834. * @param factor defines the drag to affect to the specified gradient
  16835. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16836. * @returns the current particle system
  16837. */
  16838. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16839. /**
  16840. * Remove a specific drag gradient
  16841. * @param gradient defines the gradient to remove
  16842. * @returns the current particle system
  16843. */
  16844. removeDragGradient(gradient: number): IParticleSystem;
  16845. /**
  16846. * Gets the current list of drag gradients.
  16847. * You must use addDragGradient and removeDragGradient to udpate this list
  16848. * @returns the list of drag gradients
  16849. */
  16850. getDragGradients(): Nullable<Array<FactorGradient>>;
  16851. /**
  16852. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  16853. * @param gradient defines the gradient to use (between 0 and 1)
  16854. * @param factor defines the emit rate to affect to the specified gradient
  16855. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16856. * @returns the current particle system
  16857. */
  16858. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16859. /**
  16860. * Remove a specific emit rate gradient
  16861. * @param gradient defines the gradient to remove
  16862. * @returns the current particle system
  16863. */
  16864. removeEmitRateGradient(gradient: number): IParticleSystem;
  16865. /**
  16866. * Gets the current list of emit rate gradients.
  16867. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16868. * @returns the list of emit rate gradients
  16869. */
  16870. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16871. /**
  16872. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  16873. * @param gradient defines the gradient to use (between 0 and 1)
  16874. * @param factor defines the start size to affect to the specified gradient
  16875. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16876. * @returns the current particle system
  16877. */
  16878. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16879. /**
  16880. * Remove a specific start size gradient
  16881. * @param gradient defines the gradient to remove
  16882. * @returns the current particle system
  16883. */
  16884. removeStartSizeGradient(gradient: number): IParticleSystem;
  16885. /**
  16886. * Gets the current list of start size gradients.
  16887. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16888. * @returns the list of start size gradients
  16889. */
  16890. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16891. /**
  16892. * Adds a new life time gradient
  16893. * @param gradient defines the gradient to use (between 0 and 1)
  16894. * @param factor defines the life time factor to affect to the specified gradient
  16895. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16896. * @returns the current particle system
  16897. */
  16898. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16899. /**
  16900. * Remove a specific life time gradient
  16901. * @param gradient defines the gradient to remove
  16902. * @returns the current particle system
  16903. */
  16904. removeLifeTimeGradient(gradient: number): IParticleSystem;
  16905. /**
  16906. * Gets the current list of life time gradients.
  16907. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16908. * @returns the list of life time gradients
  16909. */
  16910. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16911. /**
  16912. * Gets the current list of color gradients.
  16913. * You must use addColorGradient and removeColorGradient to udpate this list
  16914. * @returns the list of color gradients
  16915. */
  16916. getColorGradients(): Nullable<Array<ColorGradient>>;
  16917. /**
  16918. * Adds a new ramp gradient used to remap particle colors
  16919. * @param gradient defines the gradient to use (between 0 and 1)
  16920. * @param color defines the color to affect to the specified gradient
  16921. * @returns the current particle system
  16922. */
  16923. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  16924. /**
  16925. * Gets the current list of ramp gradients.
  16926. * You must use addRampGradient and removeRampGradient to udpate this list
  16927. * @returns the list of ramp gradients
  16928. */
  16929. getRampGradients(): Nullable<Array<Color3Gradient>>;
  16930. /** Gets or sets a boolean indicating that ramp gradients must be used
  16931. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  16932. */
  16933. useRampGradients: boolean;
  16934. /**
  16935. * Adds a new color remap gradient
  16936. * @param gradient defines the gradient to use (between 0 and 1)
  16937. * @param min defines the color remap minimal range
  16938. * @param max defines the color remap maximal range
  16939. * @returns the current particle system
  16940. */
  16941. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16942. /**
  16943. * Gets the current list of color remap gradients.
  16944. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16945. * @returns the list of color remap gradients
  16946. */
  16947. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16948. /**
  16949. * Adds a new alpha remap gradient
  16950. * @param gradient defines the gradient to use (between 0 and 1)
  16951. * @param min defines the alpha remap minimal range
  16952. * @param max defines the alpha remap maximal range
  16953. * @returns the current particle system
  16954. */
  16955. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16956. /**
  16957. * Gets the current list of alpha remap gradients.
  16958. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16959. * @returns the list of alpha remap gradients
  16960. */
  16961. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16962. /**
  16963. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  16964. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16965. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16966. * @returns the emitter
  16967. */
  16968. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  16969. /**
  16970. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  16971. * @param radius The radius of the hemisphere to emit from
  16972. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16973. * @returns the emitter
  16974. */
  16975. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  16976. /**
  16977. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  16978. * @param radius The radius of the sphere to emit from
  16979. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16980. * @returns the emitter
  16981. */
  16982. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  16983. /**
  16984. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  16985. * @param radius The radius of the sphere to emit from
  16986. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  16987. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  16988. * @returns the emitter
  16989. */
  16990. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  16991. /**
  16992. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  16993. * @param radius The radius of the emission cylinder
  16994. * @param height The height of the emission cylinder
  16995. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  16996. * @param directionRandomizer How much to randomize the particle direction [0-1]
  16997. * @returns the emitter
  16998. */
  16999. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  17000. /**
  17001. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  17002. * @param radius The radius of the cylinder to emit from
  17003. * @param height The height of the emission cylinder
  17004. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17005. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  17006. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  17007. * @returns the emitter
  17008. */
  17009. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  17010. /**
  17011. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  17012. * @param radius The radius of the cone to emit from
  17013. * @param angle The base angle of the cone
  17014. * @returns the emitter
  17015. */
  17016. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  17017. /**
  17018. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  17019. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17020. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17021. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17022. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17023. * @returns the emitter
  17024. */
  17025. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  17026. /**
  17027. * Get hosting scene
  17028. * @returns the scene
  17029. */
  17030. getScene(): Scene;
  17031. }
  17032. }
  17033. declare module "babylonjs/Meshes/instancedMesh" {
  17034. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  17035. import { Vector3, Matrix } from "babylonjs/Maths/math";
  17036. import { Camera } from "babylonjs/Cameras/camera";
  17037. import { Node } from "babylonjs/node";
  17038. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17039. import { Mesh } from "babylonjs/Meshes/mesh";
  17040. import { Material } from "babylonjs/Materials/material";
  17041. import { Skeleton } from "babylonjs/Bones/skeleton";
  17042. import { Light } from "babylonjs/Lights/light";
  17043. /**
  17044. * Creates an instance based on a source mesh.
  17045. */
  17046. export class InstancedMesh extends AbstractMesh {
  17047. private _sourceMesh;
  17048. private _currentLOD;
  17049. /** @hidden */
  17050. _indexInSourceMeshInstanceArray: number;
  17051. constructor(name: string, source: Mesh);
  17052. /**
  17053. * Returns the string "InstancedMesh".
  17054. */
  17055. getClassName(): string;
  17056. /** Gets the list of lights affecting that mesh */
  17057. readonly lightSources: Light[];
  17058. _resyncLightSources(): void;
  17059. _resyncLighSource(light: Light): void;
  17060. _removeLightSource(light: Light): void;
  17061. /**
  17062. * If the source mesh receives shadows
  17063. */
  17064. readonly receiveShadows: boolean;
  17065. /**
  17066. * The material of the source mesh
  17067. */
  17068. readonly material: Nullable<Material>;
  17069. /**
  17070. * Visibility of the source mesh
  17071. */
  17072. readonly visibility: number;
  17073. /**
  17074. * Skeleton of the source mesh
  17075. */
  17076. readonly skeleton: Nullable<Skeleton>;
  17077. /**
  17078. * Rendering ground id of the source mesh
  17079. */
  17080. renderingGroupId: number;
  17081. /**
  17082. * Returns the total number of vertices (integer).
  17083. */
  17084. getTotalVertices(): number;
  17085. /**
  17086. * Returns a positive integer : the total number of indices in this mesh geometry.
  17087. * @returns the numner of indices or zero if the mesh has no geometry.
  17088. */
  17089. getTotalIndices(): number;
  17090. /**
  17091. * The source mesh of the instance
  17092. */
  17093. readonly sourceMesh: Mesh;
  17094. /**
  17095. * Is this node ready to be used/rendered
  17096. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  17097. * @return {boolean} is it ready
  17098. */
  17099. isReady(completeCheck?: boolean): boolean;
  17100. /**
  17101. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  17102. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  17103. * @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.
  17104. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  17105. */
  17106. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  17107. /**
  17108. * Sets the vertex data of the mesh geometry for the requested `kind`.
  17109. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  17110. * The `data` are either a numeric array either a Float32Array.
  17111. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  17112. * 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).
  17113. * Note that a new underlying VertexBuffer object is created each call.
  17114. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  17115. *
  17116. * Possible `kind` values :
  17117. * - VertexBuffer.PositionKind
  17118. * - VertexBuffer.UVKind
  17119. * - VertexBuffer.UV2Kind
  17120. * - VertexBuffer.UV3Kind
  17121. * - VertexBuffer.UV4Kind
  17122. * - VertexBuffer.UV5Kind
  17123. * - VertexBuffer.UV6Kind
  17124. * - VertexBuffer.ColorKind
  17125. * - VertexBuffer.MatricesIndicesKind
  17126. * - VertexBuffer.MatricesIndicesExtraKind
  17127. * - VertexBuffer.MatricesWeightsKind
  17128. * - VertexBuffer.MatricesWeightsExtraKind
  17129. *
  17130. * Returns the Mesh.
  17131. */
  17132. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  17133. /**
  17134. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  17135. * If the mesh has no geometry, it is simply returned as it is.
  17136. * The `data` are either a numeric array either a Float32Array.
  17137. * No new underlying VertexBuffer object is created.
  17138. * 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.
  17139. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  17140. *
  17141. * Possible `kind` values :
  17142. * - VertexBuffer.PositionKind
  17143. * - VertexBuffer.UVKind
  17144. * - VertexBuffer.UV2Kind
  17145. * - VertexBuffer.UV3Kind
  17146. * - VertexBuffer.UV4Kind
  17147. * - VertexBuffer.UV5Kind
  17148. * - VertexBuffer.UV6Kind
  17149. * - VertexBuffer.ColorKind
  17150. * - VertexBuffer.MatricesIndicesKind
  17151. * - VertexBuffer.MatricesIndicesExtraKind
  17152. * - VertexBuffer.MatricesWeightsKind
  17153. * - VertexBuffer.MatricesWeightsExtraKind
  17154. *
  17155. * Returns the Mesh.
  17156. */
  17157. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  17158. /**
  17159. * Sets the mesh indices.
  17160. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  17161. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  17162. * This method creates a new index buffer each call.
  17163. * Returns the Mesh.
  17164. */
  17165. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  17166. /**
  17167. * Boolean : True if the mesh owns the requested kind of data.
  17168. */
  17169. isVerticesDataPresent(kind: string): boolean;
  17170. /**
  17171. * Returns an array of indices (IndicesArray).
  17172. */
  17173. getIndices(): Nullable<IndicesArray>;
  17174. readonly _positions: Nullable<Vector3[]>;
  17175. /**
  17176. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  17177. * This means the mesh underlying bounding box and sphere are recomputed.
  17178. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  17179. * @returns the current mesh
  17180. */
  17181. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  17182. /** @hidden */
  17183. _preActivate(): InstancedMesh;
  17184. /** @hidden */
  17185. _activate(renderId: number, intermediateRendering: boolean): boolean;
  17186. /** @hidden */
  17187. _postActivate(): void;
  17188. getWorldMatrix(): Matrix;
  17189. readonly isAnInstance: boolean;
  17190. /**
  17191. * Returns the current associated LOD AbstractMesh.
  17192. */
  17193. getLOD(camera: Camera): AbstractMesh;
  17194. /** @hidden */
  17195. _syncSubMeshes(): InstancedMesh;
  17196. /** @hidden */
  17197. _generatePointsArray(): boolean;
  17198. /**
  17199. * Creates a new InstancedMesh from the current mesh.
  17200. * - name (string) : the cloned mesh name
  17201. * - newParent (optional Node) : the optional Node to parent the clone to.
  17202. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  17203. *
  17204. * Returns the clone.
  17205. */
  17206. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  17207. /**
  17208. * Disposes the InstancedMesh.
  17209. * Returns nothing.
  17210. */
  17211. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  17212. }
  17213. }
  17214. declare module "babylonjs/Materials/shaderMaterial" {
  17215. import { Scene } from "babylonjs/scene";
  17216. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  17217. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17218. import { Mesh } from "babylonjs/Meshes/mesh";
  17219. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  17220. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  17221. import { Texture } from "babylonjs/Materials/Textures/texture";
  17222. import { Material } from "babylonjs/Materials/material";
  17223. /**
  17224. * Defines the options associated with the creation of a shader material.
  17225. */
  17226. export interface IShaderMaterialOptions {
  17227. /**
  17228. * Does the material work in alpha blend mode
  17229. */
  17230. needAlphaBlending: boolean;
  17231. /**
  17232. * Does the material work in alpha test mode
  17233. */
  17234. needAlphaTesting: boolean;
  17235. /**
  17236. * The list of attribute names used in the shader
  17237. */
  17238. attributes: string[];
  17239. /**
  17240. * The list of unifrom names used in the shader
  17241. */
  17242. uniforms: string[];
  17243. /**
  17244. * The list of UBO names used in the shader
  17245. */
  17246. uniformBuffers: string[];
  17247. /**
  17248. * The list of sampler names used in the shader
  17249. */
  17250. samplers: string[];
  17251. /**
  17252. * The list of defines used in the shader
  17253. */
  17254. defines: string[];
  17255. }
  17256. /**
  17257. * 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.
  17258. *
  17259. * This returned material effects how the mesh will look based on the code in the shaders.
  17260. *
  17261. * @see http://doc.babylonjs.com/how_to/shader_material
  17262. */
  17263. export class ShaderMaterial extends Material {
  17264. private _shaderPath;
  17265. private _options;
  17266. private _textures;
  17267. private _textureArrays;
  17268. private _floats;
  17269. private _ints;
  17270. private _floatsArrays;
  17271. private _colors3;
  17272. private _colors3Arrays;
  17273. private _colors4;
  17274. private _vectors2;
  17275. private _vectors3;
  17276. private _vectors4;
  17277. private _matrices;
  17278. private _matrices3x3;
  17279. private _matrices2x2;
  17280. private _vectors2Arrays;
  17281. private _vectors3Arrays;
  17282. private _cachedWorldViewMatrix;
  17283. private _cachedWorldViewProjectionMatrix;
  17284. private _renderId;
  17285. /**
  17286. * Instantiate a new shader material.
  17287. * 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.
  17288. * This returned material effects how the mesh will look based on the code in the shaders.
  17289. * @see http://doc.babylonjs.com/how_to/shader_material
  17290. * @param name Define the name of the material in the scene
  17291. * @param scene Define the scene the material belongs to
  17292. * @param shaderPath Defines the route to the shader code in one of three ways:
  17293. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  17294. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  17295. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  17296. * @param options Define the options used to create the shader
  17297. */
  17298. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  17299. /**
  17300. * Gets the options used to compile the shader.
  17301. * They can be modified to trigger a new compilation
  17302. */
  17303. readonly options: IShaderMaterialOptions;
  17304. /**
  17305. * Gets the current class name of the material e.g. "ShaderMaterial"
  17306. * Mainly use in serialization.
  17307. * @returns the class name
  17308. */
  17309. getClassName(): string;
  17310. /**
  17311. * Specifies if the material will require alpha blending
  17312. * @returns a boolean specifying if alpha blending is needed
  17313. */
  17314. needAlphaBlending(): boolean;
  17315. /**
  17316. * Specifies if this material should be rendered in alpha test mode
  17317. * @returns a boolean specifying if an alpha test is needed.
  17318. */
  17319. needAlphaTesting(): boolean;
  17320. private _checkUniform;
  17321. /**
  17322. * Set a texture in the shader.
  17323. * @param name Define the name of the uniform samplers as defined in the shader
  17324. * @param texture Define the texture to bind to this sampler
  17325. * @return the material itself allowing "fluent" like uniform updates
  17326. */
  17327. setTexture(name: string, texture: Texture): ShaderMaterial;
  17328. /**
  17329. * Set a texture array in the shader.
  17330. * @param name Define the name of the uniform sampler array as defined in the shader
  17331. * @param textures Define the list of textures to bind to this sampler
  17332. * @return the material itself allowing "fluent" like uniform updates
  17333. */
  17334. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  17335. /**
  17336. * Set a float in the shader.
  17337. * @param name Define the name of the uniform as defined in the shader
  17338. * @param value Define the value to give to the uniform
  17339. * @return the material itself allowing "fluent" like uniform updates
  17340. */
  17341. setFloat(name: string, value: number): ShaderMaterial;
  17342. /**
  17343. * Set a int in the shader.
  17344. * @param name Define the name of the uniform as defined in the shader
  17345. * @param value Define the value to give to the uniform
  17346. * @return the material itself allowing "fluent" like uniform updates
  17347. */
  17348. setInt(name: string, value: number): ShaderMaterial;
  17349. /**
  17350. * Set an array of floats in the shader.
  17351. * @param name Define the name of the uniform as defined in the shader
  17352. * @param value Define the value to give to the uniform
  17353. * @return the material itself allowing "fluent" like uniform updates
  17354. */
  17355. setFloats(name: string, value: number[]): ShaderMaterial;
  17356. /**
  17357. * Set a vec3 in the shader from a Color3.
  17358. * @param name Define the name of the uniform as defined in the shader
  17359. * @param value Define the value to give to the uniform
  17360. * @return the material itself allowing "fluent" like uniform updates
  17361. */
  17362. setColor3(name: string, value: Color3): ShaderMaterial;
  17363. /**
  17364. * Set a vec3 array in the shader from a Color3 array.
  17365. * @param name Define the name of the uniform as defined in the shader
  17366. * @param value Define the value to give to the uniform
  17367. * @return the material itself allowing "fluent" like uniform updates
  17368. */
  17369. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  17370. /**
  17371. * Set a vec4 in the shader from a Color4.
  17372. * @param name Define the name of the uniform as defined in the shader
  17373. * @param value Define the value to give to the uniform
  17374. * @return the material itself allowing "fluent" like uniform updates
  17375. */
  17376. setColor4(name: string, value: Color4): ShaderMaterial;
  17377. /**
  17378. * Set a vec2 in the shader from a Vector2.
  17379. * @param name Define the name of the uniform as defined in the shader
  17380. * @param value Define the value to give to the uniform
  17381. * @return the material itself allowing "fluent" like uniform updates
  17382. */
  17383. setVector2(name: string, value: Vector2): ShaderMaterial;
  17384. /**
  17385. * Set a vec3 in the shader from a Vector3.
  17386. * @param name Define the name of the uniform as defined in the shader
  17387. * @param value Define the value to give to the uniform
  17388. * @return the material itself allowing "fluent" like uniform updates
  17389. */
  17390. setVector3(name: string, value: Vector3): ShaderMaterial;
  17391. /**
  17392. * Set a vec4 in the shader from a Vector4.
  17393. * @param name Define the name of the uniform as defined in the shader
  17394. * @param value Define the value to give to the uniform
  17395. * @return the material itself allowing "fluent" like uniform updates
  17396. */
  17397. setVector4(name: string, value: Vector4): ShaderMaterial;
  17398. /**
  17399. * Set a mat4 in the shader from a Matrix.
  17400. * @param name Define the name of the uniform as defined in the shader
  17401. * @param value Define the value to give to the uniform
  17402. * @return the material itself allowing "fluent" like uniform updates
  17403. */
  17404. setMatrix(name: string, value: Matrix): ShaderMaterial;
  17405. /**
  17406. * Set a mat3 in the shader from a Float32Array.
  17407. * @param name Define the name of the uniform as defined in the shader
  17408. * @param value Define the value to give to the uniform
  17409. * @return the material itself allowing "fluent" like uniform updates
  17410. */
  17411. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  17412. /**
  17413. * Set a mat2 in the shader from a Float32Array.
  17414. * @param name Define the name of the uniform as defined in the shader
  17415. * @param value Define the value to give to the uniform
  17416. * @return the material itself allowing "fluent" like uniform updates
  17417. */
  17418. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  17419. /**
  17420. * Set a vec2 array in the shader from a number array.
  17421. * @param name Define the name of the uniform as defined in the shader
  17422. * @param value Define the value to give to the uniform
  17423. * @return the material itself allowing "fluent" like uniform updates
  17424. */
  17425. setArray2(name: string, value: number[]): ShaderMaterial;
  17426. /**
  17427. * Set a vec3 array in the shader from a number array.
  17428. * @param name Define the name of the uniform as defined in the shader
  17429. * @param value Define the value to give to the uniform
  17430. * @return the material itself allowing "fluent" like uniform updates
  17431. */
  17432. setArray3(name: string, value: number[]): ShaderMaterial;
  17433. private _checkCache;
  17434. /**
  17435. * Specifies that the submesh is ready to be used
  17436. * @param mesh defines the mesh to check
  17437. * @param subMesh defines which submesh to check
  17438. * @param useInstances specifies that instances should be used
  17439. * @returns a boolean indicating that the submesh is ready or not
  17440. */
  17441. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  17442. /**
  17443. * Checks if the material is ready to render the requested mesh
  17444. * @param mesh Define the mesh to render
  17445. * @param useInstances Define whether or not the material is used with instances
  17446. * @returns true if ready, otherwise false
  17447. */
  17448. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  17449. /**
  17450. * Binds the world matrix to the material
  17451. * @param world defines the world transformation matrix
  17452. */
  17453. bindOnlyWorldMatrix(world: Matrix): void;
  17454. /**
  17455. * Binds the material to the mesh
  17456. * @param world defines the world transformation matrix
  17457. * @param mesh defines the mesh to bind the material to
  17458. */
  17459. bind(world: Matrix, mesh?: Mesh): void;
  17460. /**
  17461. * Gets the active textures from the material
  17462. * @returns an array of textures
  17463. */
  17464. getActiveTextures(): BaseTexture[];
  17465. /**
  17466. * Specifies if the material uses a texture
  17467. * @param texture defines the texture to check against the material
  17468. * @returns a boolean specifying if the material uses the texture
  17469. */
  17470. hasTexture(texture: BaseTexture): boolean;
  17471. /**
  17472. * Makes a duplicate of the material, and gives it a new name
  17473. * @param name defines the new name for the duplicated material
  17474. * @returns the cloned material
  17475. */
  17476. clone(name: string): ShaderMaterial;
  17477. /**
  17478. * Disposes the material
  17479. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  17480. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  17481. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  17482. */
  17483. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  17484. /**
  17485. * Serializes this material in a JSON representation
  17486. * @returns the serialized material object
  17487. */
  17488. serialize(): any;
  17489. /**
  17490. * Creates a shader material from parsed shader material data
  17491. * @param source defines the JSON represnetation of the material
  17492. * @param scene defines the hosting scene
  17493. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17494. * @returns a new material
  17495. */
  17496. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  17497. }
  17498. }
  17499. declare module "babylonjs/Shaders/color.fragment" {
  17500. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17501. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17502. /** @hidden */
  17503. export var colorPixelShader: {
  17504. name: string;
  17505. shader: string;
  17506. };
  17507. }
  17508. declare module "babylonjs/Shaders/color.vertex" {
  17509. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  17510. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17511. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  17512. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  17513. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  17514. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17515. /** @hidden */
  17516. export var colorVertexShader: {
  17517. name: string;
  17518. shader: string;
  17519. };
  17520. }
  17521. declare module "babylonjs/Meshes/linesMesh" {
  17522. import { Nullable } from "babylonjs/types";
  17523. import { Scene } from "babylonjs/scene";
  17524. import { Color3 } from "babylonjs/Maths/math";
  17525. import { Node } from "babylonjs/node";
  17526. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17527. import { Mesh } from "babylonjs/Meshes/mesh";
  17528. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  17529. import { Effect } from "babylonjs/Materials/effect";
  17530. import { Material } from "babylonjs/Materials/material";
  17531. import "babylonjs/Shaders/color.fragment";
  17532. import "babylonjs/Shaders/color.vertex";
  17533. /**
  17534. * Line mesh
  17535. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  17536. */
  17537. export class LinesMesh extends Mesh {
  17538. /**
  17539. * If vertex color should be applied to the mesh
  17540. */
  17541. readonly useVertexColor?: boolean | undefined;
  17542. /**
  17543. * If vertex alpha should be applied to the mesh
  17544. */
  17545. readonly useVertexAlpha?: boolean | undefined;
  17546. /**
  17547. * Color of the line (Default: White)
  17548. */
  17549. color: Color3;
  17550. /**
  17551. * Alpha of the line (Default: 1)
  17552. */
  17553. alpha: number;
  17554. /**
  17555. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17556. * This margin is expressed in world space coordinates, so its value may vary.
  17557. * Default value is 0.1
  17558. */
  17559. intersectionThreshold: number;
  17560. private _colorShader;
  17561. private color4;
  17562. /**
  17563. * Creates a new LinesMesh
  17564. * @param name defines the name
  17565. * @param scene defines the hosting scene
  17566. * @param parent defines the parent mesh if any
  17567. * @param source defines the optional source LinesMesh used to clone data from
  17568. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  17569. * When false, achieved by calling a clone(), also passing False.
  17570. * This will make creation of children, recursive.
  17571. * @param useVertexColor defines if this LinesMesh supports vertex color
  17572. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  17573. */
  17574. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  17575. /**
  17576. * If vertex color should be applied to the mesh
  17577. */
  17578. useVertexColor?: boolean | undefined,
  17579. /**
  17580. * If vertex alpha should be applied to the mesh
  17581. */
  17582. useVertexAlpha?: boolean | undefined);
  17583. private _addClipPlaneDefine;
  17584. private _removeClipPlaneDefine;
  17585. isReady(): boolean;
  17586. /**
  17587. * Returns the string "LineMesh"
  17588. */
  17589. getClassName(): string;
  17590. /**
  17591. * @hidden
  17592. */
  17593. /**
  17594. * @hidden
  17595. */
  17596. material: Material;
  17597. /**
  17598. * @hidden
  17599. */
  17600. readonly checkCollisions: boolean;
  17601. /** @hidden */
  17602. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  17603. /** @hidden */
  17604. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  17605. /**
  17606. * Disposes of the line mesh
  17607. * @param doNotRecurse If children should be disposed
  17608. */
  17609. dispose(doNotRecurse?: boolean): void;
  17610. /**
  17611. * Returns a new LineMesh object cloned from the current one.
  17612. */
  17613. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  17614. /**
  17615. * Creates a new InstancedLinesMesh object from the mesh model.
  17616. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  17617. * @param name defines the name of the new instance
  17618. * @returns a new InstancedLinesMesh
  17619. */
  17620. createInstance(name: string): InstancedLinesMesh;
  17621. }
  17622. /**
  17623. * Creates an instance based on a source LinesMesh
  17624. */
  17625. export class InstancedLinesMesh extends InstancedMesh {
  17626. /**
  17627. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17628. * This margin is expressed in world space coordinates, so its value may vary.
  17629. * Initilized with the intersectionThreshold value of the source LinesMesh
  17630. */
  17631. intersectionThreshold: number;
  17632. constructor(name: string, source: LinesMesh);
  17633. /**
  17634. * Returns the string "InstancedLinesMesh".
  17635. */
  17636. getClassName(): string;
  17637. }
  17638. }
  17639. declare module "babylonjs/Shaders/line.fragment" {
  17640. /** @hidden */
  17641. export var linePixelShader: {
  17642. name: string;
  17643. shader: string;
  17644. };
  17645. }
  17646. declare module "babylonjs/Shaders/line.vertex" {
  17647. /** @hidden */
  17648. export var lineVertexShader: {
  17649. name: string;
  17650. shader: string;
  17651. };
  17652. }
  17653. declare module "babylonjs/Rendering/edgesRenderer" {
  17654. import { Nullable } from "babylonjs/types";
  17655. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  17656. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17657. import { Vector3 } from "babylonjs/Maths/math";
  17658. import { IDisposable } from "babylonjs/scene";
  17659. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  17660. import "babylonjs/Shaders/line.fragment";
  17661. import "babylonjs/Shaders/line.vertex";
  17662. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  17663. module "babylonjs/Meshes/abstractMesh" {
  17664. interface AbstractMesh {
  17665. /**
  17666. * Gets the edgesRenderer associated with the mesh
  17667. */
  17668. edgesRenderer: Nullable<EdgesRenderer>;
  17669. }
  17670. }
  17671. module "babylonjs/Meshes/linesMesh" {
  17672. interface LinesMesh {
  17673. /**
  17674. * Enables the edge rendering mode on the mesh.
  17675. * This mode makes the mesh edges visible
  17676. * @param epsilon defines the maximal distance between two angles to detect a face
  17677. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17678. * @returns the currentAbstractMesh
  17679. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17680. */
  17681. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17682. }
  17683. }
  17684. module "babylonjs/Meshes/linesMesh" {
  17685. interface InstancedLinesMesh {
  17686. /**
  17687. * Enables the edge rendering mode on the mesh.
  17688. * This mode makes the mesh edges visible
  17689. * @param epsilon defines the maximal distance between two angles to detect a face
  17690. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17691. * @returns the current InstancedLinesMesh
  17692. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17693. */
  17694. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  17695. }
  17696. }
  17697. /**
  17698. * Defines the minimum contract an Edges renderer should follow.
  17699. */
  17700. export interface IEdgesRenderer extends IDisposable {
  17701. /**
  17702. * Gets or sets a boolean indicating if the edgesRenderer is active
  17703. */
  17704. isEnabled: boolean;
  17705. /**
  17706. * Renders the edges of the attached mesh,
  17707. */
  17708. render(): void;
  17709. /**
  17710. * Checks wether or not the edges renderer is ready to render.
  17711. * @return true if ready, otherwise false.
  17712. */
  17713. isReady(): boolean;
  17714. }
  17715. /**
  17716. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  17717. */
  17718. export class EdgesRenderer implements IEdgesRenderer {
  17719. /**
  17720. * Define the size of the edges with an orthographic camera
  17721. */
  17722. edgesWidthScalerForOrthographic: number;
  17723. /**
  17724. * Define the size of the edges with a perspective camera
  17725. */
  17726. edgesWidthScalerForPerspective: number;
  17727. protected _source: AbstractMesh;
  17728. protected _linesPositions: number[];
  17729. protected _linesNormals: number[];
  17730. protected _linesIndices: number[];
  17731. protected _epsilon: number;
  17732. protected _indicesCount: number;
  17733. protected _lineShader: ShaderMaterial;
  17734. protected _ib: DataBuffer;
  17735. protected _buffers: {
  17736. [key: string]: Nullable<VertexBuffer>;
  17737. };
  17738. protected _checkVerticesInsteadOfIndices: boolean;
  17739. private _meshRebuildObserver;
  17740. private _meshDisposeObserver;
  17741. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  17742. isEnabled: boolean;
  17743. /**
  17744. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  17745. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  17746. * @param source Mesh used to create edges
  17747. * @param epsilon sum of angles in adjacency to check for edge
  17748. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  17749. * @param generateEdgesLines - should generate Lines or only prepare resources.
  17750. */
  17751. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  17752. protected _prepareRessources(): void;
  17753. /** @hidden */
  17754. _rebuild(): void;
  17755. /**
  17756. * Releases the required resources for the edges renderer
  17757. */
  17758. dispose(): void;
  17759. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  17760. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  17761. /**
  17762. * Checks if the pair of p0 and p1 is en edge
  17763. * @param faceIndex
  17764. * @param edge
  17765. * @param faceNormals
  17766. * @param p0
  17767. * @param p1
  17768. * @private
  17769. */
  17770. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  17771. /**
  17772. * push line into the position, normal and index buffer
  17773. * @protected
  17774. */
  17775. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  17776. /**
  17777. * Generates lines edges from adjacencjes
  17778. * @private
  17779. */
  17780. _generateEdgesLines(): void;
  17781. /**
  17782. * Checks wether or not the edges renderer is ready to render.
  17783. * @return true if ready, otherwise false.
  17784. */
  17785. isReady(): boolean;
  17786. /**
  17787. * Renders the edges of the attached mesh,
  17788. */
  17789. render(): void;
  17790. }
  17791. /**
  17792. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17793. */
  17794. export class LineEdgesRenderer extends EdgesRenderer {
  17795. /**
  17796. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17797. * @param source LineMesh used to generate edges
  17798. * @param epsilon not important (specified angle for edge detection)
  17799. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17800. */
  17801. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17802. /**
  17803. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17804. */
  17805. _generateEdgesLines(): void;
  17806. }
  17807. }
  17808. declare module "babylonjs/Rendering/renderingGroup" {
  17809. import { SmartArray } from "babylonjs/Misc/smartArray";
  17810. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17811. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17812. import { Nullable } from "babylonjs/types";
  17813. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17814. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  17815. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17816. import { Material } from "babylonjs/Materials/material";
  17817. import { Scene } from "babylonjs/scene";
  17818. /**
  17819. * This represents the object necessary to create a rendering group.
  17820. * This is exclusively used and created by the rendering manager.
  17821. * To modify the behavior, you use the available helpers in your scene or meshes.
  17822. * @hidden
  17823. */
  17824. export class RenderingGroup {
  17825. index: number;
  17826. private static _zeroVector;
  17827. private _scene;
  17828. private _opaqueSubMeshes;
  17829. private _transparentSubMeshes;
  17830. private _alphaTestSubMeshes;
  17831. private _depthOnlySubMeshes;
  17832. private _particleSystems;
  17833. private _spriteManagers;
  17834. private _opaqueSortCompareFn;
  17835. private _alphaTestSortCompareFn;
  17836. private _transparentSortCompareFn;
  17837. private _renderOpaque;
  17838. private _renderAlphaTest;
  17839. private _renderTransparent;
  17840. /** @hidden */
  17841. _edgesRenderers: SmartArray<IEdgesRenderer>;
  17842. onBeforeTransparentRendering: () => void;
  17843. /**
  17844. * Set the opaque sort comparison function.
  17845. * If null the sub meshes will be render in the order they were created
  17846. */
  17847. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17848. /**
  17849. * Set the alpha test sort comparison function.
  17850. * If null the sub meshes will be render in the order they were created
  17851. */
  17852. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17853. /**
  17854. * Set the transparent sort comparison function.
  17855. * If null the sub meshes will be render in the order they were created
  17856. */
  17857. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17858. /**
  17859. * Creates a new rendering group.
  17860. * @param index The rendering group index
  17861. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17862. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17863. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17864. */
  17865. 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>);
  17866. /**
  17867. * Render all the sub meshes contained in the group.
  17868. * @param customRenderFunction Used to override the default render behaviour of the group.
  17869. * @returns true if rendered some submeshes.
  17870. */
  17871. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17872. /**
  17873. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17874. * @param subMeshes The submeshes to render
  17875. */
  17876. private renderOpaqueSorted;
  17877. /**
  17878. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17879. * @param subMeshes The submeshes to render
  17880. */
  17881. private renderAlphaTestSorted;
  17882. /**
  17883. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17884. * @param subMeshes The submeshes to render
  17885. */
  17886. private renderTransparentSorted;
  17887. /**
  17888. * Renders the submeshes in a specified order.
  17889. * @param subMeshes The submeshes to sort before render
  17890. * @param sortCompareFn The comparison function use to sort
  17891. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17892. * @param transparent Specifies to activate blending if true
  17893. */
  17894. private static renderSorted;
  17895. /**
  17896. * Renders the submeshes in the order they were dispatched (no sort applied).
  17897. * @param subMeshes The submeshes to render
  17898. */
  17899. private static renderUnsorted;
  17900. /**
  17901. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17902. * are rendered back to front if in the same alpha index.
  17903. *
  17904. * @param a The first submesh
  17905. * @param b The second submesh
  17906. * @returns The result of the comparison
  17907. */
  17908. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17909. /**
  17910. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17911. * are rendered back to front.
  17912. *
  17913. * @param a The first submesh
  17914. * @param b The second submesh
  17915. * @returns The result of the comparison
  17916. */
  17917. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17918. /**
  17919. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17920. * are rendered front to back (prevent overdraw).
  17921. *
  17922. * @param a The first submesh
  17923. * @param b The second submesh
  17924. * @returns The result of the comparison
  17925. */
  17926. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17927. /**
  17928. * Resets the different lists of submeshes to prepare a new frame.
  17929. */
  17930. prepare(): void;
  17931. dispose(): void;
  17932. /**
  17933. * Inserts the submesh in its correct queue depending on its material.
  17934. * @param subMesh The submesh to dispatch
  17935. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17936. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17937. */
  17938. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17939. dispatchSprites(spriteManager: ISpriteManager): void;
  17940. dispatchParticles(particleSystem: IParticleSystem): void;
  17941. private _renderParticles;
  17942. private _renderSprites;
  17943. }
  17944. }
  17945. declare module "babylonjs/Rendering/renderingManager" {
  17946. import { Nullable } from "babylonjs/types";
  17947. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17948. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17949. import { SmartArray } from "babylonjs/Misc/smartArray";
  17950. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17951. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17952. import { Material } from "babylonjs/Materials/material";
  17953. import { Scene } from "babylonjs/scene";
  17954. import { Camera } from "babylonjs/Cameras/camera";
  17955. /**
  17956. * Interface describing the different options available in the rendering manager
  17957. * regarding Auto Clear between groups.
  17958. */
  17959. export interface IRenderingManagerAutoClearSetup {
  17960. /**
  17961. * Defines whether or not autoclear is enable.
  17962. */
  17963. autoClear: boolean;
  17964. /**
  17965. * Defines whether or not to autoclear the depth buffer.
  17966. */
  17967. depth: boolean;
  17968. /**
  17969. * Defines whether or not to autoclear the stencil buffer.
  17970. */
  17971. stencil: boolean;
  17972. }
  17973. /**
  17974. * This class is used by the onRenderingGroupObservable
  17975. */
  17976. export class RenderingGroupInfo {
  17977. /**
  17978. * The Scene that being rendered
  17979. */
  17980. scene: Scene;
  17981. /**
  17982. * The camera currently used for the rendering pass
  17983. */
  17984. camera: Nullable<Camera>;
  17985. /**
  17986. * The ID of the renderingGroup being processed
  17987. */
  17988. renderingGroupId: number;
  17989. }
  17990. /**
  17991. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17992. * It is enable to manage the different groups as well as the different necessary sort functions.
  17993. * This should not be used directly aside of the few static configurations
  17994. */
  17995. export class RenderingManager {
  17996. /**
  17997. * The max id used for rendering groups (not included)
  17998. */
  17999. static MAX_RENDERINGGROUPS: number;
  18000. /**
  18001. * The min id used for rendering groups (included)
  18002. */
  18003. static MIN_RENDERINGGROUPS: number;
  18004. /**
  18005. * Used to globally prevent autoclearing scenes.
  18006. */
  18007. static AUTOCLEAR: boolean;
  18008. /**
  18009. * @hidden
  18010. */
  18011. _useSceneAutoClearSetup: boolean;
  18012. private _scene;
  18013. private _renderingGroups;
  18014. private _depthStencilBufferAlreadyCleaned;
  18015. private _autoClearDepthStencil;
  18016. private _customOpaqueSortCompareFn;
  18017. private _customAlphaTestSortCompareFn;
  18018. private _customTransparentSortCompareFn;
  18019. private _renderingGroupInfo;
  18020. /**
  18021. * Instantiates a new rendering group for a particular scene
  18022. * @param scene Defines the scene the groups belongs to
  18023. */
  18024. constructor(scene: Scene);
  18025. private _clearDepthStencilBuffer;
  18026. /**
  18027. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  18028. * @hidden
  18029. */
  18030. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  18031. /**
  18032. * Resets the different information of the group to prepare a new frame
  18033. * @hidden
  18034. */
  18035. reset(): void;
  18036. /**
  18037. * Dispose and release the group and its associated resources.
  18038. * @hidden
  18039. */
  18040. dispose(): void;
  18041. /**
  18042. * Clear the info related to rendering groups preventing retention points during dispose.
  18043. */
  18044. freeRenderingGroups(): void;
  18045. private _prepareRenderingGroup;
  18046. /**
  18047. * Add a sprite manager to the rendering manager in order to render it this frame.
  18048. * @param spriteManager Define the sprite manager to render
  18049. */
  18050. dispatchSprites(spriteManager: ISpriteManager): void;
  18051. /**
  18052. * Add a particle system to the rendering manager in order to render it this frame.
  18053. * @param particleSystem Define the particle system to render
  18054. */
  18055. dispatchParticles(particleSystem: IParticleSystem): void;
  18056. /**
  18057. * Add a submesh to the manager in order to render it this frame
  18058. * @param subMesh The submesh to dispatch
  18059. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  18060. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  18061. */
  18062. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  18063. /**
  18064. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  18065. * This allowed control for front to back rendering or reversly depending of the special needs.
  18066. *
  18067. * @param renderingGroupId The rendering group id corresponding to its index
  18068. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  18069. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  18070. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  18071. */
  18072. 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;
  18073. /**
  18074. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  18075. *
  18076. * @param renderingGroupId The rendering group id corresponding to its index
  18077. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  18078. * @param depth Automatically clears depth between groups if true and autoClear is true.
  18079. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  18080. */
  18081. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  18082. /**
  18083. * Gets the current auto clear configuration for one rendering group of the rendering
  18084. * manager.
  18085. * @param index the rendering group index to get the information for
  18086. * @returns The auto clear setup for the requested rendering group
  18087. */
  18088. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  18089. }
  18090. }
  18091. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  18092. import { Observable } from "babylonjs/Misc/observable";
  18093. import { SmartArray } from "babylonjs/Misc/smartArray";
  18094. import { Nullable } from "babylonjs/types";
  18095. import { Camera } from "babylonjs/Cameras/camera";
  18096. import { Scene } from "babylonjs/scene";
  18097. import { Matrix, Vector3, Color4 } from "babylonjs/Maths/math";
  18098. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  18099. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18100. import { SubMesh } from "babylonjs/Meshes/subMesh";
  18101. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  18102. import { Texture } from "babylonjs/Materials/Textures/texture";
  18103. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  18104. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  18105. import "babylonjs/Engines/Extensions/engine.renderTarget";
  18106. import { Engine } from "babylonjs/Engines/engine";
  18107. /**
  18108. * This Helps creating a texture that will be created from a camera in your scene.
  18109. * It is basically a dynamic texture that could be used to create special effects for instance.
  18110. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  18111. */
  18112. export class RenderTargetTexture extends Texture {
  18113. isCube: boolean;
  18114. /**
  18115. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  18116. */
  18117. static readonly REFRESHRATE_RENDER_ONCE: number;
  18118. /**
  18119. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  18120. */
  18121. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  18122. /**
  18123. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  18124. * the central point of your effect and can save a lot of performances.
  18125. */
  18126. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  18127. /**
  18128. * Use this predicate to dynamically define the list of mesh you want to render.
  18129. * If set, the renderList property will be overwritten.
  18130. */
  18131. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  18132. private _renderList;
  18133. /**
  18134. * Use this list to define the list of mesh you want to render.
  18135. */
  18136. renderList: Nullable<Array<AbstractMesh>>;
  18137. private _hookArray;
  18138. /**
  18139. * Define if particles should be rendered in your texture.
  18140. */
  18141. renderParticles: boolean;
  18142. /**
  18143. * Define if sprites should be rendered in your texture.
  18144. */
  18145. renderSprites: boolean;
  18146. /**
  18147. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  18148. */
  18149. coordinatesMode: number;
  18150. /**
  18151. * Define the camera used to render the texture.
  18152. */
  18153. activeCamera: Nullable<Camera>;
  18154. /**
  18155. * Override the render function of the texture with your own one.
  18156. */
  18157. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  18158. /**
  18159. * Define if camera post processes should be use while rendering the texture.
  18160. */
  18161. useCameraPostProcesses: boolean;
  18162. /**
  18163. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  18164. */
  18165. ignoreCameraViewport: boolean;
  18166. private _postProcessManager;
  18167. private _postProcesses;
  18168. private _resizeObserver;
  18169. /**
  18170. * An event triggered when the texture is unbind.
  18171. */
  18172. onBeforeBindObservable: Observable<RenderTargetTexture>;
  18173. /**
  18174. * An event triggered when the texture is unbind.
  18175. */
  18176. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  18177. private _onAfterUnbindObserver;
  18178. /**
  18179. * Set a after unbind callback in the texture.
  18180. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  18181. */
  18182. onAfterUnbind: () => void;
  18183. /**
  18184. * An event triggered before rendering the texture
  18185. */
  18186. onBeforeRenderObservable: Observable<number>;
  18187. private _onBeforeRenderObserver;
  18188. /**
  18189. * Set a before render callback in the texture.
  18190. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  18191. */
  18192. onBeforeRender: (faceIndex: number) => void;
  18193. /**
  18194. * An event triggered after rendering the texture
  18195. */
  18196. onAfterRenderObservable: Observable<number>;
  18197. private _onAfterRenderObserver;
  18198. /**
  18199. * Set a after render callback in the texture.
  18200. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  18201. */
  18202. onAfterRender: (faceIndex: number) => void;
  18203. /**
  18204. * An event triggered after the texture clear
  18205. */
  18206. onClearObservable: Observable<import("babylonjs/Engines/engine").Engine>;
  18207. private _onClearObserver;
  18208. /**
  18209. * Set a clear callback in the texture.
  18210. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  18211. */
  18212. onClear: (Engine: Engine) => void;
  18213. /**
  18214. * Define the clear color of the Render Target if it should be different from the scene.
  18215. */
  18216. clearColor: Color4;
  18217. protected _size: number | {
  18218. width: number;
  18219. height: number;
  18220. };
  18221. protected _initialSizeParameter: number | {
  18222. width: number;
  18223. height: number;
  18224. } | {
  18225. ratio: number;
  18226. };
  18227. protected _sizeRatio: Nullable<number>;
  18228. /** @hidden */
  18229. _generateMipMaps: boolean;
  18230. protected _renderingManager: RenderingManager;
  18231. /** @hidden */
  18232. _waitingRenderList: string[];
  18233. protected _doNotChangeAspectRatio: boolean;
  18234. protected _currentRefreshId: number;
  18235. protected _refreshRate: number;
  18236. protected _textureMatrix: Matrix;
  18237. protected _samples: number;
  18238. protected _renderTargetOptions: RenderTargetCreationOptions;
  18239. /**
  18240. * Gets render target creation options that were used.
  18241. */
  18242. readonly renderTargetOptions: RenderTargetCreationOptions;
  18243. protected _engine: Engine;
  18244. protected _onRatioRescale(): void;
  18245. /**
  18246. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  18247. * It must define where the camera used to render the texture is set
  18248. */
  18249. boundingBoxPosition: Vector3;
  18250. private _boundingBoxSize;
  18251. /**
  18252. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  18253. * When defined, the cubemap will switch to local mode
  18254. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  18255. * @example https://www.babylonjs-playground.com/#RNASML
  18256. */
  18257. boundingBoxSize: Vector3;
  18258. /**
  18259. * In case the RTT has been created with a depth texture, get the associated
  18260. * depth texture.
  18261. * Otherwise, return null.
  18262. */
  18263. depthStencilTexture: Nullable<InternalTexture>;
  18264. /**
  18265. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  18266. * or used a shadow, depth texture...
  18267. * @param name The friendly name of the texture
  18268. * @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)
  18269. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  18270. * @param generateMipMaps True if mip maps need to be generated after render.
  18271. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  18272. * @param type The type of the buffer in the RTT (int, half float, float...)
  18273. * @param isCube True if a cube texture needs to be created
  18274. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  18275. * @param generateDepthBuffer True to generate a depth buffer
  18276. * @param generateStencilBuffer True to generate a stencil buffer
  18277. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  18278. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  18279. * @param delayAllocation if the texture allocation should be delayed (default: false)
  18280. */
  18281. constructor(name: string, size: number | {
  18282. width: number;
  18283. height: number;
  18284. } | {
  18285. ratio: number;
  18286. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  18287. /**
  18288. * Creates a depth stencil texture.
  18289. * This is only available in WebGL 2 or with the depth texture extension available.
  18290. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  18291. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  18292. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  18293. */
  18294. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  18295. private _processSizeParameter;
  18296. /**
  18297. * Define the number of samples to use in case of MSAA.
  18298. * It defaults to one meaning no MSAA has been enabled.
  18299. */
  18300. samples: number;
  18301. /**
  18302. * Resets the refresh counter of the texture and start bak from scratch.
  18303. * Could be useful to regenerate the texture if it is setup to render only once.
  18304. */
  18305. resetRefreshCounter(): void;
  18306. /**
  18307. * Define the refresh rate of the texture or the rendering frequency.
  18308. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  18309. */
  18310. refreshRate: number;
  18311. /**
  18312. * Adds a post process to the render target rendering passes.
  18313. * @param postProcess define the post process to add
  18314. */
  18315. addPostProcess(postProcess: PostProcess): void;
  18316. /**
  18317. * Clear all the post processes attached to the render target
  18318. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  18319. */
  18320. clearPostProcesses(dispose?: boolean): void;
  18321. /**
  18322. * Remove one of the post process from the list of attached post processes to the texture
  18323. * @param postProcess define the post process to remove from the list
  18324. */
  18325. removePostProcess(postProcess: PostProcess): void;
  18326. /** @hidden */
  18327. _shouldRender(): boolean;
  18328. /**
  18329. * Gets the actual render size of the texture.
  18330. * @returns the width of the render size
  18331. */
  18332. getRenderSize(): number;
  18333. /**
  18334. * Gets the actual render width of the texture.
  18335. * @returns the width of the render size
  18336. */
  18337. getRenderWidth(): number;
  18338. /**
  18339. * Gets the actual render height of the texture.
  18340. * @returns the height of the render size
  18341. */
  18342. getRenderHeight(): number;
  18343. /**
  18344. * Get if the texture can be rescaled or not.
  18345. */
  18346. readonly canRescale: boolean;
  18347. /**
  18348. * Resize the texture using a ratio.
  18349. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  18350. */
  18351. scale(ratio: number): void;
  18352. /**
  18353. * Get the texture reflection matrix used to rotate/transform the reflection.
  18354. * @returns the reflection matrix
  18355. */
  18356. getReflectionTextureMatrix(): Matrix;
  18357. /**
  18358. * Resize the texture to a new desired size.
  18359. * Be carrefull as it will recreate all the data in the new texture.
  18360. * @param size Define the new size. It can be:
  18361. * - a number for squared texture,
  18362. * - an object containing { width: number, height: number }
  18363. * - or an object containing a ratio { ratio: number }
  18364. */
  18365. resize(size: number | {
  18366. width: number;
  18367. height: number;
  18368. } | {
  18369. ratio: number;
  18370. }): void;
  18371. /**
  18372. * Renders all the objects from the render list into the texture.
  18373. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  18374. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  18375. */
  18376. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  18377. private _bestReflectionRenderTargetDimension;
  18378. /**
  18379. * @hidden
  18380. * @param faceIndex face index to bind to if this is a cubetexture
  18381. */
  18382. _bindFrameBuffer(faceIndex?: number): void;
  18383. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  18384. private renderToTarget;
  18385. /**
  18386. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  18387. * This allowed control for front to back rendering or reversly depending of the special needs.
  18388. *
  18389. * @param renderingGroupId The rendering group id corresponding to its index
  18390. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  18391. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  18392. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  18393. */
  18394. 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;
  18395. /**
  18396. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  18397. *
  18398. * @param renderingGroupId The rendering group id corresponding to its index
  18399. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  18400. */
  18401. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  18402. /**
  18403. * Clones the texture.
  18404. * @returns the cloned texture
  18405. */
  18406. clone(): RenderTargetTexture;
  18407. /**
  18408. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  18409. * @returns The JSON representation of the texture
  18410. */
  18411. serialize(): any;
  18412. /**
  18413. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  18414. */
  18415. disposeFramebufferObjects(): void;
  18416. /**
  18417. * Dispose the texture and release its associated resources.
  18418. */
  18419. dispose(): void;
  18420. /** @hidden */
  18421. _rebuild(): void;
  18422. /**
  18423. * Clear the info related to rendering groups preventing retention point in material dispose.
  18424. */
  18425. freeRenderingGroups(): void;
  18426. /**
  18427. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  18428. * @returns the view count
  18429. */
  18430. getViewCount(): number;
  18431. }
  18432. }
  18433. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  18434. import { Scene } from "babylonjs/scene";
  18435. import { Plane } from "babylonjs/Maths/math";
  18436. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  18437. /**
  18438. * Mirror texture can be used to simulate the view from a mirror in a scene.
  18439. * It will dynamically be rendered every frame to adapt to the camera point of view.
  18440. * You can then easily use it as a reflectionTexture on a flat surface.
  18441. * In case the surface is not a plane, please consider relying on reflection probes.
  18442. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18443. */
  18444. export class MirrorTexture extends RenderTargetTexture {
  18445. private scene;
  18446. /**
  18447. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  18448. * 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.
  18449. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18450. */
  18451. mirrorPlane: Plane;
  18452. /**
  18453. * Define the blur ratio used to blur the reflection if needed.
  18454. */
  18455. blurRatio: number;
  18456. /**
  18457. * Define the adaptive blur kernel used to blur the reflection if needed.
  18458. * This will autocompute the closest best match for the `blurKernel`
  18459. */
  18460. adaptiveBlurKernel: number;
  18461. /**
  18462. * Define the blur kernel used to blur the reflection if needed.
  18463. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18464. */
  18465. blurKernel: number;
  18466. /**
  18467. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  18468. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18469. */
  18470. blurKernelX: number;
  18471. /**
  18472. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  18473. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18474. */
  18475. blurKernelY: number;
  18476. private _autoComputeBlurKernel;
  18477. protected _onRatioRescale(): void;
  18478. private _updateGammaSpace;
  18479. private _imageProcessingConfigChangeObserver;
  18480. private _transformMatrix;
  18481. private _mirrorMatrix;
  18482. private _savedViewMatrix;
  18483. private _blurX;
  18484. private _blurY;
  18485. private _adaptiveBlurKernel;
  18486. private _blurKernelX;
  18487. private _blurKernelY;
  18488. private _blurRatio;
  18489. /**
  18490. * Instantiates a Mirror Texture.
  18491. * Mirror texture can be used to simulate the view from a mirror in a scene.
  18492. * It will dynamically be rendered every frame to adapt to the camera point of view.
  18493. * You can then easily use it as a reflectionTexture on a flat surface.
  18494. * In case the surface is not a plane, please consider relying on reflection probes.
  18495. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18496. * @param name
  18497. * @param size
  18498. * @param scene
  18499. * @param generateMipMaps
  18500. * @param type
  18501. * @param samplingMode
  18502. * @param generateDepthBuffer
  18503. */
  18504. constructor(name: string, size: number | {
  18505. width: number;
  18506. height: number;
  18507. } | {
  18508. ratio: number;
  18509. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  18510. private _preparePostProcesses;
  18511. /**
  18512. * Clone the mirror texture.
  18513. * @returns the cloned texture
  18514. */
  18515. clone(): MirrorTexture;
  18516. /**
  18517. * Serialize the texture to a JSON representation you could use in Parse later on
  18518. * @returns the serialized JSON representation
  18519. */
  18520. serialize(): any;
  18521. /**
  18522. * Dispose the texture and release its associated resources.
  18523. */
  18524. dispose(): void;
  18525. }
  18526. }
  18527. declare module "babylonjs/Materials/Textures/texture" {
  18528. import { Observable } from "babylonjs/Misc/observable";
  18529. import { Nullable } from "babylonjs/types";
  18530. import { Scene } from "babylonjs/scene";
  18531. import { Matrix } from "babylonjs/Maths/math";
  18532. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  18533. import { IInspectable } from "babylonjs/Misc/iInspectable";
  18534. /**
  18535. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18536. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18537. */
  18538. export class Texture extends BaseTexture {
  18539. /** @hidden */
  18540. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  18541. /** @hidden */
  18542. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  18543. /** @hidden */
  18544. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  18545. /** nearest is mag = nearest and min = nearest and mip = linear */
  18546. static readonly NEAREST_SAMPLINGMODE: number;
  18547. /** nearest is mag = nearest and min = nearest and mip = linear */
  18548. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  18549. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18550. static readonly BILINEAR_SAMPLINGMODE: number;
  18551. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18552. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  18553. /** Trilinear is mag = linear and min = linear and mip = linear */
  18554. static readonly TRILINEAR_SAMPLINGMODE: number;
  18555. /** Trilinear is mag = linear and min = linear and mip = linear */
  18556. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  18557. /** mag = nearest and min = nearest and mip = nearest */
  18558. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  18559. /** mag = nearest and min = linear and mip = nearest */
  18560. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  18561. /** mag = nearest and min = linear and mip = linear */
  18562. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  18563. /** mag = nearest and min = linear and mip = none */
  18564. static readonly NEAREST_LINEAR: number;
  18565. /** mag = nearest and min = nearest and mip = none */
  18566. static readonly NEAREST_NEAREST: number;
  18567. /** mag = linear and min = nearest and mip = nearest */
  18568. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  18569. /** mag = linear and min = nearest and mip = linear */
  18570. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  18571. /** mag = linear and min = linear and mip = none */
  18572. static readonly LINEAR_LINEAR: number;
  18573. /** mag = linear and min = nearest and mip = none */
  18574. static readonly LINEAR_NEAREST: number;
  18575. /** Explicit coordinates mode */
  18576. static readonly EXPLICIT_MODE: number;
  18577. /** Spherical coordinates mode */
  18578. static readonly SPHERICAL_MODE: number;
  18579. /** Planar coordinates mode */
  18580. static readonly PLANAR_MODE: number;
  18581. /** Cubic coordinates mode */
  18582. static readonly CUBIC_MODE: number;
  18583. /** Projection coordinates mode */
  18584. static readonly PROJECTION_MODE: number;
  18585. /** Inverse Cubic coordinates mode */
  18586. static readonly SKYBOX_MODE: number;
  18587. /** Inverse Cubic coordinates mode */
  18588. static readonly INVCUBIC_MODE: number;
  18589. /** Equirectangular coordinates mode */
  18590. static readonly EQUIRECTANGULAR_MODE: number;
  18591. /** Equirectangular Fixed coordinates mode */
  18592. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  18593. /** Equirectangular Fixed Mirrored coordinates mode */
  18594. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  18595. /** Texture is not repeating outside of 0..1 UVs */
  18596. static readonly CLAMP_ADDRESSMODE: number;
  18597. /** Texture is repeating outside of 0..1 UVs */
  18598. static readonly WRAP_ADDRESSMODE: number;
  18599. /** Texture is repeating and mirrored */
  18600. static readonly MIRROR_ADDRESSMODE: number;
  18601. /**
  18602. * 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
  18603. */
  18604. static UseSerializedUrlIfAny: boolean;
  18605. /**
  18606. * Define the url of the texture.
  18607. */
  18608. url: Nullable<string>;
  18609. /**
  18610. * Define an offset on the texture to offset the u coordinates of the UVs
  18611. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18612. */
  18613. uOffset: number;
  18614. /**
  18615. * Define an offset on the texture to offset the v coordinates of the UVs
  18616. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18617. */
  18618. vOffset: number;
  18619. /**
  18620. * Define an offset on the texture to scale the u coordinates of the UVs
  18621. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18622. */
  18623. uScale: number;
  18624. /**
  18625. * Define an offset on the texture to scale the v coordinates of the UVs
  18626. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18627. */
  18628. vScale: number;
  18629. /**
  18630. * Define an offset on the texture to rotate around the u coordinates of the UVs
  18631. * @see http://doc.babylonjs.com/how_to/more_materials
  18632. */
  18633. uAng: number;
  18634. /**
  18635. * Define an offset on the texture to rotate around the v coordinates of the UVs
  18636. * @see http://doc.babylonjs.com/how_to/more_materials
  18637. */
  18638. vAng: number;
  18639. /**
  18640. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  18641. * @see http://doc.babylonjs.com/how_to/more_materials
  18642. */
  18643. wAng: number;
  18644. /**
  18645. * Defines the center of rotation (U)
  18646. */
  18647. uRotationCenter: number;
  18648. /**
  18649. * Defines the center of rotation (V)
  18650. */
  18651. vRotationCenter: number;
  18652. /**
  18653. * Defines the center of rotation (W)
  18654. */
  18655. wRotationCenter: number;
  18656. /**
  18657. * Are mip maps generated for this texture or not.
  18658. */
  18659. readonly noMipmap: boolean;
  18660. /**
  18661. * List of inspectable custom properties (used by the Inspector)
  18662. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  18663. */
  18664. inspectableCustomProperties: Nullable<IInspectable[]>;
  18665. private _noMipmap;
  18666. /** @hidden */
  18667. _invertY: boolean;
  18668. private _rowGenerationMatrix;
  18669. private _cachedTextureMatrix;
  18670. private _projectionModeMatrix;
  18671. private _t0;
  18672. private _t1;
  18673. private _t2;
  18674. private _cachedUOffset;
  18675. private _cachedVOffset;
  18676. private _cachedUScale;
  18677. private _cachedVScale;
  18678. private _cachedUAng;
  18679. private _cachedVAng;
  18680. private _cachedWAng;
  18681. private _cachedProjectionMatrixId;
  18682. private _cachedCoordinatesMode;
  18683. /** @hidden */
  18684. protected _initialSamplingMode: number;
  18685. /** @hidden */
  18686. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  18687. private _deleteBuffer;
  18688. protected _format: Nullable<number>;
  18689. private _delayedOnLoad;
  18690. private _delayedOnError;
  18691. /**
  18692. * Observable triggered once the texture has been loaded.
  18693. */
  18694. onLoadObservable: Observable<Texture>;
  18695. protected _isBlocking: boolean;
  18696. /**
  18697. * Is the texture preventing material to render while loading.
  18698. * If false, a default texture will be used instead of the loading one during the preparation step.
  18699. */
  18700. isBlocking: boolean;
  18701. /**
  18702. * Get the current sampling mode associated with the texture.
  18703. */
  18704. readonly samplingMode: number;
  18705. /**
  18706. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  18707. */
  18708. readonly invertY: boolean;
  18709. /**
  18710. * Instantiates a new texture.
  18711. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18712. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18713. * @param url define the url of the picture to load as a texture
  18714. * @param scene define the scene the texture will belong to
  18715. * @param noMipmap define if the texture will require mip maps or not
  18716. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18717. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18718. * @param onLoad define a callback triggered when the texture has been loaded
  18719. * @param onError define a callback triggered when an error occurred during the loading session
  18720. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18721. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18722. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18723. */
  18724. constructor(url: Nullable<string>, scene: Nullable<Scene>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, deleteBuffer?: boolean, format?: number);
  18725. /**
  18726. * Update the url (and optional buffer) of this texture if url was null during construction.
  18727. * @param url the url of the texture
  18728. * @param buffer the buffer of the texture (defaults to null)
  18729. * @param onLoad callback called when the texture is loaded (defaults to null)
  18730. */
  18731. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  18732. /**
  18733. * Finish the loading sequence of a texture flagged as delayed load.
  18734. * @hidden
  18735. */
  18736. delayLoad(): void;
  18737. private _prepareRowForTextureGeneration;
  18738. /**
  18739. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  18740. * @returns the transform matrix of the texture.
  18741. */
  18742. getTextureMatrix(): Matrix;
  18743. /**
  18744. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  18745. * @returns The reflection texture transform
  18746. */
  18747. getReflectionTextureMatrix(): Matrix;
  18748. /**
  18749. * Clones the texture.
  18750. * @returns the cloned texture
  18751. */
  18752. clone(): Texture;
  18753. /**
  18754. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  18755. * @returns The JSON representation of the texture
  18756. */
  18757. serialize(): any;
  18758. /**
  18759. * Get the current class name of the texture useful for serialization or dynamic coding.
  18760. * @returns "Texture"
  18761. */
  18762. getClassName(): string;
  18763. /**
  18764. * Dispose the texture and release its associated resources.
  18765. */
  18766. dispose(): void;
  18767. /**
  18768. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  18769. * @param parsedTexture Define the JSON representation of the texture
  18770. * @param scene Define the scene the parsed texture should be instantiated in
  18771. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  18772. * @returns The parsed texture if successful
  18773. */
  18774. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  18775. /**
  18776. * Creates a texture from its base 64 representation.
  18777. * @param data Define the base64 payload without the data: prefix
  18778. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18779. * @param scene Define the scene the texture should belong to
  18780. * @param noMipmap Forces the texture to not create mip map information if true
  18781. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18782. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18783. * @param onLoad define a callback triggered when the texture has been loaded
  18784. * @param onError define a callback triggered when an error occurred during the loading session
  18785. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18786. * @returns the created texture
  18787. */
  18788. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  18789. /**
  18790. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  18791. * @param data Define the base64 payload without the data: prefix
  18792. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18793. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18794. * @param scene Define the scene the texture should belong to
  18795. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18796. * @param noMipmap Forces the texture to not create mip map information if true
  18797. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18798. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18799. * @param onLoad define a callback triggered when the texture has been loaded
  18800. * @param onError define a callback triggered when an error occurred during the loading session
  18801. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18802. * @returns the created texture
  18803. */
  18804. 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;
  18805. }
  18806. }
  18807. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  18808. import { Nullable } from "babylonjs/types";
  18809. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  18810. import { Scene } from "babylonjs/scene";
  18811. module "babylonjs/Engines/engine" {
  18812. interface Engine {
  18813. /**
  18814. * Creates a raw texture
  18815. * @param data defines the data to store in the texture
  18816. * @param width defines the width of the texture
  18817. * @param height defines the height of the texture
  18818. * @param format defines the format of the data
  18819. * @param generateMipMaps defines if the engine should generate the mip levels
  18820. * @param invertY defines if data must be stored with Y axis inverted
  18821. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  18822. * @param compression defines the compression used (null by default)
  18823. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18824. * @returns the raw texture inside an InternalTexture
  18825. */
  18826. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  18827. /**
  18828. * Update a raw texture
  18829. * @param texture defines the texture to update
  18830. * @param data defines the data to store in the texture
  18831. * @param format defines the format of the data
  18832. * @param invertY defines if data must be stored with Y axis inverted
  18833. */
  18834. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  18835. /**
  18836. * Update a raw texture
  18837. * @param texture defines the texture to update
  18838. * @param data defines the data to store in the texture
  18839. * @param format defines the format of the data
  18840. * @param invertY defines if data must be stored with Y axis inverted
  18841. * @param compression defines the compression used (null by default)
  18842. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18843. */
  18844. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  18845. /**
  18846. * Creates a new raw cube texture
  18847. * @param data defines the array of data to use to create each face
  18848. * @param size defines the size of the textures
  18849. * @param format defines the format of the data
  18850. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  18851. * @param generateMipMaps defines if the engine should generate the mip levels
  18852. * @param invertY defines if data must be stored with Y axis inverted
  18853. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  18854. * @param compression defines the compression used (null by default)
  18855. * @returns the cube texture as an InternalTexture
  18856. */
  18857. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  18858. /**
  18859. * Update a raw cube texture
  18860. * @param texture defines the texture to udpdate
  18861. * @param data defines the data to store
  18862. * @param format defines the data format
  18863. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18864. * @param invertY defines if data must be stored with Y axis inverted
  18865. */
  18866. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  18867. /**
  18868. * Update a raw cube texture
  18869. * @param texture defines the texture to udpdate
  18870. * @param data defines the data to store
  18871. * @param format defines the data format
  18872. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18873. * @param invertY defines if data must be stored with Y axis inverted
  18874. * @param compression defines the compression used (null by default)
  18875. */
  18876. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  18877. /**
  18878. * Update a raw cube texture
  18879. * @param texture defines the texture to udpdate
  18880. * @param data defines the data to store
  18881. * @param format defines the data format
  18882. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18883. * @param invertY defines if data must be stored with Y axis inverted
  18884. * @param compression defines the compression used (null by default)
  18885. * @param level defines which level of the texture to update
  18886. */
  18887. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  18888. /**
  18889. * Creates a new raw cube texture from a specified url
  18890. * @param url defines the url where the data is located
  18891. * @param scene defines the current scene
  18892. * @param size defines the size of the textures
  18893. * @param format defines the format of the data
  18894. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  18895. * @param noMipmap defines if the engine should avoid generating the mip levels
  18896. * @param callback defines a callback used to extract texture data from loaded data
  18897. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  18898. * @param onLoad defines a callback called when texture is loaded
  18899. * @param onError defines a callback called if there is an error
  18900. * @returns the cube texture as an InternalTexture
  18901. */
  18902. 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;
  18903. /**
  18904. * Creates a new raw cube texture from a specified url
  18905. * @param url defines the url where the data is located
  18906. * @param scene defines the current scene
  18907. * @param size defines the size of the textures
  18908. * @param format defines the format of the data
  18909. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  18910. * @param noMipmap defines if the engine should avoid generating the mip levels
  18911. * @param callback defines a callback used to extract texture data from loaded data
  18912. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  18913. * @param onLoad defines a callback called when texture is loaded
  18914. * @param onError defines a callback called if there is an error
  18915. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  18916. * @param invertY defines if data must be stored with Y axis inverted
  18917. * @returns the cube texture as an InternalTexture
  18918. */
  18919. 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;
  18920. /**
  18921. * Creates a new raw 3D texture
  18922. * @param data defines the data used to create the texture
  18923. * @param width defines the width of the texture
  18924. * @param height defines the height of the texture
  18925. * @param depth defines the depth of the texture
  18926. * @param format defines the format of the texture
  18927. * @param generateMipMaps defines if the engine must generate mip levels
  18928. * @param invertY defines if data must be stored with Y axis inverted
  18929. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  18930. * @param compression defines the compressed used (can be null)
  18931. * @param textureType defines the compressed used (can be null)
  18932. * @returns a new raw 3D texture (stored in an InternalTexture)
  18933. */
  18934. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  18935. /**
  18936. * Update a raw 3D texture
  18937. * @param texture defines the texture to update
  18938. * @param data defines the data to store
  18939. * @param format defines the data format
  18940. * @param invertY defines if data must be stored with Y axis inverted
  18941. */
  18942. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  18943. /**
  18944. * Update a raw 3D texture
  18945. * @param texture defines the texture to update
  18946. * @param data defines the data to store
  18947. * @param format defines the data format
  18948. * @param invertY defines if data must be stored with Y axis inverted
  18949. * @param compression defines the used compression (can be null)
  18950. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  18951. */
  18952. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  18953. }
  18954. }
  18955. }
  18956. declare module "babylonjs/Materials/Textures/rawTexture" {
  18957. import { Scene } from "babylonjs/scene";
  18958. import { Texture } from "babylonjs/Materials/Textures/texture";
  18959. import "babylonjs/Engines/Extensions/engine.rawTexture";
  18960. /**
  18961. * Raw texture can help creating a texture directly from an array of data.
  18962. * This can be super useful if you either get the data from an uncompressed source or
  18963. * if you wish to create your texture pixel by pixel.
  18964. */
  18965. export class RawTexture extends Texture {
  18966. /**
  18967. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18968. */
  18969. format: number;
  18970. private _engine;
  18971. /**
  18972. * Instantiates a new RawTexture.
  18973. * Raw texture can help creating a texture directly from an array of data.
  18974. * This can be super useful if you either get the data from an uncompressed source or
  18975. * if you wish to create your texture pixel by pixel.
  18976. * @param data define the array of data to use to create the texture
  18977. * @param width define the width of the texture
  18978. * @param height define the height of the texture
  18979. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18980. * @param scene define the scene the texture belongs to
  18981. * @param generateMipMaps define whether mip maps should be generated or not
  18982. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18983. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18984. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18985. */
  18986. constructor(data: ArrayBufferView, width: number, height: number,
  18987. /**
  18988. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18989. */
  18990. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  18991. /**
  18992. * Updates the texture underlying data.
  18993. * @param data Define the new data of the texture
  18994. */
  18995. update(data: ArrayBufferView): void;
  18996. /**
  18997. * Creates a luminance texture from some data.
  18998. * @param data Define the texture data
  18999. * @param width Define the width of the texture
  19000. * @param height Define the height of the texture
  19001. * @param scene Define the scene the texture belongs to
  19002. * @param generateMipMaps Define whether or not to create mip maps for the texture
  19003. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  19004. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  19005. * @returns the luminance texture
  19006. */
  19007. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  19008. /**
  19009. * Creates a luminance alpha texture from some data.
  19010. * @param data Define the texture data
  19011. * @param width Define the width of the texture
  19012. * @param height Define the height of the texture
  19013. * @param scene Define the scene the texture belongs to
  19014. * @param generateMipMaps Define whether or not to create mip maps for the texture
  19015. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  19016. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  19017. * @returns the luminance alpha texture
  19018. */
  19019. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  19020. /**
  19021. * Creates an alpha texture from some data.
  19022. * @param data Define the texture data
  19023. * @param width Define the width of the texture
  19024. * @param height Define the height of the texture
  19025. * @param scene Define the scene the texture belongs to
  19026. * @param generateMipMaps Define whether or not to create mip maps for the texture
  19027. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  19028. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  19029. * @returns the alpha texture
  19030. */
  19031. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  19032. /**
  19033. * Creates a RGB texture from some data.
  19034. * @param data Define the texture data
  19035. * @param width Define the width of the texture
  19036. * @param height Define the height of the texture
  19037. * @param scene Define the scene the texture belongs to
  19038. * @param generateMipMaps Define whether or not to create mip maps for the texture
  19039. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  19040. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  19041. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  19042. * @returns the RGB alpha texture
  19043. */
  19044. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  19045. /**
  19046. * Creates a RGBA texture from some data.
  19047. * @param data Define the texture data
  19048. * @param width Define the width of the texture
  19049. * @param height Define the height of the texture
  19050. * @param scene Define the scene the texture belongs to
  19051. * @param generateMipMaps Define whether or not to create mip maps for the texture
  19052. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  19053. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  19054. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  19055. * @returns the RGBA texture
  19056. */
  19057. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  19058. /**
  19059. * Creates a R texture from some data.
  19060. * @param data Define the texture data
  19061. * @param width Define the width of the texture
  19062. * @param height Define the height of the texture
  19063. * @param scene Define the scene the texture belongs to
  19064. * @param generateMipMaps Define whether or not to create mip maps for the texture
  19065. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  19066. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  19067. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  19068. * @returns the R texture
  19069. */
  19070. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  19071. }
  19072. }
  19073. declare module "babylonjs/Animations/runtimeAnimation" {
  19074. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  19075. import { Animatable } from "babylonjs/Animations/animatable";
  19076. import { Scene } from "babylonjs/scene";
  19077. /**
  19078. * Defines a runtime animation
  19079. */
  19080. export class RuntimeAnimation {
  19081. private _events;
  19082. /**
  19083. * The current frame of the runtime animation
  19084. */
  19085. private _currentFrame;
  19086. /**
  19087. * The animation used by the runtime animation
  19088. */
  19089. private _animation;
  19090. /**
  19091. * The target of the runtime animation
  19092. */
  19093. private _target;
  19094. /**
  19095. * The initiating animatable
  19096. */
  19097. private _host;
  19098. /**
  19099. * The original value of the runtime animation
  19100. */
  19101. private _originalValue;
  19102. /**
  19103. * The original blend value of the runtime animation
  19104. */
  19105. private _originalBlendValue;
  19106. /**
  19107. * The offsets cache of the runtime animation
  19108. */
  19109. private _offsetsCache;
  19110. /**
  19111. * The high limits cache of the runtime animation
  19112. */
  19113. private _highLimitsCache;
  19114. /**
  19115. * Specifies if the runtime animation has been stopped
  19116. */
  19117. private _stopped;
  19118. /**
  19119. * The blending factor of the runtime animation
  19120. */
  19121. private _blendingFactor;
  19122. /**
  19123. * The BabylonJS scene
  19124. */
  19125. private _scene;
  19126. /**
  19127. * The current value of the runtime animation
  19128. */
  19129. private _currentValue;
  19130. /** @hidden */
  19131. _animationState: _IAnimationState;
  19132. /**
  19133. * The active target of the runtime animation
  19134. */
  19135. private _activeTargets;
  19136. private _currentActiveTarget;
  19137. private _directTarget;
  19138. /**
  19139. * The target path of the runtime animation
  19140. */
  19141. private _targetPath;
  19142. /**
  19143. * The weight of the runtime animation
  19144. */
  19145. private _weight;
  19146. /**
  19147. * The ratio offset of the runtime animation
  19148. */
  19149. private _ratioOffset;
  19150. /**
  19151. * The previous delay of the runtime animation
  19152. */
  19153. private _previousDelay;
  19154. /**
  19155. * The previous ratio of the runtime animation
  19156. */
  19157. private _previousRatio;
  19158. private _enableBlending;
  19159. private _keys;
  19160. private _minFrame;
  19161. private _maxFrame;
  19162. private _minValue;
  19163. private _maxValue;
  19164. private _targetIsArray;
  19165. /**
  19166. * Gets the current frame of the runtime animation
  19167. */
  19168. readonly currentFrame: number;
  19169. /**
  19170. * Gets the weight of the runtime animation
  19171. */
  19172. readonly weight: number;
  19173. /**
  19174. * Gets the current value of the runtime animation
  19175. */
  19176. readonly currentValue: any;
  19177. /**
  19178. * Gets the target path of the runtime animation
  19179. */
  19180. readonly targetPath: string;
  19181. /**
  19182. * Gets the actual target of the runtime animation
  19183. */
  19184. readonly target: any;
  19185. /** @hidden */
  19186. _onLoop: () => void;
  19187. /**
  19188. * Create a new RuntimeAnimation object
  19189. * @param target defines the target of the animation
  19190. * @param animation defines the source animation object
  19191. * @param scene defines the hosting scene
  19192. * @param host defines the initiating Animatable
  19193. */
  19194. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  19195. private _preparePath;
  19196. /**
  19197. * Gets the animation from the runtime animation
  19198. */
  19199. readonly animation: Animation;
  19200. /**
  19201. * Resets the runtime animation to the beginning
  19202. * @param restoreOriginal defines whether to restore the target property to the original value
  19203. */
  19204. reset(restoreOriginal?: boolean): void;
  19205. /**
  19206. * Specifies if the runtime animation is stopped
  19207. * @returns Boolean specifying if the runtime animation is stopped
  19208. */
  19209. isStopped(): boolean;
  19210. /**
  19211. * Disposes of the runtime animation
  19212. */
  19213. dispose(): void;
  19214. /**
  19215. * Apply the interpolated value to the target
  19216. * @param currentValue defines the value computed by the animation
  19217. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  19218. */
  19219. setValue(currentValue: any, weight: number): void;
  19220. private _getOriginalValues;
  19221. private _setValue;
  19222. /**
  19223. * Gets the loop pmode of the runtime animation
  19224. * @returns Loop Mode
  19225. */
  19226. private _getCorrectLoopMode;
  19227. /**
  19228. * Move the current animation to a given frame
  19229. * @param frame defines the frame to move to
  19230. */
  19231. goToFrame(frame: number): void;
  19232. /**
  19233. * @hidden Internal use only
  19234. */
  19235. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  19236. /**
  19237. * Execute the current animation
  19238. * @param delay defines the delay to add to the current frame
  19239. * @param from defines the lower bound of the animation range
  19240. * @param to defines the upper bound of the animation range
  19241. * @param loop defines if the current animation must loop
  19242. * @param speedRatio defines the current speed ratio
  19243. * @param weight defines the weight of the animation (default is -1 so no weight)
  19244. * @param onLoop optional callback called when animation loops
  19245. * @returns a boolean indicating if the animation is running
  19246. */
  19247. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  19248. }
  19249. }
  19250. declare module "babylonjs/Animations/animatable" {
  19251. import { Animation } from "babylonjs/Animations/animation";
  19252. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  19253. import { Nullable } from "babylonjs/types";
  19254. import { Observable } from "babylonjs/Misc/observable";
  19255. import { Scene } from "babylonjs/scene";
  19256. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math";
  19257. import { Node } from "babylonjs/node";
  19258. /**
  19259. * Class used to store an actual running animation
  19260. */
  19261. export class Animatable {
  19262. /** defines the target object */
  19263. target: any;
  19264. /** defines the starting frame number (default is 0) */
  19265. fromFrame: number;
  19266. /** defines the ending frame number (default is 100) */
  19267. toFrame: number;
  19268. /** defines if the animation must loop (default is false) */
  19269. loopAnimation: boolean;
  19270. /** defines a callback to call when animation ends if it is not looping */
  19271. onAnimationEnd?: (() => void) | null | undefined;
  19272. /** defines a callback to call when animation loops */
  19273. onAnimationLoop?: (() => void) | null | undefined;
  19274. private _localDelayOffset;
  19275. private _pausedDelay;
  19276. private _runtimeAnimations;
  19277. private _paused;
  19278. private _scene;
  19279. private _speedRatio;
  19280. private _weight;
  19281. private _syncRoot;
  19282. /**
  19283. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  19284. * This will only apply for non looping animation (default is true)
  19285. */
  19286. disposeOnEnd: boolean;
  19287. /**
  19288. * Gets a boolean indicating if the animation has started
  19289. */
  19290. animationStarted: boolean;
  19291. /**
  19292. * Observer raised when the animation ends
  19293. */
  19294. onAnimationEndObservable: Observable<Animatable>;
  19295. /**
  19296. * Observer raised when the animation loops
  19297. */
  19298. onAnimationLoopObservable: Observable<Animatable>;
  19299. /**
  19300. * Gets the root Animatable used to synchronize and normalize animations
  19301. */
  19302. readonly syncRoot: Nullable<Animatable>;
  19303. /**
  19304. * Gets the current frame of the first RuntimeAnimation
  19305. * Used to synchronize Animatables
  19306. */
  19307. readonly masterFrame: number;
  19308. /**
  19309. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  19310. */
  19311. weight: number;
  19312. /**
  19313. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  19314. */
  19315. speedRatio: number;
  19316. /**
  19317. * Creates a new Animatable
  19318. * @param scene defines the hosting scene
  19319. * @param target defines the target object
  19320. * @param fromFrame defines the starting frame number (default is 0)
  19321. * @param toFrame defines the ending frame number (default is 100)
  19322. * @param loopAnimation defines if the animation must loop (default is false)
  19323. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  19324. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  19325. * @param animations defines a group of animation to add to the new Animatable
  19326. * @param onAnimationLoop defines a callback to call when animation loops
  19327. */
  19328. constructor(scene: Scene,
  19329. /** defines the target object */
  19330. target: any,
  19331. /** defines the starting frame number (default is 0) */
  19332. fromFrame?: number,
  19333. /** defines the ending frame number (default is 100) */
  19334. toFrame?: number,
  19335. /** defines if the animation must loop (default is false) */
  19336. loopAnimation?: boolean, speedRatio?: number,
  19337. /** defines a callback to call when animation ends if it is not looping */
  19338. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  19339. /** defines a callback to call when animation loops */
  19340. onAnimationLoop?: (() => void) | null | undefined);
  19341. /**
  19342. * Synchronize and normalize current Animatable with a source Animatable
  19343. * This is useful when using animation weights and when animations are not of the same length
  19344. * @param root defines the root Animatable to synchronize with
  19345. * @returns the current Animatable
  19346. */
  19347. syncWith(root: Animatable): Animatable;
  19348. /**
  19349. * Gets the list of runtime animations
  19350. * @returns an array of RuntimeAnimation
  19351. */
  19352. getAnimations(): RuntimeAnimation[];
  19353. /**
  19354. * Adds more animations to the current animatable
  19355. * @param target defines the target of the animations
  19356. * @param animations defines the new animations to add
  19357. */
  19358. appendAnimations(target: any, animations: Animation[]): void;
  19359. /**
  19360. * Gets the source animation for a specific property
  19361. * @param property defines the propertyu to look for
  19362. * @returns null or the source animation for the given property
  19363. */
  19364. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  19365. /**
  19366. * Gets the runtime animation for a specific property
  19367. * @param property defines the propertyu to look for
  19368. * @returns null or the runtime animation for the given property
  19369. */
  19370. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  19371. /**
  19372. * Resets the animatable to its original state
  19373. */
  19374. reset(): void;
  19375. /**
  19376. * Allows the animatable to blend with current running animations
  19377. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  19378. * @param blendingSpeed defines the blending speed to use
  19379. */
  19380. enableBlending(blendingSpeed: number): void;
  19381. /**
  19382. * Disable animation blending
  19383. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  19384. */
  19385. disableBlending(): void;
  19386. /**
  19387. * Jump directly to a given frame
  19388. * @param frame defines the frame to jump to
  19389. */
  19390. goToFrame(frame: number): void;
  19391. /**
  19392. * Pause the animation
  19393. */
  19394. pause(): void;
  19395. /**
  19396. * Restart the animation
  19397. */
  19398. restart(): void;
  19399. private _raiseOnAnimationEnd;
  19400. /**
  19401. * Stop and delete the current animation
  19402. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  19403. * @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)
  19404. */
  19405. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  19406. /**
  19407. * Wait asynchronously for the animation to end
  19408. * @returns a promise which will be fullfilled when the animation ends
  19409. */
  19410. waitAsync(): Promise<Animatable>;
  19411. /** @hidden */
  19412. _animate(delay: number): boolean;
  19413. }
  19414. module "babylonjs/scene" {
  19415. interface Scene {
  19416. /** @hidden */
  19417. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  19418. /** @hidden */
  19419. _processLateAnimationBindingsForMatrices(holder: {
  19420. totalWeight: number;
  19421. animations: RuntimeAnimation[];
  19422. originalValue: Matrix;
  19423. }): any;
  19424. /** @hidden */
  19425. _processLateAnimationBindingsForQuaternions(holder: {
  19426. totalWeight: number;
  19427. animations: RuntimeAnimation[];
  19428. originalValue: Quaternion;
  19429. }, refQuaternion: Quaternion): Quaternion;
  19430. /** @hidden */
  19431. _processLateAnimationBindings(): void;
  19432. /**
  19433. * Will start the animation sequence of a given target
  19434. * @param target defines the target
  19435. * @param from defines from which frame should animation start
  19436. * @param to defines until which frame should animation run.
  19437. * @param weight defines the weight to apply to the animation (1.0 by default)
  19438. * @param loop defines if the animation loops
  19439. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  19440. * @param onAnimationEnd defines the function to be executed when the animation ends
  19441. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  19442. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  19443. * @param onAnimationLoop defines the callback to call when an animation loops
  19444. * @returns the animatable object created for this animation
  19445. */
  19446. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  19447. /**
  19448. * Will start the animation sequence of a given target
  19449. * @param target defines the target
  19450. * @param from defines from which frame should animation start
  19451. * @param to defines until which frame should animation run.
  19452. * @param loop defines if the animation loops
  19453. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  19454. * @param onAnimationEnd defines the function to be executed when the animation ends
  19455. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  19456. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  19457. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  19458. * @param onAnimationLoop defines the callback to call when an animation loops
  19459. * @returns the animatable object created for this animation
  19460. */
  19461. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  19462. /**
  19463. * Will start the animation sequence of a given target and its hierarchy
  19464. * @param target defines the target
  19465. * @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.
  19466. * @param from defines from which frame should animation start
  19467. * @param to defines until which frame should animation run.
  19468. * @param loop defines if the animation loops
  19469. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  19470. * @param onAnimationEnd defines the function to be executed when the animation ends
  19471. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  19472. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  19473. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  19474. * @param onAnimationLoop defines the callback to call when an animation loops
  19475. * @returns the list of created animatables
  19476. */
  19477. 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[];
  19478. /**
  19479. * Begin a new animation on a given node
  19480. * @param target defines the target where the animation will take place
  19481. * @param animations defines the list of animations to start
  19482. * @param from defines the initial value
  19483. * @param to defines the final value
  19484. * @param loop defines if you want animation to loop (off by default)
  19485. * @param speedRatio defines the speed ratio to apply to all animations
  19486. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  19487. * @param onAnimationLoop defines the callback to call when an animation loops
  19488. * @returns the list of created animatables
  19489. */
  19490. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  19491. /**
  19492. * Begin a new animation on a given node and its hierarchy
  19493. * @param target defines the root node where the animation will take place
  19494. * @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.
  19495. * @param animations defines the list of animations to start
  19496. * @param from defines the initial value
  19497. * @param to defines the final value
  19498. * @param loop defines if you want animation to loop (off by default)
  19499. * @param speedRatio defines the speed ratio to apply to all animations
  19500. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  19501. * @param onAnimationLoop defines the callback to call when an animation loops
  19502. * @returns the list of animatables created for all nodes
  19503. */
  19504. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  19505. /**
  19506. * Gets the animatable associated with a specific target
  19507. * @param target defines the target of the animatable
  19508. * @returns the required animatable if found
  19509. */
  19510. getAnimatableByTarget(target: any): Nullable<Animatable>;
  19511. /**
  19512. * Gets all animatables associated with a given target
  19513. * @param target defines the target to look animatables for
  19514. * @returns an array of Animatables
  19515. */
  19516. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  19517. /**
  19518. * Stops and removes all animations that have been applied to the scene
  19519. */
  19520. stopAllAnimations(): void;
  19521. }
  19522. }
  19523. module "babylonjs/Bones/bone" {
  19524. interface Bone {
  19525. /**
  19526. * Copy an animation range from another bone
  19527. * @param source defines the source bone
  19528. * @param rangeName defines the range name to copy
  19529. * @param frameOffset defines the frame offset
  19530. * @param rescaleAsRequired defines if rescaling must be applied if required
  19531. * @param skelDimensionsRatio defines the scaling ratio
  19532. * @returns true if operation was successful
  19533. */
  19534. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  19535. }
  19536. }
  19537. }
  19538. declare module "babylonjs/Bones/skeleton" {
  19539. import { Bone } from "babylonjs/Bones/bone";
  19540. import { IAnimatable } from "babylonjs/Misc/tools";
  19541. import { Observable } from "babylonjs/Misc/observable";
  19542. import { Vector3, Matrix } from "babylonjs/Maths/math";
  19543. import { Scene } from "babylonjs/scene";
  19544. import { Nullable } from "babylonjs/types";
  19545. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19546. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  19547. import { Animatable } from "babylonjs/Animations/animatable";
  19548. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  19549. import { Animation } from "babylonjs/Animations/animation";
  19550. import { AnimationRange } from "babylonjs/Animations/animationRange";
  19551. import { IInspectable } from "babylonjs/Misc/iInspectable";
  19552. /**
  19553. * Class used to handle skinning animations
  19554. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  19555. */
  19556. export class Skeleton implements IAnimatable {
  19557. /** defines the skeleton name */
  19558. name: string;
  19559. /** defines the skeleton Id */
  19560. id: string;
  19561. /**
  19562. * Defines the list of child bones
  19563. */
  19564. bones: Bone[];
  19565. /**
  19566. * Defines an estimate of the dimension of the skeleton at rest
  19567. */
  19568. dimensionsAtRest: Vector3;
  19569. /**
  19570. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  19571. */
  19572. needInitialSkinMatrix: boolean;
  19573. /**
  19574. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  19575. */
  19576. overrideMesh: Nullable<AbstractMesh>;
  19577. /**
  19578. * Gets the list of animations attached to this skeleton
  19579. */
  19580. animations: Array<Animation>;
  19581. private _scene;
  19582. private _isDirty;
  19583. private _transformMatrices;
  19584. private _transformMatrixTexture;
  19585. private _meshesWithPoseMatrix;
  19586. private _animatables;
  19587. private _identity;
  19588. private _synchronizedWithMesh;
  19589. private _ranges;
  19590. private _lastAbsoluteTransformsUpdateId;
  19591. private _canUseTextureForBones;
  19592. private _uniqueId;
  19593. /** @hidden */
  19594. _numBonesWithLinkedTransformNode: number;
  19595. /** @hidden */
  19596. _hasWaitingData: Nullable<boolean>;
  19597. /**
  19598. * Specifies if the skeleton should be serialized
  19599. */
  19600. doNotSerialize: boolean;
  19601. private _useTextureToStoreBoneMatrices;
  19602. /**
  19603. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  19604. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  19605. */
  19606. useTextureToStoreBoneMatrices: boolean;
  19607. private _animationPropertiesOverride;
  19608. /**
  19609. * Gets or sets the animation properties override
  19610. */
  19611. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  19612. /**
  19613. * List of inspectable custom properties (used by the Inspector)
  19614. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  19615. */
  19616. inspectableCustomProperties: IInspectable[];
  19617. /**
  19618. * An observable triggered before computing the skeleton's matrices
  19619. */
  19620. onBeforeComputeObservable: Observable<Skeleton>;
  19621. /**
  19622. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  19623. */
  19624. readonly isUsingTextureForMatrices: boolean;
  19625. /**
  19626. * Gets the unique ID of this skeleton
  19627. */
  19628. readonly uniqueId: number;
  19629. /**
  19630. * Creates a new skeleton
  19631. * @param name defines the skeleton name
  19632. * @param id defines the skeleton Id
  19633. * @param scene defines the hosting scene
  19634. */
  19635. constructor(
  19636. /** defines the skeleton name */
  19637. name: string,
  19638. /** defines the skeleton Id */
  19639. id: string, scene: Scene);
  19640. /**
  19641. * Gets the current object class name.
  19642. * @return the class name
  19643. */
  19644. getClassName(): string;
  19645. /**
  19646. * Returns an array containing the root bones
  19647. * @returns an array containing the root bones
  19648. */
  19649. getChildren(): Array<Bone>;
  19650. /**
  19651. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  19652. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  19653. * @returns a Float32Array containing matrices data
  19654. */
  19655. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  19656. /**
  19657. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  19658. * @returns a raw texture containing the data
  19659. */
  19660. getTransformMatrixTexture(): Nullable<RawTexture>;
  19661. /**
  19662. * Gets the current hosting scene
  19663. * @returns a scene object
  19664. */
  19665. getScene(): Scene;
  19666. /**
  19667. * Gets a string representing the current skeleton data
  19668. * @param fullDetails defines a boolean indicating if we want a verbose version
  19669. * @returns a string representing the current skeleton data
  19670. */
  19671. toString(fullDetails?: boolean): string;
  19672. /**
  19673. * Get bone's index searching by name
  19674. * @param name defines bone's name to search for
  19675. * @return the indice of the bone. Returns -1 if not found
  19676. */
  19677. getBoneIndexByName(name: string): number;
  19678. /**
  19679. * Creater a new animation range
  19680. * @param name defines the name of the range
  19681. * @param from defines the start key
  19682. * @param to defines the end key
  19683. */
  19684. createAnimationRange(name: string, from: number, to: number): void;
  19685. /**
  19686. * Delete a specific animation range
  19687. * @param name defines the name of the range
  19688. * @param deleteFrames defines if frames must be removed as well
  19689. */
  19690. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  19691. /**
  19692. * Gets a specific animation range
  19693. * @param name defines the name of the range to look for
  19694. * @returns the requested animation range or null if not found
  19695. */
  19696. getAnimationRange(name: string): Nullable<AnimationRange>;
  19697. /**
  19698. * Gets the list of all animation ranges defined on this skeleton
  19699. * @returns an array
  19700. */
  19701. getAnimationRanges(): Nullable<AnimationRange>[];
  19702. /**
  19703. * Copy animation range from a source skeleton.
  19704. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  19705. * @param source defines the source skeleton
  19706. * @param name defines the name of the range to copy
  19707. * @param rescaleAsRequired defines if rescaling must be applied if required
  19708. * @returns true if operation was successful
  19709. */
  19710. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  19711. /**
  19712. * Forces the skeleton to go to rest pose
  19713. */
  19714. returnToRest(): void;
  19715. private _getHighestAnimationFrame;
  19716. /**
  19717. * Begin a specific animation range
  19718. * @param name defines the name of the range to start
  19719. * @param loop defines if looping must be turned on (false by default)
  19720. * @param speedRatio defines the speed ratio to apply (1 by default)
  19721. * @param onAnimationEnd defines a callback which will be called when animation will end
  19722. * @returns a new animatable
  19723. */
  19724. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  19725. /** @hidden */
  19726. _markAsDirty(): void;
  19727. /** @hidden */
  19728. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  19729. /** @hidden */
  19730. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  19731. private _computeTransformMatrices;
  19732. /**
  19733. * Build all resources required to render a skeleton
  19734. */
  19735. prepare(): void;
  19736. /**
  19737. * Gets the list of animatables currently running for this skeleton
  19738. * @returns an array of animatables
  19739. */
  19740. getAnimatables(): IAnimatable[];
  19741. /**
  19742. * Clone the current skeleton
  19743. * @param name defines the name of the new skeleton
  19744. * @param id defines the id of the new skeleton
  19745. * @returns the new skeleton
  19746. */
  19747. clone(name: string, id: string): Skeleton;
  19748. /**
  19749. * Enable animation blending for this skeleton
  19750. * @param blendingSpeed defines the blending speed to apply
  19751. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  19752. */
  19753. enableBlending(blendingSpeed?: number): void;
  19754. /**
  19755. * Releases all resources associated with the current skeleton
  19756. */
  19757. dispose(): void;
  19758. /**
  19759. * Serialize the skeleton in a JSON object
  19760. * @returns a JSON object
  19761. */
  19762. serialize(): any;
  19763. /**
  19764. * Creates a new skeleton from serialized data
  19765. * @param parsedSkeleton defines the serialized data
  19766. * @param scene defines the hosting scene
  19767. * @returns a new skeleton
  19768. */
  19769. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  19770. /**
  19771. * Compute all node absolute transforms
  19772. * @param forceUpdate defines if computation must be done even if cache is up to date
  19773. */
  19774. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  19775. /**
  19776. * Gets the root pose matrix
  19777. * @returns a matrix
  19778. */
  19779. getPoseMatrix(): Nullable<Matrix>;
  19780. /**
  19781. * Sorts bones per internal index
  19782. */
  19783. sortBones(): void;
  19784. private _sortBones;
  19785. }
  19786. }
  19787. declare module "babylonjs/Morph/morphTarget" {
  19788. import { IAnimatable } from "babylonjs/Misc/tools";
  19789. import { Observable } from "babylonjs/Misc/observable";
  19790. import { Nullable, FloatArray } from "babylonjs/types";
  19791. import { Scene } from "babylonjs/scene";
  19792. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19793. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  19794. /**
  19795. * Defines a target to use with MorphTargetManager
  19796. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  19797. */
  19798. export class MorphTarget implements IAnimatable {
  19799. /** defines the name of the target */
  19800. name: string;
  19801. /**
  19802. * Gets or sets the list of animations
  19803. */
  19804. animations: import("babylonjs/Animations/animation").Animation[];
  19805. private _scene;
  19806. private _positions;
  19807. private _normals;
  19808. private _tangents;
  19809. private _influence;
  19810. /**
  19811. * Observable raised when the influence changes
  19812. */
  19813. onInfluenceChanged: Observable<boolean>;
  19814. /** @hidden */
  19815. _onDataLayoutChanged: Observable<void>;
  19816. /**
  19817. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  19818. */
  19819. influence: number;
  19820. /**
  19821. * Gets or sets the id of the morph Target
  19822. */
  19823. id: string;
  19824. private _animationPropertiesOverride;
  19825. /**
  19826. * Gets or sets the animation properties override
  19827. */
  19828. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  19829. /**
  19830. * Creates a new MorphTarget
  19831. * @param name defines the name of the target
  19832. * @param influence defines the influence to use
  19833. * @param scene defines the scene the morphtarget belongs to
  19834. */
  19835. constructor(
  19836. /** defines the name of the target */
  19837. name: string, influence?: number, scene?: Nullable<Scene>);
  19838. /**
  19839. * Gets a boolean defining if the target contains position data
  19840. */
  19841. readonly hasPositions: boolean;
  19842. /**
  19843. * Gets a boolean defining if the target contains normal data
  19844. */
  19845. readonly hasNormals: boolean;
  19846. /**
  19847. * Gets a boolean defining if the target contains tangent data
  19848. */
  19849. readonly hasTangents: boolean;
  19850. /**
  19851. * Affects position data to this target
  19852. * @param data defines the position data to use
  19853. */
  19854. setPositions(data: Nullable<FloatArray>): void;
  19855. /**
  19856. * Gets the position data stored in this target
  19857. * @returns a FloatArray containing the position data (or null if not present)
  19858. */
  19859. getPositions(): Nullable<FloatArray>;
  19860. /**
  19861. * Affects normal data to this target
  19862. * @param data defines the normal data to use
  19863. */
  19864. setNormals(data: Nullable<FloatArray>): void;
  19865. /**
  19866. * Gets the normal data stored in this target
  19867. * @returns a FloatArray containing the normal data (or null if not present)
  19868. */
  19869. getNormals(): Nullable<FloatArray>;
  19870. /**
  19871. * Affects tangent data to this target
  19872. * @param data defines the tangent data to use
  19873. */
  19874. setTangents(data: Nullable<FloatArray>): void;
  19875. /**
  19876. * Gets the tangent data stored in this target
  19877. * @returns a FloatArray containing the tangent data (or null if not present)
  19878. */
  19879. getTangents(): Nullable<FloatArray>;
  19880. /**
  19881. * Serializes the current target into a Serialization object
  19882. * @returns the serialized object
  19883. */
  19884. serialize(): any;
  19885. /**
  19886. * Returns the string "MorphTarget"
  19887. * @returns "MorphTarget"
  19888. */
  19889. getClassName(): string;
  19890. /**
  19891. * Creates a new target from serialized data
  19892. * @param serializationObject defines the serialized data to use
  19893. * @returns a new MorphTarget
  19894. */
  19895. static Parse(serializationObject: any): MorphTarget;
  19896. /**
  19897. * Creates a MorphTarget from mesh data
  19898. * @param mesh defines the source mesh
  19899. * @param name defines the name to use for the new target
  19900. * @param influence defines the influence to attach to the target
  19901. * @returns a new MorphTarget
  19902. */
  19903. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  19904. }
  19905. }
  19906. declare module "babylonjs/Morph/morphTargetManager" {
  19907. import { Nullable } from "babylonjs/types";
  19908. import { Scene } from "babylonjs/scene";
  19909. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  19910. /**
  19911. * This class is used to deform meshes using morphing between different targets
  19912. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  19913. */
  19914. export class MorphTargetManager {
  19915. private _targets;
  19916. private _targetInfluenceChangedObservers;
  19917. private _targetDataLayoutChangedObservers;
  19918. private _activeTargets;
  19919. private _scene;
  19920. private _influences;
  19921. private _supportsNormals;
  19922. private _supportsTangents;
  19923. private _vertexCount;
  19924. private _uniqueId;
  19925. private _tempInfluences;
  19926. /**
  19927. * Creates a new MorphTargetManager
  19928. * @param scene defines the current scene
  19929. */
  19930. constructor(scene?: Nullable<Scene>);
  19931. /**
  19932. * Gets the unique ID of this manager
  19933. */
  19934. readonly uniqueId: number;
  19935. /**
  19936. * Gets the number of vertices handled by this manager
  19937. */
  19938. readonly vertexCount: number;
  19939. /**
  19940. * Gets a boolean indicating if this manager supports morphing of normals
  19941. */
  19942. readonly supportsNormals: boolean;
  19943. /**
  19944. * Gets a boolean indicating if this manager supports morphing of tangents
  19945. */
  19946. readonly supportsTangents: boolean;
  19947. /**
  19948. * Gets the number of targets stored in this manager
  19949. */
  19950. readonly numTargets: number;
  19951. /**
  19952. * Gets the number of influencers (ie. the number of targets with influences > 0)
  19953. */
  19954. readonly numInfluencers: number;
  19955. /**
  19956. * Gets the list of influences (one per target)
  19957. */
  19958. readonly influences: Float32Array;
  19959. /**
  19960. * Gets the active target at specified index. An active target is a target with an influence > 0
  19961. * @param index defines the index to check
  19962. * @returns the requested target
  19963. */
  19964. getActiveTarget(index: number): MorphTarget;
  19965. /**
  19966. * Gets the target at specified index
  19967. * @param index defines the index to check
  19968. * @returns the requested target
  19969. */
  19970. getTarget(index: number): MorphTarget;
  19971. /**
  19972. * Add a new target to this manager
  19973. * @param target defines the target to add
  19974. */
  19975. addTarget(target: MorphTarget): void;
  19976. /**
  19977. * Removes a target from the manager
  19978. * @param target defines the target to remove
  19979. */
  19980. removeTarget(target: MorphTarget): void;
  19981. /**
  19982. * Serializes the current manager into a Serialization object
  19983. * @returns the serialized object
  19984. */
  19985. serialize(): any;
  19986. private _syncActiveTargets;
  19987. /**
  19988. * Syncrhonize the targets with all the meshes using this morph target manager
  19989. */
  19990. synchronize(): void;
  19991. /**
  19992. * Creates a new MorphTargetManager from serialized data
  19993. * @param serializationObject defines the serialized data
  19994. * @param scene defines the hosting scene
  19995. * @returns the new MorphTargetManager
  19996. */
  19997. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  19998. }
  19999. }
  20000. declare module "babylonjs/Meshes/meshLODLevel" {
  20001. import { Mesh } from "babylonjs/Meshes/mesh";
  20002. import { Nullable } from "babylonjs/types";
  20003. /**
  20004. * Class used to represent a specific level of detail of a mesh
  20005. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  20006. */
  20007. export class MeshLODLevel {
  20008. /** Defines the distance where this level should star being displayed */
  20009. distance: number;
  20010. /** Defines the mesh to use to render this level */
  20011. mesh: Nullable<Mesh>;
  20012. /**
  20013. * Creates a new LOD level
  20014. * @param distance defines the distance where this level should star being displayed
  20015. * @param mesh defines the mesh to use to render this level
  20016. */
  20017. constructor(
  20018. /** Defines the distance where this level should star being displayed */
  20019. distance: number,
  20020. /** Defines the mesh to use to render this level */
  20021. mesh: Nullable<Mesh>);
  20022. }
  20023. }
  20024. declare module "babylonjs/Meshes/groundMesh" {
  20025. import { Scene } from "babylonjs/scene";
  20026. import { Vector3 } from "babylonjs/Maths/math";
  20027. import { Mesh } from "babylonjs/Meshes/mesh";
  20028. /**
  20029. * Mesh representing the gorund
  20030. */
  20031. export class GroundMesh extends Mesh {
  20032. /** If octree should be generated */
  20033. generateOctree: boolean;
  20034. private _heightQuads;
  20035. /** @hidden */
  20036. _subdivisionsX: number;
  20037. /** @hidden */
  20038. _subdivisionsY: number;
  20039. /** @hidden */
  20040. _width: number;
  20041. /** @hidden */
  20042. _height: number;
  20043. /** @hidden */
  20044. _minX: number;
  20045. /** @hidden */
  20046. _maxX: number;
  20047. /** @hidden */
  20048. _minZ: number;
  20049. /** @hidden */
  20050. _maxZ: number;
  20051. constructor(name: string, scene: Scene);
  20052. /**
  20053. * "GroundMesh"
  20054. * @returns "GroundMesh"
  20055. */
  20056. getClassName(): string;
  20057. /**
  20058. * The minimum of x and y subdivisions
  20059. */
  20060. readonly subdivisions: number;
  20061. /**
  20062. * X subdivisions
  20063. */
  20064. readonly subdivisionsX: number;
  20065. /**
  20066. * Y subdivisions
  20067. */
  20068. readonly subdivisionsY: number;
  20069. /**
  20070. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  20071. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  20072. * @param chunksCount the number of subdivisions for x and y
  20073. * @param octreeBlocksSize (Default: 32)
  20074. */
  20075. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  20076. /**
  20077. * Returns a height (y) value in the Worl system :
  20078. * the ground altitude at the coordinates (x, z) expressed in the World system.
  20079. * @param x x coordinate
  20080. * @param z z coordinate
  20081. * @returns the ground y position if (x, z) are outside the ground surface.
  20082. */
  20083. getHeightAtCoordinates(x: number, z: number): number;
  20084. /**
  20085. * Returns a normalized vector (Vector3) orthogonal to the ground
  20086. * at the ground coordinates (x, z) expressed in the World system.
  20087. * @param x x coordinate
  20088. * @param z z coordinate
  20089. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  20090. */
  20091. getNormalAtCoordinates(x: number, z: number): Vector3;
  20092. /**
  20093. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  20094. * at the ground coordinates (x, z) expressed in the World system.
  20095. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  20096. * @param x x coordinate
  20097. * @param z z coordinate
  20098. * @param ref vector to store the result
  20099. * @returns the GroundMesh.
  20100. */
  20101. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  20102. /**
  20103. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  20104. * if the ground has been updated.
  20105. * This can be used in the render loop.
  20106. * @returns the GroundMesh.
  20107. */
  20108. updateCoordinateHeights(): GroundMesh;
  20109. private _getFacetAt;
  20110. private _initHeightQuads;
  20111. private _computeHeightQuads;
  20112. /**
  20113. * Serializes this ground mesh
  20114. * @param serializationObject object to write serialization to
  20115. */
  20116. serialize(serializationObject: any): void;
  20117. /**
  20118. * Parses a serialized ground mesh
  20119. * @param parsedMesh the serialized mesh
  20120. * @param scene the scene to create the ground mesh in
  20121. * @returns the created ground mesh
  20122. */
  20123. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  20124. }
  20125. }
  20126. declare module "babylonjs/Physics/physicsJoint" {
  20127. import { Vector3 } from "babylonjs/Maths/math";
  20128. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  20129. /**
  20130. * Interface for Physics-Joint data
  20131. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20132. */
  20133. export interface PhysicsJointData {
  20134. /**
  20135. * The main pivot of the joint
  20136. */
  20137. mainPivot?: Vector3;
  20138. /**
  20139. * The connected pivot of the joint
  20140. */
  20141. connectedPivot?: Vector3;
  20142. /**
  20143. * The main axis of the joint
  20144. */
  20145. mainAxis?: Vector3;
  20146. /**
  20147. * The connected axis of the joint
  20148. */
  20149. connectedAxis?: Vector3;
  20150. /**
  20151. * The collision of the joint
  20152. */
  20153. collision?: boolean;
  20154. /**
  20155. * Native Oimo/Cannon/Energy data
  20156. */
  20157. nativeParams?: any;
  20158. }
  20159. /**
  20160. * This is a holder class for the physics joint created by the physics plugin
  20161. * It holds a set of functions to control the underlying joint
  20162. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20163. */
  20164. export class PhysicsJoint {
  20165. /**
  20166. * The type of the physics joint
  20167. */
  20168. type: number;
  20169. /**
  20170. * The data for the physics joint
  20171. */
  20172. jointData: PhysicsJointData;
  20173. private _physicsJoint;
  20174. protected _physicsPlugin: IPhysicsEnginePlugin;
  20175. /**
  20176. * Initializes the physics joint
  20177. * @param type The type of the physics joint
  20178. * @param jointData The data for the physics joint
  20179. */
  20180. constructor(
  20181. /**
  20182. * The type of the physics joint
  20183. */
  20184. type: number,
  20185. /**
  20186. * The data for the physics joint
  20187. */
  20188. jointData: PhysicsJointData);
  20189. /**
  20190. * Gets the physics joint
  20191. */
  20192. /**
  20193. * Sets the physics joint
  20194. */
  20195. physicsJoint: any;
  20196. /**
  20197. * Sets the physics plugin
  20198. */
  20199. physicsPlugin: IPhysicsEnginePlugin;
  20200. /**
  20201. * Execute a function that is physics-plugin specific.
  20202. * @param {Function} func the function that will be executed.
  20203. * It accepts two parameters: the physics world and the physics joint
  20204. */
  20205. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  20206. /**
  20207. * Distance-Joint type
  20208. */
  20209. static DistanceJoint: number;
  20210. /**
  20211. * Hinge-Joint type
  20212. */
  20213. static HingeJoint: number;
  20214. /**
  20215. * Ball-and-Socket joint type
  20216. */
  20217. static BallAndSocketJoint: number;
  20218. /**
  20219. * Wheel-Joint type
  20220. */
  20221. static WheelJoint: number;
  20222. /**
  20223. * Slider-Joint type
  20224. */
  20225. static SliderJoint: number;
  20226. /**
  20227. * Prismatic-Joint type
  20228. */
  20229. static PrismaticJoint: number;
  20230. /**
  20231. * Universal-Joint type
  20232. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  20233. */
  20234. static UniversalJoint: number;
  20235. /**
  20236. * Hinge-Joint 2 type
  20237. */
  20238. static Hinge2Joint: number;
  20239. /**
  20240. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  20241. */
  20242. static PointToPointJoint: number;
  20243. /**
  20244. * Spring-Joint type
  20245. */
  20246. static SpringJoint: number;
  20247. /**
  20248. * Lock-Joint type
  20249. */
  20250. static LockJoint: number;
  20251. }
  20252. /**
  20253. * A class representing a physics distance joint
  20254. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20255. */
  20256. export class DistanceJoint extends PhysicsJoint {
  20257. /**
  20258. *
  20259. * @param jointData The data for the Distance-Joint
  20260. */
  20261. constructor(jointData: DistanceJointData);
  20262. /**
  20263. * Update the predefined distance.
  20264. * @param maxDistance The maximum preferred distance
  20265. * @param minDistance The minimum preferred distance
  20266. */
  20267. updateDistance(maxDistance: number, minDistance?: number): void;
  20268. }
  20269. /**
  20270. * Represents a Motor-Enabled Joint
  20271. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20272. */
  20273. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  20274. /**
  20275. * Initializes the Motor-Enabled Joint
  20276. * @param type The type of the joint
  20277. * @param jointData The physica joint data for the joint
  20278. */
  20279. constructor(type: number, jointData: PhysicsJointData);
  20280. /**
  20281. * Set the motor values.
  20282. * Attention, this function is plugin specific. Engines won't react 100% the same.
  20283. * @param force the force to apply
  20284. * @param maxForce max force for this motor.
  20285. */
  20286. setMotor(force?: number, maxForce?: number): void;
  20287. /**
  20288. * Set the motor's limits.
  20289. * Attention, this function is plugin specific. Engines won't react 100% the same.
  20290. * @param upperLimit The upper limit of the motor
  20291. * @param lowerLimit The lower limit of the motor
  20292. */
  20293. setLimit(upperLimit: number, lowerLimit?: number): void;
  20294. }
  20295. /**
  20296. * This class represents a single physics Hinge-Joint
  20297. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20298. */
  20299. export class HingeJoint extends MotorEnabledJoint {
  20300. /**
  20301. * Initializes the Hinge-Joint
  20302. * @param jointData The joint data for the Hinge-Joint
  20303. */
  20304. constructor(jointData: PhysicsJointData);
  20305. /**
  20306. * Set the motor values.
  20307. * Attention, this function is plugin specific. Engines won't react 100% the same.
  20308. * @param {number} force the force to apply
  20309. * @param {number} maxForce max force for this motor.
  20310. */
  20311. setMotor(force?: number, maxForce?: number): void;
  20312. /**
  20313. * Set the motor's limits.
  20314. * Attention, this function is plugin specific. Engines won't react 100% the same.
  20315. * @param upperLimit The upper limit of the motor
  20316. * @param lowerLimit The lower limit of the motor
  20317. */
  20318. setLimit(upperLimit: number, lowerLimit?: number): void;
  20319. }
  20320. /**
  20321. * This class represents a dual hinge physics joint (same as wheel joint)
  20322. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20323. */
  20324. export class Hinge2Joint extends MotorEnabledJoint {
  20325. /**
  20326. * Initializes the Hinge2-Joint
  20327. * @param jointData The joint data for the Hinge2-Joint
  20328. */
  20329. constructor(jointData: PhysicsJointData);
  20330. /**
  20331. * Set the motor values.
  20332. * Attention, this function is plugin specific. Engines won't react 100% the same.
  20333. * @param {number} targetSpeed the speed the motor is to reach
  20334. * @param {number} maxForce max force for this motor.
  20335. * @param {motorIndex} the motor's index, 0 or 1.
  20336. */
  20337. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  20338. /**
  20339. * Set the motor limits.
  20340. * Attention, this function is plugin specific. Engines won't react 100% the same.
  20341. * @param {number} upperLimit the upper limit
  20342. * @param {number} lowerLimit lower limit
  20343. * @param {motorIndex} the motor's index, 0 or 1.
  20344. */
  20345. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  20346. }
  20347. /**
  20348. * Interface for a motor enabled joint
  20349. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20350. */
  20351. export interface IMotorEnabledJoint {
  20352. /**
  20353. * Physics joint
  20354. */
  20355. physicsJoint: any;
  20356. /**
  20357. * Sets the motor of the motor-enabled joint
  20358. * @param force The force of the motor
  20359. * @param maxForce The maximum force of the motor
  20360. * @param motorIndex The index of the motor
  20361. */
  20362. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  20363. /**
  20364. * Sets the limit of the motor
  20365. * @param upperLimit The upper limit of the motor
  20366. * @param lowerLimit The lower limit of the motor
  20367. * @param motorIndex The index of the motor
  20368. */
  20369. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  20370. }
  20371. /**
  20372. * Joint data for a Distance-Joint
  20373. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20374. */
  20375. export interface DistanceJointData extends PhysicsJointData {
  20376. /**
  20377. * Max distance the 2 joint objects can be apart
  20378. */
  20379. maxDistance: number;
  20380. }
  20381. /**
  20382. * Joint data from a spring joint
  20383. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20384. */
  20385. export interface SpringJointData extends PhysicsJointData {
  20386. /**
  20387. * Length of the spring
  20388. */
  20389. length: number;
  20390. /**
  20391. * Stiffness of the spring
  20392. */
  20393. stiffness: number;
  20394. /**
  20395. * Damping of the spring
  20396. */
  20397. damping: number;
  20398. /** this callback will be called when applying the force to the impostors. */
  20399. forceApplicationCallback: () => void;
  20400. }
  20401. }
  20402. declare module "babylonjs/Physics/physicsRaycastResult" {
  20403. import { Vector3 } from "babylonjs/Maths/math";
  20404. /**
  20405. * Holds the data for the raycast result
  20406. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20407. */
  20408. export class PhysicsRaycastResult {
  20409. private _hasHit;
  20410. private _hitDistance;
  20411. private _hitNormalWorld;
  20412. private _hitPointWorld;
  20413. private _rayFromWorld;
  20414. private _rayToWorld;
  20415. /**
  20416. * Gets if there was a hit
  20417. */
  20418. readonly hasHit: boolean;
  20419. /**
  20420. * Gets the distance from the hit
  20421. */
  20422. readonly hitDistance: number;
  20423. /**
  20424. * Gets the hit normal/direction in the world
  20425. */
  20426. readonly hitNormalWorld: Vector3;
  20427. /**
  20428. * Gets the hit point in the world
  20429. */
  20430. readonly hitPointWorld: Vector3;
  20431. /**
  20432. * Gets the ray "start point" of the ray in the world
  20433. */
  20434. readonly rayFromWorld: Vector3;
  20435. /**
  20436. * Gets the ray "end point" of the ray in the world
  20437. */
  20438. readonly rayToWorld: Vector3;
  20439. /**
  20440. * Sets the hit data (normal & point in world space)
  20441. * @param hitNormalWorld defines the normal in world space
  20442. * @param hitPointWorld defines the point in world space
  20443. */
  20444. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  20445. /**
  20446. * Sets the distance from the start point to the hit point
  20447. * @param distance
  20448. */
  20449. setHitDistance(distance: number): void;
  20450. /**
  20451. * Calculates the distance manually
  20452. */
  20453. calculateHitDistance(): void;
  20454. /**
  20455. * Resets all the values to default
  20456. * @param from The from point on world space
  20457. * @param to The to point on world space
  20458. */
  20459. reset(from?: Vector3, to?: Vector3): void;
  20460. }
  20461. /**
  20462. * Interface for the size containing width and height
  20463. */
  20464. interface IXYZ {
  20465. /**
  20466. * X
  20467. */
  20468. x: number;
  20469. /**
  20470. * Y
  20471. */
  20472. y: number;
  20473. /**
  20474. * Z
  20475. */
  20476. z: number;
  20477. }
  20478. }
  20479. declare module "babylonjs/Physics/IPhysicsEngine" {
  20480. import { Nullable } from "babylonjs/types";
  20481. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  20482. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20483. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  20484. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  20485. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  20486. /**
  20487. * Interface used to describe a physics joint
  20488. */
  20489. export interface PhysicsImpostorJoint {
  20490. /** Defines the main impostor to which the joint is linked */
  20491. mainImpostor: PhysicsImpostor;
  20492. /** Defines the impostor that is connected to the main impostor using this joint */
  20493. connectedImpostor: PhysicsImpostor;
  20494. /** Defines the joint itself */
  20495. joint: PhysicsJoint;
  20496. }
  20497. /** @hidden */
  20498. export interface IPhysicsEnginePlugin {
  20499. world: any;
  20500. name: string;
  20501. setGravity(gravity: Vector3): void;
  20502. setTimeStep(timeStep: number): void;
  20503. getTimeStep(): number;
  20504. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  20505. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  20506. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  20507. generatePhysicsBody(impostor: PhysicsImpostor): void;
  20508. removePhysicsBody(impostor: PhysicsImpostor): void;
  20509. generateJoint(joint: PhysicsImpostorJoint): void;
  20510. removeJoint(joint: PhysicsImpostorJoint): void;
  20511. isSupported(): boolean;
  20512. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  20513. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  20514. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  20515. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  20516. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  20517. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  20518. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  20519. getBodyMass(impostor: PhysicsImpostor): number;
  20520. getBodyFriction(impostor: PhysicsImpostor): number;
  20521. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  20522. getBodyRestitution(impostor: PhysicsImpostor): number;
  20523. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  20524. getBodyPressure?(impostor: PhysicsImpostor): number;
  20525. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  20526. getBodyStiffness?(impostor: PhysicsImpostor): number;
  20527. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  20528. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  20529. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  20530. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  20531. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  20532. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  20533. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  20534. sleepBody(impostor: PhysicsImpostor): void;
  20535. wakeUpBody(impostor: PhysicsImpostor): void;
  20536. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  20537. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  20538. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  20539. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  20540. getRadius(impostor: PhysicsImpostor): number;
  20541. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  20542. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  20543. dispose(): void;
  20544. }
  20545. /**
  20546. * Interface used to define a physics engine
  20547. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  20548. */
  20549. export interface IPhysicsEngine {
  20550. /**
  20551. * Gets the gravity vector used by the simulation
  20552. */
  20553. gravity: Vector3;
  20554. /**
  20555. * Sets the gravity vector used by the simulation
  20556. * @param gravity defines the gravity vector to use
  20557. */
  20558. setGravity(gravity: Vector3): void;
  20559. /**
  20560. * Set the time step of the physics engine.
  20561. * Default is 1/60.
  20562. * To slow it down, enter 1/600 for example.
  20563. * To speed it up, 1/30
  20564. * @param newTimeStep the new timestep to apply to this world.
  20565. */
  20566. setTimeStep(newTimeStep: number): void;
  20567. /**
  20568. * Get the time step of the physics engine.
  20569. * @returns the current time step
  20570. */
  20571. getTimeStep(): number;
  20572. /**
  20573. * Release all resources
  20574. */
  20575. dispose(): void;
  20576. /**
  20577. * Gets the name of the current physics plugin
  20578. * @returns the name of the plugin
  20579. */
  20580. getPhysicsPluginName(): string;
  20581. /**
  20582. * Adding a new impostor for the impostor tracking.
  20583. * This will be done by the impostor itself.
  20584. * @param impostor the impostor to add
  20585. */
  20586. addImpostor(impostor: PhysicsImpostor): void;
  20587. /**
  20588. * Remove an impostor from the engine.
  20589. * This impostor and its mesh will not longer be updated by the physics engine.
  20590. * @param impostor the impostor to remove
  20591. */
  20592. removeImpostor(impostor: PhysicsImpostor): void;
  20593. /**
  20594. * Add a joint to the physics engine
  20595. * @param mainImpostor defines the main impostor to which the joint is added.
  20596. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  20597. * @param joint defines the joint that will connect both impostors.
  20598. */
  20599. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  20600. /**
  20601. * Removes a joint from the simulation
  20602. * @param mainImpostor defines the impostor used with the joint
  20603. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  20604. * @param joint defines the joint to remove
  20605. */
  20606. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  20607. /**
  20608. * Gets the current plugin used to run the simulation
  20609. * @returns current plugin
  20610. */
  20611. getPhysicsPlugin(): IPhysicsEnginePlugin;
  20612. /**
  20613. * Gets the list of physic impostors
  20614. * @returns an array of PhysicsImpostor
  20615. */
  20616. getImpostors(): Array<PhysicsImpostor>;
  20617. /**
  20618. * Gets the impostor for a physics enabled object
  20619. * @param object defines the object impersonated by the impostor
  20620. * @returns the PhysicsImpostor or null if not found
  20621. */
  20622. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  20623. /**
  20624. * Gets the impostor for a physics body object
  20625. * @param body defines physics body used by the impostor
  20626. * @returns the PhysicsImpostor or null if not found
  20627. */
  20628. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  20629. /**
  20630. * Does a raycast in the physics world
  20631. * @param from when should the ray start?
  20632. * @param to when should the ray end?
  20633. * @returns PhysicsRaycastResult
  20634. */
  20635. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  20636. /**
  20637. * Called by the scene. No need to call it.
  20638. * @param delta defines the timespam between frames
  20639. */
  20640. _step(delta: number): void;
  20641. }
  20642. }
  20643. declare module "babylonjs/Physics/physicsImpostor" {
  20644. import { Nullable, IndicesArray } from "babylonjs/types";
  20645. import { Vector3, Matrix, Quaternion, Space } from "babylonjs/Maths/math";
  20646. import { TransformNode } from "babylonjs/Meshes/transformNode";
  20647. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20648. import { Scene } from "babylonjs/scene";
  20649. import { Bone } from "babylonjs/Bones/bone";
  20650. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  20651. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  20652. /**
  20653. * The interface for the physics imposter parameters
  20654. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20655. */
  20656. export interface PhysicsImpostorParameters {
  20657. /**
  20658. * The mass of the physics imposter
  20659. */
  20660. mass: number;
  20661. /**
  20662. * The friction of the physics imposter
  20663. */
  20664. friction?: number;
  20665. /**
  20666. * The coefficient of restitution of the physics imposter
  20667. */
  20668. restitution?: number;
  20669. /**
  20670. * The native options of the physics imposter
  20671. */
  20672. nativeOptions?: any;
  20673. /**
  20674. * Specifies if the parent should be ignored
  20675. */
  20676. ignoreParent?: boolean;
  20677. /**
  20678. * Specifies if bi-directional transformations should be disabled
  20679. */
  20680. disableBidirectionalTransformation?: boolean;
  20681. /**
  20682. * The pressure inside the physics imposter, soft object only
  20683. */
  20684. pressure?: number;
  20685. /**
  20686. * The stiffness the physics imposter, soft object only
  20687. */
  20688. stiffness?: number;
  20689. /**
  20690. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  20691. */
  20692. velocityIterations?: number;
  20693. /**
  20694. * The number of iterations used in maintaining consistent vertex positions, soft object only
  20695. */
  20696. positionIterations?: number;
  20697. /**
  20698. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  20699. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  20700. * Add to fix multiple points
  20701. */
  20702. fixedPoints?: number;
  20703. /**
  20704. * The collision margin around a soft object
  20705. */
  20706. margin?: number;
  20707. /**
  20708. * The collision margin around a soft object
  20709. */
  20710. damping?: number;
  20711. /**
  20712. * The path for a rope based on an extrusion
  20713. */
  20714. path?: any;
  20715. /**
  20716. * The shape of an extrusion used for a rope based on an extrusion
  20717. */
  20718. shape?: any;
  20719. }
  20720. /**
  20721. * Interface for a physics-enabled object
  20722. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20723. */
  20724. export interface IPhysicsEnabledObject {
  20725. /**
  20726. * The position of the physics-enabled object
  20727. */
  20728. position: Vector3;
  20729. /**
  20730. * The rotation of the physics-enabled object
  20731. */
  20732. rotationQuaternion: Nullable<Quaternion>;
  20733. /**
  20734. * The scale of the physics-enabled object
  20735. */
  20736. scaling: Vector3;
  20737. /**
  20738. * The rotation of the physics-enabled object
  20739. */
  20740. rotation?: Vector3;
  20741. /**
  20742. * The parent of the physics-enabled object
  20743. */
  20744. parent?: any;
  20745. /**
  20746. * The bounding info of the physics-enabled object
  20747. * @returns The bounding info of the physics-enabled object
  20748. */
  20749. getBoundingInfo(): BoundingInfo;
  20750. /**
  20751. * Computes the world matrix
  20752. * @param force Specifies if the world matrix should be computed by force
  20753. * @returns A world matrix
  20754. */
  20755. computeWorldMatrix(force: boolean): Matrix;
  20756. /**
  20757. * Gets the world matrix
  20758. * @returns A world matrix
  20759. */
  20760. getWorldMatrix?(): Matrix;
  20761. /**
  20762. * Gets the child meshes
  20763. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  20764. * @returns An array of abstract meshes
  20765. */
  20766. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  20767. /**
  20768. * Gets the vertex data
  20769. * @param kind The type of vertex data
  20770. * @returns A nullable array of numbers, or a float32 array
  20771. */
  20772. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  20773. /**
  20774. * Gets the indices from the mesh
  20775. * @returns A nullable array of index arrays
  20776. */
  20777. getIndices?(): Nullable<IndicesArray>;
  20778. /**
  20779. * Gets the scene from the mesh
  20780. * @returns the indices array or null
  20781. */
  20782. getScene?(): Scene;
  20783. /**
  20784. * Gets the absolute position from the mesh
  20785. * @returns the absolute position
  20786. */
  20787. getAbsolutePosition(): Vector3;
  20788. /**
  20789. * Gets the absolute pivot point from the mesh
  20790. * @returns the absolute pivot point
  20791. */
  20792. getAbsolutePivotPoint(): Vector3;
  20793. /**
  20794. * Rotates the mesh
  20795. * @param axis The axis of rotation
  20796. * @param amount The amount of rotation
  20797. * @param space The space of the rotation
  20798. * @returns The rotation transform node
  20799. */
  20800. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  20801. /**
  20802. * Translates the mesh
  20803. * @param axis The axis of translation
  20804. * @param distance The distance of translation
  20805. * @param space The space of the translation
  20806. * @returns The transform node
  20807. */
  20808. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  20809. /**
  20810. * Sets the absolute position of the mesh
  20811. * @param absolutePosition The absolute position of the mesh
  20812. * @returns The transform node
  20813. */
  20814. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  20815. /**
  20816. * Gets the class name of the mesh
  20817. * @returns The class name
  20818. */
  20819. getClassName(): string;
  20820. }
  20821. /**
  20822. * Represents a physics imposter
  20823. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20824. */
  20825. export class PhysicsImpostor {
  20826. /**
  20827. * The physics-enabled object used as the physics imposter
  20828. */
  20829. object: IPhysicsEnabledObject;
  20830. /**
  20831. * The type of the physics imposter
  20832. */
  20833. type: number;
  20834. private _options;
  20835. private _scene?;
  20836. /**
  20837. * The default object size of the imposter
  20838. */
  20839. static DEFAULT_OBJECT_SIZE: Vector3;
  20840. /**
  20841. * The identity quaternion of the imposter
  20842. */
  20843. static IDENTITY_QUATERNION: Quaternion;
  20844. /** @hidden */
  20845. _pluginData: any;
  20846. private _physicsEngine;
  20847. private _physicsBody;
  20848. private _bodyUpdateRequired;
  20849. private _onBeforePhysicsStepCallbacks;
  20850. private _onAfterPhysicsStepCallbacks;
  20851. /** @hidden */
  20852. _onPhysicsCollideCallbacks: Array<{
  20853. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  20854. otherImpostors: Array<PhysicsImpostor>;
  20855. }>;
  20856. private _deltaPosition;
  20857. private _deltaRotation;
  20858. private _deltaRotationConjugated;
  20859. /** hidden */
  20860. _isFromLine: boolean;
  20861. private _parent;
  20862. private _isDisposed;
  20863. private static _tmpVecs;
  20864. private static _tmpQuat;
  20865. /**
  20866. * Specifies if the physics imposter is disposed
  20867. */
  20868. readonly isDisposed: boolean;
  20869. /**
  20870. * Gets the mass of the physics imposter
  20871. */
  20872. mass: number;
  20873. /**
  20874. * Gets the coefficient of friction
  20875. */
  20876. /**
  20877. * Sets the coefficient of friction
  20878. */
  20879. friction: number;
  20880. /**
  20881. * Gets the coefficient of restitution
  20882. */
  20883. /**
  20884. * Sets the coefficient of restitution
  20885. */
  20886. restitution: number;
  20887. /**
  20888. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  20889. */
  20890. /**
  20891. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  20892. */
  20893. pressure: number;
  20894. /**
  20895. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  20896. */
  20897. /**
  20898. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  20899. */
  20900. stiffness: number;
  20901. /**
  20902. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  20903. */
  20904. /**
  20905. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  20906. */
  20907. velocityIterations: number;
  20908. /**
  20909. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  20910. */
  20911. /**
  20912. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  20913. */
  20914. positionIterations: number;
  20915. /**
  20916. * The unique id of the physics imposter
  20917. * set by the physics engine when adding this impostor to the array
  20918. */
  20919. uniqueId: number;
  20920. /**
  20921. * @hidden
  20922. */
  20923. soft: boolean;
  20924. /**
  20925. * @hidden
  20926. */
  20927. segments: number;
  20928. private _joints;
  20929. /**
  20930. * Initializes the physics imposter
  20931. * @param object The physics-enabled object used as the physics imposter
  20932. * @param type The type of the physics imposter
  20933. * @param _options The options for the physics imposter
  20934. * @param _scene The Babylon scene
  20935. */
  20936. constructor(
  20937. /**
  20938. * The physics-enabled object used as the physics imposter
  20939. */
  20940. object: IPhysicsEnabledObject,
  20941. /**
  20942. * The type of the physics imposter
  20943. */
  20944. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  20945. /**
  20946. * This function will completly initialize this impostor.
  20947. * It will create a new body - but only if this mesh has no parent.
  20948. * If it has, this impostor will not be used other than to define the impostor
  20949. * of the child mesh.
  20950. * @hidden
  20951. */
  20952. _init(): void;
  20953. private _getPhysicsParent;
  20954. /**
  20955. * Should a new body be generated.
  20956. * @returns boolean specifying if body initialization is required
  20957. */
  20958. isBodyInitRequired(): boolean;
  20959. /**
  20960. * Sets the updated scaling
  20961. * @param updated Specifies if the scaling is updated
  20962. */
  20963. setScalingUpdated(): void;
  20964. /**
  20965. * Force a regeneration of this or the parent's impostor's body.
  20966. * Use under cautious - This will remove all joints already implemented.
  20967. */
  20968. forceUpdate(): void;
  20969. /**
  20970. * Gets the body that holds this impostor. Either its own, or its parent.
  20971. */
  20972. /**
  20973. * Set the physics body. Used mainly by the physics engine/plugin
  20974. */
  20975. physicsBody: any;
  20976. /**
  20977. * Get the parent of the physics imposter
  20978. * @returns Physics imposter or null
  20979. */
  20980. /**
  20981. * Sets the parent of the physics imposter
  20982. */
  20983. parent: Nullable<PhysicsImpostor>;
  20984. /**
  20985. * Resets the update flags
  20986. */
  20987. resetUpdateFlags(): void;
  20988. /**
  20989. * Gets the object extend size
  20990. * @returns the object extend size
  20991. */
  20992. getObjectExtendSize(): Vector3;
  20993. /**
  20994. * Gets the object center
  20995. * @returns The object center
  20996. */
  20997. getObjectCenter(): Vector3;
  20998. /**
  20999. * Get a specific parametes from the options parameter
  21000. * @param paramName The object parameter name
  21001. * @returns The object parameter
  21002. */
  21003. getParam(paramName: string): any;
  21004. /**
  21005. * Sets a specific parameter in the options given to the physics plugin
  21006. * @param paramName The parameter name
  21007. * @param value The value of the parameter
  21008. */
  21009. setParam(paramName: string, value: number): void;
  21010. /**
  21011. * Specifically change the body's mass option. Won't recreate the physics body object
  21012. * @param mass The mass of the physics imposter
  21013. */
  21014. setMass(mass: number): void;
  21015. /**
  21016. * Gets the linear velocity
  21017. * @returns linear velocity or null
  21018. */
  21019. getLinearVelocity(): Nullable<Vector3>;
  21020. /**
  21021. * Sets the linear velocity
  21022. * @param velocity linear velocity or null
  21023. */
  21024. setLinearVelocity(velocity: Nullable<Vector3>): void;
  21025. /**
  21026. * Gets the angular velocity
  21027. * @returns angular velocity or null
  21028. */
  21029. getAngularVelocity(): Nullable<Vector3>;
  21030. /**
  21031. * Sets the angular velocity
  21032. * @param velocity The velocity or null
  21033. */
  21034. setAngularVelocity(velocity: Nullable<Vector3>): void;
  21035. /**
  21036. * Execute a function with the physics plugin native code
  21037. * Provide a function the will have two variables - the world object and the physics body object
  21038. * @param func The function to execute with the physics plugin native code
  21039. */
  21040. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  21041. /**
  21042. * Register a function that will be executed before the physics world is stepping forward
  21043. * @param func The function to execute before the physics world is stepped forward
  21044. */
  21045. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  21046. /**
  21047. * Unregister a function that will be executed before the physics world is stepping forward
  21048. * @param func The function to execute before the physics world is stepped forward
  21049. */
  21050. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  21051. /**
  21052. * Register a function that will be executed after the physics step
  21053. * @param func The function to execute after physics step
  21054. */
  21055. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  21056. /**
  21057. * Unregisters a function that will be executed after the physics step
  21058. * @param func The function to execute after physics step
  21059. */
  21060. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  21061. /**
  21062. * register a function that will be executed when this impostor collides against a different body
  21063. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  21064. * @param func Callback that is executed on collision
  21065. */
  21066. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  21067. /**
  21068. * Unregisters the physics imposter on contact
  21069. * @param collideAgainst The physics object to collide against
  21070. * @param func Callback to execute on collision
  21071. */
  21072. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  21073. private _tmpQuat;
  21074. private _tmpQuat2;
  21075. /**
  21076. * Get the parent rotation
  21077. * @returns The parent rotation
  21078. */
  21079. getParentsRotation(): Quaternion;
  21080. /**
  21081. * this function is executed by the physics engine.
  21082. */
  21083. beforeStep: () => void;
  21084. /**
  21085. * this function is executed by the physics engine
  21086. */
  21087. afterStep: () => void;
  21088. /**
  21089. * Legacy collision detection event support
  21090. */
  21091. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  21092. /**
  21093. * event and body object due to cannon's event-based architecture.
  21094. */
  21095. onCollide: (e: {
  21096. body: any;
  21097. }) => void;
  21098. /**
  21099. * Apply a force
  21100. * @param force The force to apply
  21101. * @param contactPoint The contact point for the force
  21102. * @returns The physics imposter
  21103. */
  21104. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  21105. /**
  21106. * Apply an impulse
  21107. * @param force The impulse force
  21108. * @param contactPoint The contact point for the impulse force
  21109. * @returns The physics imposter
  21110. */
  21111. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  21112. /**
  21113. * A help function to create a joint
  21114. * @param otherImpostor A physics imposter used to create a joint
  21115. * @param jointType The type of joint
  21116. * @param jointData The data for the joint
  21117. * @returns The physics imposter
  21118. */
  21119. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  21120. /**
  21121. * Add a joint to this impostor with a different impostor
  21122. * @param otherImpostor A physics imposter used to add a joint
  21123. * @param joint The joint to add
  21124. * @returns The physics imposter
  21125. */
  21126. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  21127. /**
  21128. * Add an anchor to a cloth impostor
  21129. * @param otherImpostor rigid impostor to anchor to
  21130. * @param width ratio across width from 0 to 1
  21131. * @param height ratio up height from 0 to 1
  21132. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  21133. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  21134. * @returns impostor the soft imposter
  21135. */
  21136. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  21137. /**
  21138. * Add a hook to a rope impostor
  21139. * @param otherImpostor rigid impostor to anchor to
  21140. * @param length ratio across rope from 0 to 1
  21141. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  21142. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  21143. * @returns impostor the rope imposter
  21144. */
  21145. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  21146. /**
  21147. * Will keep this body still, in a sleep mode.
  21148. * @returns the physics imposter
  21149. */
  21150. sleep(): PhysicsImpostor;
  21151. /**
  21152. * Wake the body up.
  21153. * @returns The physics imposter
  21154. */
  21155. wakeUp(): PhysicsImpostor;
  21156. /**
  21157. * Clones the physics imposter
  21158. * @param newObject The physics imposter clones to this physics-enabled object
  21159. * @returns A nullable physics imposter
  21160. */
  21161. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  21162. /**
  21163. * Disposes the physics imposter
  21164. */
  21165. dispose(): void;
  21166. /**
  21167. * Sets the delta position
  21168. * @param position The delta position amount
  21169. */
  21170. setDeltaPosition(position: Vector3): void;
  21171. /**
  21172. * Sets the delta rotation
  21173. * @param rotation The delta rotation amount
  21174. */
  21175. setDeltaRotation(rotation: Quaternion): void;
  21176. /**
  21177. * Gets the box size of the physics imposter and stores the result in the input parameter
  21178. * @param result Stores the box size
  21179. * @returns The physics imposter
  21180. */
  21181. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  21182. /**
  21183. * Gets the radius of the physics imposter
  21184. * @returns Radius of the physics imposter
  21185. */
  21186. getRadius(): number;
  21187. /**
  21188. * Sync a bone with this impostor
  21189. * @param bone The bone to sync to the impostor.
  21190. * @param boneMesh The mesh that the bone is influencing.
  21191. * @param jointPivot The pivot of the joint / bone in local space.
  21192. * @param distToJoint Optional distance from the impostor to the joint.
  21193. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  21194. */
  21195. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  21196. /**
  21197. * Sync impostor to a bone
  21198. * @param bone The bone that the impostor will be synced to.
  21199. * @param boneMesh The mesh that the bone is influencing.
  21200. * @param jointPivot The pivot of the joint / bone in local space.
  21201. * @param distToJoint Optional distance from the impostor to the joint.
  21202. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  21203. * @param boneAxis Optional vector3 axis the bone is aligned with
  21204. */
  21205. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  21206. /**
  21207. * No-Imposter type
  21208. */
  21209. static NoImpostor: number;
  21210. /**
  21211. * Sphere-Imposter type
  21212. */
  21213. static SphereImpostor: number;
  21214. /**
  21215. * Box-Imposter type
  21216. */
  21217. static BoxImpostor: number;
  21218. /**
  21219. * Plane-Imposter type
  21220. */
  21221. static PlaneImpostor: number;
  21222. /**
  21223. * Mesh-imposter type
  21224. */
  21225. static MeshImpostor: number;
  21226. /**
  21227. * Cylinder-Imposter type
  21228. */
  21229. static CylinderImpostor: number;
  21230. /**
  21231. * Particle-Imposter type
  21232. */
  21233. static ParticleImpostor: number;
  21234. /**
  21235. * Heightmap-Imposter type
  21236. */
  21237. static HeightmapImpostor: number;
  21238. /**
  21239. * ConvexHull-Impostor type (Ammo.js plugin only)
  21240. */
  21241. static ConvexHullImpostor: number;
  21242. /**
  21243. * Rope-Imposter type
  21244. */
  21245. static RopeImpostor: number;
  21246. /**
  21247. * Cloth-Imposter type
  21248. */
  21249. static ClothImpostor: number;
  21250. /**
  21251. * Softbody-Imposter type
  21252. */
  21253. static SoftbodyImpostor: number;
  21254. }
  21255. }
  21256. declare module "babylonjs/Meshes/mesh" {
  21257. import { Observable } from "babylonjs/Misc/observable";
  21258. import { IAnimatable } from "babylonjs/Misc/tools";
  21259. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  21260. import { Camera } from "babylonjs/Cameras/camera";
  21261. import { Scene } from "babylonjs/scene";
  21262. import { Matrix, Vector3, Vector2, Color4, Plane, Vector4, Path3D } from "babylonjs/Maths/math";
  21263. import { Engine } from "babylonjs/Engines/engine";
  21264. import { Node } from "babylonjs/node";
  21265. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  21266. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  21267. import { Buffer } from "babylonjs/Meshes/buffer";
  21268. import { Geometry } from "babylonjs/Meshes/geometry";
  21269. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21270. import { SubMesh } from "babylonjs/Meshes/subMesh";
  21271. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  21272. import { Effect } from "babylonjs/Materials/effect";
  21273. import { Material } from "babylonjs/Materials/material";
  21274. import { Skeleton } from "babylonjs/Bones/skeleton";
  21275. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  21276. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  21277. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  21278. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  21279. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  21280. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  21281. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  21282. /**
  21283. * @hidden
  21284. **/
  21285. export class _CreationDataStorage {
  21286. closePath?: boolean;
  21287. closeArray?: boolean;
  21288. idx: number[];
  21289. dashSize: number;
  21290. gapSize: number;
  21291. path3D: Path3D;
  21292. pathArray: Vector3[][];
  21293. arc: number;
  21294. radius: number;
  21295. cap: number;
  21296. tessellation: number;
  21297. }
  21298. /**
  21299. * @hidden
  21300. **/
  21301. class _InstanceDataStorage {
  21302. visibleInstances: any;
  21303. batchCache: _InstancesBatch;
  21304. instancesBufferSize: number;
  21305. instancesBuffer: Nullable<Buffer>;
  21306. instancesData: Float32Array;
  21307. overridenInstanceCount: number;
  21308. isFrozen: boolean;
  21309. previousBatch: _InstancesBatch;
  21310. hardwareInstancedRendering: boolean;
  21311. sideOrientation: number;
  21312. }
  21313. /**
  21314. * @hidden
  21315. **/
  21316. export class _InstancesBatch {
  21317. mustReturn: boolean;
  21318. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  21319. renderSelf: boolean[];
  21320. hardwareInstancedRendering: boolean[];
  21321. }
  21322. /**
  21323. * Class used to represent renderable models
  21324. */
  21325. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  21326. /**
  21327. * Mesh side orientation : usually the external or front surface
  21328. */
  21329. static readonly FRONTSIDE: number;
  21330. /**
  21331. * Mesh side orientation : usually the internal or back surface
  21332. */
  21333. static readonly BACKSIDE: number;
  21334. /**
  21335. * Mesh side orientation : both internal and external or front and back surfaces
  21336. */
  21337. static readonly DOUBLESIDE: number;
  21338. /**
  21339. * Mesh side orientation : by default, `FRONTSIDE`
  21340. */
  21341. static readonly DEFAULTSIDE: number;
  21342. /**
  21343. * Mesh cap setting : no cap
  21344. */
  21345. static readonly NO_CAP: number;
  21346. /**
  21347. * Mesh cap setting : one cap at the beginning of the mesh
  21348. */
  21349. static readonly CAP_START: number;
  21350. /**
  21351. * Mesh cap setting : one cap at the end of the mesh
  21352. */
  21353. static readonly CAP_END: number;
  21354. /**
  21355. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  21356. */
  21357. static readonly CAP_ALL: number;
  21358. /**
  21359. * Mesh pattern setting : no flip or rotate
  21360. */
  21361. static readonly NO_FLIP: number;
  21362. /**
  21363. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  21364. */
  21365. static readonly FLIP_TILE: number;
  21366. /**
  21367. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  21368. */
  21369. static readonly ROTATE_TILE: number;
  21370. /**
  21371. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  21372. */
  21373. static readonly FLIP_ROW: number;
  21374. /**
  21375. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  21376. */
  21377. static readonly ROTATE_ROW: number;
  21378. /**
  21379. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  21380. */
  21381. static readonly FLIP_N_ROTATE_TILE: number;
  21382. /**
  21383. * Mesh pattern setting : rotate pattern and rotate
  21384. */
  21385. static readonly FLIP_N_ROTATE_ROW: number;
  21386. /**
  21387. * Mesh tile positioning : part tiles same on left/right or top/bottom
  21388. */
  21389. static readonly CENTER: number;
  21390. /**
  21391. * Mesh tile positioning : part tiles on left
  21392. */
  21393. static readonly LEFT: number;
  21394. /**
  21395. * Mesh tile positioning : part tiles on right
  21396. */
  21397. static readonly RIGHT: number;
  21398. /**
  21399. * Mesh tile positioning : part tiles on top
  21400. */
  21401. static readonly TOP: number;
  21402. /**
  21403. * Mesh tile positioning : part tiles on bottom
  21404. */
  21405. static readonly BOTTOM: number;
  21406. /**
  21407. * Gets the default side orientation.
  21408. * @param orientation the orientation to value to attempt to get
  21409. * @returns the default orientation
  21410. * @hidden
  21411. */
  21412. static _GetDefaultSideOrientation(orientation?: number): number;
  21413. private _internalMeshDataInfo;
  21414. /**
  21415. * An event triggered before rendering the mesh
  21416. */
  21417. readonly onBeforeRenderObservable: Observable<Mesh>;
  21418. /**
  21419. * An event triggered before binding the mesh
  21420. */
  21421. readonly onBeforeBindObservable: Observable<Mesh>;
  21422. /**
  21423. * An event triggered after rendering the mesh
  21424. */
  21425. readonly onAfterRenderObservable: Observable<Mesh>;
  21426. /**
  21427. * An event triggered before drawing the mesh
  21428. */
  21429. readonly onBeforeDrawObservable: Observable<Mesh>;
  21430. private _onBeforeDrawObserver;
  21431. /**
  21432. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  21433. */
  21434. onBeforeDraw: () => void;
  21435. /**
  21436. * Gets the delay loading state of the mesh (when delay loading is turned on)
  21437. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  21438. */
  21439. delayLoadState: number;
  21440. /**
  21441. * Gets the list of instances created from this mesh
  21442. * it is not supposed to be modified manually.
  21443. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  21444. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  21445. */
  21446. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  21447. /**
  21448. * Gets the file containing delay loading data for this mesh
  21449. */
  21450. delayLoadingFile: string;
  21451. /** @hidden */
  21452. _binaryInfo: any;
  21453. /**
  21454. * User defined function used to change how LOD level selection is done
  21455. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  21456. */
  21457. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  21458. /**
  21459. * Gets or sets the morph target manager
  21460. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  21461. */
  21462. morphTargetManager: Nullable<MorphTargetManager>;
  21463. /** @hidden */
  21464. _creationDataStorage: Nullable<_CreationDataStorage>;
  21465. /** @hidden */
  21466. _geometry: Nullable<Geometry>;
  21467. /** @hidden */
  21468. _delayInfo: Array<string>;
  21469. /** @hidden */
  21470. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  21471. /** @hidden */
  21472. _instanceDataStorage: _InstanceDataStorage;
  21473. private _effectiveMaterial;
  21474. /** @hidden */
  21475. _shouldGenerateFlatShading: boolean;
  21476. /** @hidden */
  21477. _originalBuilderSideOrientation: number;
  21478. /**
  21479. * Use this property to change the original side orientation defined at construction time
  21480. */
  21481. overrideMaterialSideOrientation: Nullable<number>;
  21482. /**
  21483. * Gets the source mesh (the one used to clone this one from)
  21484. */
  21485. readonly source: Nullable<Mesh>;
  21486. /**
  21487. * Gets or sets a boolean indicating that this mesh does not use index buffer
  21488. */
  21489. isUnIndexed: boolean;
  21490. /**
  21491. * @constructor
  21492. * @param name The value used by scene.getMeshByName() to do a lookup.
  21493. * @param scene The scene to add this mesh to.
  21494. * @param parent The parent of this mesh, if it has one
  21495. * @param source An optional Mesh from which geometry is shared, cloned.
  21496. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  21497. * When false, achieved by calling a clone(), also passing False.
  21498. * This will make creation of children, recursive.
  21499. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  21500. */
  21501. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  21502. /**
  21503. * Gets the class name
  21504. * @returns the string "Mesh".
  21505. */
  21506. getClassName(): string;
  21507. /** @hidden */
  21508. readonly _isMesh: boolean;
  21509. /**
  21510. * Returns a description of this mesh
  21511. * @param fullDetails define if full details about this mesh must be used
  21512. * @returns a descriptive string representing this mesh
  21513. */
  21514. toString(fullDetails?: boolean): string;
  21515. /** @hidden */
  21516. _unBindEffect(): void;
  21517. /**
  21518. * Gets a boolean indicating if this mesh has LOD
  21519. */
  21520. readonly hasLODLevels: boolean;
  21521. /**
  21522. * Gets the list of MeshLODLevel associated with the current mesh
  21523. * @returns an array of MeshLODLevel
  21524. */
  21525. getLODLevels(): MeshLODLevel[];
  21526. private _sortLODLevels;
  21527. /**
  21528. * Add a mesh as LOD level triggered at the given distance.
  21529. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  21530. * @param distance The distance from the center of the object to show this level
  21531. * @param mesh The mesh to be added as LOD level (can be null)
  21532. * @return This mesh (for chaining)
  21533. */
  21534. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  21535. /**
  21536. * Returns the LOD level mesh at the passed distance or null if not found.
  21537. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  21538. * @param distance The distance from the center of the object to show this level
  21539. * @returns a Mesh or `null`
  21540. */
  21541. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  21542. /**
  21543. * Remove a mesh from the LOD array
  21544. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  21545. * @param mesh defines the mesh to be removed
  21546. * @return This mesh (for chaining)
  21547. */
  21548. removeLODLevel(mesh: Mesh): Mesh;
  21549. /**
  21550. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  21551. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  21552. * @param camera defines the camera to use to compute distance
  21553. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  21554. * @return This mesh (for chaining)
  21555. */
  21556. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  21557. /**
  21558. * Gets the mesh internal Geometry object
  21559. */
  21560. readonly geometry: Nullable<Geometry>;
  21561. /**
  21562. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  21563. * @returns the total number of vertices
  21564. */
  21565. getTotalVertices(): number;
  21566. /**
  21567. * Returns the content of an associated vertex buffer
  21568. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  21569. * - VertexBuffer.PositionKind
  21570. * - VertexBuffer.UVKind
  21571. * - VertexBuffer.UV2Kind
  21572. * - VertexBuffer.UV3Kind
  21573. * - VertexBuffer.UV4Kind
  21574. * - VertexBuffer.UV5Kind
  21575. * - VertexBuffer.UV6Kind
  21576. * - VertexBuffer.ColorKind
  21577. * - VertexBuffer.MatricesIndicesKind
  21578. * - VertexBuffer.MatricesIndicesExtraKind
  21579. * - VertexBuffer.MatricesWeightsKind
  21580. * - VertexBuffer.MatricesWeightsExtraKind
  21581. * @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
  21582. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  21583. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  21584. */
  21585. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21586. /**
  21587. * Returns the mesh VertexBuffer object from the requested `kind`
  21588. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  21589. * - VertexBuffer.PositionKind
  21590. * - VertexBuffer.NormalKind
  21591. * - VertexBuffer.UVKind
  21592. * - VertexBuffer.UV2Kind
  21593. * - VertexBuffer.UV3Kind
  21594. * - VertexBuffer.UV4Kind
  21595. * - VertexBuffer.UV5Kind
  21596. * - VertexBuffer.UV6Kind
  21597. * - VertexBuffer.ColorKind
  21598. * - VertexBuffer.MatricesIndicesKind
  21599. * - VertexBuffer.MatricesIndicesExtraKind
  21600. * - VertexBuffer.MatricesWeightsKind
  21601. * - VertexBuffer.MatricesWeightsExtraKind
  21602. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  21603. */
  21604. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21605. /**
  21606. * Tests if a specific vertex buffer is associated with this mesh
  21607. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  21608. * - VertexBuffer.PositionKind
  21609. * - VertexBuffer.NormalKind
  21610. * - VertexBuffer.UVKind
  21611. * - VertexBuffer.UV2Kind
  21612. * - VertexBuffer.UV3Kind
  21613. * - VertexBuffer.UV4Kind
  21614. * - VertexBuffer.UV5Kind
  21615. * - VertexBuffer.UV6Kind
  21616. * - VertexBuffer.ColorKind
  21617. * - VertexBuffer.MatricesIndicesKind
  21618. * - VertexBuffer.MatricesIndicesExtraKind
  21619. * - VertexBuffer.MatricesWeightsKind
  21620. * - VertexBuffer.MatricesWeightsExtraKind
  21621. * @returns a boolean
  21622. */
  21623. isVerticesDataPresent(kind: string): boolean;
  21624. /**
  21625. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  21626. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  21627. * - VertexBuffer.PositionKind
  21628. * - VertexBuffer.UVKind
  21629. * - VertexBuffer.UV2Kind
  21630. * - VertexBuffer.UV3Kind
  21631. * - VertexBuffer.UV4Kind
  21632. * - VertexBuffer.UV5Kind
  21633. * - VertexBuffer.UV6Kind
  21634. * - VertexBuffer.ColorKind
  21635. * - VertexBuffer.MatricesIndicesKind
  21636. * - VertexBuffer.MatricesIndicesExtraKind
  21637. * - VertexBuffer.MatricesWeightsKind
  21638. * - VertexBuffer.MatricesWeightsExtraKind
  21639. * @returns a boolean
  21640. */
  21641. isVertexBufferUpdatable(kind: string): boolean;
  21642. /**
  21643. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  21644. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  21645. * - VertexBuffer.PositionKind
  21646. * - VertexBuffer.NormalKind
  21647. * - VertexBuffer.UVKind
  21648. * - VertexBuffer.UV2Kind
  21649. * - VertexBuffer.UV3Kind
  21650. * - VertexBuffer.UV4Kind
  21651. * - VertexBuffer.UV5Kind
  21652. * - VertexBuffer.UV6Kind
  21653. * - VertexBuffer.ColorKind
  21654. * - VertexBuffer.MatricesIndicesKind
  21655. * - VertexBuffer.MatricesIndicesExtraKind
  21656. * - VertexBuffer.MatricesWeightsKind
  21657. * - VertexBuffer.MatricesWeightsExtraKind
  21658. * @returns an array of strings
  21659. */
  21660. getVerticesDataKinds(): string[];
  21661. /**
  21662. * Returns a positive integer : the total number of indices in this mesh geometry.
  21663. * @returns the numner of indices or zero if the mesh has no geometry.
  21664. */
  21665. getTotalIndices(): number;
  21666. /**
  21667. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21668. * @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.
  21669. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21670. * @returns the indices array or an empty array if the mesh has no geometry
  21671. */
  21672. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21673. readonly isBlocked: boolean;
  21674. /**
  21675. * Determine if the current mesh is ready to be rendered
  21676. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  21677. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  21678. * @returns true if all associated assets are ready (material, textures, shaders)
  21679. */
  21680. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  21681. /**
  21682. * 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.
  21683. */
  21684. readonly areNormalsFrozen: boolean;
  21685. /**
  21686. * 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.
  21687. * @returns the current mesh
  21688. */
  21689. freezeNormals(): Mesh;
  21690. /**
  21691. * 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
  21692. * @returns the current mesh
  21693. */
  21694. unfreezeNormals(): Mesh;
  21695. /**
  21696. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  21697. */
  21698. overridenInstanceCount: number;
  21699. /** @hidden */
  21700. _preActivate(): Mesh;
  21701. /** @hidden */
  21702. _preActivateForIntermediateRendering(renderId: number): Mesh;
  21703. /** @hidden */
  21704. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  21705. /**
  21706. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  21707. * This means the mesh underlying bounding box and sphere are recomputed.
  21708. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  21709. * @returns the current mesh
  21710. */
  21711. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  21712. /** @hidden */
  21713. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  21714. /**
  21715. * This function will subdivide the mesh into multiple submeshes
  21716. * @param count defines the expected number of submeshes
  21717. */
  21718. subdivide(count: number): void;
  21719. /**
  21720. * Copy a FloatArray into a specific associated vertex buffer
  21721. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21722. * - VertexBuffer.PositionKind
  21723. * - VertexBuffer.UVKind
  21724. * - VertexBuffer.UV2Kind
  21725. * - VertexBuffer.UV3Kind
  21726. * - VertexBuffer.UV4Kind
  21727. * - VertexBuffer.UV5Kind
  21728. * - VertexBuffer.UV6Kind
  21729. * - VertexBuffer.ColorKind
  21730. * - VertexBuffer.MatricesIndicesKind
  21731. * - VertexBuffer.MatricesIndicesExtraKind
  21732. * - VertexBuffer.MatricesWeightsKind
  21733. * - VertexBuffer.MatricesWeightsExtraKind
  21734. * @param data defines the data source
  21735. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  21736. * @param stride defines the data stride size (can be null)
  21737. * @returns the current mesh
  21738. */
  21739. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  21740. /**
  21741. * Flags an associated vertex buffer as updatable
  21742. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  21743. * - VertexBuffer.PositionKind
  21744. * - VertexBuffer.UVKind
  21745. * - VertexBuffer.UV2Kind
  21746. * - VertexBuffer.UV3Kind
  21747. * - VertexBuffer.UV4Kind
  21748. * - VertexBuffer.UV5Kind
  21749. * - VertexBuffer.UV6Kind
  21750. * - VertexBuffer.ColorKind
  21751. * - VertexBuffer.MatricesIndicesKind
  21752. * - VertexBuffer.MatricesIndicesExtraKind
  21753. * - VertexBuffer.MatricesWeightsKind
  21754. * - VertexBuffer.MatricesWeightsExtraKind
  21755. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  21756. */
  21757. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  21758. /**
  21759. * Sets the mesh global Vertex Buffer
  21760. * @param buffer defines the buffer to use
  21761. * @returns the current mesh
  21762. */
  21763. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  21764. /**
  21765. * Update a specific associated vertex buffer
  21766. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21767. * - VertexBuffer.PositionKind
  21768. * - VertexBuffer.UVKind
  21769. * - VertexBuffer.UV2Kind
  21770. * - VertexBuffer.UV3Kind
  21771. * - VertexBuffer.UV4Kind
  21772. * - VertexBuffer.UV5Kind
  21773. * - VertexBuffer.UV6Kind
  21774. * - VertexBuffer.ColorKind
  21775. * - VertexBuffer.MatricesIndicesKind
  21776. * - VertexBuffer.MatricesIndicesExtraKind
  21777. * - VertexBuffer.MatricesWeightsKind
  21778. * - VertexBuffer.MatricesWeightsExtraKind
  21779. * @param data defines the data source
  21780. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  21781. * @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)
  21782. * @returns the current mesh
  21783. */
  21784. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  21785. /**
  21786. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  21787. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  21788. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  21789. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  21790. * @returns the current mesh
  21791. */
  21792. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  21793. /**
  21794. * Creates a un-shared specific occurence of the geometry for the mesh.
  21795. * @returns the current mesh
  21796. */
  21797. makeGeometryUnique(): Mesh;
  21798. /**
  21799. * Set the index buffer of this mesh
  21800. * @param indices defines the source data
  21801. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  21802. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  21803. * @returns the current mesh
  21804. */
  21805. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  21806. /**
  21807. * Update the current index buffer
  21808. * @param indices defines the source data
  21809. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  21810. * @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)
  21811. * @returns the current mesh
  21812. */
  21813. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  21814. /**
  21815. * Invert the geometry to move from a right handed system to a left handed one.
  21816. * @returns the current mesh
  21817. */
  21818. toLeftHanded(): Mesh;
  21819. /** @hidden */
  21820. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  21821. /** @hidden */
  21822. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  21823. /**
  21824. * Registers for this mesh a javascript function called just before the rendering process
  21825. * @param func defines the function to call before rendering this mesh
  21826. * @returns the current mesh
  21827. */
  21828. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  21829. /**
  21830. * Disposes a previously registered javascript function called before the rendering
  21831. * @param func defines the function to remove
  21832. * @returns the current mesh
  21833. */
  21834. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  21835. /**
  21836. * Registers for this mesh a javascript function called just after the rendering is complete
  21837. * @param func defines the function to call after rendering this mesh
  21838. * @returns the current mesh
  21839. */
  21840. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  21841. /**
  21842. * Disposes a previously registered javascript function called after the rendering.
  21843. * @param func defines the function to remove
  21844. * @returns the current mesh
  21845. */
  21846. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  21847. /** @hidden */
  21848. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  21849. /** @hidden */
  21850. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  21851. /** @hidden */
  21852. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  21853. /** @hidden */
  21854. _freeze(): void;
  21855. /** @hidden */
  21856. _unFreeze(): void;
  21857. /**
  21858. * 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
  21859. * @param subMesh defines the subMesh to render
  21860. * @param enableAlphaMode defines if alpha mode can be changed
  21861. * @returns the current mesh
  21862. */
  21863. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  21864. private _onBeforeDraw;
  21865. /**
  21866. * Renormalize the mesh and patch it up if there are no weights
  21867. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  21868. * However in the case of zero weights then we set just a single influence to 1.
  21869. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  21870. */
  21871. cleanMatrixWeights(): void;
  21872. private normalizeSkinFourWeights;
  21873. private normalizeSkinWeightsAndExtra;
  21874. /**
  21875. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  21876. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  21877. * the user know there was an issue with importing the mesh
  21878. * @returns a validation object with skinned, valid and report string
  21879. */
  21880. validateSkinning(): {
  21881. skinned: boolean;
  21882. valid: boolean;
  21883. report: string;
  21884. };
  21885. /** @hidden */
  21886. _checkDelayState(): Mesh;
  21887. private _queueLoad;
  21888. /**
  21889. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  21890. * A mesh is in the frustum if its bounding box intersects the frustum
  21891. * @param frustumPlanes defines the frustum to test
  21892. * @returns true if the mesh is in the frustum planes
  21893. */
  21894. isInFrustum(frustumPlanes: Plane[]): boolean;
  21895. /**
  21896. * Sets the mesh material by the material or multiMaterial `id` property
  21897. * @param id is a string identifying the material or the multiMaterial
  21898. * @returns the current mesh
  21899. */
  21900. setMaterialByID(id: string): Mesh;
  21901. /**
  21902. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  21903. * @returns an array of IAnimatable
  21904. */
  21905. getAnimatables(): IAnimatable[];
  21906. /**
  21907. * Modifies the mesh geometry according to the passed transformation matrix.
  21908. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  21909. * The mesh normals are modified using the same transformation.
  21910. * Note that, under the hood, this method sets a new VertexBuffer each call.
  21911. * @param transform defines the transform matrix to use
  21912. * @see http://doc.babylonjs.com/resources/baking_transformations
  21913. * @returns the current mesh
  21914. */
  21915. bakeTransformIntoVertices(transform: Matrix): Mesh;
  21916. /**
  21917. * Modifies the mesh geometry according to its own current World Matrix.
  21918. * The mesh World Matrix is then reset.
  21919. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  21920. * Note that, under the hood, this method sets a new VertexBuffer each call.
  21921. * @see http://doc.babylonjs.com/resources/baking_transformations
  21922. * @returns the current mesh
  21923. */
  21924. bakeCurrentTransformIntoVertices(): Mesh;
  21925. /** @hidden */
  21926. readonly _positions: Nullable<Vector3[]>;
  21927. /** @hidden */
  21928. _resetPointsArrayCache(): Mesh;
  21929. /** @hidden */
  21930. _generatePointsArray(): boolean;
  21931. /**
  21932. * Returns a new Mesh object generated from the current mesh properties.
  21933. * This method must not get confused with createInstance()
  21934. * @param name is a string, the name given to the new mesh
  21935. * @param newParent can be any Node object (default `null`)
  21936. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  21937. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  21938. * @returns a new mesh
  21939. */
  21940. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  21941. /**
  21942. * Releases resources associated with this mesh.
  21943. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  21944. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  21945. */
  21946. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  21947. /**
  21948. * Modifies the mesh geometry according to a displacement map.
  21949. * 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.
  21950. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  21951. * @param url is a string, the URL from the image file is to be downloaded.
  21952. * @param minHeight is the lower limit of the displacement.
  21953. * @param maxHeight is the upper limit of the displacement.
  21954. * @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.
  21955. * @param uvOffset is an optional vector2 used to offset UV.
  21956. * @param uvScale is an optional vector2 used to scale UV.
  21957. * @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.
  21958. * @returns the Mesh.
  21959. */
  21960. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  21961. /**
  21962. * Modifies the mesh geometry according to a displacementMap buffer.
  21963. * 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.
  21964. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  21965. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  21966. * @param heightMapWidth is the width of the buffer image.
  21967. * @param heightMapHeight is the height of the buffer image.
  21968. * @param minHeight is the lower limit of the displacement.
  21969. * @param maxHeight is the upper limit of the displacement.
  21970. * @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.
  21971. * @param uvOffset is an optional vector2 used to offset UV.
  21972. * @param uvScale is an optional vector2 used to scale UV.
  21973. * @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.
  21974. * @returns the Mesh.
  21975. */
  21976. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  21977. /**
  21978. * Modify the mesh to get a flat shading rendering.
  21979. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  21980. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  21981. * @returns current mesh
  21982. */
  21983. convertToFlatShadedMesh(): Mesh;
  21984. /**
  21985. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  21986. * In other words, more vertices, no more indices and a single bigger VBO.
  21987. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  21988. * @returns current mesh
  21989. */
  21990. convertToUnIndexedMesh(): Mesh;
  21991. /**
  21992. * Inverses facet orientations.
  21993. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  21994. * @param flipNormals will also inverts the normals
  21995. * @returns current mesh
  21996. */
  21997. flipFaces(flipNormals?: boolean): Mesh;
  21998. /**
  21999. * Increase the number of facets and hence vertices in a mesh
  22000. * Vertex normals are interpolated from existing vertex normals
  22001. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  22002. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  22003. */
  22004. increaseVertices(numberPerEdge: number): void;
  22005. /**
  22006. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  22007. * This will undo any application of covertToFlatShadedMesh
  22008. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  22009. */
  22010. forceSharedVertices(): void;
  22011. /** @hidden */
  22012. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  22013. /** @hidden */
  22014. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  22015. /**
  22016. * Creates a new InstancedMesh object from the mesh model.
  22017. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  22018. * @param name defines the name of the new instance
  22019. * @returns a new InstancedMesh
  22020. */
  22021. createInstance(name: string): InstancedMesh;
  22022. /**
  22023. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  22024. * After this call, all the mesh instances have the same submeshes than the current mesh.
  22025. * @returns the current mesh
  22026. */
  22027. synchronizeInstances(): Mesh;
  22028. /**
  22029. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  22030. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  22031. * This should be used together with the simplification to avoid disappearing triangles.
  22032. * @param successCallback an optional success callback to be called after the optimization finished.
  22033. * @returns the current mesh
  22034. */
  22035. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  22036. /**
  22037. * Serialize current mesh
  22038. * @param serializationObject defines the object which will receive the serialization data
  22039. */
  22040. serialize(serializationObject: any): void;
  22041. /** @hidden */
  22042. _syncGeometryWithMorphTargetManager(): void;
  22043. /** @hidden */
  22044. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  22045. /**
  22046. * Returns a new Mesh object parsed from the source provided.
  22047. * @param parsedMesh is the source
  22048. * @param scene defines the hosting scene
  22049. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  22050. * @returns a new Mesh
  22051. */
  22052. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  22053. /**
  22054. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  22055. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  22056. * @param name defines the name of the mesh to create
  22057. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  22058. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  22059. * @param closePath creates a seam between the first and the last points of each path of the path array
  22060. * @param offset is taken in account only if the `pathArray` is containing a single path
  22061. * @param scene defines the hosting scene
  22062. * @param updatable defines if the mesh must be flagged as updatable
  22063. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22064. * @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)
  22065. * @returns a new Mesh
  22066. */
  22067. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  22068. /**
  22069. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  22070. * @param name defines the name of the mesh to create
  22071. * @param radius sets the radius size (float) of the polygon (default 0.5)
  22072. * @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
  22073. * @param scene defines the hosting scene
  22074. * @param updatable defines if the mesh must be flagged as updatable
  22075. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22076. * @returns a new Mesh
  22077. */
  22078. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  22079. /**
  22080. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  22081. * @param name defines the name of the mesh to create
  22082. * @param size sets the size (float) of each box side (default 1)
  22083. * @param scene defines the hosting scene
  22084. * @param updatable defines if the mesh must be flagged as updatable
  22085. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22086. * @returns a new Mesh
  22087. */
  22088. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  22089. /**
  22090. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  22091. * @param name defines the name of the mesh to create
  22092. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  22093. * @param diameter sets the diameter size (float) of the sphere (default 1)
  22094. * @param scene defines the hosting scene
  22095. * @param updatable defines if the mesh must be flagged as updatable
  22096. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22097. * @returns a new Mesh
  22098. */
  22099. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  22100. /**
  22101. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  22102. * @param name defines the name of the mesh to create
  22103. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  22104. * @param diameter sets the diameter size (float) of the sphere (default 1)
  22105. * @param scene defines the hosting scene
  22106. * @returns a new Mesh
  22107. */
  22108. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  22109. /**
  22110. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  22111. * @param name defines the name of the mesh to create
  22112. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  22113. * @param diameterTop set the top cap diameter (floats, default 1)
  22114. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  22115. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  22116. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  22117. * @param scene defines the hosting scene
  22118. * @param updatable defines if the mesh must be flagged as updatable
  22119. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22120. * @returns a new Mesh
  22121. */
  22122. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  22123. /**
  22124. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  22125. * @param name defines the name of the mesh to create
  22126. * @param diameter sets the diameter size (float) of the torus (default 1)
  22127. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  22128. * @param tessellation sets the number of torus sides (postive integer, default 16)
  22129. * @param scene defines the hosting scene
  22130. * @param updatable defines if the mesh must be flagged as updatable
  22131. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22132. * @returns a new Mesh
  22133. */
  22134. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  22135. /**
  22136. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  22137. * @param name defines the name of the mesh to create
  22138. * @param radius sets the global radius size (float) of the torus knot (default 2)
  22139. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  22140. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  22141. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  22142. * @param p the number of windings on X axis (positive integers, default 2)
  22143. * @param q the number of windings on Y axis (positive integers, default 3)
  22144. * @param scene defines the hosting scene
  22145. * @param updatable defines if the mesh must be flagged as updatable
  22146. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22147. * @returns a new Mesh
  22148. */
  22149. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  22150. /**
  22151. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  22152. * @param name defines the name of the mesh to create
  22153. * @param points is an array successive Vector3
  22154. * @param scene defines the hosting scene
  22155. * @param updatable defines if the mesh must be flagged as updatable
  22156. * @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).
  22157. * @returns a new Mesh
  22158. */
  22159. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  22160. /**
  22161. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  22162. * @param name defines the name of the mesh to create
  22163. * @param points is an array successive Vector3
  22164. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  22165. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  22166. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  22167. * @param scene defines the hosting scene
  22168. * @param updatable defines if the mesh must be flagged as updatable
  22169. * @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)
  22170. * @returns a new Mesh
  22171. */
  22172. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  22173. /**
  22174. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  22175. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  22176. * 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.
  22177. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22178. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22179. * Remember you can only change the shape positions, not their number when updating a polygon.
  22180. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  22181. * @param name defines the name of the mesh to create
  22182. * @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
  22183. * @param scene defines the hosting scene
  22184. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  22185. * @param updatable defines if the mesh must be flagged as updatable
  22186. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22187. * @param earcutInjection can be used to inject your own earcut reference
  22188. * @returns a new Mesh
  22189. */
  22190. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  22191. /**
  22192. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  22193. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  22194. * @param name defines the name of the mesh to create
  22195. * @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
  22196. * @param depth defines the height of extrusion
  22197. * @param scene defines the hosting scene
  22198. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  22199. * @param updatable defines if the mesh must be flagged as updatable
  22200. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22201. * @param earcutInjection can be used to inject your own earcut reference
  22202. * @returns a new Mesh
  22203. */
  22204. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  22205. /**
  22206. * Creates an extruded shape mesh.
  22207. * 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
  22208. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  22209. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  22210. * @param name defines the name of the mesh to create
  22211. * @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
  22212. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  22213. * @param scale is the value to scale the shape
  22214. * @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
  22215. * @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
  22216. * @param scene defines the hosting scene
  22217. * @param updatable defines if the mesh must be flagged as updatable
  22218. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22219. * @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)
  22220. * @returns a new Mesh
  22221. */
  22222. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  22223. /**
  22224. * Creates an custom extruded shape mesh.
  22225. * The custom extrusion is a parametric shape.
  22226. * It has no predefined shape. Its final shape will depend on the input parameters.
  22227. * Please consider using the same method from the MeshBuilder class instead
  22228. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  22229. * @param name defines the name of the mesh to create
  22230. * @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
  22231. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  22232. * @param scaleFunction is a custom Javascript function called on each path point
  22233. * @param rotationFunction is a custom Javascript function called on each path point
  22234. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  22235. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  22236. * @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
  22237. * @param scene defines the hosting scene
  22238. * @param updatable defines if the mesh must be flagged as updatable
  22239. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22240. * @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)
  22241. * @returns a new Mesh
  22242. */
  22243. 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;
  22244. /**
  22245. * Creates lathe mesh.
  22246. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  22247. * Please consider using the same method from the MeshBuilder class instead
  22248. * @param name defines the name of the mesh to create
  22249. * @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
  22250. * @param radius is the radius value of the lathe
  22251. * @param tessellation is the side number of the lathe.
  22252. * @param scene defines the hosting scene
  22253. * @param updatable defines if the mesh must be flagged as updatable
  22254. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22255. * @returns a new Mesh
  22256. */
  22257. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  22258. /**
  22259. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  22260. * @param name defines the name of the mesh to create
  22261. * @param size sets the size (float) of both sides of the plane at once (default 1)
  22262. * @param scene defines the hosting scene
  22263. * @param updatable defines if the mesh must be flagged as updatable
  22264. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22265. * @returns a new Mesh
  22266. */
  22267. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  22268. /**
  22269. * Creates a ground mesh.
  22270. * Please consider using the same method from the MeshBuilder class instead
  22271. * @param name defines the name of the mesh to create
  22272. * @param width set the width of the ground
  22273. * @param height set the height of the ground
  22274. * @param subdivisions sets the number of subdivisions per side
  22275. * @param scene defines the hosting scene
  22276. * @param updatable defines if the mesh must be flagged as updatable
  22277. * @returns a new Mesh
  22278. */
  22279. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  22280. /**
  22281. * Creates a tiled ground mesh.
  22282. * Please consider using the same method from the MeshBuilder class instead
  22283. * @param name defines the name of the mesh to create
  22284. * @param xmin set the ground minimum X coordinate
  22285. * @param zmin set the ground minimum Y coordinate
  22286. * @param xmax set the ground maximum X coordinate
  22287. * @param zmax set the ground maximum Z coordinate
  22288. * @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
  22289. * @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
  22290. * @param scene defines the hosting scene
  22291. * @param updatable defines if the mesh must be flagged as updatable
  22292. * @returns a new Mesh
  22293. */
  22294. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  22295. w: number;
  22296. h: number;
  22297. }, precision: {
  22298. w: number;
  22299. h: number;
  22300. }, scene: Scene, updatable?: boolean): Mesh;
  22301. /**
  22302. * Creates a ground mesh from a height map.
  22303. * Please consider using the same method from the MeshBuilder class instead
  22304. * @see http://doc.babylonjs.com/babylon101/height_map
  22305. * @param name defines the name of the mesh to create
  22306. * @param url sets the URL of the height map image resource
  22307. * @param width set the ground width size
  22308. * @param height set the ground height size
  22309. * @param subdivisions sets the number of subdivision per side
  22310. * @param minHeight is the minimum altitude on the ground
  22311. * @param maxHeight is the maximum altitude on the ground
  22312. * @param scene defines the hosting scene
  22313. * @param updatable defines if the mesh must be flagged as updatable
  22314. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  22315. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  22316. * @returns a new Mesh
  22317. */
  22318. 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;
  22319. /**
  22320. * Creates a tube mesh.
  22321. * The tube is a parametric shape.
  22322. * It has no predefined shape. Its final shape will depend on the input parameters.
  22323. * Please consider using the same method from the MeshBuilder class instead
  22324. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  22325. * @param name defines the name of the mesh to create
  22326. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  22327. * @param radius sets the tube radius size
  22328. * @param tessellation is the number of sides on the tubular surface
  22329. * @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
  22330. * @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
  22331. * @param scene defines the hosting scene
  22332. * @param updatable defines if the mesh must be flagged as updatable
  22333. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22334. * @param 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)
  22335. * @returns a new Mesh
  22336. */
  22337. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  22338. (i: number, distance: number): number;
  22339. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  22340. /**
  22341. * Creates a polyhedron mesh.
  22342. * Please consider using the same method from the MeshBuilder class instead.
  22343. * * 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
  22344. * * The parameter `size` (positive float, default 1) sets the polygon size
  22345. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  22346. * * 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`
  22347. * * 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
  22348. * * 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)`)
  22349. * * 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
  22350. * * 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
  22351. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22352. * * If you create a double-sided mesh, you can choose what parts of 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
  22353. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22354. * @param name defines the name of the mesh to create
  22355. * @param options defines the options used to create the mesh
  22356. * @param scene defines the hosting scene
  22357. * @returns a new Mesh
  22358. */
  22359. static CreatePolyhedron(name: string, options: {
  22360. type?: number;
  22361. size?: number;
  22362. sizeX?: number;
  22363. sizeY?: number;
  22364. sizeZ?: number;
  22365. custom?: any;
  22366. faceUV?: Vector4[];
  22367. faceColors?: Color4[];
  22368. updatable?: boolean;
  22369. sideOrientation?: number;
  22370. }, scene: Scene): Mesh;
  22371. /**
  22372. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  22373. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  22374. * * 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`)
  22375. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  22376. * * 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
  22377. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22378. * * If you create a double-sided mesh, you can choose what parts of 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
  22379. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22380. * @param name defines the name of the mesh
  22381. * @param options defines the options used to create the mesh
  22382. * @param scene defines the hosting scene
  22383. * @returns a new Mesh
  22384. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  22385. */
  22386. static CreateIcoSphere(name: string, options: {
  22387. radius?: number;
  22388. flat?: boolean;
  22389. subdivisions?: number;
  22390. sideOrientation?: number;
  22391. updatable?: boolean;
  22392. }, scene: Scene): Mesh;
  22393. /**
  22394. * Creates a decal mesh.
  22395. * Please consider using the same method from the MeshBuilder class instead.
  22396. * A decal is a mesh usually applied as a model onto the surface of another mesh
  22397. * @param name defines the name of the mesh
  22398. * @param sourceMesh defines the mesh receiving the decal
  22399. * @param position sets the position of the decal in world coordinates
  22400. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  22401. * @param size sets the decal scaling
  22402. * @param angle sets the angle to rotate the decal
  22403. * @returns a new Mesh
  22404. */
  22405. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  22406. /**
  22407. * Prepare internal position array for software CPU skinning
  22408. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  22409. */
  22410. setPositionsForCPUSkinning(): Float32Array;
  22411. /**
  22412. * Prepare internal normal array for software CPU skinning
  22413. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  22414. */
  22415. setNormalsForCPUSkinning(): Float32Array;
  22416. /**
  22417. * Updates the vertex buffer by applying transformation from the bones
  22418. * @param skeleton defines the skeleton to apply to current mesh
  22419. * @returns the current mesh
  22420. */
  22421. applySkeleton(skeleton: Skeleton): Mesh;
  22422. /**
  22423. * 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
  22424. * @param meshes defines the list of meshes to scan
  22425. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  22426. */
  22427. static MinMax(meshes: AbstractMesh[]): {
  22428. min: Vector3;
  22429. max: Vector3;
  22430. };
  22431. /**
  22432. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  22433. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  22434. * @returns a vector3
  22435. */
  22436. static Center(meshesOrMinMaxVector: {
  22437. min: Vector3;
  22438. max: Vector3;
  22439. } | AbstractMesh[]): Vector3;
  22440. /**
  22441. * Merge the array of meshes into a single mesh for performance reasons.
  22442. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  22443. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  22444. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  22445. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  22446. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  22447. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  22448. * @returns a new mesh
  22449. */
  22450. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  22451. /** @hidden */
  22452. addInstance(instance: InstancedMesh): void;
  22453. /** @hidden */
  22454. removeInstance(instance: InstancedMesh): void;
  22455. }
  22456. }
  22457. declare module "babylonjs/Materials/material" {
  22458. import { IAnimatable } from "babylonjs/Misc/tools";
  22459. import { SmartArray } from "babylonjs/Misc/smartArray";
  22460. import { Observable } from "babylonjs/Misc/observable";
  22461. import { Nullable } from "babylonjs/types";
  22462. import { Scene } from "babylonjs/scene";
  22463. import { Matrix } from "babylonjs/Maths/math";
  22464. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  22465. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22466. import { Mesh } from "babylonjs/Meshes/mesh";
  22467. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  22468. import { Effect } from "babylonjs/Materials/effect";
  22469. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  22470. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  22471. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  22472. import { IInspectable } from "babylonjs/Misc/iInspectable";
  22473. import { Animation } from "babylonjs/Animations/animation";
  22474. /**
  22475. * Base class for the main features of a material in Babylon.js
  22476. */
  22477. export class Material implements IAnimatable {
  22478. /**
  22479. * Returns the triangle fill mode
  22480. */
  22481. static readonly TriangleFillMode: number;
  22482. /**
  22483. * Returns the wireframe mode
  22484. */
  22485. static readonly WireFrameFillMode: number;
  22486. /**
  22487. * Returns the point fill mode
  22488. */
  22489. static readonly PointFillMode: number;
  22490. /**
  22491. * Returns the point list draw mode
  22492. */
  22493. static readonly PointListDrawMode: number;
  22494. /**
  22495. * Returns the line list draw mode
  22496. */
  22497. static readonly LineListDrawMode: number;
  22498. /**
  22499. * Returns the line loop draw mode
  22500. */
  22501. static readonly LineLoopDrawMode: number;
  22502. /**
  22503. * Returns the line strip draw mode
  22504. */
  22505. static readonly LineStripDrawMode: number;
  22506. /**
  22507. * Returns the triangle strip draw mode
  22508. */
  22509. static readonly TriangleStripDrawMode: number;
  22510. /**
  22511. * Returns the triangle fan draw mode
  22512. */
  22513. static readonly TriangleFanDrawMode: number;
  22514. /**
  22515. * Stores the clock-wise side orientation
  22516. */
  22517. static readonly ClockWiseSideOrientation: number;
  22518. /**
  22519. * Stores the counter clock-wise side orientation
  22520. */
  22521. static readonly CounterClockWiseSideOrientation: number;
  22522. /**
  22523. * The dirty texture flag value
  22524. */
  22525. static readonly TextureDirtyFlag: number;
  22526. /**
  22527. * The dirty light flag value
  22528. */
  22529. static readonly LightDirtyFlag: number;
  22530. /**
  22531. * The dirty fresnel flag value
  22532. */
  22533. static readonly FresnelDirtyFlag: number;
  22534. /**
  22535. * The dirty attribute flag value
  22536. */
  22537. static readonly AttributesDirtyFlag: number;
  22538. /**
  22539. * The dirty misc flag value
  22540. */
  22541. static readonly MiscDirtyFlag: number;
  22542. /**
  22543. * The all dirty flag value
  22544. */
  22545. static readonly AllDirtyFlag: number;
  22546. /**
  22547. * The ID of the material
  22548. */
  22549. id: string;
  22550. /**
  22551. * Gets or sets the unique id of the material
  22552. */
  22553. uniqueId: number;
  22554. /**
  22555. * The name of the material
  22556. */
  22557. name: string;
  22558. /**
  22559. * Gets or sets user defined metadata
  22560. */
  22561. metadata: any;
  22562. /**
  22563. * For internal use only. Please do not use.
  22564. */
  22565. reservedDataStore: any;
  22566. /**
  22567. * Specifies if the ready state should be checked on each call
  22568. */
  22569. checkReadyOnEveryCall: boolean;
  22570. /**
  22571. * Specifies if the ready state should be checked once
  22572. */
  22573. checkReadyOnlyOnce: boolean;
  22574. /**
  22575. * The state of the material
  22576. */
  22577. state: string;
  22578. /**
  22579. * The alpha value of the material
  22580. */
  22581. protected _alpha: number;
  22582. /**
  22583. * List of inspectable custom properties (used by the Inspector)
  22584. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  22585. */
  22586. inspectableCustomProperties: IInspectable[];
  22587. /**
  22588. * Sets the alpha value of the material
  22589. */
  22590. /**
  22591. * Gets the alpha value of the material
  22592. */
  22593. alpha: number;
  22594. /**
  22595. * Specifies if back face culling is enabled
  22596. */
  22597. protected _backFaceCulling: boolean;
  22598. /**
  22599. * Sets the back-face culling state
  22600. */
  22601. /**
  22602. * Gets the back-face culling state
  22603. */
  22604. backFaceCulling: boolean;
  22605. /**
  22606. * Stores the value for side orientation
  22607. */
  22608. sideOrientation: number;
  22609. /**
  22610. * Callback triggered when the material is compiled
  22611. */
  22612. onCompiled: Nullable<(effect: Effect) => void>;
  22613. /**
  22614. * Callback triggered when an error occurs
  22615. */
  22616. onError: Nullable<(effect: Effect, errors: string) => void>;
  22617. /**
  22618. * Callback triggered to get the render target textures
  22619. */
  22620. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  22621. /**
  22622. * Gets a boolean indicating that current material needs to register RTT
  22623. */
  22624. readonly hasRenderTargetTextures: boolean;
  22625. /**
  22626. * Specifies if the material should be serialized
  22627. */
  22628. doNotSerialize: boolean;
  22629. /**
  22630. * @hidden
  22631. */
  22632. _storeEffectOnSubMeshes: boolean;
  22633. /**
  22634. * Stores the animations for the material
  22635. */
  22636. animations: Nullable<Array<Animation>>;
  22637. /**
  22638. * An event triggered when the material is disposed
  22639. */
  22640. onDisposeObservable: Observable<Material>;
  22641. /**
  22642. * An observer which watches for dispose events
  22643. */
  22644. private _onDisposeObserver;
  22645. private _onUnBindObservable;
  22646. /**
  22647. * Called during a dispose event
  22648. */
  22649. onDispose: () => void;
  22650. private _onBindObservable;
  22651. /**
  22652. * An event triggered when the material is bound
  22653. */
  22654. readonly onBindObservable: Observable<AbstractMesh>;
  22655. /**
  22656. * An observer which watches for bind events
  22657. */
  22658. private _onBindObserver;
  22659. /**
  22660. * Called during a bind event
  22661. */
  22662. onBind: (Mesh: AbstractMesh) => void;
  22663. /**
  22664. * An event triggered when the material is unbound
  22665. */
  22666. readonly onUnBindObservable: Observable<Material>;
  22667. /**
  22668. * Stores the value of the alpha mode
  22669. */
  22670. private _alphaMode;
  22671. /**
  22672. * Sets the value of the alpha mode.
  22673. *
  22674. * | Value | Type | Description |
  22675. * | --- | --- | --- |
  22676. * | 0 | ALPHA_DISABLE | |
  22677. * | 1 | ALPHA_ADD | |
  22678. * | 2 | ALPHA_COMBINE | |
  22679. * | 3 | ALPHA_SUBTRACT | |
  22680. * | 4 | ALPHA_MULTIPLY | |
  22681. * | 5 | ALPHA_MAXIMIZED | |
  22682. * | 6 | ALPHA_ONEONE | |
  22683. * | 7 | ALPHA_PREMULTIPLIED | |
  22684. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  22685. * | 9 | ALPHA_INTERPOLATE | |
  22686. * | 10 | ALPHA_SCREENMODE | |
  22687. *
  22688. */
  22689. /**
  22690. * Gets the value of the alpha mode
  22691. */
  22692. alphaMode: number;
  22693. /**
  22694. * Stores the state of the need depth pre-pass value
  22695. */
  22696. private _needDepthPrePass;
  22697. /**
  22698. * Sets the need depth pre-pass value
  22699. */
  22700. /**
  22701. * Gets the depth pre-pass value
  22702. */
  22703. needDepthPrePass: boolean;
  22704. /**
  22705. * Specifies if depth writing should be disabled
  22706. */
  22707. disableDepthWrite: boolean;
  22708. /**
  22709. * Specifies if depth writing should be forced
  22710. */
  22711. forceDepthWrite: boolean;
  22712. /**
  22713. * Specifies if there should be a separate pass for culling
  22714. */
  22715. separateCullingPass: boolean;
  22716. /**
  22717. * Stores the state specifing if fog should be enabled
  22718. */
  22719. private _fogEnabled;
  22720. /**
  22721. * Sets the state for enabling fog
  22722. */
  22723. /**
  22724. * Gets the value of the fog enabled state
  22725. */
  22726. fogEnabled: boolean;
  22727. /**
  22728. * Stores the size of points
  22729. */
  22730. pointSize: number;
  22731. /**
  22732. * Stores the z offset value
  22733. */
  22734. zOffset: number;
  22735. /**
  22736. * Gets a value specifying if wireframe mode is enabled
  22737. */
  22738. /**
  22739. * Sets the state of wireframe mode
  22740. */
  22741. wireframe: boolean;
  22742. /**
  22743. * Gets the value specifying if point clouds are enabled
  22744. */
  22745. /**
  22746. * Sets the state of point cloud mode
  22747. */
  22748. pointsCloud: boolean;
  22749. /**
  22750. * Gets the material fill mode
  22751. */
  22752. /**
  22753. * Sets the material fill mode
  22754. */
  22755. fillMode: number;
  22756. /**
  22757. * @hidden
  22758. * Stores the effects for the material
  22759. */
  22760. _effect: Nullable<Effect>;
  22761. /**
  22762. * @hidden
  22763. * Specifies if the material was previously ready
  22764. */
  22765. _wasPreviouslyReady: boolean;
  22766. /**
  22767. * Specifies if uniform buffers should be used
  22768. */
  22769. private _useUBO;
  22770. /**
  22771. * Stores a reference to the scene
  22772. */
  22773. private _scene;
  22774. /**
  22775. * Stores the fill mode state
  22776. */
  22777. private _fillMode;
  22778. /**
  22779. * Specifies if the depth write state should be cached
  22780. */
  22781. private _cachedDepthWriteState;
  22782. /**
  22783. * Stores the uniform buffer
  22784. */
  22785. protected _uniformBuffer: UniformBuffer;
  22786. /** @hidden */
  22787. _indexInSceneMaterialArray: number;
  22788. /** @hidden */
  22789. meshMap: Nullable<{
  22790. [id: string]: AbstractMesh | undefined;
  22791. }>;
  22792. /**
  22793. * Creates a material instance
  22794. * @param name defines the name of the material
  22795. * @param scene defines the scene to reference
  22796. * @param doNotAdd specifies if the material should be added to the scene
  22797. */
  22798. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  22799. /**
  22800. * Returns a string representation of the current material
  22801. * @param fullDetails defines a boolean indicating which levels of logging is desired
  22802. * @returns a string with material information
  22803. */
  22804. toString(fullDetails?: boolean): string;
  22805. /**
  22806. * Gets the class name of the material
  22807. * @returns a string with the class name of the material
  22808. */
  22809. getClassName(): string;
  22810. /**
  22811. * Specifies if updates for the material been locked
  22812. */
  22813. readonly isFrozen: boolean;
  22814. /**
  22815. * Locks updates for the material
  22816. */
  22817. freeze(): void;
  22818. /**
  22819. * Unlocks updates for the material
  22820. */
  22821. unfreeze(): void;
  22822. /**
  22823. * Specifies if the material is ready to be used
  22824. * @param mesh defines the mesh to check
  22825. * @param useInstances specifies if instances should be used
  22826. * @returns a boolean indicating if the material is ready to be used
  22827. */
  22828. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  22829. /**
  22830. * Specifies that the submesh is ready to be used
  22831. * @param mesh defines the mesh to check
  22832. * @param subMesh defines which submesh to check
  22833. * @param useInstances specifies that instances should be used
  22834. * @returns a boolean indicating that the submesh is ready or not
  22835. */
  22836. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  22837. /**
  22838. * Returns the material effect
  22839. * @returns the effect associated with the material
  22840. */
  22841. getEffect(): Nullable<Effect>;
  22842. /**
  22843. * Returns the current scene
  22844. * @returns a Scene
  22845. */
  22846. getScene(): Scene;
  22847. /**
  22848. * Specifies if the material will require alpha blending
  22849. * @returns a boolean specifying if alpha blending is needed
  22850. */
  22851. needAlphaBlending(): boolean;
  22852. /**
  22853. * Specifies if the mesh will require alpha blending
  22854. * @param mesh defines the mesh to check
  22855. * @returns a boolean specifying if alpha blending is needed for the mesh
  22856. */
  22857. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  22858. /**
  22859. * Specifies if this material should be rendered in alpha test mode
  22860. * @returns a boolean specifying if an alpha test is needed.
  22861. */
  22862. needAlphaTesting(): boolean;
  22863. /**
  22864. * Gets the texture used for the alpha test
  22865. * @returns the texture to use for alpha testing
  22866. */
  22867. getAlphaTestTexture(): Nullable<BaseTexture>;
  22868. /**
  22869. * Marks the material to indicate that it needs to be re-calculated
  22870. */
  22871. markDirty(): void;
  22872. /** @hidden */
  22873. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  22874. /**
  22875. * Binds the material to the mesh
  22876. * @param world defines the world transformation matrix
  22877. * @param mesh defines the mesh to bind the material to
  22878. */
  22879. bind(world: Matrix, mesh?: Mesh): void;
  22880. /**
  22881. * Binds the submesh to the material
  22882. * @param world defines the world transformation matrix
  22883. * @param mesh defines the mesh containing the submesh
  22884. * @param subMesh defines the submesh to bind the material to
  22885. */
  22886. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  22887. /**
  22888. * Binds the world matrix to the material
  22889. * @param world defines the world transformation matrix
  22890. */
  22891. bindOnlyWorldMatrix(world: Matrix): void;
  22892. /**
  22893. * Binds the scene's uniform buffer to the effect.
  22894. * @param effect defines the effect to bind to the scene uniform buffer
  22895. * @param sceneUbo defines the uniform buffer storing scene data
  22896. */
  22897. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  22898. /**
  22899. * Binds the view matrix to the effect
  22900. * @param effect defines the effect to bind the view matrix to
  22901. */
  22902. bindView(effect: Effect): void;
  22903. /**
  22904. * Binds the view projection matrix to the effect
  22905. * @param effect defines the effect to bind the view projection matrix to
  22906. */
  22907. bindViewProjection(effect: Effect): void;
  22908. /**
  22909. * Specifies if material alpha testing should be turned on for the mesh
  22910. * @param mesh defines the mesh to check
  22911. */
  22912. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  22913. /**
  22914. * Processes to execute after binding the material to a mesh
  22915. * @param mesh defines the rendered mesh
  22916. */
  22917. protected _afterBind(mesh?: Mesh): void;
  22918. /**
  22919. * Unbinds the material from the mesh
  22920. */
  22921. unbind(): void;
  22922. /**
  22923. * Gets the active textures from the material
  22924. * @returns an array of textures
  22925. */
  22926. getActiveTextures(): BaseTexture[];
  22927. /**
  22928. * Specifies if the material uses a texture
  22929. * @param texture defines the texture to check against the material
  22930. * @returns a boolean specifying if the material uses the texture
  22931. */
  22932. hasTexture(texture: BaseTexture): boolean;
  22933. /**
  22934. * Makes a duplicate of the material, and gives it a new name
  22935. * @param name defines the new name for the duplicated material
  22936. * @returns the cloned material
  22937. */
  22938. clone(name: string): Nullable<Material>;
  22939. /**
  22940. * Gets the meshes bound to the material
  22941. * @returns an array of meshes bound to the material
  22942. */
  22943. getBindedMeshes(): AbstractMesh[];
  22944. /**
  22945. * Force shader compilation
  22946. * @param mesh defines the mesh associated with this material
  22947. * @param onCompiled defines a function to execute once the material is compiled
  22948. * @param options defines the options to configure the compilation
  22949. */
  22950. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  22951. clipPlane: boolean;
  22952. }>): void;
  22953. /**
  22954. * Force shader compilation
  22955. * @param mesh defines the mesh that will use this material
  22956. * @param options defines additional options for compiling the shaders
  22957. * @returns a promise that resolves when the compilation completes
  22958. */
  22959. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  22960. clipPlane: boolean;
  22961. }>): Promise<void>;
  22962. private static readonly _AllDirtyCallBack;
  22963. private static readonly _ImageProcessingDirtyCallBack;
  22964. private static readonly _TextureDirtyCallBack;
  22965. private static readonly _FresnelDirtyCallBack;
  22966. private static readonly _MiscDirtyCallBack;
  22967. private static readonly _LightsDirtyCallBack;
  22968. private static readonly _AttributeDirtyCallBack;
  22969. private static _FresnelAndMiscDirtyCallBack;
  22970. private static _TextureAndMiscDirtyCallBack;
  22971. private static readonly _DirtyCallbackArray;
  22972. private static readonly _RunDirtyCallBacks;
  22973. /**
  22974. * Marks a define in the material to indicate that it needs to be re-computed
  22975. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  22976. */
  22977. markAsDirty(flag: number): void;
  22978. /**
  22979. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  22980. * @param func defines a function which checks material defines against the submeshes
  22981. */
  22982. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  22983. /**
  22984. * Indicates that we need to re-calculated for all submeshes
  22985. */
  22986. protected _markAllSubMeshesAsAllDirty(): void;
  22987. /**
  22988. * Indicates that image processing needs to be re-calculated for all submeshes
  22989. */
  22990. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  22991. /**
  22992. * Indicates that textures need to be re-calculated for all submeshes
  22993. */
  22994. protected _markAllSubMeshesAsTexturesDirty(): void;
  22995. /**
  22996. * Indicates that fresnel needs to be re-calculated for all submeshes
  22997. */
  22998. protected _markAllSubMeshesAsFresnelDirty(): void;
  22999. /**
  23000. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  23001. */
  23002. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  23003. /**
  23004. * Indicates that lights need to be re-calculated for all submeshes
  23005. */
  23006. protected _markAllSubMeshesAsLightsDirty(): void;
  23007. /**
  23008. * Indicates that attributes need to be re-calculated for all submeshes
  23009. */
  23010. protected _markAllSubMeshesAsAttributesDirty(): void;
  23011. /**
  23012. * Indicates that misc needs to be re-calculated for all submeshes
  23013. */
  23014. protected _markAllSubMeshesAsMiscDirty(): void;
  23015. /**
  23016. * Indicates that textures and misc need to be re-calculated for all submeshes
  23017. */
  23018. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  23019. /**
  23020. * Disposes the material
  23021. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  23022. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  23023. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  23024. */
  23025. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  23026. /** @hidden */
  23027. private releaseVertexArrayObject;
  23028. /**
  23029. * Serializes this material
  23030. * @returns the serialized material object
  23031. */
  23032. serialize(): any;
  23033. /**
  23034. * Creates a material from parsed material data
  23035. * @param parsedMaterial defines parsed material data
  23036. * @param scene defines the hosting scene
  23037. * @param rootUrl defines the root URL to use to load textures
  23038. * @returns a new material
  23039. */
  23040. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  23041. }
  23042. }
  23043. declare module "babylonjs/Meshes/subMesh" {
  23044. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  23045. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  23046. import { Engine } from "babylonjs/Engines/engine";
  23047. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  23048. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23049. import { Effect } from "babylonjs/Materials/effect";
  23050. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  23051. import { Collider } from "babylonjs/Collisions/collider";
  23052. import { Material } from "babylonjs/Materials/material";
  23053. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  23054. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23055. import { Mesh } from "babylonjs/Meshes/mesh";
  23056. import { Ray } from "babylonjs/Culling/ray";
  23057. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  23058. /**
  23059. * Base class for submeshes
  23060. */
  23061. export class BaseSubMesh {
  23062. /** @hidden */
  23063. _materialDefines: Nullable<MaterialDefines>;
  23064. /** @hidden */
  23065. _materialEffect: Nullable<Effect>;
  23066. /**
  23067. * Gets associated effect
  23068. */
  23069. readonly effect: Nullable<Effect>;
  23070. /**
  23071. * Sets associated effect (effect used to render this submesh)
  23072. * @param effect defines the effect to associate with
  23073. * @param defines defines the set of defines used to compile this effect
  23074. */
  23075. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  23076. }
  23077. /**
  23078. * Defines a subdivision inside a mesh
  23079. */
  23080. export class SubMesh extends BaseSubMesh implements ICullable {
  23081. /** the material index to use */
  23082. materialIndex: number;
  23083. /** vertex index start */
  23084. verticesStart: number;
  23085. /** vertices count */
  23086. verticesCount: number;
  23087. /** index start */
  23088. indexStart: number;
  23089. /** indices count */
  23090. indexCount: number;
  23091. /** @hidden */
  23092. _linesIndexCount: number;
  23093. private _mesh;
  23094. private _renderingMesh;
  23095. private _boundingInfo;
  23096. private _linesIndexBuffer;
  23097. /** @hidden */
  23098. _lastColliderWorldVertices: Nullable<Vector3[]>;
  23099. /** @hidden */
  23100. _trianglePlanes: Plane[];
  23101. /** @hidden */
  23102. _lastColliderTransformMatrix: Nullable<Matrix>;
  23103. /** @hidden */
  23104. _renderId: number;
  23105. /** @hidden */
  23106. _alphaIndex: number;
  23107. /** @hidden */
  23108. _distanceToCamera: number;
  23109. /** @hidden */
  23110. _id: number;
  23111. private _currentMaterial;
  23112. /**
  23113. * Add a new submesh to a mesh
  23114. * @param materialIndex defines the material index to use
  23115. * @param verticesStart defines vertex index start
  23116. * @param verticesCount defines vertices count
  23117. * @param indexStart defines index start
  23118. * @param indexCount defines indices count
  23119. * @param mesh defines the parent mesh
  23120. * @param renderingMesh defines an optional rendering mesh
  23121. * @param createBoundingBox defines if bounding box should be created for this submesh
  23122. * @returns the new submesh
  23123. */
  23124. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  23125. /**
  23126. * Creates a new submesh
  23127. * @param materialIndex defines the material index to use
  23128. * @param verticesStart defines vertex index start
  23129. * @param verticesCount defines vertices count
  23130. * @param indexStart defines index start
  23131. * @param indexCount defines indices count
  23132. * @param mesh defines the parent mesh
  23133. * @param renderingMesh defines an optional rendering mesh
  23134. * @param createBoundingBox defines if bounding box should be created for this submesh
  23135. */
  23136. constructor(
  23137. /** the material index to use */
  23138. materialIndex: number,
  23139. /** vertex index start */
  23140. verticesStart: number,
  23141. /** vertices count */
  23142. verticesCount: number,
  23143. /** index start */
  23144. indexStart: number,
  23145. /** indices count */
  23146. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  23147. /**
  23148. * Returns true if this submesh covers the entire parent mesh
  23149. * @ignorenaming
  23150. */
  23151. readonly IsGlobal: boolean;
  23152. /**
  23153. * Returns the submesh BoudingInfo object
  23154. * @returns current bounding info (or mesh's one if the submesh is global)
  23155. */
  23156. getBoundingInfo(): BoundingInfo;
  23157. /**
  23158. * Sets the submesh BoundingInfo
  23159. * @param boundingInfo defines the new bounding info to use
  23160. * @returns the SubMesh
  23161. */
  23162. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  23163. /**
  23164. * Returns the mesh of the current submesh
  23165. * @return the parent mesh
  23166. */
  23167. getMesh(): AbstractMesh;
  23168. /**
  23169. * Returns the rendering mesh of the submesh
  23170. * @returns the rendering mesh (could be different from parent mesh)
  23171. */
  23172. getRenderingMesh(): Mesh;
  23173. /**
  23174. * Returns the submesh material
  23175. * @returns null or the current material
  23176. */
  23177. getMaterial(): Nullable<Material>;
  23178. /**
  23179. * Sets a new updated BoundingInfo object to the submesh
  23180. * @param data defines an optional position array to use to determine the bounding info
  23181. * @returns the SubMesh
  23182. */
  23183. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  23184. /** @hidden */
  23185. _checkCollision(collider: Collider): boolean;
  23186. /**
  23187. * Updates the submesh BoundingInfo
  23188. * @param world defines the world matrix to use to update the bounding info
  23189. * @returns the submesh
  23190. */
  23191. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  23192. /**
  23193. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  23194. * @param frustumPlanes defines the frustum planes
  23195. * @returns true if the submesh is intersecting with the frustum
  23196. */
  23197. isInFrustum(frustumPlanes: Plane[]): boolean;
  23198. /**
  23199. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  23200. * @param frustumPlanes defines the frustum planes
  23201. * @returns true if the submesh is inside the frustum
  23202. */
  23203. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  23204. /**
  23205. * Renders the submesh
  23206. * @param enableAlphaMode defines if alpha needs to be used
  23207. * @returns the submesh
  23208. */
  23209. render(enableAlphaMode: boolean): SubMesh;
  23210. /**
  23211. * @hidden
  23212. */
  23213. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  23214. /**
  23215. * Checks if the submesh intersects with a ray
  23216. * @param ray defines the ray to test
  23217. * @returns true is the passed ray intersects the submesh bounding box
  23218. */
  23219. canIntersects(ray: Ray): boolean;
  23220. /**
  23221. * Intersects current submesh with a ray
  23222. * @param ray defines the ray to test
  23223. * @param positions defines mesh's positions array
  23224. * @param indices defines mesh's indices array
  23225. * @param fastCheck defines if only bounding info should be used
  23226. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  23227. * @returns intersection info or null if no intersection
  23228. */
  23229. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  23230. /** @hidden */
  23231. private _intersectLines;
  23232. /** @hidden */
  23233. private _intersectUnIndexedLines;
  23234. /** @hidden */
  23235. private _intersectTriangles;
  23236. /** @hidden */
  23237. private _intersectUnIndexedTriangles;
  23238. /** @hidden */
  23239. _rebuild(): void;
  23240. /**
  23241. * Creates a new submesh from the passed mesh
  23242. * @param newMesh defines the new hosting mesh
  23243. * @param newRenderingMesh defines an optional rendering mesh
  23244. * @returns the new submesh
  23245. */
  23246. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  23247. /**
  23248. * Release associated resources
  23249. */
  23250. dispose(): void;
  23251. /**
  23252. * Gets the class name
  23253. * @returns the string "SubMesh".
  23254. */
  23255. getClassName(): string;
  23256. /**
  23257. * Creates a new submesh from indices data
  23258. * @param materialIndex the index of the main mesh material
  23259. * @param startIndex the index where to start the copy in the mesh indices array
  23260. * @param indexCount the number of indices to copy then from the startIndex
  23261. * @param mesh the main mesh to create the submesh from
  23262. * @param renderingMesh the optional rendering mesh
  23263. * @returns a new submesh
  23264. */
  23265. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  23266. }
  23267. }
  23268. declare module "babylonjs/Meshes/geometry" {
  23269. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  23270. import { Scene } from "babylonjs/scene";
  23271. import { Vector3, Vector2 } from "babylonjs/Maths/math";
  23272. import { Engine } from "babylonjs/Engines/engine";
  23273. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  23274. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  23275. import { Effect } from "babylonjs/Materials/effect";
  23276. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23277. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  23278. import { Mesh } from "babylonjs/Meshes/mesh";
  23279. /**
  23280. * Class used to store geometry data (vertex buffers + index buffer)
  23281. */
  23282. export class Geometry implements IGetSetVerticesData {
  23283. /**
  23284. * Gets or sets the ID of the geometry
  23285. */
  23286. id: string;
  23287. /**
  23288. * Gets or sets the unique ID of the geometry
  23289. */
  23290. uniqueId: number;
  23291. /**
  23292. * Gets the delay loading state of the geometry (none by default which means not delayed)
  23293. */
  23294. delayLoadState: number;
  23295. /**
  23296. * Gets the file containing the data to load when running in delay load state
  23297. */
  23298. delayLoadingFile: Nullable<string>;
  23299. /**
  23300. * Callback called when the geometry is updated
  23301. */
  23302. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  23303. private _scene;
  23304. private _engine;
  23305. private _meshes;
  23306. private _totalVertices;
  23307. /** @hidden */
  23308. _indices: IndicesArray;
  23309. /** @hidden */
  23310. _vertexBuffers: {
  23311. [key: string]: VertexBuffer;
  23312. };
  23313. private _isDisposed;
  23314. private _extend;
  23315. private _boundingBias;
  23316. /** @hidden */
  23317. _delayInfo: Array<string>;
  23318. private _indexBuffer;
  23319. private _indexBufferIsUpdatable;
  23320. /** @hidden */
  23321. _boundingInfo: Nullable<BoundingInfo>;
  23322. /** @hidden */
  23323. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  23324. /** @hidden */
  23325. _softwareSkinningFrameId: number;
  23326. private _vertexArrayObjects;
  23327. private _updatable;
  23328. /** @hidden */
  23329. _positions: Nullable<Vector3[]>;
  23330. /**
  23331. * 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
  23332. */
  23333. /**
  23334. * 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
  23335. */
  23336. boundingBias: Vector2;
  23337. /**
  23338. * Static function used to attach a new empty geometry to a mesh
  23339. * @param mesh defines the mesh to attach the geometry to
  23340. * @returns the new Geometry
  23341. */
  23342. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  23343. /**
  23344. * Creates a new geometry
  23345. * @param id defines the unique ID
  23346. * @param scene defines the hosting scene
  23347. * @param vertexData defines the VertexData used to get geometry data
  23348. * @param updatable defines if geometry must be updatable (false by default)
  23349. * @param mesh defines the mesh that will be associated with the geometry
  23350. */
  23351. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  23352. /**
  23353. * Gets the current extend of the geometry
  23354. */
  23355. readonly extend: {
  23356. minimum: Vector3;
  23357. maximum: Vector3;
  23358. };
  23359. /**
  23360. * Gets the hosting scene
  23361. * @returns the hosting Scene
  23362. */
  23363. getScene(): Scene;
  23364. /**
  23365. * Gets the hosting engine
  23366. * @returns the hosting Engine
  23367. */
  23368. getEngine(): Engine;
  23369. /**
  23370. * Defines if the geometry is ready to use
  23371. * @returns true if the geometry is ready to be used
  23372. */
  23373. isReady(): boolean;
  23374. /**
  23375. * Gets a value indicating that the geometry should not be serialized
  23376. */
  23377. readonly doNotSerialize: boolean;
  23378. /** @hidden */
  23379. _rebuild(): void;
  23380. /**
  23381. * Affects all geometry data in one call
  23382. * @param vertexData defines the geometry data
  23383. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  23384. */
  23385. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  23386. /**
  23387. * Set specific vertex data
  23388. * @param kind defines the data kind (Position, normal, etc...)
  23389. * @param data defines the vertex data to use
  23390. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  23391. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  23392. */
  23393. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  23394. /**
  23395. * Removes a specific vertex data
  23396. * @param kind defines the data kind (Position, normal, etc...)
  23397. */
  23398. removeVerticesData(kind: string): void;
  23399. /**
  23400. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  23401. * @param buffer defines the vertex buffer to use
  23402. * @param totalVertices defines the total number of vertices for position kind (could be null)
  23403. */
  23404. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  23405. /**
  23406. * Update a specific vertex buffer
  23407. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  23408. * It will do nothing if the buffer is not updatable
  23409. * @param kind defines the data kind (Position, normal, etc...)
  23410. * @param data defines the data to use
  23411. * @param offset defines the offset in the target buffer where to store the data
  23412. * @param useBytes set to true if the offset is in bytes
  23413. */
  23414. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  23415. /**
  23416. * Update a specific vertex buffer
  23417. * This function will create a new buffer if the current one is not updatable
  23418. * @param kind defines the data kind (Position, normal, etc...)
  23419. * @param data defines the data to use
  23420. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  23421. */
  23422. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  23423. private _updateBoundingInfo;
  23424. /** @hidden */
  23425. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  23426. /**
  23427. * Gets total number of vertices
  23428. * @returns the total number of vertices
  23429. */
  23430. getTotalVertices(): number;
  23431. /**
  23432. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  23433. * @param kind defines the data kind (Position, normal, etc...)
  23434. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23435. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23436. * @returns a float array containing vertex data
  23437. */
  23438. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23439. /**
  23440. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  23441. * @param kind defines the data kind (Position, normal, etc...)
  23442. * @returns true if the vertex buffer with the specified kind is updatable
  23443. */
  23444. isVertexBufferUpdatable(kind: string): boolean;
  23445. /**
  23446. * Gets a specific vertex buffer
  23447. * @param kind defines the data kind (Position, normal, etc...)
  23448. * @returns a VertexBuffer
  23449. */
  23450. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  23451. /**
  23452. * Returns all vertex buffers
  23453. * @return an object holding all vertex buffers indexed by kind
  23454. */
  23455. getVertexBuffers(): Nullable<{
  23456. [key: string]: VertexBuffer;
  23457. }>;
  23458. /**
  23459. * Gets a boolean indicating if specific vertex buffer is present
  23460. * @param kind defines the data kind (Position, normal, etc...)
  23461. * @returns true if data is present
  23462. */
  23463. isVerticesDataPresent(kind: string): boolean;
  23464. /**
  23465. * Gets a list of all attached data kinds (Position, normal, etc...)
  23466. * @returns a list of string containing all kinds
  23467. */
  23468. getVerticesDataKinds(): string[];
  23469. /**
  23470. * Update index buffer
  23471. * @param indices defines the indices to store in the index buffer
  23472. * @param offset defines the offset in the target buffer where to store the data
  23473. * @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)
  23474. */
  23475. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  23476. /**
  23477. * Creates a new index buffer
  23478. * @param indices defines the indices to store in the index buffer
  23479. * @param totalVertices defines the total number of vertices (could be null)
  23480. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  23481. */
  23482. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  23483. /**
  23484. * Return the total number of indices
  23485. * @returns the total number of indices
  23486. */
  23487. getTotalIndices(): number;
  23488. /**
  23489. * Gets the index buffer array
  23490. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23491. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23492. * @returns the index buffer array
  23493. */
  23494. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23495. /**
  23496. * Gets the index buffer
  23497. * @return the index buffer
  23498. */
  23499. getIndexBuffer(): Nullable<DataBuffer>;
  23500. /** @hidden */
  23501. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  23502. /**
  23503. * Release the associated resources for a specific mesh
  23504. * @param mesh defines the source mesh
  23505. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  23506. */
  23507. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  23508. /**
  23509. * Apply current geometry to a given mesh
  23510. * @param mesh defines the mesh to apply geometry to
  23511. */
  23512. applyToMesh(mesh: Mesh): void;
  23513. private _updateExtend;
  23514. private _applyToMesh;
  23515. private notifyUpdate;
  23516. /**
  23517. * Load the geometry if it was flagged as delay loaded
  23518. * @param scene defines the hosting scene
  23519. * @param onLoaded defines a callback called when the geometry is loaded
  23520. */
  23521. load(scene: Scene, onLoaded?: () => void): void;
  23522. private _queueLoad;
  23523. /**
  23524. * Invert the geometry to move from a right handed system to a left handed one.
  23525. */
  23526. toLeftHanded(): void;
  23527. /** @hidden */
  23528. _resetPointsArrayCache(): void;
  23529. /** @hidden */
  23530. _generatePointsArray(): boolean;
  23531. /**
  23532. * Gets a value indicating if the geometry is disposed
  23533. * @returns true if the geometry was disposed
  23534. */
  23535. isDisposed(): boolean;
  23536. private _disposeVertexArrayObjects;
  23537. /**
  23538. * Free all associated resources
  23539. */
  23540. dispose(): void;
  23541. /**
  23542. * Clone the current geometry into a new geometry
  23543. * @param id defines the unique ID of the new geometry
  23544. * @returns a new geometry object
  23545. */
  23546. copy(id: string): Geometry;
  23547. /**
  23548. * Serialize the current geometry info (and not the vertices data) into a JSON object
  23549. * @return a JSON representation of the current geometry data (without the vertices data)
  23550. */
  23551. serialize(): any;
  23552. private toNumberArray;
  23553. /**
  23554. * Serialize all vertices data into a JSON oject
  23555. * @returns a JSON representation of the current geometry data
  23556. */
  23557. serializeVerticeData(): any;
  23558. /**
  23559. * Extracts a clone of a mesh geometry
  23560. * @param mesh defines the source mesh
  23561. * @param id defines the unique ID of the new geometry object
  23562. * @returns the new geometry object
  23563. */
  23564. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  23565. /**
  23566. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  23567. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  23568. * Be aware Math.random() could cause collisions, but:
  23569. * "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"
  23570. * @returns a string containing a new GUID
  23571. */
  23572. static RandomId(): string;
  23573. /** @hidden */
  23574. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  23575. private static _CleanMatricesWeights;
  23576. /**
  23577. * Create a new geometry from persisted data (Using .babylon file format)
  23578. * @param parsedVertexData defines the persisted data
  23579. * @param scene defines the hosting scene
  23580. * @param rootUrl defines the root url to use to load assets (like delayed data)
  23581. * @returns the new geometry object
  23582. */
  23583. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  23584. }
  23585. }
  23586. declare module "babylonjs/Meshes/mesh.vertexData" {
  23587. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  23588. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  23589. import { Geometry } from "babylonjs/Meshes/geometry";
  23590. import { Mesh } from "babylonjs/Meshes/mesh";
  23591. /**
  23592. * Define an interface for all classes that will get and set the data on vertices
  23593. */
  23594. export interface IGetSetVerticesData {
  23595. /**
  23596. * Gets a boolean indicating if specific vertex data is present
  23597. * @param kind defines the vertex data kind to use
  23598. * @returns true is data kind is present
  23599. */
  23600. isVerticesDataPresent(kind: string): boolean;
  23601. /**
  23602. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  23603. * @param kind defines the data kind (Position, normal, etc...)
  23604. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23605. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23606. * @returns a float array containing vertex data
  23607. */
  23608. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23609. /**
  23610. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  23611. * @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.
  23612. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23613. * @returns the indices array or an empty array if the mesh has no geometry
  23614. */
  23615. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23616. /**
  23617. * Set specific vertex data
  23618. * @param kind defines the data kind (Position, normal, etc...)
  23619. * @param data defines the vertex data to use
  23620. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  23621. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  23622. */
  23623. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  23624. /**
  23625. * Update a specific associated vertex buffer
  23626. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  23627. * - VertexBuffer.PositionKind
  23628. * - VertexBuffer.UVKind
  23629. * - VertexBuffer.UV2Kind
  23630. * - VertexBuffer.UV3Kind
  23631. * - VertexBuffer.UV4Kind
  23632. * - VertexBuffer.UV5Kind
  23633. * - VertexBuffer.UV6Kind
  23634. * - VertexBuffer.ColorKind
  23635. * - VertexBuffer.MatricesIndicesKind
  23636. * - VertexBuffer.MatricesIndicesExtraKind
  23637. * - VertexBuffer.MatricesWeightsKind
  23638. * - VertexBuffer.MatricesWeightsExtraKind
  23639. * @param data defines the data source
  23640. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  23641. * @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)
  23642. */
  23643. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  23644. /**
  23645. * Creates a new index buffer
  23646. * @param indices defines the indices to store in the index buffer
  23647. * @param totalVertices defines the total number of vertices (could be null)
  23648. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  23649. */
  23650. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  23651. }
  23652. /**
  23653. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  23654. */
  23655. export class VertexData {
  23656. /**
  23657. * Mesh side orientation : usually the external or front surface
  23658. */
  23659. static readonly FRONTSIDE: number;
  23660. /**
  23661. * Mesh side orientation : usually the internal or back surface
  23662. */
  23663. static readonly BACKSIDE: number;
  23664. /**
  23665. * Mesh side orientation : both internal and external or front and back surfaces
  23666. */
  23667. static readonly DOUBLESIDE: number;
  23668. /**
  23669. * Mesh side orientation : by default, `FRONTSIDE`
  23670. */
  23671. static readonly DEFAULTSIDE: number;
  23672. /**
  23673. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  23674. */
  23675. positions: Nullable<FloatArray>;
  23676. /**
  23677. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  23678. */
  23679. normals: Nullable<FloatArray>;
  23680. /**
  23681. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  23682. */
  23683. tangents: Nullable<FloatArray>;
  23684. /**
  23685. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23686. */
  23687. uvs: Nullable<FloatArray>;
  23688. /**
  23689. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23690. */
  23691. uvs2: Nullable<FloatArray>;
  23692. /**
  23693. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23694. */
  23695. uvs3: Nullable<FloatArray>;
  23696. /**
  23697. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23698. */
  23699. uvs4: Nullable<FloatArray>;
  23700. /**
  23701. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23702. */
  23703. uvs5: Nullable<FloatArray>;
  23704. /**
  23705. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23706. */
  23707. uvs6: Nullable<FloatArray>;
  23708. /**
  23709. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  23710. */
  23711. colors: Nullable<FloatArray>;
  23712. /**
  23713. * 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).
  23714. */
  23715. matricesIndices: Nullable<FloatArray>;
  23716. /**
  23717. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  23718. */
  23719. matricesWeights: Nullable<FloatArray>;
  23720. /**
  23721. * An array extending the number of possible indices
  23722. */
  23723. matricesIndicesExtra: Nullable<FloatArray>;
  23724. /**
  23725. * An array extending the number of possible weights when the number of indices is extended
  23726. */
  23727. matricesWeightsExtra: Nullable<FloatArray>;
  23728. /**
  23729. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  23730. */
  23731. indices: Nullable<IndicesArray>;
  23732. /**
  23733. * Uses the passed data array to set the set the values for the specified kind of data
  23734. * @param data a linear array of floating numbers
  23735. * @param kind the type of data that is being set, eg positions, colors etc
  23736. */
  23737. set(data: FloatArray, kind: string): void;
  23738. /**
  23739. * Associates the vertexData to the passed Mesh.
  23740. * Sets it as updatable or not (default `false`)
  23741. * @param mesh the mesh the vertexData is applied to
  23742. * @param updatable when used and having the value true allows new data to update the vertexData
  23743. * @returns the VertexData
  23744. */
  23745. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  23746. /**
  23747. * Associates the vertexData to the passed Geometry.
  23748. * Sets it as updatable or not (default `false`)
  23749. * @param geometry the geometry the vertexData is applied to
  23750. * @param updatable when used and having the value true allows new data to update the vertexData
  23751. * @returns VertexData
  23752. */
  23753. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  23754. /**
  23755. * Updates the associated mesh
  23756. * @param mesh the mesh to be updated
  23757. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  23758. * @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
  23759. * @returns VertexData
  23760. */
  23761. updateMesh(mesh: Mesh): VertexData;
  23762. /**
  23763. * Updates the associated geometry
  23764. * @param geometry the geometry to be updated
  23765. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  23766. * @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
  23767. * @returns VertexData.
  23768. */
  23769. updateGeometry(geometry: Geometry): VertexData;
  23770. private _applyTo;
  23771. private _update;
  23772. /**
  23773. * Transforms each position and each normal of the vertexData according to the passed Matrix
  23774. * @param matrix the transforming matrix
  23775. * @returns the VertexData
  23776. */
  23777. transform(matrix: Matrix): VertexData;
  23778. /**
  23779. * Merges the passed VertexData into the current one
  23780. * @param other the VertexData to be merged into the current one
  23781. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  23782. * @returns the modified VertexData
  23783. */
  23784. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  23785. private _mergeElement;
  23786. private _validate;
  23787. /**
  23788. * Serializes the VertexData
  23789. * @returns a serialized object
  23790. */
  23791. serialize(): any;
  23792. /**
  23793. * Extracts the vertexData from a mesh
  23794. * @param mesh the mesh from which to extract the VertexData
  23795. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  23796. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  23797. * @returns the object VertexData associated to the passed mesh
  23798. */
  23799. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  23800. /**
  23801. * Extracts the vertexData from the geometry
  23802. * @param geometry the geometry from which to extract the VertexData
  23803. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  23804. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  23805. * @returns the object VertexData associated to the passed mesh
  23806. */
  23807. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  23808. private static _ExtractFrom;
  23809. /**
  23810. * Creates the VertexData for a Ribbon
  23811. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  23812. * * pathArray array of paths, each of which an array of successive Vector3
  23813. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  23814. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  23815. * * 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
  23816. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23817. * * 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)
  23818. * * 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)
  23819. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  23820. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  23821. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  23822. * @returns the VertexData of the ribbon
  23823. */
  23824. static CreateRibbon(options: {
  23825. pathArray: Vector3[][];
  23826. closeArray?: boolean;
  23827. closePath?: boolean;
  23828. offset?: number;
  23829. sideOrientation?: number;
  23830. frontUVs?: Vector4;
  23831. backUVs?: Vector4;
  23832. invertUV?: boolean;
  23833. uvs?: Vector2[];
  23834. colors?: Color4[];
  23835. }): VertexData;
  23836. /**
  23837. * Creates the VertexData for a box
  23838. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23839. * * size sets the width, height and depth of the box to the value of size, optional default 1
  23840. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  23841. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  23842. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  23843. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  23844. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  23845. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23846. * * 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)
  23847. * * 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)
  23848. * @returns the VertexData of the box
  23849. */
  23850. static CreateBox(options: {
  23851. size?: number;
  23852. width?: number;
  23853. height?: number;
  23854. depth?: number;
  23855. faceUV?: Vector4[];
  23856. faceColors?: Color4[];
  23857. sideOrientation?: number;
  23858. frontUVs?: Vector4;
  23859. backUVs?: Vector4;
  23860. }): VertexData;
  23861. /**
  23862. * Creates the VertexData for a tiled box
  23863. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23864. * * faceTiles sets the pattern, tile size and number of tiles for a face
  23865. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  23866. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  23867. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23868. * @returns the VertexData of the box
  23869. */
  23870. static CreateTiledBox(options: {
  23871. pattern?: number;
  23872. width?: number;
  23873. height?: number;
  23874. depth?: number;
  23875. tileSize?: number;
  23876. tileWidth?: number;
  23877. tileHeight?: number;
  23878. alignHorizontal?: number;
  23879. alignVertical?: number;
  23880. faceUV?: Vector4[];
  23881. faceColors?: Color4[];
  23882. sideOrientation?: number;
  23883. }): VertexData;
  23884. /**
  23885. * Creates the VertexData for a tiled plane
  23886. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23887. * * pattern a limited pattern arrangement depending on the number
  23888. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  23889. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  23890. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  23891. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23892. * * 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)
  23893. * * 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)
  23894. * @returns the VertexData of the tiled plane
  23895. */
  23896. static CreateTiledPlane(options: {
  23897. pattern?: number;
  23898. tileSize?: number;
  23899. tileWidth?: number;
  23900. tileHeight?: number;
  23901. size?: number;
  23902. width?: number;
  23903. height?: number;
  23904. alignHorizontal?: number;
  23905. alignVertical?: number;
  23906. sideOrientation?: number;
  23907. frontUVs?: Vector4;
  23908. backUVs?: Vector4;
  23909. }): VertexData;
  23910. /**
  23911. * Creates the VertexData for an ellipsoid, defaults to a sphere
  23912. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23913. * * segments sets the number of horizontal strips optional, default 32
  23914. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  23915. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  23916. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  23917. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  23918. * * 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
  23919. * * 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
  23920. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23921. * * 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)
  23922. * * 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)
  23923. * @returns the VertexData of the ellipsoid
  23924. */
  23925. static CreateSphere(options: {
  23926. segments?: number;
  23927. diameter?: number;
  23928. diameterX?: number;
  23929. diameterY?: number;
  23930. diameterZ?: number;
  23931. arc?: number;
  23932. slice?: number;
  23933. sideOrientation?: number;
  23934. frontUVs?: Vector4;
  23935. backUVs?: Vector4;
  23936. }): VertexData;
  23937. /**
  23938. * Creates the VertexData for a cylinder, cone or prism
  23939. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23940. * * height sets the height (y direction) of the cylinder, optional, default 2
  23941. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  23942. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  23943. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  23944. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23945. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  23946. * * 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
  23947. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23948. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23949. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  23950. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  23951. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23952. * * 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)
  23953. * * 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)
  23954. * @returns the VertexData of the cylinder, cone or prism
  23955. */
  23956. static CreateCylinder(options: {
  23957. height?: number;
  23958. diameterTop?: number;
  23959. diameterBottom?: number;
  23960. diameter?: number;
  23961. tessellation?: number;
  23962. subdivisions?: number;
  23963. arc?: number;
  23964. faceColors?: Color4[];
  23965. faceUV?: Vector4[];
  23966. hasRings?: boolean;
  23967. enclose?: boolean;
  23968. sideOrientation?: number;
  23969. frontUVs?: Vector4;
  23970. backUVs?: Vector4;
  23971. }): VertexData;
  23972. /**
  23973. * Creates the VertexData for a torus
  23974. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23975. * * diameter the diameter of the torus, optional default 1
  23976. * * thickness the diameter of the tube forming the torus, optional default 0.5
  23977. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23978. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23979. * * 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)
  23980. * * 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)
  23981. * @returns the VertexData of the torus
  23982. */
  23983. static CreateTorus(options: {
  23984. diameter?: number;
  23985. thickness?: number;
  23986. tessellation?: number;
  23987. sideOrientation?: number;
  23988. frontUVs?: Vector4;
  23989. backUVs?: Vector4;
  23990. }): VertexData;
  23991. /**
  23992. * Creates the VertexData of the LineSystem
  23993. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  23994. * - lines an array of lines, each line being an array of successive Vector3
  23995. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  23996. * @returns the VertexData of the LineSystem
  23997. */
  23998. static CreateLineSystem(options: {
  23999. lines: Vector3[][];
  24000. colors?: Nullable<Color4[][]>;
  24001. }): VertexData;
  24002. /**
  24003. * Create the VertexData for a DashedLines
  24004. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  24005. * - points an array successive Vector3
  24006. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  24007. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  24008. * - dashNb the intended total number of dashes, optional, default 200
  24009. * @returns the VertexData for the DashedLines
  24010. */
  24011. static CreateDashedLines(options: {
  24012. points: Vector3[];
  24013. dashSize?: number;
  24014. gapSize?: number;
  24015. dashNb?: number;
  24016. }): VertexData;
  24017. /**
  24018. * Creates the VertexData for a Ground
  24019. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  24020. * - width the width (x direction) of the ground, optional, default 1
  24021. * - height the height (z direction) of the ground, optional, default 1
  24022. * - subdivisions the number of subdivisions per side, optional, default 1
  24023. * @returns the VertexData of the Ground
  24024. */
  24025. static CreateGround(options: {
  24026. width?: number;
  24027. height?: number;
  24028. subdivisions?: number;
  24029. subdivisionsX?: number;
  24030. subdivisionsY?: number;
  24031. }): VertexData;
  24032. /**
  24033. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  24034. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  24035. * * xmin the ground minimum X coordinate, optional, default -1
  24036. * * zmin the ground minimum Z coordinate, optional, default -1
  24037. * * xmax the ground maximum X coordinate, optional, default 1
  24038. * * zmax the ground maximum Z coordinate, optional, default 1
  24039. * * 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}
  24040. * * 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}
  24041. * @returns the VertexData of the TiledGround
  24042. */
  24043. static CreateTiledGround(options: {
  24044. xmin: number;
  24045. zmin: number;
  24046. xmax: number;
  24047. zmax: number;
  24048. subdivisions?: {
  24049. w: number;
  24050. h: number;
  24051. };
  24052. precision?: {
  24053. w: number;
  24054. h: number;
  24055. };
  24056. }): VertexData;
  24057. /**
  24058. * Creates the VertexData of the Ground designed from a heightmap
  24059. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  24060. * * width the width (x direction) of the ground
  24061. * * height the height (z direction) of the ground
  24062. * * subdivisions the number of subdivisions per side
  24063. * * minHeight the minimum altitude on the ground, optional, default 0
  24064. * * maxHeight the maximum altitude on the ground, optional default 1
  24065. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  24066. * * buffer the array holding the image color data
  24067. * * bufferWidth the width of image
  24068. * * bufferHeight the height of image
  24069. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  24070. * @returns the VertexData of the Ground designed from a heightmap
  24071. */
  24072. static CreateGroundFromHeightMap(options: {
  24073. width: number;
  24074. height: number;
  24075. subdivisions: number;
  24076. minHeight: number;
  24077. maxHeight: number;
  24078. colorFilter: Color3;
  24079. buffer: Uint8Array;
  24080. bufferWidth: number;
  24081. bufferHeight: number;
  24082. alphaFilter: number;
  24083. }): VertexData;
  24084. /**
  24085. * Creates the VertexData for a Plane
  24086. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  24087. * * size sets the width and height of the plane to the value of size, optional default 1
  24088. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  24089. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  24090. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24091. * * 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)
  24092. * * 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)
  24093. * @returns the VertexData of the box
  24094. */
  24095. static CreatePlane(options: {
  24096. size?: number;
  24097. width?: number;
  24098. height?: number;
  24099. sideOrientation?: number;
  24100. frontUVs?: Vector4;
  24101. backUVs?: Vector4;
  24102. }): VertexData;
  24103. /**
  24104. * Creates the VertexData of the Disc or regular Polygon
  24105. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  24106. * * radius the radius of the disc, optional default 0.5
  24107. * * tessellation the number of polygon sides, optional, default 64
  24108. * * 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
  24109. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24110. * * 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)
  24111. * * 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)
  24112. * @returns the VertexData of the box
  24113. */
  24114. static CreateDisc(options: {
  24115. radius?: number;
  24116. tessellation?: number;
  24117. arc?: number;
  24118. sideOrientation?: number;
  24119. frontUVs?: Vector4;
  24120. backUVs?: Vector4;
  24121. }): VertexData;
  24122. /**
  24123. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  24124. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  24125. * @param polygon a mesh built from polygonTriangulation.build()
  24126. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24127. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  24128. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  24129. * @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)
  24130. * @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)
  24131. * @returns the VertexData of the Polygon
  24132. */
  24133. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  24134. /**
  24135. * Creates the VertexData of the IcoSphere
  24136. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  24137. * * radius the radius of the IcoSphere, optional default 1
  24138. * * radiusX allows stretching in the x direction, optional, default radius
  24139. * * radiusY allows stretching in the y direction, optional, default radius
  24140. * * radiusZ allows stretching in the z direction, optional, default radius
  24141. * * flat when true creates a flat shaded mesh, optional, default true
  24142. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  24143. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24144. * * 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)
  24145. * * 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)
  24146. * @returns the VertexData of the IcoSphere
  24147. */
  24148. static CreateIcoSphere(options: {
  24149. radius?: number;
  24150. radiusX?: number;
  24151. radiusY?: number;
  24152. radiusZ?: number;
  24153. flat?: boolean;
  24154. subdivisions?: number;
  24155. sideOrientation?: number;
  24156. frontUVs?: Vector4;
  24157. backUVs?: Vector4;
  24158. }): VertexData;
  24159. /**
  24160. * Creates the VertexData for a Polyhedron
  24161. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  24162. * * type provided types are:
  24163. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  24164. * * 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)
  24165. * * size the size of the IcoSphere, optional default 1
  24166. * * sizeX allows stretching in the x direction, optional, default size
  24167. * * sizeY allows stretching in the y direction, optional, default size
  24168. * * sizeZ allows stretching in the z direction, optional, default size
  24169. * * 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
  24170. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  24171. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  24172. * * flat when true creates a flat shaded mesh, optional, default true
  24173. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  24174. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24175. * * 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)
  24176. * * 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)
  24177. * @returns the VertexData of the Polyhedron
  24178. */
  24179. static CreatePolyhedron(options: {
  24180. type?: number;
  24181. size?: number;
  24182. sizeX?: number;
  24183. sizeY?: number;
  24184. sizeZ?: number;
  24185. custom?: any;
  24186. faceUV?: Vector4[];
  24187. faceColors?: Color4[];
  24188. flat?: boolean;
  24189. sideOrientation?: number;
  24190. frontUVs?: Vector4;
  24191. backUVs?: Vector4;
  24192. }): VertexData;
  24193. /**
  24194. * Creates the VertexData for a TorusKnot
  24195. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  24196. * * radius the radius of the torus knot, optional, default 2
  24197. * * tube the thickness of the tube, optional, default 0.5
  24198. * * radialSegments the number of sides on each tube segments, optional, default 32
  24199. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  24200. * * p the number of windings around the z axis, optional, default 2
  24201. * * q the number of windings around the x axis, optional, default 3
  24202. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24203. * * 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)
  24204. * * 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)
  24205. * @returns the VertexData of the Torus Knot
  24206. */
  24207. static CreateTorusKnot(options: {
  24208. radius?: number;
  24209. tube?: number;
  24210. radialSegments?: number;
  24211. tubularSegments?: number;
  24212. p?: number;
  24213. q?: number;
  24214. sideOrientation?: number;
  24215. frontUVs?: Vector4;
  24216. backUVs?: Vector4;
  24217. }): VertexData;
  24218. /**
  24219. * Compute normals for given positions and indices
  24220. * @param positions an array of vertex positions, [...., x, y, z, ......]
  24221. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  24222. * @param normals an array of vertex normals, [...., x, y, z, ......]
  24223. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  24224. * * facetNormals : optional array of facet normals (vector3)
  24225. * * facetPositions : optional array of facet positions (vector3)
  24226. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  24227. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  24228. * * bInfo : optional bounding info, required for facetPartitioning computation
  24229. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  24230. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  24231. * * useRightHandedSystem: optional boolean to for right handed system computation
  24232. * * depthSort : optional boolean to enable the facet depth sort computation
  24233. * * distanceTo : optional Vector3 to compute the facet depth from this location
  24234. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  24235. */
  24236. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  24237. facetNormals?: any;
  24238. facetPositions?: any;
  24239. facetPartitioning?: any;
  24240. ratio?: number;
  24241. bInfo?: any;
  24242. bbSize?: Vector3;
  24243. subDiv?: any;
  24244. useRightHandedSystem?: boolean;
  24245. depthSort?: boolean;
  24246. distanceTo?: Vector3;
  24247. depthSortedFacets?: any;
  24248. }): void;
  24249. /** @hidden */
  24250. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  24251. /**
  24252. * Applies VertexData created from the imported parameters to the geometry
  24253. * @param parsedVertexData the parsed data from an imported file
  24254. * @param geometry the geometry to apply the VertexData to
  24255. */
  24256. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  24257. }
  24258. }
  24259. declare module "babylonjs/Meshes/Builders/discBuilder" {
  24260. import { Nullable } from "babylonjs/types";
  24261. import { Scene } from "babylonjs/scene";
  24262. import { Vector4 } from "babylonjs/Maths/math";
  24263. import { Mesh } from "babylonjs/Meshes/mesh";
  24264. /**
  24265. * Class containing static functions to help procedurally build meshes
  24266. */
  24267. export class DiscBuilder {
  24268. /**
  24269. * Creates a plane polygonal mesh. By default, this is a disc
  24270. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  24271. * * 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
  24272. * * 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
  24273. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  24274. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  24275. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24276. * @param name defines the name of the mesh
  24277. * @param options defines the options used to create the mesh
  24278. * @param scene defines the hosting scene
  24279. * @returns the plane polygonal mesh
  24280. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  24281. */
  24282. static CreateDisc(name: string, options: {
  24283. radius?: number;
  24284. tessellation?: number;
  24285. arc?: number;
  24286. updatable?: boolean;
  24287. sideOrientation?: number;
  24288. frontUVs?: Vector4;
  24289. backUVs?: Vector4;
  24290. }, scene?: Nullable<Scene>): Mesh;
  24291. }
  24292. }
  24293. declare module "babylonjs/Particles/solidParticleSystem" {
  24294. import { Vector3 } from "babylonjs/Maths/math";
  24295. import { Mesh } from "babylonjs/Meshes/mesh";
  24296. import { Scene, IDisposable } from "babylonjs/scene";
  24297. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  24298. /**
  24299. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  24300. *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.
  24301. * The SPS is also a particle system. It provides some methods to manage the particles.
  24302. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  24303. *
  24304. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  24305. */
  24306. export class SolidParticleSystem implements IDisposable {
  24307. /**
  24308. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  24309. * Example : var p = SPS.particles[i];
  24310. */
  24311. particles: SolidParticle[];
  24312. /**
  24313. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  24314. */
  24315. nbParticles: number;
  24316. /**
  24317. * If the particles must ever face the camera (default false). Useful for planar particles.
  24318. */
  24319. billboard: boolean;
  24320. /**
  24321. * Recompute normals when adding a shape
  24322. */
  24323. recomputeNormals: boolean;
  24324. /**
  24325. * This a counter ofr your own usage. It's not set by any SPS functions.
  24326. */
  24327. counter: number;
  24328. /**
  24329. * The SPS name. This name is also given to the underlying mesh.
  24330. */
  24331. name: string;
  24332. /**
  24333. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  24334. */
  24335. mesh: Mesh;
  24336. /**
  24337. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  24338. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  24339. */
  24340. vars: any;
  24341. /**
  24342. * This array is populated when the SPS is set as 'pickable'.
  24343. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  24344. * Each element of this array is an object `{idx: int, faceId: int}`.
  24345. * `idx` is the picked particle index in the `SPS.particles` array
  24346. * `faceId` is the picked face index counted within this particle.
  24347. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  24348. */
  24349. pickedParticles: {
  24350. idx: number;
  24351. faceId: number;
  24352. }[];
  24353. /**
  24354. * This array is populated when `enableDepthSort` is set to true.
  24355. * Each element of this array is an instance of the class DepthSortedParticle.
  24356. */
  24357. depthSortedParticles: DepthSortedParticle[];
  24358. /**
  24359. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  24360. * @hidden
  24361. */
  24362. _bSphereOnly: boolean;
  24363. /**
  24364. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  24365. * @hidden
  24366. */
  24367. _bSphereRadiusFactor: number;
  24368. private _scene;
  24369. private _positions;
  24370. private _indices;
  24371. private _normals;
  24372. private _colors;
  24373. private _uvs;
  24374. private _indices32;
  24375. private _positions32;
  24376. private _normals32;
  24377. private _fixedNormal32;
  24378. private _colors32;
  24379. private _uvs32;
  24380. private _index;
  24381. private _updatable;
  24382. private _pickable;
  24383. private _isVisibilityBoxLocked;
  24384. private _alwaysVisible;
  24385. private _depthSort;
  24386. private _shapeCounter;
  24387. private _copy;
  24388. private _color;
  24389. private _computeParticleColor;
  24390. private _computeParticleTexture;
  24391. private _computeParticleRotation;
  24392. private _computeParticleVertex;
  24393. private _computeBoundingBox;
  24394. private _depthSortParticles;
  24395. private _camera;
  24396. private _mustUnrotateFixedNormals;
  24397. private _particlesIntersect;
  24398. private _needs32Bits;
  24399. /**
  24400. * Creates a SPS (Solid Particle System) object.
  24401. * @param name (String) is the SPS name, this will be the underlying mesh name.
  24402. * @param scene (Scene) is the scene in which the SPS is added.
  24403. * @param options defines the options of the sps e.g.
  24404. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  24405. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  24406. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  24407. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  24408. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  24409. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  24410. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  24411. */
  24412. constructor(name: string, scene: Scene, options?: {
  24413. updatable?: boolean;
  24414. isPickable?: boolean;
  24415. enableDepthSort?: boolean;
  24416. particleIntersection?: boolean;
  24417. boundingSphereOnly?: boolean;
  24418. bSphereRadiusFactor?: number;
  24419. });
  24420. /**
  24421. * Builds the SPS underlying mesh. Returns a standard Mesh.
  24422. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  24423. * @returns the created mesh
  24424. */
  24425. buildMesh(): Mesh;
  24426. /**
  24427. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  24428. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  24429. * Thus the particles generated from `digest()` have their property `position` set yet.
  24430. * @param mesh ( Mesh ) is the mesh to be digested
  24431. * @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
  24432. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  24433. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  24434. * @returns the current SPS
  24435. */
  24436. digest(mesh: Mesh, options?: {
  24437. facetNb?: number;
  24438. number?: number;
  24439. delta?: number;
  24440. }): SolidParticleSystem;
  24441. private _unrotateFixedNormals;
  24442. private _resetCopy;
  24443. private _meshBuilder;
  24444. private _posToShape;
  24445. private _uvsToShapeUV;
  24446. private _addParticle;
  24447. /**
  24448. * Adds some particles to the SPS from the model shape. Returns the shape id.
  24449. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  24450. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  24451. * @param nb (positive integer) the number of particles to be created from this model
  24452. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  24453. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  24454. * @returns the number of shapes in the system
  24455. */
  24456. addShape(mesh: Mesh, nb: number, options?: {
  24457. positionFunction?: any;
  24458. vertexFunction?: any;
  24459. }): number;
  24460. private _rebuildParticle;
  24461. /**
  24462. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  24463. * @returns the SPS.
  24464. */
  24465. rebuildMesh(): SolidParticleSystem;
  24466. /**
  24467. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  24468. * This method calls `updateParticle()` for each particle of the SPS.
  24469. * For an animated SPS, it is usually called within the render loop.
  24470. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  24471. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  24472. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  24473. * @returns the SPS.
  24474. */
  24475. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  24476. /**
  24477. * Disposes the SPS.
  24478. */
  24479. dispose(): void;
  24480. /**
  24481. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  24482. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24483. * @returns the SPS.
  24484. */
  24485. refreshVisibleSize(): SolidParticleSystem;
  24486. /**
  24487. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  24488. * @param size the size (float) of the visibility box
  24489. * note : this doesn't lock the SPS mesh bounding box.
  24490. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24491. */
  24492. setVisibilityBox(size: number): void;
  24493. /**
  24494. * Gets whether the SPS as always visible or not
  24495. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24496. */
  24497. /**
  24498. * Sets the SPS as always visible or not
  24499. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24500. */
  24501. isAlwaysVisible: boolean;
  24502. /**
  24503. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  24504. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24505. */
  24506. /**
  24507. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  24508. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24509. */
  24510. isVisibilityBoxLocked: boolean;
  24511. /**
  24512. * Tells to `setParticles()` to compute the particle rotations or not.
  24513. * Default value : true. The SPS is faster when it's set to false.
  24514. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  24515. */
  24516. /**
  24517. * Gets if `setParticles()` computes the particle rotations or not.
  24518. * Default value : true. The SPS is faster when it's set to false.
  24519. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  24520. */
  24521. computeParticleRotation: boolean;
  24522. /**
  24523. * Tells to `setParticles()` to compute the particle colors or not.
  24524. * Default value : true. The SPS is faster when it's set to false.
  24525. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  24526. */
  24527. /**
  24528. * Gets if `setParticles()` computes the particle colors or not.
  24529. * Default value : true. The SPS is faster when it's set to false.
  24530. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  24531. */
  24532. computeParticleColor: boolean;
  24533. /**
  24534. * Gets if `setParticles()` computes the particle textures or not.
  24535. * Default value : true. The SPS is faster when it's set to false.
  24536. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  24537. */
  24538. computeParticleTexture: boolean;
  24539. /**
  24540. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  24541. * Default value : false. The SPS is faster when it's set to false.
  24542. * Note : the particle custom vertex positions aren't stored values.
  24543. */
  24544. /**
  24545. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  24546. * Default value : false. The SPS is faster when it's set to false.
  24547. * Note : the particle custom vertex positions aren't stored values.
  24548. */
  24549. computeParticleVertex: boolean;
  24550. /**
  24551. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  24552. */
  24553. /**
  24554. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  24555. */
  24556. computeBoundingBox: boolean;
  24557. /**
  24558. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  24559. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  24560. * Default : `true`
  24561. */
  24562. /**
  24563. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  24564. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  24565. * Default : `true`
  24566. */
  24567. depthSortParticles: boolean;
  24568. /**
  24569. * This function does nothing. It may be overwritten to set all the particle first values.
  24570. * The SPS doesn't call this function, you may have to call it by your own.
  24571. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24572. */
  24573. initParticles(): void;
  24574. /**
  24575. * This function does nothing. It may be overwritten to recycle a particle.
  24576. * The SPS doesn't call this function, you may have to call it by your own.
  24577. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24578. * @param particle The particle to recycle
  24579. * @returns the recycled particle
  24580. */
  24581. recycleParticle(particle: SolidParticle): SolidParticle;
  24582. /**
  24583. * Updates a particle : this function should be overwritten by the user.
  24584. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  24585. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24586. * @example : just set a particle position or velocity and recycle conditions
  24587. * @param particle The particle to update
  24588. * @returns the updated particle
  24589. */
  24590. updateParticle(particle: SolidParticle): SolidParticle;
  24591. /**
  24592. * Updates a vertex of a particle : it can be overwritten by the user.
  24593. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  24594. * @param particle the current particle
  24595. * @param vertex the current index of the current particle
  24596. * @param pt the index of the current vertex in the particle shape
  24597. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  24598. * @example : just set a vertex particle position
  24599. * @returns the updated vertex
  24600. */
  24601. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  24602. /**
  24603. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  24604. * This does nothing and may be overwritten by the user.
  24605. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24606. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24607. * @param update the boolean update value actually passed to setParticles()
  24608. */
  24609. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  24610. /**
  24611. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  24612. * This will be passed three parameters.
  24613. * This does nothing and may be overwritten by the user.
  24614. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24615. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24616. * @param update the boolean update value actually passed to setParticles()
  24617. */
  24618. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  24619. }
  24620. }
  24621. declare module "babylonjs/Particles/solidParticle" {
  24622. import { Nullable } from "babylonjs/types";
  24623. import { Color4, Vector3, Matrix, Quaternion, Vector4, Plane } from "babylonjs/Maths/math";
  24624. import { Mesh } from "babylonjs/Meshes/mesh";
  24625. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  24626. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  24627. /**
  24628. * Represents one particle of a solid particle system.
  24629. */
  24630. export class SolidParticle {
  24631. /**
  24632. * particle global index
  24633. */
  24634. idx: number;
  24635. /**
  24636. * The color of the particle
  24637. */
  24638. color: Nullable<Color4>;
  24639. /**
  24640. * The world space position of the particle.
  24641. */
  24642. position: Vector3;
  24643. /**
  24644. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  24645. */
  24646. rotation: Vector3;
  24647. /**
  24648. * The world space rotation quaternion of the particle.
  24649. */
  24650. rotationQuaternion: Nullable<Quaternion>;
  24651. /**
  24652. * The scaling of the particle.
  24653. */
  24654. scaling: Vector3;
  24655. /**
  24656. * The uvs of the particle.
  24657. */
  24658. uvs: Vector4;
  24659. /**
  24660. * The current speed of the particle.
  24661. */
  24662. velocity: Vector3;
  24663. /**
  24664. * The pivot point in the particle local space.
  24665. */
  24666. pivot: Vector3;
  24667. /**
  24668. * Must the particle be translated from its pivot point in its local space ?
  24669. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  24670. * Default : false
  24671. */
  24672. translateFromPivot: boolean;
  24673. /**
  24674. * Is the particle active or not ?
  24675. */
  24676. alive: boolean;
  24677. /**
  24678. * Is the particle visible or not ?
  24679. */
  24680. isVisible: boolean;
  24681. /**
  24682. * Index of this particle in the global "positions" array (Internal use)
  24683. * @hidden
  24684. */
  24685. _pos: number;
  24686. /**
  24687. * @hidden Index of this particle in the global "indices" array (Internal use)
  24688. */
  24689. _ind: number;
  24690. /**
  24691. * @hidden ModelShape of this particle (Internal use)
  24692. */
  24693. _model: ModelShape;
  24694. /**
  24695. * ModelShape id of this particle
  24696. */
  24697. shapeId: number;
  24698. /**
  24699. * Index of the particle in its shape id (Internal use)
  24700. */
  24701. idxInShape: number;
  24702. /**
  24703. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  24704. */
  24705. _modelBoundingInfo: BoundingInfo;
  24706. /**
  24707. * @hidden Particle BoundingInfo object (Internal use)
  24708. */
  24709. _boundingInfo: BoundingInfo;
  24710. /**
  24711. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  24712. */
  24713. _sps: SolidParticleSystem;
  24714. /**
  24715. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  24716. */
  24717. _stillInvisible: boolean;
  24718. /**
  24719. * @hidden Last computed particle rotation matrix
  24720. */
  24721. _rotationMatrix: number[];
  24722. /**
  24723. * Parent particle Id, if any.
  24724. * Default null.
  24725. */
  24726. parentId: Nullable<number>;
  24727. /**
  24728. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  24729. * The possible values are :
  24730. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  24731. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24732. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  24733. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  24734. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24735. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  24736. * */
  24737. cullingStrategy: number;
  24738. /**
  24739. * @hidden Internal global position in the SPS.
  24740. */
  24741. _globalPosition: Vector3;
  24742. /**
  24743. * Creates a Solid Particle object.
  24744. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  24745. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  24746. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  24747. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  24748. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  24749. * @param shapeId (integer) is the model shape identifier in the SPS.
  24750. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  24751. * @param sps defines the sps it is associated to
  24752. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  24753. */
  24754. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  24755. /**
  24756. * Legacy support, changed scale to scaling
  24757. */
  24758. /**
  24759. * Legacy support, changed scale to scaling
  24760. */
  24761. scale: Vector3;
  24762. /**
  24763. * Legacy support, changed quaternion to rotationQuaternion
  24764. */
  24765. /**
  24766. * Legacy support, changed quaternion to rotationQuaternion
  24767. */
  24768. quaternion: Nullable<Quaternion>;
  24769. /**
  24770. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  24771. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  24772. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  24773. * @returns true if it intersects
  24774. */
  24775. intersectsMesh(target: Mesh | SolidParticle): boolean;
  24776. /**
  24777. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  24778. * A particle is in the frustum if its bounding box intersects the frustum
  24779. * @param frustumPlanes defines the frustum to test
  24780. * @returns true if the particle is in the frustum planes
  24781. */
  24782. isInFrustum(frustumPlanes: Plane[]): boolean;
  24783. /**
  24784. * get the rotation matrix of the particle
  24785. * @hidden
  24786. */
  24787. getRotationMatrix(m: Matrix): void;
  24788. }
  24789. /**
  24790. * Represents the shape of the model used by one particle of a solid particle system.
  24791. * SPS internal tool, don't use it manually.
  24792. */
  24793. export class ModelShape {
  24794. /**
  24795. * The shape id
  24796. * @hidden
  24797. */
  24798. shapeID: number;
  24799. /**
  24800. * flat array of model positions (internal use)
  24801. * @hidden
  24802. */
  24803. _shape: Vector3[];
  24804. /**
  24805. * flat array of model UVs (internal use)
  24806. * @hidden
  24807. */
  24808. _shapeUV: number[];
  24809. /**
  24810. * length of the shape in the model indices array (internal use)
  24811. * @hidden
  24812. */
  24813. _indicesLength: number;
  24814. /**
  24815. * Custom position function (internal use)
  24816. * @hidden
  24817. */
  24818. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  24819. /**
  24820. * Custom vertex function (internal use)
  24821. * @hidden
  24822. */
  24823. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  24824. /**
  24825. * 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.
  24826. * SPS internal tool, don't use it manually.
  24827. * @hidden
  24828. */
  24829. 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>);
  24830. }
  24831. /**
  24832. * Represents a Depth Sorted Particle in the solid particle system.
  24833. */
  24834. export class DepthSortedParticle {
  24835. /**
  24836. * Index of the particle in the "indices" array
  24837. */
  24838. ind: number;
  24839. /**
  24840. * Length of the particle shape in the "indices" array
  24841. */
  24842. indicesLength: number;
  24843. /**
  24844. * Squared distance from the particle to the camera
  24845. */
  24846. sqDistance: number;
  24847. }
  24848. }
  24849. declare module "babylonjs/Collisions/meshCollisionData" {
  24850. import { Collider } from "babylonjs/Collisions/collider";
  24851. import { Vector3 } from "babylonjs/Maths/math";
  24852. import { Nullable } from "babylonjs/types";
  24853. import { Observer } from "babylonjs/Misc/observable";
  24854. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24855. /**
  24856. * @hidden
  24857. */
  24858. export class _MeshCollisionData {
  24859. _checkCollisions: boolean;
  24860. _collisionMask: number;
  24861. _collisionGroup: number;
  24862. _collider: Nullable<Collider>;
  24863. _oldPositionForCollisions: Vector3;
  24864. _diffPositionForCollisions: Vector3;
  24865. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  24866. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  24867. }
  24868. }
  24869. declare module "babylonjs/Meshes/abstractMesh" {
  24870. import { Observable } from "babylonjs/Misc/observable";
  24871. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  24872. import { Camera } from "babylonjs/Cameras/camera";
  24873. import { Scene, IDisposable } from "babylonjs/scene";
  24874. import { Matrix, Vector3, Color3, Color4, Plane, Vector2 } from "babylonjs/Maths/math";
  24875. import { Node } from "babylonjs/node";
  24876. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  24877. import { TransformNode } from "babylonjs/Meshes/transformNode";
  24878. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24879. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  24880. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  24881. import { Material } from "babylonjs/Materials/material";
  24882. import { Light } from "babylonjs/Lights/light";
  24883. import { Skeleton } from "babylonjs/Bones/skeleton";
  24884. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  24885. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  24886. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  24887. import { Ray } from "babylonjs/Culling/ray";
  24888. import { Collider } from "babylonjs/Collisions/collider";
  24889. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  24890. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  24891. /** @hidden */
  24892. class _FacetDataStorage {
  24893. facetPositions: Vector3[];
  24894. facetNormals: Vector3[];
  24895. facetPartitioning: number[][];
  24896. facetNb: number;
  24897. partitioningSubdivisions: number;
  24898. partitioningBBoxRatio: number;
  24899. facetDataEnabled: boolean;
  24900. facetParameters: any;
  24901. bbSize: Vector3;
  24902. subDiv: {
  24903. max: number;
  24904. X: number;
  24905. Y: number;
  24906. Z: number;
  24907. };
  24908. facetDepthSort: boolean;
  24909. facetDepthSortEnabled: boolean;
  24910. depthSortedIndices: IndicesArray;
  24911. depthSortedFacets: {
  24912. ind: number;
  24913. sqDistance: number;
  24914. }[];
  24915. facetDepthSortFunction: (f1: {
  24916. ind: number;
  24917. sqDistance: number;
  24918. }, f2: {
  24919. ind: number;
  24920. sqDistance: number;
  24921. }) => number;
  24922. facetDepthSortFrom: Vector3;
  24923. facetDepthSortOrigin: Vector3;
  24924. invertedMatrix: Matrix;
  24925. }
  24926. /**
  24927. * @hidden
  24928. **/
  24929. class _InternalAbstractMeshDataInfo {
  24930. _hasVertexAlpha: boolean;
  24931. _useVertexColors: boolean;
  24932. _numBoneInfluencers: number;
  24933. _applyFog: boolean;
  24934. _receiveShadows: boolean;
  24935. _facetData: _FacetDataStorage;
  24936. _visibility: number;
  24937. _skeleton: Nullable<Skeleton>;
  24938. _layerMask: number;
  24939. _computeBonesUsingShaders: boolean;
  24940. _isActive: boolean;
  24941. _onlyForInstances: boolean;
  24942. _isActiveIntermediate: boolean;
  24943. _onlyForInstancesIntermediate: boolean;
  24944. }
  24945. /**
  24946. * Class used to store all common mesh properties
  24947. */
  24948. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  24949. /** No occlusion */
  24950. static OCCLUSION_TYPE_NONE: number;
  24951. /** Occlusion set to optimisitic */
  24952. static OCCLUSION_TYPE_OPTIMISTIC: number;
  24953. /** Occlusion set to strict */
  24954. static OCCLUSION_TYPE_STRICT: number;
  24955. /** Use an accurante occlusion algorithm */
  24956. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  24957. /** Use a conservative occlusion algorithm */
  24958. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  24959. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  24960. * Test order :
  24961. * Is the bounding sphere outside the frustum ?
  24962. * If not, are the bounding box vertices outside the frustum ?
  24963. * It not, then the cullable object is in the frustum.
  24964. */
  24965. static readonly CULLINGSTRATEGY_STANDARD: number;
  24966. /** Culling strategy : Bounding Sphere Only.
  24967. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  24968. * It's also less accurate than the standard because some not visible objects can still be selected.
  24969. * Test : is the bounding sphere outside the frustum ?
  24970. * If not, then the cullable object is in the frustum.
  24971. */
  24972. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  24973. /** Culling strategy : Optimistic Inclusion.
  24974. * This in an inclusion test first, then the standard exclusion test.
  24975. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  24976. * 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.
  24977. * Anyway, it's as accurate as the standard strategy.
  24978. * Test :
  24979. * Is the cullable object bounding sphere center in the frustum ?
  24980. * If not, apply the default culling strategy.
  24981. */
  24982. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  24983. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  24984. * This in an inclusion test first, then the bounding sphere only exclusion test.
  24985. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  24986. * 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.
  24987. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  24988. * Test :
  24989. * Is the cullable object bounding sphere center in the frustum ?
  24990. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  24991. */
  24992. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  24993. /**
  24994. * No billboard
  24995. */
  24996. static readonly BILLBOARDMODE_NONE: number;
  24997. /** Billboard on X axis */
  24998. static readonly BILLBOARDMODE_X: number;
  24999. /** Billboard on Y axis */
  25000. static readonly BILLBOARDMODE_Y: number;
  25001. /** Billboard on Z axis */
  25002. static readonly BILLBOARDMODE_Z: number;
  25003. /** Billboard on all axes */
  25004. static readonly BILLBOARDMODE_ALL: number;
  25005. /** @hidden */
  25006. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  25007. /**
  25008. * The culling strategy to use to check whether the mesh must be rendered or not.
  25009. * This value can be changed at any time and will be used on the next render mesh selection.
  25010. * The possible values are :
  25011. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  25012. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  25013. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  25014. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  25015. * Please read each static variable documentation to get details about the culling process.
  25016. * */
  25017. cullingStrategy: number;
  25018. /**
  25019. * Gets the number of facets in the mesh
  25020. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  25021. */
  25022. readonly facetNb: number;
  25023. /**
  25024. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  25025. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  25026. */
  25027. partitioningSubdivisions: number;
  25028. /**
  25029. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  25030. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  25031. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  25032. */
  25033. partitioningBBoxRatio: number;
  25034. /**
  25035. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  25036. * Works only for updatable meshes.
  25037. * Doesn't work with multi-materials
  25038. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  25039. */
  25040. mustDepthSortFacets: boolean;
  25041. /**
  25042. * The location (Vector3) where the facet depth sort must be computed from.
  25043. * By default, the active camera position.
  25044. * Used only when facet depth sort is enabled
  25045. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  25046. */
  25047. facetDepthSortFrom: Vector3;
  25048. /**
  25049. * gets a boolean indicating if facetData is enabled
  25050. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  25051. */
  25052. readonly isFacetDataEnabled: boolean;
  25053. /** @hidden */
  25054. _updateNonUniformScalingState(value: boolean): boolean;
  25055. /**
  25056. * An event triggered when this mesh collides with another one
  25057. */
  25058. onCollideObservable: Observable<AbstractMesh>;
  25059. /** Set a function to call when this mesh collides with another one */
  25060. onCollide: () => void;
  25061. /**
  25062. * An event triggered when the collision's position changes
  25063. */
  25064. onCollisionPositionChangeObservable: Observable<Vector3>;
  25065. /** Set a function to call when the collision's position changes */
  25066. onCollisionPositionChange: () => void;
  25067. /**
  25068. * An event triggered when material is changed
  25069. */
  25070. onMaterialChangedObservable: Observable<AbstractMesh>;
  25071. /**
  25072. * Gets or sets the orientation for POV movement & rotation
  25073. */
  25074. definedFacingForward: boolean;
  25075. /** @hidden */
  25076. _occlusionQuery: Nullable<WebGLQuery>;
  25077. /** @hidden */
  25078. _renderingGroup: Nullable<RenderingGroup>;
  25079. /**
  25080. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  25081. */
  25082. /**
  25083. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  25084. */
  25085. visibility: number;
  25086. /** Gets or sets the alpha index used to sort transparent meshes
  25087. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  25088. */
  25089. alphaIndex: number;
  25090. /**
  25091. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  25092. */
  25093. isVisible: boolean;
  25094. /**
  25095. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  25096. */
  25097. isPickable: boolean;
  25098. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  25099. showSubMeshesBoundingBox: boolean;
  25100. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  25101. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  25102. */
  25103. isBlocker: boolean;
  25104. /**
  25105. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  25106. */
  25107. enablePointerMoveEvents: boolean;
  25108. /**
  25109. * Specifies the rendering group id for this mesh (0 by default)
  25110. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  25111. */
  25112. renderingGroupId: number;
  25113. private _material;
  25114. /** Gets or sets current material */
  25115. material: Nullable<Material>;
  25116. /**
  25117. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  25118. * @see http://doc.babylonjs.com/babylon101/shadows
  25119. */
  25120. receiveShadows: boolean;
  25121. /** Defines color to use when rendering outline */
  25122. outlineColor: Color3;
  25123. /** Define width to use when rendering outline */
  25124. outlineWidth: number;
  25125. /** Defines color to use when rendering overlay */
  25126. overlayColor: Color3;
  25127. /** Defines alpha to use when rendering overlay */
  25128. overlayAlpha: number;
  25129. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  25130. hasVertexAlpha: boolean;
  25131. /** 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) */
  25132. useVertexColors: boolean;
  25133. /**
  25134. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  25135. */
  25136. computeBonesUsingShaders: boolean;
  25137. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  25138. numBoneInfluencers: number;
  25139. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  25140. applyFog: boolean;
  25141. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  25142. useOctreeForRenderingSelection: boolean;
  25143. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  25144. useOctreeForPicking: boolean;
  25145. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  25146. useOctreeForCollisions: boolean;
  25147. /**
  25148. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  25149. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  25150. */
  25151. layerMask: number;
  25152. /**
  25153. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  25154. */
  25155. alwaysSelectAsActiveMesh: boolean;
  25156. /**
  25157. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  25158. */
  25159. doNotSyncBoundingInfo: boolean;
  25160. /**
  25161. * Gets or sets the current action manager
  25162. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  25163. */
  25164. actionManager: Nullable<AbstractActionManager>;
  25165. private _meshCollisionData;
  25166. /**
  25167. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  25168. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25169. */
  25170. ellipsoid: Vector3;
  25171. /**
  25172. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  25173. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25174. */
  25175. ellipsoidOffset: Vector3;
  25176. /**
  25177. * Gets or sets a collision mask used to mask collisions (default is -1).
  25178. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  25179. */
  25180. collisionMask: number;
  25181. /**
  25182. * Gets or sets the current collision group mask (-1 by default).
  25183. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  25184. */
  25185. collisionGroup: number;
  25186. /**
  25187. * Defines edge width used when edgesRenderer is enabled
  25188. * @see https://www.babylonjs-playground.com/#10OJSG#13
  25189. */
  25190. edgesWidth: number;
  25191. /**
  25192. * Defines edge color used when edgesRenderer is enabled
  25193. * @see https://www.babylonjs-playground.com/#10OJSG#13
  25194. */
  25195. edgesColor: Color4;
  25196. /** @hidden */
  25197. _edgesRenderer: Nullable<IEdgesRenderer>;
  25198. /** @hidden */
  25199. _masterMesh: Nullable<AbstractMesh>;
  25200. /** @hidden */
  25201. _boundingInfo: Nullable<BoundingInfo>;
  25202. /** @hidden */
  25203. _renderId: number;
  25204. /**
  25205. * Gets or sets the list of subMeshes
  25206. * @see http://doc.babylonjs.com/how_to/multi_materials
  25207. */
  25208. subMeshes: SubMesh[];
  25209. /** @hidden */
  25210. _intersectionsInProgress: AbstractMesh[];
  25211. /** @hidden */
  25212. _unIndexed: boolean;
  25213. /** @hidden */
  25214. _lightSources: Light[];
  25215. /** Gets the list of lights affecting that mesh */
  25216. readonly lightSources: Light[];
  25217. /** @hidden */
  25218. readonly _positions: Nullable<Vector3[]>;
  25219. /** @hidden */
  25220. _waitingData: {
  25221. lods: Nullable<any>;
  25222. actions: Nullable<any>;
  25223. freezeWorldMatrix: Nullable<boolean>;
  25224. };
  25225. /** @hidden */
  25226. _bonesTransformMatrices: Nullable<Float32Array>;
  25227. /**
  25228. * Gets or sets a skeleton to apply skining transformations
  25229. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  25230. */
  25231. skeleton: Nullable<Skeleton>;
  25232. /**
  25233. * An event triggered when the mesh is rebuilt.
  25234. */
  25235. onRebuildObservable: Observable<AbstractMesh>;
  25236. /**
  25237. * Creates a new AbstractMesh
  25238. * @param name defines the name of the mesh
  25239. * @param scene defines the hosting scene
  25240. */
  25241. constructor(name: string, scene?: Nullable<Scene>);
  25242. /**
  25243. * Returns the string "AbstractMesh"
  25244. * @returns "AbstractMesh"
  25245. */
  25246. getClassName(): string;
  25247. /**
  25248. * Gets a string representation of the current mesh
  25249. * @param fullDetails defines a boolean indicating if full details must be included
  25250. * @returns a string representation of the current mesh
  25251. */
  25252. toString(fullDetails?: boolean): string;
  25253. /**
  25254. * @hidden
  25255. */
  25256. protected _getEffectiveParent(): Nullable<Node>;
  25257. /** @hidden */
  25258. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  25259. /** @hidden */
  25260. _rebuild(): void;
  25261. /** @hidden */
  25262. _resyncLightSources(): void;
  25263. /** @hidden */
  25264. _resyncLighSource(light: Light): void;
  25265. /** @hidden */
  25266. _unBindEffect(): void;
  25267. /** @hidden */
  25268. _removeLightSource(light: Light): void;
  25269. private _markSubMeshesAsDirty;
  25270. /** @hidden */
  25271. _markSubMeshesAsLightDirty(): void;
  25272. /** @hidden */
  25273. _markSubMeshesAsAttributesDirty(): void;
  25274. /** @hidden */
  25275. _markSubMeshesAsMiscDirty(): void;
  25276. /**
  25277. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  25278. */
  25279. scaling: Vector3;
  25280. /**
  25281. * Returns true if the mesh is blocked. Implemented by child classes
  25282. */
  25283. readonly isBlocked: boolean;
  25284. /**
  25285. * Returns the mesh itself by default. Implemented by child classes
  25286. * @param camera defines the camera to use to pick the right LOD level
  25287. * @returns the currentAbstractMesh
  25288. */
  25289. getLOD(camera: Camera): Nullable<AbstractMesh>;
  25290. /**
  25291. * Returns 0 by default. Implemented by child classes
  25292. * @returns an integer
  25293. */
  25294. getTotalVertices(): number;
  25295. /**
  25296. * Returns a positive integer : the total number of indices in this mesh geometry.
  25297. * @returns the numner of indices or zero if the mesh has no geometry.
  25298. */
  25299. getTotalIndices(): number;
  25300. /**
  25301. * Returns null by default. Implemented by child classes
  25302. * @returns null
  25303. */
  25304. getIndices(): Nullable<IndicesArray>;
  25305. /**
  25306. * Returns the array of the requested vertex data kind. Implemented by child classes
  25307. * @param kind defines the vertex data kind to use
  25308. * @returns null
  25309. */
  25310. getVerticesData(kind: string): Nullable<FloatArray>;
  25311. /**
  25312. * Sets the vertex data of the mesh geometry for the requested `kind`.
  25313. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  25314. * Note that a new underlying VertexBuffer object is created each call.
  25315. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  25316. * @param kind defines vertex data kind:
  25317. * * VertexBuffer.PositionKind
  25318. * * VertexBuffer.UVKind
  25319. * * VertexBuffer.UV2Kind
  25320. * * VertexBuffer.UV3Kind
  25321. * * VertexBuffer.UV4Kind
  25322. * * VertexBuffer.UV5Kind
  25323. * * VertexBuffer.UV6Kind
  25324. * * VertexBuffer.ColorKind
  25325. * * VertexBuffer.MatricesIndicesKind
  25326. * * VertexBuffer.MatricesIndicesExtraKind
  25327. * * VertexBuffer.MatricesWeightsKind
  25328. * * VertexBuffer.MatricesWeightsExtraKind
  25329. * @param data defines the data source
  25330. * @param updatable defines if the data must be flagged as updatable (or static)
  25331. * @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
  25332. * @returns the current mesh
  25333. */
  25334. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  25335. /**
  25336. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  25337. * If the mesh has no geometry, it is simply returned as it is.
  25338. * @param kind defines vertex data kind:
  25339. * * VertexBuffer.PositionKind
  25340. * * VertexBuffer.UVKind
  25341. * * VertexBuffer.UV2Kind
  25342. * * VertexBuffer.UV3Kind
  25343. * * VertexBuffer.UV4Kind
  25344. * * VertexBuffer.UV5Kind
  25345. * * VertexBuffer.UV6Kind
  25346. * * VertexBuffer.ColorKind
  25347. * * VertexBuffer.MatricesIndicesKind
  25348. * * VertexBuffer.MatricesIndicesExtraKind
  25349. * * VertexBuffer.MatricesWeightsKind
  25350. * * VertexBuffer.MatricesWeightsExtraKind
  25351. * @param data defines the data source
  25352. * @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
  25353. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  25354. * @returns the current mesh
  25355. */
  25356. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  25357. /**
  25358. * Sets the mesh indices,
  25359. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  25360. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  25361. * @param totalVertices Defines the total number of vertices
  25362. * @returns the current mesh
  25363. */
  25364. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  25365. /**
  25366. * Gets a boolean indicating if specific vertex data is present
  25367. * @param kind defines the vertex data kind to use
  25368. * @returns true is data kind is present
  25369. */
  25370. isVerticesDataPresent(kind: string): boolean;
  25371. /**
  25372. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  25373. * @returns a BoundingInfo
  25374. */
  25375. getBoundingInfo(): BoundingInfo;
  25376. /**
  25377. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  25378. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  25379. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  25380. * @returns the current mesh
  25381. */
  25382. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean): AbstractMesh;
  25383. /**
  25384. * Overwrite the current bounding info
  25385. * @param boundingInfo defines the new bounding info
  25386. * @returns the current mesh
  25387. */
  25388. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  25389. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  25390. readonly useBones: boolean;
  25391. /** @hidden */
  25392. _preActivate(): void;
  25393. /** @hidden */
  25394. _preActivateForIntermediateRendering(renderId: number): void;
  25395. /** @hidden */
  25396. _activate(renderId: number, intermediateRendering: boolean): boolean;
  25397. /** @hidden */
  25398. _postActivate(): void;
  25399. /** @hidden */
  25400. _freeze(): void;
  25401. /** @hidden */
  25402. _unFreeze(): void;
  25403. /**
  25404. * Gets the current world matrix
  25405. * @returns a Matrix
  25406. */
  25407. getWorldMatrix(): Matrix;
  25408. /** @hidden */
  25409. _getWorldMatrixDeterminant(): number;
  25410. /**
  25411. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  25412. */
  25413. readonly isAnInstance: boolean;
  25414. /**
  25415. * Perform relative position change from the point of view of behind the front of the mesh.
  25416. * This is performed taking into account the meshes current rotation, so you do not have to care.
  25417. * Supports definition of mesh facing forward or backward
  25418. * @param amountRight defines the distance on the right axis
  25419. * @param amountUp defines the distance on the up axis
  25420. * @param amountForward defines the distance on the forward axis
  25421. * @returns the current mesh
  25422. */
  25423. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  25424. /**
  25425. * Calculate relative position change from the point of view of behind the front of the mesh.
  25426. * This is performed taking into account the meshes current rotation, so you do not have to care.
  25427. * Supports definition of mesh facing forward or backward
  25428. * @param amountRight defines the distance on the right axis
  25429. * @param amountUp defines the distance on the up axis
  25430. * @param amountForward defines the distance on the forward axis
  25431. * @returns the new displacement vector
  25432. */
  25433. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  25434. /**
  25435. * Perform relative rotation change from the point of view of behind the front of the mesh.
  25436. * Supports definition of mesh facing forward or backward
  25437. * @param flipBack defines the flip
  25438. * @param twirlClockwise defines the twirl
  25439. * @param tiltRight defines the tilt
  25440. * @returns the current mesh
  25441. */
  25442. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  25443. /**
  25444. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  25445. * Supports definition of mesh facing forward or backward.
  25446. * @param flipBack defines the flip
  25447. * @param twirlClockwise defines the twirl
  25448. * @param tiltRight defines the tilt
  25449. * @returns the new rotation vector
  25450. */
  25451. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  25452. /**
  25453. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  25454. * This means the mesh underlying bounding box and sphere are recomputed.
  25455. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  25456. * @returns the current mesh
  25457. */
  25458. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  25459. /** @hidden */
  25460. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  25461. /** @hidden */
  25462. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  25463. /** @hidden */
  25464. _updateBoundingInfo(): AbstractMesh;
  25465. /** @hidden */
  25466. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  25467. /** @hidden */
  25468. protected _afterComputeWorldMatrix(): void;
  25469. /** @hidden */
  25470. readonly _effectiveMesh: AbstractMesh;
  25471. /**
  25472. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  25473. * A mesh is in the frustum if its bounding box intersects the frustum
  25474. * @param frustumPlanes defines the frustum to test
  25475. * @returns true if the mesh is in the frustum planes
  25476. */
  25477. isInFrustum(frustumPlanes: Plane[]): boolean;
  25478. /**
  25479. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  25480. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  25481. * @param frustumPlanes defines the frustum to test
  25482. * @returns true if the mesh is completely in the frustum planes
  25483. */
  25484. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  25485. /**
  25486. * True if the mesh intersects another mesh or a SolidParticle object
  25487. * @param mesh defines a target mesh or SolidParticle to test
  25488. * @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)
  25489. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  25490. * @returns true if there is an intersection
  25491. */
  25492. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  25493. /**
  25494. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  25495. * @param point defines the point to test
  25496. * @returns true if there is an intersection
  25497. */
  25498. intersectsPoint(point: Vector3): boolean;
  25499. /**
  25500. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  25501. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25502. */
  25503. checkCollisions: boolean;
  25504. /**
  25505. * Gets Collider object used to compute collisions (not physics)
  25506. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25507. */
  25508. readonly collider: Nullable<Collider>;
  25509. /**
  25510. * Move the mesh using collision engine
  25511. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25512. * @param displacement defines the requested displacement vector
  25513. * @returns the current mesh
  25514. */
  25515. moveWithCollisions(displacement: Vector3): AbstractMesh;
  25516. private _onCollisionPositionChange;
  25517. /** @hidden */
  25518. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  25519. /** @hidden */
  25520. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  25521. /** @hidden */
  25522. _checkCollision(collider: Collider): AbstractMesh;
  25523. /** @hidden */
  25524. _generatePointsArray(): boolean;
  25525. /**
  25526. * Checks if the passed Ray intersects with the mesh
  25527. * @param ray defines the ray to use
  25528. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  25529. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  25530. * @returns the picking info
  25531. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  25532. */
  25533. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  25534. /**
  25535. * Clones the current mesh
  25536. * @param name defines the mesh name
  25537. * @param newParent defines the new mesh parent
  25538. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  25539. * @returns the new mesh
  25540. */
  25541. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  25542. /**
  25543. * Disposes all the submeshes of the current meshnp
  25544. * @returns the current mesh
  25545. */
  25546. releaseSubMeshes(): AbstractMesh;
  25547. /**
  25548. * Releases resources associated with this abstract mesh.
  25549. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25550. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25551. */
  25552. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25553. /**
  25554. * Adds the passed mesh as a child to the current mesh
  25555. * @param mesh defines the child mesh
  25556. * @returns the current mesh
  25557. */
  25558. addChild(mesh: AbstractMesh): AbstractMesh;
  25559. /**
  25560. * Removes the passed mesh from the current mesh children list
  25561. * @param mesh defines the child mesh
  25562. * @returns the current mesh
  25563. */
  25564. removeChild(mesh: AbstractMesh): AbstractMesh;
  25565. /** @hidden */
  25566. private _initFacetData;
  25567. /**
  25568. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  25569. * This method can be called within the render loop.
  25570. * 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
  25571. * @returns the current mesh
  25572. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25573. */
  25574. updateFacetData(): AbstractMesh;
  25575. /**
  25576. * Returns the facetLocalNormals array.
  25577. * The normals are expressed in the mesh local spac
  25578. * @returns an array of Vector3
  25579. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25580. */
  25581. getFacetLocalNormals(): Vector3[];
  25582. /**
  25583. * Returns the facetLocalPositions array.
  25584. * The facet positions are expressed in the mesh local space
  25585. * @returns an array of Vector3
  25586. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25587. */
  25588. getFacetLocalPositions(): Vector3[];
  25589. /**
  25590. * Returns the facetLocalPartioning array
  25591. * @returns an array of array of numbers
  25592. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25593. */
  25594. getFacetLocalPartitioning(): number[][];
  25595. /**
  25596. * Returns the i-th facet position in the world system.
  25597. * This method allocates a new Vector3 per call
  25598. * @param i defines the facet index
  25599. * @returns a new Vector3
  25600. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25601. */
  25602. getFacetPosition(i: number): Vector3;
  25603. /**
  25604. * Sets the reference Vector3 with the i-th facet position in the world system
  25605. * @param i defines the facet index
  25606. * @param ref defines the target vector
  25607. * @returns the current mesh
  25608. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25609. */
  25610. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  25611. /**
  25612. * Returns the i-th facet normal in the world system.
  25613. * This method allocates a new Vector3 per call
  25614. * @param i defines the facet index
  25615. * @returns a new Vector3
  25616. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25617. */
  25618. getFacetNormal(i: number): Vector3;
  25619. /**
  25620. * Sets the reference Vector3 with the i-th facet normal in the world system
  25621. * @param i defines the facet index
  25622. * @param ref defines the target vector
  25623. * @returns the current mesh
  25624. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25625. */
  25626. getFacetNormalToRef(i: number, ref: Vector3): this;
  25627. /**
  25628. * 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)
  25629. * @param x defines x coordinate
  25630. * @param y defines y coordinate
  25631. * @param z defines z coordinate
  25632. * @returns the array of facet indexes
  25633. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25634. */
  25635. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  25636. /**
  25637. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  25638. * @param projected sets as the (x,y,z) world projection on the facet
  25639. * @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
  25640. * @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
  25641. * @param x defines x coordinate
  25642. * @param y defines y coordinate
  25643. * @param z defines z coordinate
  25644. * @returns the face index if found (or null instead)
  25645. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25646. */
  25647. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  25648. /**
  25649. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  25650. * @param projected sets as the (x,y,z) local projection on the facet
  25651. * @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
  25652. * @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
  25653. * @param x defines x coordinate
  25654. * @param y defines y coordinate
  25655. * @param z defines z coordinate
  25656. * @returns the face index if found (or null instead)
  25657. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25658. */
  25659. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  25660. /**
  25661. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  25662. * @returns the parameters
  25663. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25664. */
  25665. getFacetDataParameters(): any;
  25666. /**
  25667. * Disables the feature FacetData and frees the related memory
  25668. * @returns the current mesh
  25669. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25670. */
  25671. disableFacetData(): AbstractMesh;
  25672. /**
  25673. * Updates the AbstractMesh indices array
  25674. * @param indices defines the data source
  25675. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  25676. * @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)
  25677. * @returns the current mesh
  25678. */
  25679. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  25680. /**
  25681. * Creates new normals data for the mesh
  25682. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  25683. * @returns the current mesh
  25684. */
  25685. createNormals(updatable: boolean): AbstractMesh;
  25686. /**
  25687. * Align the mesh with a normal
  25688. * @param normal defines the normal to use
  25689. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  25690. * @returns the current mesh
  25691. */
  25692. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  25693. /** @hidden */
  25694. _checkOcclusionQuery(): boolean;
  25695. /**
  25696. * Disables the mesh edge rendering mode
  25697. * @returns the currentAbstractMesh
  25698. */
  25699. disableEdgesRendering(): AbstractMesh;
  25700. /**
  25701. * Enables the edge rendering mode on the mesh.
  25702. * This mode makes the mesh edges visible
  25703. * @param epsilon defines the maximal distance between two angles to detect a face
  25704. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  25705. * @returns the currentAbstractMesh
  25706. * @see https://www.babylonjs-playground.com/#19O9TU#0
  25707. */
  25708. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  25709. }
  25710. }
  25711. declare module "babylonjs/Actions/actionEvent" {
  25712. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25713. import { Nullable } from "babylonjs/types";
  25714. import { Sprite } from "babylonjs/Sprites/sprite";
  25715. import { Scene } from "babylonjs/scene";
  25716. import { Vector2 } from "babylonjs/Maths/math";
  25717. /**
  25718. * Interface used to define ActionEvent
  25719. */
  25720. export interface IActionEvent {
  25721. /** The mesh or sprite that triggered the action */
  25722. source: any;
  25723. /** The X mouse cursor position at the time of the event */
  25724. pointerX: number;
  25725. /** The Y mouse cursor position at the time of the event */
  25726. pointerY: number;
  25727. /** The mesh that is currently pointed at (can be null) */
  25728. meshUnderPointer: Nullable<AbstractMesh>;
  25729. /** the original (browser) event that triggered the ActionEvent */
  25730. sourceEvent?: any;
  25731. /** additional data for the event */
  25732. additionalData?: any;
  25733. }
  25734. /**
  25735. * ActionEvent is the event being sent when an action is triggered.
  25736. */
  25737. export class ActionEvent implements IActionEvent {
  25738. /** The mesh or sprite that triggered the action */
  25739. source: any;
  25740. /** The X mouse cursor position at the time of the event */
  25741. pointerX: number;
  25742. /** The Y mouse cursor position at the time of the event */
  25743. pointerY: number;
  25744. /** The mesh that is currently pointed at (can be null) */
  25745. meshUnderPointer: Nullable<AbstractMesh>;
  25746. /** the original (browser) event that triggered the ActionEvent */
  25747. sourceEvent?: any;
  25748. /** additional data for the event */
  25749. additionalData?: any;
  25750. /**
  25751. * Creates a new ActionEvent
  25752. * @param source The mesh or sprite that triggered the action
  25753. * @param pointerX The X mouse cursor position at the time of the event
  25754. * @param pointerY The Y mouse cursor position at the time of the event
  25755. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  25756. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  25757. * @param additionalData additional data for the event
  25758. */
  25759. constructor(
  25760. /** The mesh or sprite that triggered the action */
  25761. source: any,
  25762. /** The X mouse cursor position at the time of the event */
  25763. pointerX: number,
  25764. /** The Y mouse cursor position at the time of the event */
  25765. pointerY: number,
  25766. /** The mesh that is currently pointed at (can be null) */
  25767. meshUnderPointer: Nullable<AbstractMesh>,
  25768. /** the original (browser) event that triggered the ActionEvent */
  25769. sourceEvent?: any,
  25770. /** additional data for the event */
  25771. additionalData?: any);
  25772. /**
  25773. * Helper function to auto-create an ActionEvent from a source mesh.
  25774. * @param source The source mesh that triggered the event
  25775. * @param evt The original (browser) event
  25776. * @param additionalData additional data for the event
  25777. * @returns the new ActionEvent
  25778. */
  25779. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  25780. /**
  25781. * Helper function to auto-create an ActionEvent from a source sprite
  25782. * @param source The source sprite that triggered the event
  25783. * @param scene Scene associated with the sprite
  25784. * @param evt The original (browser) event
  25785. * @param additionalData additional data for the event
  25786. * @returns the new ActionEvent
  25787. */
  25788. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  25789. /**
  25790. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  25791. * @param scene the scene where the event occurred
  25792. * @param evt The original (browser) event
  25793. * @returns the new ActionEvent
  25794. */
  25795. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  25796. /**
  25797. * Helper function to auto-create an ActionEvent from a primitive
  25798. * @param prim defines the target primitive
  25799. * @param pointerPos defines the pointer position
  25800. * @param evt The original (browser) event
  25801. * @param additionalData additional data for the event
  25802. * @returns the new ActionEvent
  25803. */
  25804. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  25805. }
  25806. }
  25807. declare module "babylonjs/Actions/abstractActionManager" {
  25808. import { IDisposable } from "babylonjs/scene";
  25809. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  25810. import { IAction } from "babylonjs/Actions/action";
  25811. import { Nullable } from "babylonjs/types";
  25812. /**
  25813. * Abstract class used to decouple action Manager from scene and meshes.
  25814. * Do not instantiate.
  25815. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  25816. */
  25817. export abstract class AbstractActionManager implements IDisposable {
  25818. /** Gets the list of active triggers */
  25819. static Triggers: {
  25820. [key: string]: number;
  25821. };
  25822. /** Gets the cursor to use when hovering items */
  25823. hoverCursor: string;
  25824. /** Gets the list of actions */
  25825. actions: IAction[];
  25826. /**
  25827. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  25828. */
  25829. isRecursive: boolean;
  25830. /**
  25831. * Releases all associated resources
  25832. */
  25833. abstract dispose(): void;
  25834. /**
  25835. * Does this action manager has pointer triggers
  25836. */
  25837. abstract readonly hasPointerTriggers: boolean;
  25838. /**
  25839. * Does this action manager has pick triggers
  25840. */
  25841. abstract readonly hasPickTriggers: boolean;
  25842. /**
  25843. * Process a specific trigger
  25844. * @param trigger defines the trigger to process
  25845. * @param evt defines the event details to be processed
  25846. */
  25847. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  25848. /**
  25849. * Does this action manager handles actions of any of the given triggers
  25850. * @param triggers defines the triggers to be tested
  25851. * @return a boolean indicating whether one (or more) of the triggers is handled
  25852. */
  25853. abstract hasSpecificTriggers(triggers: number[]): boolean;
  25854. /**
  25855. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  25856. * speed.
  25857. * @param triggerA defines the trigger to be tested
  25858. * @param triggerB defines the trigger to be tested
  25859. * @return a boolean indicating whether one (or more) of the triggers is handled
  25860. */
  25861. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  25862. /**
  25863. * Does this action manager handles actions of a given trigger
  25864. * @param trigger defines the trigger to be tested
  25865. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  25866. * @return whether the trigger is handled
  25867. */
  25868. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  25869. /**
  25870. * Serialize this manager to a JSON object
  25871. * @param name defines the property name to store this manager
  25872. * @returns a JSON representation of this manager
  25873. */
  25874. abstract serialize(name: string): any;
  25875. /**
  25876. * Registers an action to this action manager
  25877. * @param action defines the action to be registered
  25878. * @return the action amended (prepared) after registration
  25879. */
  25880. abstract registerAction(action: IAction): Nullable<IAction>;
  25881. /**
  25882. * Unregisters an action to this action manager
  25883. * @param action defines the action to be unregistered
  25884. * @return a boolean indicating whether the action has been unregistered
  25885. */
  25886. abstract unregisterAction(action: IAction): Boolean;
  25887. /**
  25888. * Does exist one action manager with at least one trigger
  25889. **/
  25890. static readonly HasTriggers: boolean;
  25891. /**
  25892. * Does exist one action manager with at least one pick trigger
  25893. **/
  25894. static readonly HasPickTriggers: boolean;
  25895. /**
  25896. * Does exist one action manager that handles actions of a given trigger
  25897. * @param trigger defines the trigger to be tested
  25898. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  25899. **/
  25900. static HasSpecificTrigger(trigger: number): boolean;
  25901. }
  25902. }
  25903. declare module "babylonjs/node" {
  25904. import { Scene } from "babylonjs/scene";
  25905. import { Nullable } from "babylonjs/types";
  25906. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  25907. import { Engine } from "babylonjs/Engines/engine";
  25908. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  25909. import { Observable } from "babylonjs/Misc/observable";
  25910. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  25911. import { IInspectable } from "babylonjs/Misc/iInspectable";
  25912. import { Animatable } from "babylonjs/Animations/animatable";
  25913. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  25914. import { Animation } from "babylonjs/Animations/animation";
  25915. import { AnimationRange } from "babylonjs/Animations/animationRange";
  25916. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25917. /**
  25918. * Defines how a node can be built from a string name.
  25919. */
  25920. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  25921. /**
  25922. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  25923. */
  25924. export class Node implements IBehaviorAware<Node> {
  25925. /** @hidden */
  25926. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  25927. private static _NodeConstructors;
  25928. /**
  25929. * Add a new node constructor
  25930. * @param type defines the type name of the node to construct
  25931. * @param constructorFunc defines the constructor function
  25932. */
  25933. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  25934. /**
  25935. * Returns a node constructor based on type name
  25936. * @param type defines the type name
  25937. * @param name defines the new node name
  25938. * @param scene defines the hosting scene
  25939. * @param options defines optional options to transmit to constructors
  25940. * @returns the new constructor or null
  25941. */
  25942. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  25943. /**
  25944. * Gets or sets the name of the node
  25945. */
  25946. name: string;
  25947. /**
  25948. * Gets or sets the id of the node
  25949. */
  25950. id: string;
  25951. /**
  25952. * Gets or sets the unique id of the node
  25953. */
  25954. uniqueId: number;
  25955. /**
  25956. * Gets or sets a string used to store user defined state for the node
  25957. */
  25958. state: string;
  25959. /**
  25960. * Gets or sets an object used to store user defined information for the node
  25961. */
  25962. metadata: any;
  25963. /**
  25964. * For internal use only. Please do not use.
  25965. */
  25966. reservedDataStore: any;
  25967. /**
  25968. * List of inspectable custom properties (used by the Inspector)
  25969. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  25970. */
  25971. inspectableCustomProperties: IInspectable[];
  25972. /**
  25973. * Gets or sets a boolean used to define if the node must be serialized
  25974. */
  25975. doNotSerialize: boolean;
  25976. /** @hidden */
  25977. _isDisposed: boolean;
  25978. /**
  25979. * Gets a list of Animations associated with the node
  25980. */
  25981. animations: import("babylonjs/Animations/animation").Animation[];
  25982. protected _ranges: {
  25983. [name: string]: Nullable<AnimationRange>;
  25984. };
  25985. /**
  25986. * Callback raised when the node is ready to be used
  25987. */
  25988. onReady: Nullable<(node: Node) => void>;
  25989. private _isEnabled;
  25990. private _isParentEnabled;
  25991. private _isReady;
  25992. /** @hidden */
  25993. _currentRenderId: number;
  25994. private _parentUpdateId;
  25995. /** @hidden */
  25996. _childUpdateId: number;
  25997. /** @hidden */
  25998. _waitingParentId: Nullable<string>;
  25999. /** @hidden */
  26000. _scene: Scene;
  26001. /** @hidden */
  26002. _cache: any;
  26003. private _parentNode;
  26004. private _children;
  26005. /** @hidden */
  26006. _worldMatrix: Matrix;
  26007. /** @hidden */
  26008. _worldMatrixDeterminant: number;
  26009. /** @hidden */
  26010. _worldMatrixDeterminantIsDirty: boolean;
  26011. /** @hidden */
  26012. private _sceneRootNodesIndex;
  26013. /**
  26014. * Gets a boolean indicating if the node has been disposed
  26015. * @returns true if the node was disposed
  26016. */
  26017. isDisposed(): boolean;
  26018. /**
  26019. * Gets or sets the parent of the node (without keeping the current position in the scene)
  26020. * @see https://doc.babylonjs.com/how_to/parenting
  26021. */
  26022. parent: Nullable<Node>;
  26023. private addToSceneRootNodes;
  26024. private removeFromSceneRootNodes;
  26025. private _animationPropertiesOverride;
  26026. /**
  26027. * Gets or sets the animation properties override
  26028. */
  26029. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  26030. /**
  26031. * Gets a string idenfifying the name of the class
  26032. * @returns "Node" string
  26033. */
  26034. getClassName(): string;
  26035. /** @hidden */
  26036. readonly _isNode: boolean;
  26037. /**
  26038. * An event triggered when the mesh is disposed
  26039. */
  26040. onDisposeObservable: Observable<Node>;
  26041. private _onDisposeObserver;
  26042. /**
  26043. * Sets a callback that will be raised when the node will be disposed
  26044. */
  26045. onDispose: () => void;
  26046. /**
  26047. * Creates a new Node
  26048. * @param name the name and id to be given to this node
  26049. * @param scene the scene this node will be added to
  26050. * @param addToRootNodes the node will be added to scene.rootNodes
  26051. */
  26052. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  26053. /**
  26054. * Gets the scene of the node
  26055. * @returns a scene
  26056. */
  26057. getScene(): Scene;
  26058. /**
  26059. * Gets the engine of the node
  26060. * @returns a Engine
  26061. */
  26062. getEngine(): Engine;
  26063. private _behaviors;
  26064. /**
  26065. * Attach a behavior to the node
  26066. * @see http://doc.babylonjs.com/features/behaviour
  26067. * @param behavior defines the behavior to attach
  26068. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  26069. * @returns the current Node
  26070. */
  26071. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  26072. /**
  26073. * Remove an attached behavior
  26074. * @see http://doc.babylonjs.com/features/behaviour
  26075. * @param behavior defines the behavior to attach
  26076. * @returns the current Node
  26077. */
  26078. removeBehavior(behavior: Behavior<Node>): Node;
  26079. /**
  26080. * Gets the list of attached behaviors
  26081. * @see http://doc.babylonjs.com/features/behaviour
  26082. */
  26083. readonly behaviors: Behavior<Node>[];
  26084. /**
  26085. * Gets an attached behavior by name
  26086. * @param name defines the name of the behavior to look for
  26087. * @see http://doc.babylonjs.com/features/behaviour
  26088. * @returns null if behavior was not found else the requested behavior
  26089. */
  26090. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  26091. /**
  26092. * Returns the latest update of the World matrix
  26093. * @returns a Matrix
  26094. */
  26095. getWorldMatrix(): Matrix;
  26096. /** @hidden */
  26097. _getWorldMatrixDeterminant(): number;
  26098. /**
  26099. * Returns directly the latest state of the mesh World matrix.
  26100. * A Matrix is returned.
  26101. */
  26102. readonly worldMatrixFromCache: Matrix;
  26103. /** @hidden */
  26104. _initCache(): void;
  26105. /** @hidden */
  26106. updateCache(force?: boolean): void;
  26107. /** @hidden */
  26108. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  26109. /** @hidden */
  26110. _updateCache(ignoreParentClass?: boolean): void;
  26111. /** @hidden */
  26112. _isSynchronized(): boolean;
  26113. /** @hidden */
  26114. _markSyncedWithParent(): void;
  26115. /** @hidden */
  26116. isSynchronizedWithParent(): boolean;
  26117. /** @hidden */
  26118. isSynchronized(): boolean;
  26119. /**
  26120. * Is this node ready to be used/rendered
  26121. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  26122. * @return true if the node is ready
  26123. */
  26124. isReady(completeCheck?: boolean): boolean;
  26125. /**
  26126. * Is this node enabled?
  26127. * 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
  26128. * @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
  26129. * @return whether this node (and its parent) is enabled
  26130. */
  26131. isEnabled(checkAncestors?: boolean): boolean;
  26132. /** @hidden */
  26133. protected _syncParentEnabledState(): void;
  26134. /**
  26135. * Set the enabled state of this node
  26136. * @param value defines the new enabled state
  26137. */
  26138. setEnabled(value: boolean): void;
  26139. /**
  26140. * Is this node a descendant of the given node?
  26141. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  26142. * @param ancestor defines the parent node to inspect
  26143. * @returns a boolean indicating if this node is a descendant of the given node
  26144. */
  26145. isDescendantOf(ancestor: Node): boolean;
  26146. /** @hidden */
  26147. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  26148. /**
  26149. * Will return all nodes that have this node as ascendant
  26150. * @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
  26151. * @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
  26152. * @return all children nodes of all types
  26153. */
  26154. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  26155. /**
  26156. * Get all child-meshes of this node
  26157. * @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)
  26158. * @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
  26159. * @returns an array of AbstractMesh
  26160. */
  26161. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  26162. /**
  26163. * Get all direct children of this node
  26164. * @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
  26165. * @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)
  26166. * @returns an array of Node
  26167. */
  26168. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  26169. /** @hidden */
  26170. _setReady(state: boolean): void;
  26171. /**
  26172. * Get an animation by name
  26173. * @param name defines the name of the animation to look for
  26174. * @returns null if not found else the requested animation
  26175. */
  26176. getAnimationByName(name: string): Nullable<Animation>;
  26177. /**
  26178. * Creates an animation range for this node
  26179. * @param name defines the name of the range
  26180. * @param from defines the starting key
  26181. * @param to defines the end key
  26182. */
  26183. createAnimationRange(name: string, from: number, to: number): void;
  26184. /**
  26185. * Delete a specific animation range
  26186. * @param name defines the name of the range to delete
  26187. * @param deleteFrames defines if animation frames from the range must be deleted as well
  26188. */
  26189. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  26190. /**
  26191. * Get an animation range by name
  26192. * @param name defines the name of the animation range to look for
  26193. * @returns null if not found else the requested animation range
  26194. */
  26195. getAnimationRange(name: string): Nullable<AnimationRange>;
  26196. /**
  26197. * Gets the list of all animation ranges defined on this node
  26198. * @returns an array
  26199. */
  26200. getAnimationRanges(): Nullable<AnimationRange>[];
  26201. /**
  26202. * Will start the animation sequence
  26203. * @param name defines the range frames for animation sequence
  26204. * @param loop defines if the animation should loop (false by default)
  26205. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  26206. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  26207. * @returns the object created for this animation. If range does not exist, it will return null
  26208. */
  26209. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  26210. /**
  26211. * Serialize animation ranges into a JSON compatible object
  26212. * @returns serialization object
  26213. */
  26214. serializeAnimationRanges(): any;
  26215. /**
  26216. * Computes the world matrix of the node
  26217. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  26218. * @returns the world matrix
  26219. */
  26220. computeWorldMatrix(force?: boolean): Matrix;
  26221. /**
  26222. * Releases resources associated with this node.
  26223. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26224. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26225. */
  26226. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26227. /**
  26228. * Parse animation range data from a serialization object and store them into a given node
  26229. * @param node defines where to store the animation ranges
  26230. * @param parsedNode defines the serialization object to read data from
  26231. * @param scene defines the hosting scene
  26232. */
  26233. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  26234. /**
  26235. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  26236. * @param includeDescendants Include bounding info from descendants as well (true by default)
  26237. * @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
  26238. * @returns the new bounding vectors
  26239. */
  26240. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  26241. min: Vector3;
  26242. max: Vector3;
  26243. };
  26244. }
  26245. }
  26246. declare module "babylonjs/Animations/animation" {
  26247. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  26248. import { Vector3, Quaternion, Vector2, Color3, Size, Matrix } from "babylonjs/Maths/math";
  26249. import { Nullable } from "babylonjs/types";
  26250. import { Scene } from "babylonjs/scene";
  26251. import { IAnimatable } from "babylonjs/Misc/tools";
  26252. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  26253. import { AnimationRange } from "babylonjs/Animations/animationRange";
  26254. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  26255. import { Node } from "babylonjs/node";
  26256. import { Animatable } from "babylonjs/Animations/animatable";
  26257. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  26258. /**
  26259. * @hidden
  26260. */
  26261. export class _IAnimationState {
  26262. key: number;
  26263. repeatCount: number;
  26264. workValue?: any;
  26265. loopMode?: number;
  26266. offsetValue?: any;
  26267. highLimitValue?: any;
  26268. }
  26269. /**
  26270. * Class used to store any kind of animation
  26271. */
  26272. export class Animation {
  26273. /**Name of the animation */
  26274. name: string;
  26275. /**Property to animate */
  26276. targetProperty: string;
  26277. /**The frames per second of the animation */
  26278. framePerSecond: number;
  26279. /**The data type of the animation */
  26280. dataType: number;
  26281. /**The loop mode of the animation */
  26282. loopMode?: number | undefined;
  26283. /**Specifies if blending should be enabled */
  26284. enableBlending?: boolean | undefined;
  26285. /**
  26286. * Use matrix interpolation instead of using direct key value when animating matrices
  26287. */
  26288. static AllowMatricesInterpolation: boolean;
  26289. /**
  26290. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  26291. */
  26292. static AllowMatrixDecomposeForInterpolation: boolean;
  26293. /**
  26294. * Stores the key frames of the animation
  26295. */
  26296. private _keys;
  26297. /**
  26298. * Stores the easing function of the animation
  26299. */
  26300. private _easingFunction;
  26301. /**
  26302. * @hidden Internal use only
  26303. */
  26304. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  26305. /**
  26306. * The set of event that will be linked to this animation
  26307. */
  26308. private _events;
  26309. /**
  26310. * Stores an array of target property paths
  26311. */
  26312. targetPropertyPath: string[];
  26313. /**
  26314. * Stores the blending speed of the animation
  26315. */
  26316. blendingSpeed: number;
  26317. /**
  26318. * Stores the animation ranges for the animation
  26319. */
  26320. private _ranges;
  26321. /**
  26322. * @hidden Internal use
  26323. */
  26324. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  26325. /**
  26326. * Sets up an animation
  26327. * @param property The property to animate
  26328. * @param animationType The animation type to apply
  26329. * @param framePerSecond The frames per second of the animation
  26330. * @param easingFunction The easing function used in the animation
  26331. * @returns The created animation
  26332. */
  26333. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  26334. /**
  26335. * Create and start an animation on a node
  26336. * @param name defines the name of the global animation that will be run on all nodes
  26337. * @param node defines the root node where the animation will take place
  26338. * @param targetProperty defines property to animate
  26339. * @param framePerSecond defines the number of frame per second yo use
  26340. * @param totalFrame defines the number of frames in total
  26341. * @param from defines the initial value
  26342. * @param to defines the final value
  26343. * @param loopMode defines which loop mode you want to use (off by default)
  26344. * @param easingFunction defines the easing function to use (linear by default)
  26345. * @param onAnimationEnd defines the callback to call when animation end
  26346. * @returns the animatable created for this animation
  26347. */
  26348. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  26349. /**
  26350. * Create and start an animation on a node and its descendants
  26351. * @param name defines the name of the global animation that will be run on all nodes
  26352. * @param node defines the root node where the animation will take place
  26353. * @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
  26354. * @param targetProperty defines property to animate
  26355. * @param framePerSecond defines the number of frame per second to use
  26356. * @param totalFrame defines the number of frames in total
  26357. * @param from defines the initial value
  26358. * @param to defines the final value
  26359. * @param loopMode defines which loop mode you want to use (off by default)
  26360. * @param easingFunction defines the easing function to use (linear by default)
  26361. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  26362. * @returns the list of animatables created for all nodes
  26363. * @example https://www.babylonjs-playground.com/#MH0VLI
  26364. */
  26365. 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[]>;
  26366. /**
  26367. * Creates a new animation, merges it with the existing animations and starts it
  26368. * @param name Name of the animation
  26369. * @param node Node which contains the scene that begins the animations
  26370. * @param targetProperty Specifies which property to animate
  26371. * @param framePerSecond The frames per second of the animation
  26372. * @param totalFrame The total number of frames
  26373. * @param from The frame at the beginning of the animation
  26374. * @param to The frame at the end of the animation
  26375. * @param loopMode Specifies the loop mode of the animation
  26376. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  26377. * @param onAnimationEnd Callback to run once the animation is complete
  26378. * @returns Nullable animation
  26379. */
  26380. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  26381. /**
  26382. * Transition property of an host to the target Value
  26383. * @param property The property to transition
  26384. * @param targetValue The target Value of the property
  26385. * @param host The object where the property to animate belongs
  26386. * @param scene Scene used to run the animation
  26387. * @param frameRate Framerate (in frame/s) to use
  26388. * @param transition The transition type we want to use
  26389. * @param duration The duration of the animation, in milliseconds
  26390. * @param onAnimationEnd Callback trigger at the end of the animation
  26391. * @returns Nullable animation
  26392. */
  26393. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  26394. /**
  26395. * Return the array of runtime animations currently using this animation
  26396. */
  26397. readonly runtimeAnimations: RuntimeAnimation[];
  26398. /**
  26399. * Specifies if any of the runtime animations are currently running
  26400. */
  26401. readonly hasRunningRuntimeAnimations: boolean;
  26402. /**
  26403. * Initializes the animation
  26404. * @param name Name of the animation
  26405. * @param targetProperty Property to animate
  26406. * @param framePerSecond The frames per second of the animation
  26407. * @param dataType The data type of the animation
  26408. * @param loopMode The loop mode of the animation
  26409. * @param enableBlending Specifies if blending should be enabled
  26410. */
  26411. constructor(
  26412. /**Name of the animation */
  26413. name: string,
  26414. /**Property to animate */
  26415. targetProperty: string,
  26416. /**The frames per second of the animation */
  26417. framePerSecond: number,
  26418. /**The data type of the animation */
  26419. dataType: number,
  26420. /**The loop mode of the animation */
  26421. loopMode?: number | undefined,
  26422. /**Specifies if blending should be enabled */
  26423. enableBlending?: boolean | undefined);
  26424. /**
  26425. * Converts the animation to a string
  26426. * @param fullDetails support for multiple levels of logging within scene loading
  26427. * @returns String form of the animation
  26428. */
  26429. toString(fullDetails?: boolean): string;
  26430. /**
  26431. * Add an event to this animation
  26432. * @param event Event to add
  26433. */
  26434. addEvent(event: AnimationEvent): void;
  26435. /**
  26436. * Remove all events found at the given frame
  26437. * @param frame The frame to remove events from
  26438. */
  26439. removeEvents(frame: number): void;
  26440. /**
  26441. * Retrieves all the events from the animation
  26442. * @returns Events from the animation
  26443. */
  26444. getEvents(): AnimationEvent[];
  26445. /**
  26446. * Creates an animation range
  26447. * @param name Name of the animation range
  26448. * @param from Starting frame of the animation range
  26449. * @param to Ending frame of the animation
  26450. */
  26451. createRange(name: string, from: number, to: number): void;
  26452. /**
  26453. * Deletes an animation range by name
  26454. * @param name Name of the animation range to delete
  26455. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  26456. */
  26457. deleteRange(name: string, deleteFrames?: boolean): void;
  26458. /**
  26459. * Gets the animation range by name, or null if not defined
  26460. * @param name Name of the animation range
  26461. * @returns Nullable animation range
  26462. */
  26463. getRange(name: string): Nullable<AnimationRange>;
  26464. /**
  26465. * Gets the key frames from the animation
  26466. * @returns The key frames of the animation
  26467. */
  26468. getKeys(): Array<IAnimationKey>;
  26469. /**
  26470. * Gets the highest frame rate of the animation
  26471. * @returns Highest frame rate of the animation
  26472. */
  26473. getHighestFrame(): number;
  26474. /**
  26475. * Gets the easing function of the animation
  26476. * @returns Easing function of the animation
  26477. */
  26478. getEasingFunction(): IEasingFunction;
  26479. /**
  26480. * Sets the easing function of the animation
  26481. * @param easingFunction A custom mathematical formula for animation
  26482. */
  26483. setEasingFunction(easingFunction: EasingFunction): void;
  26484. /**
  26485. * Interpolates a scalar linearly
  26486. * @param startValue Start value of the animation curve
  26487. * @param endValue End value of the animation curve
  26488. * @param gradient Scalar amount to interpolate
  26489. * @returns Interpolated scalar value
  26490. */
  26491. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  26492. /**
  26493. * Interpolates a scalar cubically
  26494. * @param startValue Start value of the animation curve
  26495. * @param outTangent End tangent of the animation
  26496. * @param endValue End value of the animation curve
  26497. * @param inTangent Start tangent of the animation curve
  26498. * @param gradient Scalar amount to interpolate
  26499. * @returns Interpolated scalar value
  26500. */
  26501. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  26502. /**
  26503. * Interpolates a quaternion using a spherical linear interpolation
  26504. * @param startValue Start value of the animation curve
  26505. * @param endValue End value of the animation curve
  26506. * @param gradient Scalar amount to interpolate
  26507. * @returns Interpolated quaternion value
  26508. */
  26509. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  26510. /**
  26511. * Interpolates a quaternion cubically
  26512. * @param startValue Start value of the animation curve
  26513. * @param outTangent End tangent of the animation curve
  26514. * @param endValue End value of the animation curve
  26515. * @param inTangent Start tangent of the animation curve
  26516. * @param gradient Scalar amount to interpolate
  26517. * @returns Interpolated quaternion value
  26518. */
  26519. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  26520. /**
  26521. * Interpolates a Vector3 linearl
  26522. * @param startValue Start value of the animation curve
  26523. * @param endValue End value of the animation curve
  26524. * @param gradient Scalar amount to interpolate
  26525. * @returns Interpolated scalar value
  26526. */
  26527. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  26528. /**
  26529. * Interpolates a Vector3 cubically
  26530. * @param startValue Start value of the animation curve
  26531. * @param outTangent End tangent of the animation
  26532. * @param endValue End value of the animation curve
  26533. * @param inTangent Start tangent of the animation curve
  26534. * @param gradient Scalar amount to interpolate
  26535. * @returns InterpolatedVector3 value
  26536. */
  26537. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  26538. /**
  26539. * Interpolates a Vector2 linearly
  26540. * @param startValue Start value of the animation curve
  26541. * @param endValue End value of the animation curve
  26542. * @param gradient Scalar amount to interpolate
  26543. * @returns Interpolated Vector2 value
  26544. */
  26545. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  26546. /**
  26547. * Interpolates a Vector2 cubically
  26548. * @param startValue Start value of the animation curve
  26549. * @param outTangent End tangent of the animation
  26550. * @param endValue End value of the animation curve
  26551. * @param inTangent Start tangent of the animation curve
  26552. * @param gradient Scalar amount to interpolate
  26553. * @returns Interpolated Vector2 value
  26554. */
  26555. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  26556. /**
  26557. * Interpolates a size linearly
  26558. * @param startValue Start value of the animation curve
  26559. * @param endValue End value of the animation curve
  26560. * @param gradient Scalar amount to interpolate
  26561. * @returns Interpolated Size value
  26562. */
  26563. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  26564. /**
  26565. * Interpolates a Color3 linearly
  26566. * @param startValue Start value of the animation curve
  26567. * @param endValue End value of the animation curve
  26568. * @param gradient Scalar amount to interpolate
  26569. * @returns Interpolated Color3 value
  26570. */
  26571. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  26572. /**
  26573. * @hidden Internal use only
  26574. */
  26575. _getKeyValue(value: any): any;
  26576. /**
  26577. * @hidden Internal use only
  26578. */
  26579. _interpolate(currentFrame: number, state: _IAnimationState): any;
  26580. /**
  26581. * Defines the function to use to interpolate matrices
  26582. * @param startValue defines the start matrix
  26583. * @param endValue defines the end matrix
  26584. * @param gradient defines the gradient between both matrices
  26585. * @param result defines an optional target matrix where to store the interpolation
  26586. * @returns the interpolated matrix
  26587. */
  26588. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  26589. /**
  26590. * Makes a copy of the animation
  26591. * @returns Cloned animation
  26592. */
  26593. clone(): Animation;
  26594. /**
  26595. * Sets the key frames of the animation
  26596. * @param values The animation key frames to set
  26597. */
  26598. setKeys(values: Array<IAnimationKey>): void;
  26599. /**
  26600. * Serializes the animation to an object
  26601. * @returns Serialized object
  26602. */
  26603. serialize(): any;
  26604. /**
  26605. * Float animation type
  26606. */
  26607. private static _ANIMATIONTYPE_FLOAT;
  26608. /**
  26609. * Vector3 animation type
  26610. */
  26611. private static _ANIMATIONTYPE_VECTOR3;
  26612. /**
  26613. * Quaternion animation type
  26614. */
  26615. private static _ANIMATIONTYPE_QUATERNION;
  26616. /**
  26617. * Matrix animation type
  26618. */
  26619. private static _ANIMATIONTYPE_MATRIX;
  26620. /**
  26621. * Color3 animation type
  26622. */
  26623. private static _ANIMATIONTYPE_COLOR3;
  26624. /**
  26625. * Vector2 animation type
  26626. */
  26627. private static _ANIMATIONTYPE_VECTOR2;
  26628. /**
  26629. * Size animation type
  26630. */
  26631. private static _ANIMATIONTYPE_SIZE;
  26632. /**
  26633. * Relative Loop Mode
  26634. */
  26635. private static _ANIMATIONLOOPMODE_RELATIVE;
  26636. /**
  26637. * Cycle Loop Mode
  26638. */
  26639. private static _ANIMATIONLOOPMODE_CYCLE;
  26640. /**
  26641. * Constant Loop Mode
  26642. */
  26643. private static _ANIMATIONLOOPMODE_CONSTANT;
  26644. /**
  26645. * Get the float animation type
  26646. */
  26647. static readonly ANIMATIONTYPE_FLOAT: number;
  26648. /**
  26649. * Get the Vector3 animation type
  26650. */
  26651. static readonly ANIMATIONTYPE_VECTOR3: number;
  26652. /**
  26653. * Get the Vector2 animation type
  26654. */
  26655. static readonly ANIMATIONTYPE_VECTOR2: number;
  26656. /**
  26657. * Get the Size animation type
  26658. */
  26659. static readonly ANIMATIONTYPE_SIZE: number;
  26660. /**
  26661. * Get the Quaternion animation type
  26662. */
  26663. static readonly ANIMATIONTYPE_QUATERNION: number;
  26664. /**
  26665. * Get the Matrix animation type
  26666. */
  26667. static readonly ANIMATIONTYPE_MATRIX: number;
  26668. /**
  26669. * Get the Color3 animation type
  26670. */
  26671. static readonly ANIMATIONTYPE_COLOR3: number;
  26672. /**
  26673. * Get the Relative Loop Mode
  26674. */
  26675. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  26676. /**
  26677. * Get the Cycle Loop Mode
  26678. */
  26679. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  26680. /**
  26681. * Get the Constant Loop Mode
  26682. */
  26683. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  26684. /** @hidden */
  26685. static _UniversalLerp(left: any, right: any, amount: number): any;
  26686. /**
  26687. * Parses an animation object and creates an animation
  26688. * @param parsedAnimation Parsed animation object
  26689. * @returns Animation object
  26690. */
  26691. static Parse(parsedAnimation: any): Animation;
  26692. /**
  26693. * Appends the serialized animations from the source animations
  26694. * @param source Source containing the animations
  26695. * @param destination Target to store the animations
  26696. */
  26697. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  26698. }
  26699. }
  26700. declare module "babylonjs/Materials/Textures/baseTexture" {
  26701. import { Observable } from "babylonjs/Misc/observable";
  26702. import { IAnimatable } from "babylonjs/Misc/tools";
  26703. import { Nullable } from "babylonjs/types";
  26704. import { Scene } from "babylonjs/scene";
  26705. import { Matrix, ISize } from "babylonjs/Maths/math";
  26706. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  26707. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  26708. /**
  26709. * Base class of all the textures in babylon.
  26710. * It groups all the common properties the materials, post process, lights... might need
  26711. * in order to make a correct use of the texture.
  26712. */
  26713. export class BaseTexture implements IAnimatable {
  26714. /**
  26715. * Default anisotropic filtering level for the application.
  26716. * It is set to 4 as a good tradeoff between perf and quality.
  26717. */
  26718. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  26719. /**
  26720. * Gets or sets the unique id of the texture
  26721. */
  26722. uniqueId: number;
  26723. /**
  26724. * Define the name of the texture.
  26725. */
  26726. name: string;
  26727. /**
  26728. * Gets or sets an object used to store user defined information.
  26729. */
  26730. metadata: any;
  26731. /**
  26732. * For internal use only. Please do not use.
  26733. */
  26734. reservedDataStore: any;
  26735. private _hasAlpha;
  26736. /**
  26737. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  26738. */
  26739. hasAlpha: boolean;
  26740. /**
  26741. * Defines if the alpha value should be determined via the rgb values.
  26742. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  26743. */
  26744. getAlphaFromRGB: boolean;
  26745. /**
  26746. * Intensity or strength of the texture.
  26747. * It is commonly used by materials to fine tune the intensity of the texture
  26748. */
  26749. level: number;
  26750. /**
  26751. * Define the UV chanel to use starting from 0 and defaulting to 0.
  26752. * This is part of the texture as textures usually maps to one uv set.
  26753. */
  26754. coordinatesIndex: number;
  26755. private _coordinatesMode;
  26756. /**
  26757. * How a texture is mapped.
  26758. *
  26759. * | Value | Type | Description |
  26760. * | ----- | ----------------------------------- | ----------- |
  26761. * | 0 | EXPLICIT_MODE | |
  26762. * | 1 | SPHERICAL_MODE | |
  26763. * | 2 | PLANAR_MODE | |
  26764. * | 3 | CUBIC_MODE | |
  26765. * | 4 | PROJECTION_MODE | |
  26766. * | 5 | SKYBOX_MODE | |
  26767. * | 6 | INVCUBIC_MODE | |
  26768. * | 7 | EQUIRECTANGULAR_MODE | |
  26769. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  26770. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  26771. */
  26772. coordinatesMode: number;
  26773. /**
  26774. * | Value | Type | Description |
  26775. * | ----- | ------------------ | ----------- |
  26776. * | 0 | CLAMP_ADDRESSMODE | |
  26777. * | 1 | WRAP_ADDRESSMODE | |
  26778. * | 2 | MIRROR_ADDRESSMODE | |
  26779. */
  26780. wrapU: number;
  26781. /**
  26782. * | Value | Type | Description |
  26783. * | ----- | ------------------ | ----------- |
  26784. * | 0 | CLAMP_ADDRESSMODE | |
  26785. * | 1 | WRAP_ADDRESSMODE | |
  26786. * | 2 | MIRROR_ADDRESSMODE | |
  26787. */
  26788. wrapV: number;
  26789. /**
  26790. * | Value | Type | Description |
  26791. * | ----- | ------------------ | ----------- |
  26792. * | 0 | CLAMP_ADDRESSMODE | |
  26793. * | 1 | WRAP_ADDRESSMODE | |
  26794. * | 2 | MIRROR_ADDRESSMODE | |
  26795. */
  26796. wrapR: number;
  26797. /**
  26798. * With compliant hardware and browser (supporting anisotropic filtering)
  26799. * this defines the level of anisotropic filtering in the texture.
  26800. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  26801. */
  26802. anisotropicFilteringLevel: number;
  26803. /**
  26804. * Define if the texture is a cube texture or if false a 2d texture.
  26805. */
  26806. isCube: boolean;
  26807. /**
  26808. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  26809. */
  26810. is3D: boolean;
  26811. /**
  26812. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  26813. * HDR texture are usually stored in linear space.
  26814. * This only impacts the PBR and Background materials
  26815. */
  26816. gammaSpace: boolean;
  26817. /**
  26818. * Gets whether or not the texture contains RGBD data.
  26819. */
  26820. readonly isRGBD: boolean;
  26821. /**
  26822. * Is Z inverted in the texture (useful in a cube texture).
  26823. */
  26824. invertZ: boolean;
  26825. /**
  26826. * Are mip maps generated for this texture or not.
  26827. */
  26828. readonly noMipmap: boolean;
  26829. /**
  26830. * @hidden
  26831. */
  26832. lodLevelInAlpha: boolean;
  26833. /**
  26834. * With prefiltered texture, defined the offset used during the prefiltering steps.
  26835. */
  26836. lodGenerationOffset: number;
  26837. /**
  26838. * With prefiltered texture, defined the scale used during the prefiltering steps.
  26839. */
  26840. lodGenerationScale: number;
  26841. /**
  26842. * Define if the texture is a render target.
  26843. */
  26844. isRenderTarget: boolean;
  26845. /**
  26846. * Define the unique id of the texture in the scene.
  26847. */
  26848. readonly uid: string;
  26849. /**
  26850. * Return a string representation of the texture.
  26851. * @returns the texture as a string
  26852. */
  26853. toString(): string;
  26854. /**
  26855. * Get the class name of the texture.
  26856. * @returns "BaseTexture"
  26857. */
  26858. getClassName(): string;
  26859. /**
  26860. * Define the list of animation attached to the texture.
  26861. */
  26862. animations: import("babylonjs/Animations/animation").Animation[];
  26863. /**
  26864. * An event triggered when the texture is disposed.
  26865. */
  26866. onDisposeObservable: Observable<BaseTexture>;
  26867. private _onDisposeObserver;
  26868. /**
  26869. * Callback triggered when the texture has been disposed.
  26870. * Kept for back compatibility, you can use the onDisposeObservable instead.
  26871. */
  26872. onDispose: () => void;
  26873. /**
  26874. * Define the current state of the loading sequence when in delayed load mode.
  26875. */
  26876. delayLoadState: number;
  26877. private _scene;
  26878. /** @hidden */
  26879. _texture: Nullable<InternalTexture>;
  26880. private _uid;
  26881. /**
  26882. * Define if the texture is preventinga material to render or not.
  26883. * If not and the texture is not ready, the engine will use a default black texture instead.
  26884. */
  26885. readonly isBlocking: boolean;
  26886. /**
  26887. * Instantiates a new BaseTexture.
  26888. * Base class of all the textures in babylon.
  26889. * It groups all the common properties the materials, post process, lights... might need
  26890. * in order to make a correct use of the texture.
  26891. * @param scene Define the scene the texture blongs to
  26892. */
  26893. constructor(scene: Nullable<Scene>);
  26894. /**
  26895. * Get the scene the texture belongs to.
  26896. * @returns the scene or null if undefined
  26897. */
  26898. getScene(): Nullable<Scene>;
  26899. /**
  26900. * Get the texture transform matrix used to offset tile the texture for istance.
  26901. * @returns the transformation matrix
  26902. */
  26903. getTextureMatrix(): Matrix;
  26904. /**
  26905. * Get the texture reflection matrix used to rotate/transform the reflection.
  26906. * @returns the reflection matrix
  26907. */
  26908. getReflectionTextureMatrix(): Matrix;
  26909. /**
  26910. * Get the underlying lower level texture from Babylon.
  26911. * @returns the insternal texture
  26912. */
  26913. getInternalTexture(): Nullable<InternalTexture>;
  26914. /**
  26915. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  26916. * @returns true if ready or not blocking
  26917. */
  26918. isReadyOrNotBlocking(): boolean;
  26919. /**
  26920. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  26921. * @returns true if fully ready
  26922. */
  26923. isReady(): boolean;
  26924. private _cachedSize;
  26925. /**
  26926. * Get the size of the texture.
  26927. * @returns the texture size.
  26928. */
  26929. getSize(): ISize;
  26930. /**
  26931. * Get the base size of the texture.
  26932. * It can be different from the size if the texture has been resized for POT for instance
  26933. * @returns the base size
  26934. */
  26935. getBaseSize(): ISize;
  26936. /**
  26937. * Update the sampling mode of the texture.
  26938. * Default is Trilinear mode.
  26939. *
  26940. * | Value | Type | Description |
  26941. * | ----- | ------------------ | ----------- |
  26942. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  26943. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  26944. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  26945. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  26946. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  26947. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  26948. * | 7 | NEAREST_LINEAR | |
  26949. * | 8 | NEAREST_NEAREST | |
  26950. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  26951. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  26952. * | 11 | LINEAR_LINEAR | |
  26953. * | 12 | LINEAR_NEAREST | |
  26954. *
  26955. * > _mag_: magnification filter (close to the viewer)
  26956. * > _min_: minification filter (far from the viewer)
  26957. * > _mip_: filter used between mip map levels
  26958. *@param samplingMode Define the new sampling mode of the texture
  26959. */
  26960. updateSamplingMode(samplingMode: number): void;
  26961. /**
  26962. * Scales the texture if is `canRescale()`
  26963. * @param ratio the resize factor we want to use to rescale
  26964. */
  26965. scale(ratio: number): void;
  26966. /**
  26967. * Get if the texture can rescale.
  26968. */
  26969. readonly canRescale: boolean;
  26970. /** @hidden */
  26971. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  26972. /** @hidden */
  26973. _rebuild(): void;
  26974. /**
  26975. * Triggers the load sequence in delayed load mode.
  26976. */
  26977. delayLoad(): void;
  26978. /**
  26979. * Clones the texture.
  26980. * @returns the cloned texture
  26981. */
  26982. clone(): Nullable<BaseTexture>;
  26983. /**
  26984. * Get the texture underlying type (INT, FLOAT...)
  26985. */
  26986. readonly textureType: number;
  26987. /**
  26988. * Get the texture underlying format (RGB, RGBA...)
  26989. */
  26990. readonly textureFormat: number;
  26991. /**
  26992. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  26993. * This will returns an RGBA array buffer containing either in values (0-255) or
  26994. * float values (0-1) depending of the underlying buffer type.
  26995. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  26996. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  26997. * @param buffer defines a user defined buffer to fill with data (can be null)
  26998. * @returns The Array buffer containing the pixels data.
  26999. */
  27000. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  27001. /**
  27002. * Release and destroy the underlying lower level texture aka internalTexture.
  27003. */
  27004. releaseInternalTexture(): void;
  27005. /**
  27006. * Get the polynomial representation of the texture data.
  27007. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  27008. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  27009. */
  27010. sphericalPolynomial: Nullable<SphericalPolynomial>;
  27011. /** @hidden */
  27012. readonly _lodTextureHigh: Nullable<BaseTexture>;
  27013. /** @hidden */
  27014. readonly _lodTextureMid: Nullable<BaseTexture>;
  27015. /** @hidden */
  27016. readonly _lodTextureLow: Nullable<BaseTexture>;
  27017. /**
  27018. * Dispose the texture and release its associated resources.
  27019. */
  27020. dispose(): void;
  27021. /**
  27022. * Serialize the texture into a JSON representation that can be parsed later on.
  27023. * @returns the JSON representation of the texture
  27024. */
  27025. serialize(): any;
  27026. /**
  27027. * Helper function to be called back once a list of texture contains only ready textures.
  27028. * @param textures Define the list of textures to wait for
  27029. * @param callback Define the callback triggered once the entire list will be ready
  27030. */
  27031. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  27032. }
  27033. }
  27034. declare module "babylonjs/Materials/uniformBuffer" {
  27035. import { Nullable, FloatArray } from "babylonjs/types";
  27036. import { Matrix, Vector3, Color3, Vector4 } from "babylonjs/Maths/math";
  27037. import { Engine } from "babylonjs/Engines/engine";
  27038. import { Effect } from "babylonjs/Materials/effect";
  27039. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  27040. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  27041. /**
  27042. * Uniform buffer objects.
  27043. *
  27044. * Handles blocks of uniform on the GPU.
  27045. *
  27046. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  27047. *
  27048. * For more information, please refer to :
  27049. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  27050. */
  27051. export class UniformBuffer {
  27052. private _engine;
  27053. private _buffer;
  27054. private _data;
  27055. private _bufferData;
  27056. private _dynamic?;
  27057. private _uniformLocations;
  27058. private _uniformSizes;
  27059. private _uniformLocationPointer;
  27060. private _needSync;
  27061. private _noUBO;
  27062. private _currentEffect;
  27063. private static _MAX_UNIFORM_SIZE;
  27064. private static _tempBuffer;
  27065. /**
  27066. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  27067. * This is dynamic to allow compat with webgl 1 and 2.
  27068. * You will need to pass the name of the uniform as well as the value.
  27069. */
  27070. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  27071. /**
  27072. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  27073. * This is dynamic to allow compat with webgl 1 and 2.
  27074. * You will need to pass the name of the uniform as well as the value.
  27075. */
  27076. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  27077. /**
  27078. * Lambda to Update a single float in a uniform buffer.
  27079. * This is dynamic to allow compat with webgl 1 and 2.
  27080. * You will need to pass the name of the uniform as well as the value.
  27081. */
  27082. updateFloat: (name: string, x: number) => void;
  27083. /**
  27084. * Lambda to Update a vec2 of float in a uniform buffer.
  27085. * This is dynamic to allow compat with webgl 1 and 2.
  27086. * You will need to pass the name of the uniform as well as the value.
  27087. */
  27088. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  27089. /**
  27090. * Lambda to Update a vec3 of float in a uniform buffer.
  27091. * This is dynamic to allow compat with webgl 1 and 2.
  27092. * You will need to pass the name of the uniform as well as the value.
  27093. */
  27094. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  27095. /**
  27096. * Lambda to Update a vec4 of float in a uniform buffer.
  27097. * This is dynamic to allow compat with webgl 1 and 2.
  27098. * You will need to pass the name of the uniform as well as the value.
  27099. */
  27100. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  27101. /**
  27102. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  27103. * This is dynamic to allow compat with webgl 1 and 2.
  27104. * You will need to pass the name of the uniform as well as the value.
  27105. */
  27106. updateMatrix: (name: string, mat: Matrix) => void;
  27107. /**
  27108. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  27109. * This is dynamic to allow compat with webgl 1 and 2.
  27110. * You will need to pass the name of the uniform as well as the value.
  27111. */
  27112. updateVector3: (name: string, vector: Vector3) => void;
  27113. /**
  27114. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  27115. * This is dynamic to allow compat with webgl 1 and 2.
  27116. * You will need to pass the name of the uniform as well as the value.
  27117. */
  27118. updateVector4: (name: string, vector: Vector4) => void;
  27119. /**
  27120. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  27121. * This is dynamic to allow compat with webgl 1 and 2.
  27122. * You will need to pass the name of the uniform as well as the value.
  27123. */
  27124. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  27125. /**
  27126. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  27127. * This is dynamic to allow compat with webgl 1 and 2.
  27128. * You will need to pass the name of the uniform as well as the value.
  27129. */
  27130. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  27131. /**
  27132. * Instantiates a new Uniform buffer objects.
  27133. *
  27134. * Handles blocks of uniform on the GPU.
  27135. *
  27136. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  27137. *
  27138. * For more information, please refer to :
  27139. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  27140. * @param engine Define the engine the buffer is associated with
  27141. * @param data Define the data contained in the buffer
  27142. * @param dynamic Define if the buffer is updatable
  27143. */
  27144. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  27145. /**
  27146. * Indicates if the buffer is using the WebGL2 UBO implementation,
  27147. * or just falling back on setUniformXXX calls.
  27148. */
  27149. readonly useUbo: boolean;
  27150. /**
  27151. * Indicates if the WebGL underlying uniform buffer is in sync
  27152. * with the javascript cache data.
  27153. */
  27154. readonly isSync: boolean;
  27155. /**
  27156. * Indicates if the WebGL underlying uniform buffer is dynamic.
  27157. * Also, a dynamic UniformBuffer will disable cache verification and always
  27158. * update the underlying WebGL uniform buffer to the GPU.
  27159. * @returns if Dynamic, otherwise false
  27160. */
  27161. isDynamic(): boolean;
  27162. /**
  27163. * The data cache on JS side.
  27164. * @returns the underlying data as a float array
  27165. */
  27166. getData(): Float32Array;
  27167. /**
  27168. * The underlying WebGL Uniform buffer.
  27169. * @returns the webgl buffer
  27170. */
  27171. getBuffer(): Nullable<DataBuffer>;
  27172. /**
  27173. * std140 layout specifies how to align data within an UBO structure.
  27174. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  27175. * for specs.
  27176. */
  27177. private _fillAlignment;
  27178. /**
  27179. * Adds an uniform in the buffer.
  27180. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  27181. * for the layout to be correct !
  27182. * @param name Name of the uniform, as used in the uniform block in the shader.
  27183. * @param size Data size, or data directly.
  27184. */
  27185. addUniform(name: string, size: number | number[]): void;
  27186. /**
  27187. * Adds a Matrix 4x4 to the uniform buffer.
  27188. * @param name Name of the uniform, as used in the uniform block in the shader.
  27189. * @param mat A 4x4 matrix.
  27190. */
  27191. addMatrix(name: string, mat: Matrix): void;
  27192. /**
  27193. * Adds a vec2 to the uniform buffer.
  27194. * @param name Name of the uniform, as used in the uniform block in the shader.
  27195. * @param x Define the x component value of the vec2
  27196. * @param y Define the y component value of the vec2
  27197. */
  27198. addFloat2(name: string, x: number, y: number): void;
  27199. /**
  27200. * Adds a vec3 to the uniform buffer.
  27201. * @param name Name of the uniform, as used in the uniform block in the shader.
  27202. * @param x Define the x component value of the vec3
  27203. * @param y Define the y component value of the vec3
  27204. * @param z Define the z component value of the vec3
  27205. */
  27206. addFloat3(name: string, x: number, y: number, z: number): void;
  27207. /**
  27208. * Adds a vec3 to the uniform buffer.
  27209. * @param name Name of the uniform, as used in the uniform block in the shader.
  27210. * @param color Define the vec3 from a Color
  27211. */
  27212. addColor3(name: string, color: Color3): void;
  27213. /**
  27214. * Adds a vec4 to the uniform buffer.
  27215. * @param name Name of the uniform, as used in the uniform block in the shader.
  27216. * @param color Define the rgb components from a Color
  27217. * @param alpha Define the a component of the vec4
  27218. */
  27219. addColor4(name: string, color: Color3, alpha: number): void;
  27220. /**
  27221. * Adds a vec3 to the uniform buffer.
  27222. * @param name Name of the uniform, as used in the uniform block in the shader.
  27223. * @param vector Define the vec3 components from a Vector
  27224. */
  27225. addVector3(name: string, vector: Vector3): void;
  27226. /**
  27227. * Adds a Matrix 3x3 to the uniform buffer.
  27228. * @param name Name of the uniform, as used in the uniform block in the shader.
  27229. */
  27230. addMatrix3x3(name: string): void;
  27231. /**
  27232. * Adds a Matrix 2x2 to the uniform buffer.
  27233. * @param name Name of the uniform, as used in the uniform block in the shader.
  27234. */
  27235. addMatrix2x2(name: string): void;
  27236. /**
  27237. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  27238. */
  27239. create(): void;
  27240. /** @hidden */
  27241. _rebuild(): void;
  27242. /**
  27243. * Updates the WebGL Uniform Buffer on the GPU.
  27244. * If the `dynamic` flag is set to true, no cache comparison is done.
  27245. * Otherwise, the buffer will be updated only if the cache differs.
  27246. */
  27247. update(): void;
  27248. /**
  27249. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  27250. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  27251. * @param data Define the flattened data
  27252. * @param size Define the size of the data.
  27253. */
  27254. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  27255. private _updateMatrix3x3ForUniform;
  27256. private _updateMatrix3x3ForEffect;
  27257. private _updateMatrix2x2ForEffect;
  27258. private _updateMatrix2x2ForUniform;
  27259. private _updateFloatForEffect;
  27260. private _updateFloatForUniform;
  27261. private _updateFloat2ForEffect;
  27262. private _updateFloat2ForUniform;
  27263. private _updateFloat3ForEffect;
  27264. private _updateFloat3ForUniform;
  27265. private _updateFloat4ForEffect;
  27266. private _updateFloat4ForUniform;
  27267. private _updateMatrixForEffect;
  27268. private _updateMatrixForUniform;
  27269. private _updateVector3ForEffect;
  27270. private _updateVector3ForUniform;
  27271. private _updateVector4ForEffect;
  27272. private _updateVector4ForUniform;
  27273. private _updateColor3ForEffect;
  27274. private _updateColor3ForUniform;
  27275. private _updateColor4ForEffect;
  27276. private _updateColor4ForUniform;
  27277. /**
  27278. * Sets a sampler uniform on the effect.
  27279. * @param name Define the name of the sampler.
  27280. * @param texture Define the texture to set in the sampler
  27281. */
  27282. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  27283. /**
  27284. * Directly updates the value of the uniform in the cache AND on the GPU.
  27285. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  27286. * @param data Define the flattened data
  27287. */
  27288. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  27289. /**
  27290. * Binds this uniform buffer to an effect.
  27291. * @param effect Define the effect to bind the buffer to
  27292. * @param name Name of the uniform block in the shader.
  27293. */
  27294. bindToEffect(effect: Effect, name: string): void;
  27295. /**
  27296. * Disposes the uniform buffer.
  27297. */
  27298. dispose(): void;
  27299. }
  27300. }
  27301. declare module "babylonjs/Audio/analyser" {
  27302. import { Scene } from "babylonjs/scene";
  27303. /**
  27304. * Class used to work with sound analyzer using fast fourier transform (FFT)
  27305. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27306. */
  27307. export class Analyser {
  27308. /**
  27309. * Gets or sets the smoothing
  27310. * @ignorenaming
  27311. */
  27312. SMOOTHING: number;
  27313. /**
  27314. * Gets or sets the FFT table size
  27315. * @ignorenaming
  27316. */
  27317. FFT_SIZE: number;
  27318. /**
  27319. * Gets or sets the bar graph amplitude
  27320. * @ignorenaming
  27321. */
  27322. BARGRAPHAMPLITUDE: number;
  27323. /**
  27324. * Gets or sets the position of the debug canvas
  27325. * @ignorenaming
  27326. */
  27327. DEBUGCANVASPOS: {
  27328. x: number;
  27329. y: number;
  27330. };
  27331. /**
  27332. * Gets or sets the debug canvas size
  27333. * @ignorenaming
  27334. */
  27335. DEBUGCANVASSIZE: {
  27336. width: number;
  27337. height: number;
  27338. };
  27339. private _byteFreqs;
  27340. private _byteTime;
  27341. private _floatFreqs;
  27342. private _webAudioAnalyser;
  27343. private _debugCanvas;
  27344. private _debugCanvasContext;
  27345. private _scene;
  27346. private _registerFunc;
  27347. private _audioEngine;
  27348. /**
  27349. * Creates a new analyser
  27350. * @param scene defines hosting scene
  27351. */
  27352. constructor(scene: Scene);
  27353. /**
  27354. * Get the number of data values you will have to play with for the visualization
  27355. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  27356. * @returns a number
  27357. */
  27358. getFrequencyBinCount(): number;
  27359. /**
  27360. * Gets the current frequency data as a byte array
  27361. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  27362. * @returns a Uint8Array
  27363. */
  27364. getByteFrequencyData(): Uint8Array;
  27365. /**
  27366. * Gets the current waveform as a byte array
  27367. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  27368. * @returns a Uint8Array
  27369. */
  27370. getByteTimeDomainData(): Uint8Array;
  27371. /**
  27372. * Gets the current frequency data as a float array
  27373. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  27374. * @returns a Float32Array
  27375. */
  27376. getFloatFrequencyData(): Float32Array;
  27377. /**
  27378. * Renders the debug canvas
  27379. */
  27380. drawDebugCanvas(): void;
  27381. /**
  27382. * Stops rendering the debug canvas and removes it
  27383. */
  27384. stopDebugCanvas(): void;
  27385. /**
  27386. * Connects two audio nodes
  27387. * @param inputAudioNode defines first node to connect
  27388. * @param outputAudioNode defines second node to connect
  27389. */
  27390. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  27391. /**
  27392. * Releases all associated resources
  27393. */
  27394. dispose(): void;
  27395. }
  27396. }
  27397. declare module "babylonjs/Audio/audioEngine" {
  27398. import { IDisposable } from "babylonjs/scene";
  27399. import { Analyser } from "babylonjs/Audio/analyser";
  27400. import { Nullable } from "babylonjs/types";
  27401. import { Observable } from "babylonjs/Misc/observable";
  27402. /**
  27403. * This represents an audio engine and it is responsible
  27404. * to play, synchronize and analyse sounds throughout the application.
  27405. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27406. */
  27407. export interface IAudioEngine extends IDisposable {
  27408. /**
  27409. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  27410. */
  27411. readonly canUseWebAudio: boolean;
  27412. /**
  27413. * Gets the current AudioContext if available.
  27414. */
  27415. readonly audioContext: Nullable<AudioContext>;
  27416. /**
  27417. * The master gain node defines the global audio volume of your audio engine.
  27418. */
  27419. readonly masterGain: GainNode;
  27420. /**
  27421. * Gets whether or not mp3 are supported by your browser.
  27422. */
  27423. readonly isMP3supported: boolean;
  27424. /**
  27425. * Gets whether or not ogg are supported by your browser.
  27426. */
  27427. readonly isOGGsupported: boolean;
  27428. /**
  27429. * Defines if Babylon should emit a warning if WebAudio is not supported.
  27430. * @ignoreNaming
  27431. */
  27432. WarnedWebAudioUnsupported: boolean;
  27433. /**
  27434. * Defines if the audio engine relies on a custom unlocked button.
  27435. * In this case, the embedded button will not be displayed.
  27436. */
  27437. useCustomUnlockedButton: boolean;
  27438. /**
  27439. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  27440. */
  27441. readonly unlocked: boolean;
  27442. /**
  27443. * Event raised when audio has been unlocked on the browser.
  27444. */
  27445. onAudioUnlockedObservable: Observable<AudioEngine>;
  27446. /**
  27447. * Event raised when audio has been locked on the browser.
  27448. */
  27449. onAudioLockedObservable: Observable<AudioEngine>;
  27450. /**
  27451. * Flags the audio engine in Locked state.
  27452. * This happens due to new browser policies preventing audio to autoplay.
  27453. */
  27454. lock(): void;
  27455. /**
  27456. * Unlocks the audio engine once a user action has been done on the dom.
  27457. * This is helpful to resume play once browser policies have been satisfied.
  27458. */
  27459. unlock(): void;
  27460. }
  27461. /**
  27462. * This represents the default audio engine used in babylon.
  27463. * It is responsible to play, synchronize and analyse sounds throughout the application.
  27464. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27465. */
  27466. export class AudioEngine implements IAudioEngine {
  27467. private _audioContext;
  27468. private _audioContextInitialized;
  27469. private _muteButton;
  27470. private _hostElement;
  27471. /**
  27472. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  27473. */
  27474. canUseWebAudio: boolean;
  27475. /**
  27476. * The master gain node defines the global audio volume of your audio engine.
  27477. */
  27478. masterGain: GainNode;
  27479. /**
  27480. * Defines if Babylon should emit a warning if WebAudio is not supported.
  27481. * @ignoreNaming
  27482. */
  27483. WarnedWebAudioUnsupported: boolean;
  27484. /**
  27485. * Gets whether or not mp3 are supported by your browser.
  27486. */
  27487. isMP3supported: boolean;
  27488. /**
  27489. * Gets whether or not ogg are supported by your browser.
  27490. */
  27491. isOGGsupported: boolean;
  27492. /**
  27493. * Gets whether audio has been unlocked on the device.
  27494. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  27495. * a user interaction has happened.
  27496. */
  27497. unlocked: boolean;
  27498. /**
  27499. * Defines if the audio engine relies on a custom unlocked button.
  27500. * In this case, the embedded button will not be displayed.
  27501. */
  27502. useCustomUnlockedButton: boolean;
  27503. /**
  27504. * Event raised when audio has been unlocked on the browser.
  27505. */
  27506. onAudioUnlockedObservable: Observable<AudioEngine>;
  27507. /**
  27508. * Event raised when audio has been locked on the browser.
  27509. */
  27510. onAudioLockedObservable: Observable<AudioEngine>;
  27511. /**
  27512. * Gets the current AudioContext if available.
  27513. */
  27514. readonly audioContext: Nullable<AudioContext>;
  27515. private _connectedAnalyser;
  27516. /**
  27517. * Instantiates a new audio engine.
  27518. *
  27519. * There should be only one per page as some browsers restrict the number
  27520. * of audio contexts you can create.
  27521. * @param hostElement defines the host element where to display the mute icon if necessary
  27522. */
  27523. constructor(hostElement?: Nullable<HTMLElement>);
  27524. /**
  27525. * Flags the audio engine in Locked state.
  27526. * This happens due to new browser policies preventing audio to autoplay.
  27527. */
  27528. lock(): void;
  27529. /**
  27530. * Unlocks the audio engine once a user action has been done on the dom.
  27531. * This is helpful to resume play once browser policies have been satisfied.
  27532. */
  27533. unlock(): void;
  27534. private _resumeAudioContext;
  27535. private _initializeAudioContext;
  27536. private _tryToRun;
  27537. private _triggerRunningState;
  27538. private _triggerSuspendedState;
  27539. private _displayMuteButton;
  27540. private _moveButtonToTopLeft;
  27541. private _onResize;
  27542. private _hideMuteButton;
  27543. /**
  27544. * Destroy and release the resources associated with the audio ccontext.
  27545. */
  27546. dispose(): void;
  27547. /**
  27548. * Gets the global volume sets on the master gain.
  27549. * @returns the global volume if set or -1 otherwise
  27550. */
  27551. getGlobalVolume(): number;
  27552. /**
  27553. * Sets the global volume of your experience (sets on the master gain).
  27554. * @param newVolume Defines the new global volume of the application
  27555. */
  27556. setGlobalVolume(newVolume: number): void;
  27557. /**
  27558. * Connect the audio engine to an audio analyser allowing some amazing
  27559. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  27560. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  27561. * @param analyser The analyser to connect to the engine
  27562. */
  27563. connectToAnalyser(analyser: Analyser): void;
  27564. }
  27565. }
  27566. declare module "babylonjs/Loading/loadingScreen" {
  27567. /**
  27568. * Interface used to present a loading screen while loading a scene
  27569. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  27570. */
  27571. export interface ILoadingScreen {
  27572. /**
  27573. * Function called to display the loading screen
  27574. */
  27575. displayLoadingUI: () => void;
  27576. /**
  27577. * Function called to hide the loading screen
  27578. */
  27579. hideLoadingUI: () => void;
  27580. /**
  27581. * Gets or sets the color to use for the background
  27582. */
  27583. loadingUIBackgroundColor: string;
  27584. /**
  27585. * Gets or sets the text to display while loading
  27586. */
  27587. loadingUIText: string;
  27588. }
  27589. /**
  27590. * Class used for the default loading screen
  27591. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  27592. */
  27593. export class DefaultLoadingScreen implements ILoadingScreen {
  27594. private _renderingCanvas;
  27595. private _loadingText;
  27596. private _loadingDivBackgroundColor;
  27597. private _loadingDiv;
  27598. private _loadingTextDiv;
  27599. /** Gets or sets the logo url to use for the default loading screen */
  27600. static DefaultLogoUrl: string;
  27601. /** Gets or sets the spinner url to use for the default loading screen */
  27602. static DefaultSpinnerUrl: string;
  27603. /**
  27604. * Creates a new default loading screen
  27605. * @param _renderingCanvas defines the canvas used to render the scene
  27606. * @param _loadingText defines the default text to display
  27607. * @param _loadingDivBackgroundColor defines the default background color
  27608. */
  27609. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  27610. /**
  27611. * Function called to display the loading screen
  27612. */
  27613. displayLoadingUI(): void;
  27614. /**
  27615. * Function called to hide the loading screen
  27616. */
  27617. hideLoadingUI(): void;
  27618. /**
  27619. * Gets or sets the text to display while loading
  27620. */
  27621. loadingUIText: string;
  27622. /**
  27623. * Gets or sets the color to use for the background
  27624. */
  27625. loadingUIBackgroundColor: string;
  27626. private _resizeLoadingUI;
  27627. }
  27628. }
  27629. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  27630. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  27631. import { Engine } from "babylonjs/Engines/engine";
  27632. import { Nullable } from "babylonjs/types";
  27633. /** @hidden */
  27634. export class WebGLPipelineContext implements IPipelineContext {
  27635. engine: Engine;
  27636. program: Nullable<WebGLProgram>;
  27637. context?: WebGLRenderingContext;
  27638. vertexShader?: WebGLShader;
  27639. fragmentShader?: WebGLShader;
  27640. isParallelCompiled: boolean;
  27641. onCompiled?: () => void;
  27642. transformFeedback?: WebGLTransformFeedback | null;
  27643. readonly isAsync: boolean;
  27644. readonly isReady: boolean;
  27645. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  27646. }
  27647. }
  27648. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  27649. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  27650. /** @hidden */
  27651. export class WebGLDataBuffer extends DataBuffer {
  27652. private _buffer;
  27653. constructor(resource: WebGLBuffer);
  27654. readonly underlyingResource: any;
  27655. }
  27656. }
  27657. declare module "babylonjs/Materials/Textures/videoTexture" {
  27658. import { Observable } from "babylonjs/Misc/observable";
  27659. import { Nullable } from "babylonjs/types";
  27660. import { Scene } from "babylonjs/scene";
  27661. import { Texture } from "babylonjs/Materials/Textures/texture";
  27662. /**
  27663. * Settings for finer control over video usage
  27664. */
  27665. export interface VideoTextureSettings {
  27666. /**
  27667. * Applies `autoplay` to video, if specified
  27668. */
  27669. autoPlay?: boolean;
  27670. /**
  27671. * Applies `loop` to video, if specified
  27672. */
  27673. loop?: boolean;
  27674. /**
  27675. * Automatically updates internal texture from video at every frame in the render loop
  27676. */
  27677. autoUpdateTexture: boolean;
  27678. /**
  27679. * Image src displayed during the video loading or until the user interacts with the video.
  27680. */
  27681. poster?: string;
  27682. }
  27683. /**
  27684. * If you want to display a video in your scene, this is the special texture for that.
  27685. * This special texture works similar to other textures, with the exception of a few parameters.
  27686. * @see https://doc.babylonjs.com/how_to/video_texture
  27687. */
  27688. export class VideoTexture extends Texture {
  27689. /**
  27690. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  27691. */
  27692. readonly autoUpdateTexture: boolean;
  27693. /**
  27694. * The video instance used by the texture internally
  27695. */
  27696. readonly video: HTMLVideoElement;
  27697. private _onUserActionRequestedObservable;
  27698. /**
  27699. * Event triggerd when a dom action is required by the user to play the video.
  27700. * This happens due to recent changes in browser policies preventing video to auto start.
  27701. */
  27702. readonly onUserActionRequestedObservable: Observable<Texture>;
  27703. private _generateMipMaps;
  27704. private _engine;
  27705. private _stillImageCaptured;
  27706. private _displayingPosterTexture;
  27707. private _settings;
  27708. private _createInternalTextureOnEvent;
  27709. /**
  27710. * Creates a video texture.
  27711. * If you want to display a video in your scene, this is the special texture for that.
  27712. * This special texture works similar to other textures, with the exception of a few parameters.
  27713. * @see https://doc.babylonjs.com/how_to/video_texture
  27714. * @param name optional name, will detect from video source, if not defined
  27715. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  27716. * @param scene is obviously the current scene.
  27717. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  27718. * @param invertY is false by default but can be used to invert video on Y axis
  27719. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  27720. * @param settings allows finer control over video usage
  27721. */
  27722. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  27723. private _getName;
  27724. private _getVideo;
  27725. private _createInternalTexture;
  27726. private reset;
  27727. /**
  27728. * @hidden Internal method to initiate `update`.
  27729. */
  27730. _rebuild(): void;
  27731. /**
  27732. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  27733. */
  27734. update(): void;
  27735. /**
  27736. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  27737. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  27738. */
  27739. updateTexture(isVisible: boolean): void;
  27740. protected _updateInternalTexture: () => void;
  27741. /**
  27742. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  27743. * @param url New url.
  27744. */
  27745. updateURL(url: string): void;
  27746. /**
  27747. * Dispose the texture and release its associated resources.
  27748. */
  27749. dispose(): void;
  27750. /**
  27751. * Creates a video texture straight from a stream.
  27752. * @param scene Define the scene the texture should be created in
  27753. * @param stream Define the stream the texture should be created from
  27754. * @returns The created video texture as a promise
  27755. */
  27756. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  27757. /**
  27758. * Creates a video texture straight from your WebCam video feed.
  27759. * @param scene Define the scene the texture should be created in
  27760. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  27761. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  27762. * @returns The created video texture as a promise
  27763. */
  27764. static CreateFromWebCamAsync(scene: Scene, constraints: {
  27765. minWidth: number;
  27766. maxWidth: number;
  27767. minHeight: number;
  27768. maxHeight: number;
  27769. deviceId: string;
  27770. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  27771. /**
  27772. * Creates a video texture straight from your WebCam video feed.
  27773. * @param scene Define the scene the texture should be created in
  27774. * @param onReady Define a callback to triggered once the texture will be ready
  27775. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  27776. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  27777. */
  27778. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  27779. minWidth: number;
  27780. maxWidth: number;
  27781. minHeight: number;
  27782. maxHeight: number;
  27783. deviceId: string;
  27784. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  27785. }
  27786. }
  27787. declare module "babylonjs/Engines/engine" {
  27788. import { Observable } from "babylonjs/Misc/observable";
  27789. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  27790. import { ICustomAnimationFrameRequester, PerfCounter, IFileRequest } from "babylonjs/Misc/tools";
  27791. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  27792. import { Camera } from "babylonjs/Cameras/camera";
  27793. import { Scene } from "babylonjs/scene";
  27794. import { Matrix, Color3, Color4, Viewport } from "babylonjs/Maths/math";
  27795. import { IDisplayChangedEventArgs } from "babylonjs/Engines/engine";
  27796. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  27797. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  27798. import { Effect, EffectCreationOptions, EffectFallbacks } from "babylonjs/Materials/effect";
  27799. import { Material } from "babylonjs/Materials/material";
  27800. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  27801. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  27802. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  27803. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  27804. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  27805. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  27806. import { _DepthCullingState, _StencilState, _AlphaState } from "babylonjs/States/index";
  27807. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  27808. import { WebRequest } from "babylonjs/Misc/webRequest";
  27809. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  27810. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  27811. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  27812. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  27813. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  27814. /**
  27815. * Interface for attribute information associated with buffer instanciation
  27816. */
  27817. export class InstancingAttributeInfo {
  27818. /**
  27819. * Index/offset of the attribute in the vertex shader
  27820. */
  27821. index: number;
  27822. /**
  27823. * size of the attribute, 1, 2, 3 or 4
  27824. */
  27825. attributeSize: number;
  27826. /**
  27827. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  27828. * default is FLOAT
  27829. */
  27830. attribyteType: number;
  27831. /**
  27832. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  27833. */
  27834. normalized: boolean;
  27835. /**
  27836. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  27837. */
  27838. offset: number;
  27839. /**
  27840. * Name of the GLSL attribute, for debugging purpose only
  27841. */
  27842. attributeName: string;
  27843. }
  27844. /**
  27845. * Define options used to create a depth texture
  27846. */
  27847. export class DepthTextureCreationOptions {
  27848. /** Specifies whether or not a stencil should be allocated in the texture */
  27849. generateStencil?: boolean;
  27850. /** Specifies whether or not bilinear filtering is enable on the texture */
  27851. bilinearFiltering?: boolean;
  27852. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  27853. comparisonFunction?: number;
  27854. /** Specifies if the created texture is a cube texture */
  27855. isCube?: boolean;
  27856. }
  27857. /**
  27858. * Class used to describe the capabilities of the engine relatively to the current browser
  27859. */
  27860. export class EngineCapabilities {
  27861. /** Maximum textures units per fragment shader */
  27862. maxTexturesImageUnits: number;
  27863. /** Maximum texture units per vertex shader */
  27864. maxVertexTextureImageUnits: number;
  27865. /** Maximum textures units in the entire pipeline */
  27866. maxCombinedTexturesImageUnits: number;
  27867. /** Maximum texture size */
  27868. maxTextureSize: number;
  27869. /** Maximum cube texture size */
  27870. maxCubemapTextureSize: number;
  27871. /** Maximum render texture size */
  27872. maxRenderTextureSize: number;
  27873. /** Maximum number of vertex attributes */
  27874. maxVertexAttribs: number;
  27875. /** Maximum number of varyings */
  27876. maxVaryingVectors: number;
  27877. /** Maximum number of uniforms per vertex shader */
  27878. maxVertexUniformVectors: number;
  27879. /** Maximum number of uniforms per fragment shader */
  27880. maxFragmentUniformVectors: number;
  27881. /** Defines if standard derivates (dx/dy) are supported */
  27882. standardDerivatives: boolean;
  27883. /** Defines if s3tc texture compression is supported */
  27884. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  27885. /** Defines if pvrtc texture compression is supported */
  27886. pvrtc: any;
  27887. /** Defines if etc1 texture compression is supported */
  27888. etc1: any;
  27889. /** Defines if etc2 texture compression is supported */
  27890. etc2: any;
  27891. /** Defines if astc texture compression is supported */
  27892. astc: any;
  27893. /** Defines if float textures are supported */
  27894. textureFloat: boolean;
  27895. /** Defines if vertex array objects are supported */
  27896. vertexArrayObject: boolean;
  27897. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  27898. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  27899. /** Gets the maximum level of anisotropy supported */
  27900. maxAnisotropy: number;
  27901. /** Defines if instancing is supported */
  27902. instancedArrays: boolean;
  27903. /** Defines if 32 bits indices are supported */
  27904. uintIndices: boolean;
  27905. /** Defines if high precision shaders are supported */
  27906. highPrecisionShaderSupported: boolean;
  27907. /** Defines if depth reading in the fragment shader is supported */
  27908. fragmentDepthSupported: boolean;
  27909. /** Defines if float texture linear filtering is supported*/
  27910. textureFloatLinearFiltering: boolean;
  27911. /** Defines if rendering to float textures is supported */
  27912. textureFloatRender: boolean;
  27913. /** Defines if half float textures are supported*/
  27914. textureHalfFloat: boolean;
  27915. /** Defines if half float texture linear filtering is supported*/
  27916. textureHalfFloatLinearFiltering: boolean;
  27917. /** Defines if rendering to half float textures is supported */
  27918. textureHalfFloatRender: boolean;
  27919. /** Defines if textureLOD shader command is supported */
  27920. textureLOD: boolean;
  27921. /** Defines if draw buffers extension is supported */
  27922. drawBuffersExtension: boolean;
  27923. /** Defines if depth textures are supported */
  27924. depthTextureExtension: boolean;
  27925. /** Defines if float color buffer are supported */
  27926. colorBufferFloat: boolean;
  27927. /** Gets disjoint timer query extension (null if not supported) */
  27928. timerQuery: EXT_disjoint_timer_query;
  27929. /** Defines if timestamp can be used with timer query */
  27930. canUseTimestampForTimerQuery: boolean;
  27931. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  27932. multiview: any;
  27933. /** Function used to let the system compiles shaders in background */
  27934. parallelShaderCompile: {
  27935. COMPLETION_STATUS_KHR: number;
  27936. };
  27937. }
  27938. /** Interface defining initialization parameters for Engine class */
  27939. export interface EngineOptions extends WebGLContextAttributes {
  27940. /**
  27941. * Defines if the engine should no exceed a specified device ratio
  27942. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  27943. */
  27944. limitDeviceRatio?: number;
  27945. /**
  27946. * Defines if webvr should be enabled automatically
  27947. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27948. */
  27949. autoEnableWebVR?: boolean;
  27950. /**
  27951. * Defines if webgl2 should be turned off even if supported
  27952. * @see http://doc.babylonjs.com/features/webgl2
  27953. */
  27954. disableWebGL2Support?: boolean;
  27955. /**
  27956. * Defines if webaudio should be initialized as well
  27957. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27958. */
  27959. audioEngine?: boolean;
  27960. /**
  27961. * Defines if animations should run using a deterministic lock step
  27962. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27963. */
  27964. deterministicLockstep?: boolean;
  27965. /** Defines the maximum steps to use with deterministic lock step mode */
  27966. lockstepMaxSteps?: number;
  27967. /**
  27968. * Defines that engine should ignore context lost events
  27969. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  27970. */
  27971. doNotHandleContextLost?: boolean;
  27972. /**
  27973. * Defines that engine should ignore modifying touch action attribute and style
  27974. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  27975. */
  27976. doNotHandleTouchAction?: boolean;
  27977. /**
  27978. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  27979. */
  27980. useHighPrecisionFloats?: boolean;
  27981. }
  27982. /**
  27983. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  27984. */
  27985. export class Engine {
  27986. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  27987. static ExceptionList: ({
  27988. key: string;
  27989. capture: string;
  27990. captureConstraint: number;
  27991. targets: string[];
  27992. } | {
  27993. key: string;
  27994. capture: null;
  27995. captureConstraint: null;
  27996. targets: string[];
  27997. })[];
  27998. /** Gets the list of created engines */
  27999. static readonly Instances: Engine[];
  28000. /**
  28001. * Gets the latest created engine
  28002. */
  28003. static readonly LastCreatedEngine: Nullable<Engine>;
  28004. /**
  28005. * Gets the latest created scene
  28006. */
  28007. static readonly LastCreatedScene: Nullable<Scene>;
  28008. /**
  28009. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  28010. * @param flag defines which part of the materials must be marked as dirty
  28011. * @param predicate defines a predicate used to filter which materials should be affected
  28012. */
  28013. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  28014. /**
  28015. * Hidden
  28016. */
  28017. static _TextureLoaders: IInternalTextureLoader[];
  28018. /** Defines that alpha blending is disabled */
  28019. static readonly ALPHA_DISABLE: number;
  28020. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  28021. static readonly ALPHA_ADD: number;
  28022. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  28023. static readonly ALPHA_COMBINE: number;
  28024. /** Defines that alpha blending to DEST - SRC * DEST */
  28025. static readonly ALPHA_SUBTRACT: number;
  28026. /** Defines that alpha blending to SRC * DEST */
  28027. static readonly ALPHA_MULTIPLY: number;
  28028. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  28029. static readonly ALPHA_MAXIMIZED: number;
  28030. /** Defines that alpha blending to SRC + DEST */
  28031. static readonly ALPHA_ONEONE: number;
  28032. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  28033. static readonly ALPHA_PREMULTIPLIED: number;
  28034. /**
  28035. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  28036. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  28037. */
  28038. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  28039. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  28040. static readonly ALPHA_INTERPOLATE: number;
  28041. /**
  28042. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  28043. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  28044. */
  28045. static readonly ALPHA_SCREENMODE: number;
  28046. /** Defines that the ressource is not delayed*/
  28047. static readonly DELAYLOADSTATE_NONE: number;
  28048. /** Defines that the ressource was successfully delay loaded */
  28049. static readonly DELAYLOADSTATE_LOADED: number;
  28050. /** Defines that the ressource is currently delay loading */
  28051. static readonly DELAYLOADSTATE_LOADING: number;
  28052. /** Defines that the ressource is delayed and has not started loading */
  28053. static readonly DELAYLOADSTATE_NOTLOADED: number;
  28054. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  28055. static readonly NEVER: number;
  28056. /** 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 */
  28057. static readonly ALWAYS: number;
  28058. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  28059. static readonly LESS: number;
  28060. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  28061. static readonly EQUAL: number;
  28062. /** 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 */
  28063. static readonly LEQUAL: number;
  28064. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  28065. static readonly GREATER: number;
  28066. /** 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 */
  28067. static readonly GEQUAL: number;
  28068. /** 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 */
  28069. static readonly NOTEQUAL: number;
  28070. /** Passed to stencilOperation to specify that stencil value must be kept */
  28071. static readonly KEEP: number;
  28072. /** Passed to stencilOperation to specify that stencil value must be replaced */
  28073. static readonly REPLACE: number;
  28074. /** Passed to stencilOperation to specify that stencil value must be incremented */
  28075. static readonly INCR: number;
  28076. /** Passed to stencilOperation to specify that stencil value must be decremented */
  28077. static readonly DECR: number;
  28078. /** Passed to stencilOperation to specify that stencil value must be inverted */
  28079. static readonly INVERT: number;
  28080. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  28081. static readonly INCR_WRAP: number;
  28082. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  28083. static readonly DECR_WRAP: number;
  28084. /** Texture is not repeating outside of 0..1 UVs */
  28085. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  28086. /** Texture is repeating outside of 0..1 UVs */
  28087. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  28088. /** Texture is repeating and mirrored */
  28089. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  28090. /** ALPHA */
  28091. static readonly TEXTUREFORMAT_ALPHA: number;
  28092. /** LUMINANCE */
  28093. static readonly TEXTUREFORMAT_LUMINANCE: number;
  28094. /** LUMINANCE_ALPHA */
  28095. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  28096. /** RGB */
  28097. static readonly TEXTUREFORMAT_RGB: number;
  28098. /** RGBA */
  28099. static readonly TEXTUREFORMAT_RGBA: number;
  28100. /** RED */
  28101. static readonly TEXTUREFORMAT_RED: number;
  28102. /** RED (2nd reference) */
  28103. static readonly TEXTUREFORMAT_R: number;
  28104. /** RG */
  28105. static readonly TEXTUREFORMAT_RG: number;
  28106. /** RED_INTEGER */
  28107. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  28108. /** RED_INTEGER (2nd reference) */
  28109. static readonly TEXTUREFORMAT_R_INTEGER: number;
  28110. /** RG_INTEGER */
  28111. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  28112. /** RGB_INTEGER */
  28113. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  28114. /** RGBA_INTEGER */
  28115. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  28116. /** UNSIGNED_BYTE */
  28117. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  28118. /** UNSIGNED_BYTE (2nd reference) */
  28119. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  28120. /** FLOAT */
  28121. static readonly TEXTURETYPE_FLOAT: number;
  28122. /** HALF_FLOAT */
  28123. static readonly TEXTURETYPE_HALF_FLOAT: number;
  28124. /** BYTE */
  28125. static readonly TEXTURETYPE_BYTE: number;
  28126. /** SHORT */
  28127. static readonly TEXTURETYPE_SHORT: number;
  28128. /** UNSIGNED_SHORT */
  28129. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  28130. /** INT */
  28131. static readonly TEXTURETYPE_INT: number;
  28132. /** UNSIGNED_INT */
  28133. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  28134. /** UNSIGNED_SHORT_4_4_4_4 */
  28135. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  28136. /** UNSIGNED_SHORT_5_5_5_1 */
  28137. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  28138. /** UNSIGNED_SHORT_5_6_5 */
  28139. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  28140. /** UNSIGNED_INT_2_10_10_10_REV */
  28141. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  28142. /** UNSIGNED_INT_24_8 */
  28143. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  28144. /** UNSIGNED_INT_10F_11F_11F_REV */
  28145. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  28146. /** UNSIGNED_INT_5_9_9_9_REV */
  28147. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  28148. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  28149. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  28150. /** nearest is mag = nearest and min = nearest and mip = linear */
  28151. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  28152. /** Bilinear is mag = linear and min = linear and mip = nearest */
  28153. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  28154. /** Trilinear is mag = linear and min = linear and mip = linear */
  28155. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  28156. /** nearest is mag = nearest and min = nearest and mip = linear */
  28157. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  28158. /** Bilinear is mag = linear and min = linear and mip = nearest */
  28159. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  28160. /** Trilinear is mag = linear and min = linear and mip = linear */
  28161. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  28162. /** mag = nearest and min = nearest and mip = nearest */
  28163. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  28164. /** mag = nearest and min = linear and mip = nearest */
  28165. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  28166. /** mag = nearest and min = linear and mip = linear */
  28167. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  28168. /** mag = nearest and min = linear and mip = none */
  28169. static readonly TEXTURE_NEAREST_LINEAR: number;
  28170. /** mag = nearest and min = nearest and mip = none */
  28171. static readonly TEXTURE_NEAREST_NEAREST: number;
  28172. /** mag = linear and min = nearest and mip = nearest */
  28173. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  28174. /** mag = linear and min = nearest and mip = linear */
  28175. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  28176. /** mag = linear and min = linear and mip = none */
  28177. static readonly TEXTURE_LINEAR_LINEAR: number;
  28178. /** mag = linear and min = nearest and mip = none */
  28179. static readonly TEXTURE_LINEAR_NEAREST: number;
  28180. /** Explicit coordinates mode */
  28181. static readonly TEXTURE_EXPLICIT_MODE: number;
  28182. /** Spherical coordinates mode */
  28183. static readonly TEXTURE_SPHERICAL_MODE: number;
  28184. /** Planar coordinates mode */
  28185. static readonly TEXTURE_PLANAR_MODE: number;
  28186. /** Cubic coordinates mode */
  28187. static readonly TEXTURE_CUBIC_MODE: number;
  28188. /** Projection coordinates mode */
  28189. static readonly TEXTURE_PROJECTION_MODE: number;
  28190. /** Skybox coordinates mode */
  28191. static readonly TEXTURE_SKYBOX_MODE: number;
  28192. /** Inverse Cubic coordinates mode */
  28193. static readonly TEXTURE_INVCUBIC_MODE: number;
  28194. /** Equirectangular coordinates mode */
  28195. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  28196. /** Equirectangular Fixed coordinates mode */
  28197. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  28198. /** Equirectangular Fixed Mirrored coordinates mode */
  28199. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  28200. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  28201. static readonly SCALEMODE_FLOOR: number;
  28202. /** Defines that texture rescaling will look for the nearest power of 2 size */
  28203. static readonly SCALEMODE_NEAREST: number;
  28204. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  28205. static readonly SCALEMODE_CEILING: number;
  28206. /**
  28207. * Returns the current npm package of the sdk
  28208. */
  28209. static readonly NpmPackage: string;
  28210. /**
  28211. * Returns the current version of the framework
  28212. */
  28213. static readonly Version: string;
  28214. /**
  28215. * Returns a string describing the current engine
  28216. */
  28217. readonly description: string;
  28218. /**
  28219. * Gets or sets the epsilon value used by collision engine
  28220. */
  28221. static CollisionsEpsilon: number;
  28222. /**
  28223. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  28224. */
  28225. static ShadersRepository: string;
  28226. /**
  28227. * Method called to create the default loading screen.
  28228. * This can be overriden in your own app.
  28229. * @param canvas The rendering canvas element
  28230. * @returns The loading screen
  28231. */
  28232. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  28233. /**
  28234. * Method called to create the default rescale post process on each engine.
  28235. */
  28236. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  28237. /**
  28238. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  28239. */
  28240. forcePOTTextures: boolean;
  28241. /**
  28242. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  28243. */
  28244. isFullscreen: boolean;
  28245. /**
  28246. * Gets a boolean indicating if the pointer is currently locked
  28247. */
  28248. isPointerLock: boolean;
  28249. /**
  28250. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  28251. */
  28252. cullBackFaces: boolean;
  28253. /**
  28254. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  28255. */
  28256. renderEvenInBackground: boolean;
  28257. /**
  28258. * Gets or sets a boolean indicating that cache can be kept between frames
  28259. */
  28260. preventCacheWipeBetweenFrames: boolean;
  28261. /**
  28262. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  28263. **/
  28264. enableOfflineSupport: boolean;
  28265. /**
  28266. * 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)
  28267. **/
  28268. disableManifestCheck: boolean;
  28269. /**
  28270. * Gets the list of created scenes
  28271. */
  28272. scenes: Scene[];
  28273. /**
  28274. * Event raised when a new scene is created
  28275. */
  28276. onNewSceneAddedObservable: Observable<Scene>;
  28277. /**
  28278. * Gets the list of created postprocesses
  28279. */
  28280. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  28281. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  28282. validateShaderPrograms: boolean;
  28283. /**
  28284. * Observable event triggered each time the rendering canvas is resized
  28285. */
  28286. onResizeObservable: Observable<Engine>;
  28287. /**
  28288. * Observable event triggered each time the canvas loses focus
  28289. */
  28290. onCanvasBlurObservable: Observable<Engine>;
  28291. /**
  28292. * Observable event triggered each time the canvas gains focus
  28293. */
  28294. onCanvasFocusObservable: Observable<Engine>;
  28295. /**
  28296. * Observable event triggered each time the canvas receives pointerout event
  28297. */
  28298. onCanvasPointerOutObservable: Observable<PointerEvent>;
  28299. /**
  28300. * Observable event triggered before each texture is initialized
  28301. */
  28302. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  28303. /**
  28304. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  28305. */
  28306. disableUniformBuffers: boolean;
  28307. /** @hidden */
  28308. _uniformBuffers: UniformBuffer[];
  28309. /**
  28310. * Gets a boolean indicating that the engine supports uniform buffers
  28311. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28312. */
  28313. readonly supportsUniformBuffers: boolean;
  28314. /**
  28315. * Observable raised when the engine begins a new frame
  28316. */
  28317. onBeginFrameObservable: Observable<Engine>;
  28318. /**
  28319. * If set, will be used to request the next animation frame for the render loop
  28320. */
  28321. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  28322. /**
  28323. * Observable raised when the engine ends the current frame
  28324. */
  28325. onEndFrameObservable: Observable<Engine>;
  28326. /**
  28327. * Observable raised when the engine is about to compile a shader
  28328. */
  28329. onBeforeShaderCompilationObservable: Observable<Engine>;
  28330. /**
  28331. * Observable raised when the engine has jsut compiled a shader
  28332. */
  28333. onAfterShaderCompilationObservable: Observable<Engine>;
  28334. /** @hidden */
  28335. _gl: WebGLRenderingContext;
  28336. private _renderingCanvas;
  28337. private _windowIsBackground;
  28338. private _webGLVersion;
  28339. protected _highPrecisionShadersAllowed: boolean;
  28340. /** @hidden */
  28341. readonly _shouldUseHighPrecisionShader: boolean;
  28342. /**
  28343. * Gets a boolean indicating that only power of 2 textures are supported
  28344. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  28345. */
  28346. readonly needPOTTextures: boolean;
  28347. /** @hidden */
  28348. _badOS: boolean;
  28349. /** @hidden */
  28350. _badDesktopOS: boolean;
  28351. /**
  28352. * Gets the audio engine
  28353. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  28354. * @ignorenaming
  28355. */
  28356. static audioEngine: IAudioEngine;
  28357. /**
  28358. * Default AudioEngine factory responsible of creating the Audio Engine.
  28359. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  28360. */
  28361. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  28362. /**
  28363. * Default offline support factory responsible of creating a tool used to store data locally.
  28364. * By default, this will create a Database object if the workload has been embedded.
  28365. */
  28366. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  28367. private _onFocus;
  28368. private _onBlur;
  28369. private _onCanvasPointerOut;
  28370. private _onCanvasBlur;
  28371. private _onCanvasFocus;
  28372. private _onFullscreenChange;
  28373. private _onPointerLockChange;
  28374. private _hardwareScalingLevel;
  28375. /** @hidden */
  28376. _caps: EngineCapabilities;
  28377. private _pointerLockRequested;
  28378. private _isStencilEnable;
  28379. private _colorWrite;
  28380. private _loadingScreen;
  28381. /** @hidden */
  28382. _drawCalls: PerfCounter;
  28383. private _glVersion;
  28384. private _glRenderer;
  28385. private _glVendor;
  28386. private _videoTextureSupported;
  28387. private _renderingQueueLaunched;
  28388. private _activeRenderLoops;
  28389. private _deterministicLockstep;
  28390. private _lockstepMaxSteps;
  28391. /**
  28392. * Observable signaled when a context lost event is raised
  28393. */
  28394. onContextLostObservable: Observable<Engine>;
  28395. /**
  28396. * Observable signaled when a context restored event is raised
  28397. */
  28398. onContextRestoredObservable: Observable<Engine>;
  28399. private _onContextLost;
  28400. private _onContextRestored;
  28401. private _contextWasLost;
  28402. /** @hidden */
  28403. _doNotHandleContextLost: boolean;
  28404. /**
  28405. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  28406. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  28407. */
  28408. doNotHandleContextLost: boolean;
  28409. private _performanceMonitor;
  28410. private _fps;
  28411. private _deltaTime;
  28412. /**
  28413. * Turn this value on if you want to pause FPS computation when in background
  28414. */
  28415. disablePerformanceMonitorInBackground: boolean;
  28416. /**
  28417. * Gets the performance monitor attached to this engine
  28418. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  28419. */
  28420. readonly performanceMonitor: PerformanceMonitor;
  28421. /**
  28422. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  28423. */
  28424. disableVertexArrayObjects: boolean;
  28425. /** @hidden */
  28426. protected _depthCullingState: _DepthCullingState;
  28427. /** @hidden */
  28428. protected _stencilState: _StencilState;
  28429. /** @hidden */
  28430. protected _alphaState: _AlphaState;
  28431. /** @hidden */
  28432. protected _alphaMode: number;
  28433. /** @hidden */
  28434. _internalTexturesCache: InternalTexture[];
  28435. /** @hidden */
  28436. protected _activeChannel: number;
  28437. private _currentTextureChannel;
  28438. /** @hidden */
  28439. protected _boundTexturesCache: {
  28440. [key: string]: Nullable<InternalTexture>;
  28441. };
  28442. /** @hidden */
  28443. protected _currentEffect: Nullable<Effect>;
  28444. /** @hidden */
  28445. protected _currentProgram: Nullable<WebGLProgram>;
  28446. private _compiledEffects;
  28447. private _vertexAttribArraysEnabled;
  28448. /** @hidden */
  28449. protected _cachedViewport: Nullable<Viewport>;
  28450. private _cachedVertexArrayObject;
  28451. /** @hidden */
  28452. protected _cachedVertexBuffers: any;
  28453. /** @hidden */
  28454. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  28455. /** @hidden */
  28456. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  28457. /** @hidden */
  28458. _currentRenderTarget: Nullable<InternalTexture>;
  28459. private _uintIndicesCurrentlySet;
  28460. private _currentBoundBuffer;
  28461. /** @hidden */
  28462. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  28463. private _currentBufferPointers;
  28464. private _currentInstanceLocations;
  28465. private _currentInstanceBuffers;
  28466. private _textureUnits;
  28467. /** @hidden */
  28468. _workingCanvas: Nullable<HTMLCanvasElement>;
  28469. /** @hidden */
  28470. _workingContext: Nullable<CanvasRenderingContext2D>;
  28471. private _rescalePostProcess;
  28472. private _dummyFramebuffer;
  28473. private _externalData;
  28474. /** @hidden */
  28475. _bindedRenderFunction: any;
  28476. private _vaoRecordInProgress;
  28477. private _mustWipeVertexAttributes;
  28478. private _emptyTexture;
  28479. private _emptyCubeTexture;
  28480. private _emptyTexture3D;
  28481. /** @hidden */
  28482. _frameHandler: number;
  28483. private _nextFreeTextureSlots;
  28484. private _maxSimultaneousTextures;
  28485. private _activeRequests;
  28486. private _texturesSupported;
  28487. /** @hidden */
  28488. _textureFormatInUse: Nullable<string>;
  28489. /**
  28490. * Gets the list of texture formats supported
  28491. */
  28492. readonly texturesSupported: Array<string>;
  28493. /**
  28494. * Gets the list of texture formats in use
  28495. */
  28496. readonly textureFormatInUse: Nullable<string>;
  28497. /**
  28498. * Gets the current viewport
  28499. */
  28500. readonly currentViewport: Nullable<Viewport>;
  28501. /**
  28502. * Gets the default empty texture
  28503. */
  28504. readonly emptyTexture: InternalTexture;
  28505. /**
  28506. * Gets the default empty 3D texture
  28507. */
  28508. readonly emptyTexture3D: InternalTexture;
  28509. /**
  28510. * Gets the default empty cube texture
  28511. */
  28512. readonly emptyCubeTexture: InternalTexture;
  28513. /**
  28514. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  28515. */
  28516. readonly premultipliedAlpha: boolean;
  28517. /**
  28518. * Creates a new engine
  28519. * @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
  28520. * @param antialias defines enable antialiasing (default: false)
  28521. * @param options defines further options to be sent to the getContext() function
  28522. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  28523. */
  28524. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  28525. /**
  28526. * Initializes a webVR display and starts listening to display change events
  28527. * The onVRDisplayChangedObservable will be notified upon these changes
  28528. * @returns The onVRDisplayChangedObservable
  28529. */
  28530. initWebVR(): Observable<IDisplayChangedEventArgs>;
  28531. /** @hidden */
  28532. _prepareVRComponent(): void;
  28533. /** @hidden */
  28534. _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  28535. /** @hidden */
  28536. _submitVRFrame(): void;
  28537. /**
  28538. * Call this function to leave webVR mode
  28539. * Will do nothing if webVR is not supported or if there is no webVR device
  28540. * @see http://doc.babylonjs.com/how_to/webvr_camera
  28541. */
  28542. disableVR(): void;
  28543. /**
  28544. * Gets a boolean indicating that the system is in VR mode and is presenting
  28545. * @returns true if VR mode is engaged
  28546. */
  28547. isVRPresenting(): boolean;
  28548. /** @hidden */
  28549. _requestVRFrame(): void;
  28550. private _disableTouchAction;
  28551. private _rebuildInternalTextures;
  28552. private _rebuildEffects;
  28553. /**
  28554. * Gets a boolean indicating if all created effects are ready
  28555. * @returns true if all effects are ready
  28556. */
  28557. areAllEffectsReady(): boolean;
  28558. private _rebuildBuffers;
  28559. private _initGLContext;
  28560. /**
  28561. * Gets version of the current webGL context
  28562. */
  28563. readonly webGLVersion: number;
  28564. /**
  28565. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  28566. */
  28567. readonly isStencilEnable: boolean;
  28568. /** @hidden */
  28569. _prepareWorkingCanvas(): void;
  28570. /**
  28571. * Reset the texture cache to empty state
  28572. */
  28573. resetTextureCache(): void;
  28574. /**
  28575. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  28576. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  28577. * @returns true if engine is in deterministic lock step mode
  28578. */
  28579. isDeterministicLockStep(): boolean;
  28580. /**
  28581. * Gets the max steps when engine is running in deterministic lock step
  28582. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  28583. * @returns the max steps
  28584. */
  28585. getLockstepMaxSteps(): number;
  28586. /**
  28587. * Gets an object containing information about the current webGL context
  28588. * @returns an object containing the vender, the renderer and the version of the current webGL context
  28589. */
  28590. getGlInfo(): {
  28591. vendor: string;
  28592. renderer: string;
  28593. version: string;
  28594. };
  28595. /**
  28596. * Gets current aspect ratio
  28597. * @param camera defines the camera to use to get the aspect ratio
  28598. * @param useScreen defines if screen size must be used (or the current render target if any)
  28599. * @returns a number defining the aspect ratio
  28600. */
  28601. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  28602. /**
  28603. * Gets current screen aspect ratio
  28604. * @returns a number defining the aspect ratio
  28605. */
  28606. getScreenAspectRatio(): number;
  28607. /**
  28608. * Gets the current render width
  28609. * @param useScreen defines if screen size must be used (or the current render target if any)
  28610. * @returns a number defining the current render width
  28611. */
  28612. getRenderWidth(useScreen?: boolean): number;
  28613. /**
  28614. * Gets the current render height
  28615. * @param useScreen defines if screen size must be used (or the current render target if any)
  28616. * @returns a number defining the current render height
  28617. */
  28618. getRenderHeight(useScreen?: boolean): number;
  28619. /**
  28620. * Gets the HTML canvas attached with the current webGL context
  28621. * @returns a HTML canvas
  28622. */
  28623. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  28624. /**
  28625. * Gets the client rect of the HTML canvas attached with the current webGL context
  28626. * @returns a client rectanglee
  28627. */
  28628. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  28629. /**
  28630. * Defines the hardware scaling level.
  28631. * By default the hardware scaling level is computed from the window device ratio.
  28632. * 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.
  28633. * @param level defines the level to use
  28634. */
  28635. setHardwareScalingLevel(level: number): void;
  28636. /**
  28637. * Gets the current hardware scaling level.
  28638. * By default the hardware scaling level is computed from the window device ratio.
  28639. * 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.
  28640. * @returns a number indicating the current hardware scaling level
  28641. */
  28642. getHardwareScalingLevel(): number;
  28643. /**
  28644. * Gets the list of loaded textures
  28645. * @returns an array containing all loaded textures
  28646. */
  28647. getLoadedTexturesCache(): InternalTexture[];
  28648. /**
  28649. * Gets the object containing all engine capabilities
  28650. * @returns the EngineCapabilities object
  28651. */
  28652. getCaps(): EngineCapabilities;
  28653. /**
  28654. * Gets the current depth function
  28655. * @returns a number defining the depth function
  28656. */
  28657. getDepthFunction(): Nullable<number>;
  28658. /**
  28659. * Sets the current depth function
  28660. * @param depthFunc defines the function to use
  28661. */
  28662. setDepthFunction(depthFunc: number): void;
  28663. /**
  28664. * Sets the current depth function to GREATER
  28665. */
  28666. setDepthFunctionToGreater(): void;
  28667. /**
  28668. * Sets the current depth function to GEQUAL
  28669. */
  28670. setDepthFunctionToGreaterOrEqual(): void;
  28671. /**
  28672. * Sets the current depth function to LESS
  28673. */
  28674. setDepthFunctionToLess(): void;
  28675. private _cachedStencilBuffer;
  28676. private _cachedStencilFunction;
  28677. private _cachedStencilMask;
  28678. private _cachedStencilOperationPass;
  28679. private _cachedStencilOperationFail;
  28680. private _cachedStencilOperationDepthFail;
  28681. private _cachedStencilReference;
  28682. /**
  28683. * Caches the the state of the stencil buffer
  28684. */
  28685. cacheStencilState(): void;
  28686. /**
  28687. * Restores the state of the stencil buffer
  28688. */
  28689. restoreStencilState(): void;
  28690. /**
  28691. * Sets the current depth function to LEQUAL
  28692. */
  28693. setDepthFunctionToLessOrEqual(): void;
  28694. /**
  28695. * Gets a boolean indicating if stencil buffer is enabled
  28696. * @returns the current stencil buffer state
  28697. */
  28698. getStencilBuffer(): boolean;
  28699. /**
  28700. * Enable or disable the stencil buffer
  28701. * @param enable defines if the stencil buffer must be enabled or disabled
  28702. */
  28703. setStencilBuffer(enable: boolean): void;
  28704. /**
  28705. * Gets the current stencil mask
  28706. * @returns a number defining the new stencil mask to use
  28707. */
  28708. getStencilMask(): number;
  28709. /**
  28710. * Sets the current stencil mask
  28711. * @param mask defines the new stencil mask to use
  28712. */
  28713. setStencilMask(mask: number): void;
  28714. /**
  28715. * Gets the current stencil function
  28716. * @returns a number defining the stencil function to use
  28717. */
  28718. getStencilFunction(): number;
  28719. /**
  28720. * Gets the current stencil reference value
  28721. * @returns a number defining the stencil reference value to use
  28722. */
  28723. getStencilFunctionReference(): number;
  28724. /**
  28725. * Gets the current stencil mask
  28726. * @returns a number defining the stencil mask to use
  28727. */
  28728. getStencilFunctionMask(): number;
  28729. /**
  28730. * Sets the current stencil function
  28731. * @param stencilFunc defines the new stencil function to use
  28732. */
  28733. setStencilFunction(stencilFunc: number): void;
  28734. /**
  28735. * Sets the current stencil reference
  28736. * @param reference defines the new stencil reference to use
  28737. */
  28738. setStencilFunctionReference(reference: number): void;
  28739. /**
  28740. * Sets the current stencil mask
  28741. * @param mask defines the new stencil mask to use
  28742. */
  28743. setStencilFunctionMask(mask: number): void;
  28744. /**
  28745. * Gets the current stencil operation when stencil fails
  28746. * @returns a number defining stencil operation to use when stencil fails
  28747. */
  28748. getStencilOperationFail(): number;
  28749. /**
  28750. * Gets the current stencil operation when depth fails
  28751. * @returns a number defining stencil operation to use when depth fails
  28752. */
  28753. getStencilOperationDepthFail(): number;
  28754. /**
  28755. * Gets the current stencil operation when stencil passes
  28756. * @returns a number defining stencil operation to use when stencil passes
  28757. */
  28758. getStencilOperationPass(): number;
  28759. /**
  28760. * Sets the stencil operation to use when stencil fails
  28761. * @param operation defines the stencil operation to use when stencil fails
  28762. */
  28763. setStencilOperationFail(operation: number): void;
  28764. /**
  28765. * Sets the stencil operation to use when depth fails
  28766. * @param operation defines the stencil operation to use when depth fails
  28767. */
  28768. setStencilOperationDepthFail(operation: number): void;
  28769. /**
  28770. * Sets the stencil operation to use when stencil passes
  28771. * @param operation defines the stencil operation to use when stencil passes
  28772. */
  28773. setStencilOperationPass(operation: number): void;
  28774. /**
  28775. * Sets a boolean indicating if the dithering state is enabled or disabled
  28776. * @param value defines the dithering state
  28777. */
  28778. setDitheringState(value: boolean): void;
  28779. /**
  28780. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  28781. * @param value defines the rasterizer state
  28782. */
  28783. setRasterizerState(value: boolean): void;
  28784. /**
  28785. * stop executing a render loop function and remove it from the execution array
  28786. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  28787. */
  28788. stopRenderLoop(renderFunction?: () => void): void;
  28789. /** @hidden */
  28790. _renderLoop(): void;
  28791. /**
  28792. * Register and execute a render loop. The engine can have more than one render function
  28793. * @param renderFunction defines the function to continuously execute
  28794. */
  28795. runRenderLoop(renderFunction: () => void): void;
  28796. /**
  28797. * Toggle full screen mode
  28798. * @param requestPointerLock defines if a pointer lock should be requested from the user
  28799. */
  28800. switchFullscreen(requestPointerLock: boolean): void;
  28801. /**
  28802. * Enters full screen mode
  28803. * @param requestPointerLock defines if a pointer lock should be requested from the user
  28804. */
  28805. enterFullscreen(requestPointerLock: boolean): void;
  28806. /**
  28807. * Exits full screen mode
  28808. */
  28809. exitFullscreen(): void;
  28810. /**
  28811. * Clear the current render buffer or the current render target (if any is set up)
  28812. * @param color defines the color to use
  28813. * @param backBuffer defines if the back buffer must be cleared
  28814. * @param depth defines if the depth buffer must be cleared
  28815. * @param stencil defines if the stencil buffer must be cleared
  28816. */
  28817. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  28818. /**
  28819. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  28820. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  28821. * @param y defines the y-coordinate of the corner of the clear rectangle
  28822. * @param width defines the width of the clear rectangle
  28823. * @param height defines the height of the clear rectangle
  28824. * @param clearColor defines the clear color
  28825. */
  28826. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  28827. /**
  28828. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  28829. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  28830. * @param y defines the y-coordinate of the corner of the clear rectangle
  28831. * @param width defines the width of the clear rectangle
  28832. * @param height defines the height of the clear rectangle
  28833. */
  28834. enableScissor(x: number, y: number, width: number, height: number): void;
  28835. /**
  28836. * Disable previously set scissor test rectangle
  28837. */
  28838. disableScissor(): void;
  28839. private _viewportCached;
  28840. /** @hidden */
  28841. _viewport(x: number, y: number, width: number, height: number): void;
  28842. /**
  28843. * Set the WebGL's viewport
  28844. * @param viewport defines the viewport element to be used
  28845. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  28846. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  28847. */
  28848. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  28849. /**
  28850. * Directly set the WebGL Viewport
  28851. * @param x defines the x coordinate of the viewport (in screen space)
  28852. * @param y defines the y coordinate of the viewport (in screen space)
  28853. * @param width defines the width of the viewport (in screen space)
  28854. * @param height defines the height of the viewport (in screen space)
  28855. * @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
  28856. */
  28857. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  28858. /**
  28859. * Begin a new frame
  28860. */
  28861. beginFrame(): void;
  28862. /**
  28863. * Enf the current frame
  28864. */
  28865. endFrame(): void;
  28866. /**
  28867. * Resize the view according to the canvas' size
  28868. */
  28869. resize(): void;
  28870. /**
  28871. * Force a specific size of the canvas
  28872. * @param width defines the new canvas' width
  28873. * @param height defines the new canvas' height
  28874. */
  28875. setSize(width: number, height: number): void;
  28876. /**
  28877. * Binds the frame buffer to the specified texture.
  28878. * @param texture The texture to render to or null for the default canvas
  28879. * @param faceIndex The face of the texture to render to in case of cube texture
  28880. * @param requiredWidth The width of the target to render to
  28881. * @param requiredHeight The height of the target to render to
  28882. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  28883. * @param depthStencilTexture The depth stencil texture to use to render
  28884. * @param lodLevel defines le lod level to bind to the frame buffer
  28885. */
  28886. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  28887. /** @hidden */
  28888. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  28889. /**
  28890. * Unbind the current render target texture from the webGL context
  28891. * @param texture defines the render target texture to unbind
  28892. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  28893. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  28894. */
  28895. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  28896. /**
  28897. * Force the mipmap generation for the given render target texture
  28898. * @param texture defines the render target texture to use
  28899. */
  28900. generateMipMapsForCubemap(texture: InternalTexture): void;
  28901. /**
  28902. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  28903. */
  28904. flushFramebuffer(): void;
  28905. /**
  28906. * Unbind the current render target and bind the default framebuffer
  28907. */
  28908. restoreDefaultFramebuffer(): void;
  28909. /**
  28910. * Create an uniform buffer
  28911. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28912. * @param elements defines the content of the uniform buffer
  28913. * @returns the webGL uniform buffer
  28914. */
  28915. createUniformBuffer(elements: FloatArray): DataBuffer;
  28916. /**
  28917. * Create a dynamic uniform buffer
  28918. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28919. * @param elements defines the content of the uniform buffer
  28920. * @returns the webGL uniform buffer
  28921. */
  28922. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  28923. /**
  28924. * Update an existing uniform buffer
  28925. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28926. * @param uniformBuffer defines the target uniform buffer
  28927. * @param elements defines the content to update
  28928. * @param offset defines the offset in the uniform buffer where update should start
  28929. * @param count defines the size of the data to update
  28930. */
  28931. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  28932. private _resetVertexBufferBinding;
  28933. /**
  28934. * Creates a vertex buffer
  28935. * @param data the data for the vertex buffer
  28936. * @returns the new WebGL static buffer
  28937. */
  28938. createVertexBuffer(data: DataArray): DataBuffer;
  28939. /**
  28940. * Creates a dynamic vertex buffer
  28941. * @param data the data for the dynamic vertex buffer
  28942. * @returns the new WebGL dynamic buffer
  28943. */
  28944. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  28945. /**
  28946. * Update a dynamic index buffer
  28947. * @param indexBuffer defines the target index buffer
  28948. * @param indices defines the data to update
  28949. * @param offset defines the offset in the target index buffer where update should start
  28950. */
  28951. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  28952. /**
  28953. * Updates a dynamic vertex buffer.
  28954. * @param vertexBuffer the vertex buffer to update
  28955. * @param data the data used to update the vertex buffer
  28956. * @param byteOffset the byte offset of the data
  28957. * @param byteLength the byte length of the data
  28958. */
  28959. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  28960. private _resetIndexBufferBinding;
  28961. /**
  28962. * Creates a new index buffer
  28963. * @param indices defines the content of the index buffer
  28964. * @param updatable defines if the index buffer must be updatable
  28965. * @returns a new webGL buffer
  28966. */
  28967. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  28968. /**
  28969. * Bind a webGL buffer to the webGL context
  28970. * @param buffer defines the buffer to bind
  28971. */
  28972. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  28973. /**
  28974. * Bind an uniform buffer to the current webGL context
  28975. * @param buffer defines the buffer to bind
  28976. */
  28977. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  28978. /**
  28979. * Bind a buffer to the current webGL context at a given location
  28980. * @param buffer defines the buffer to bind
  28981. * @param location defines the index where to bind the buffer
  28982. */
  28983. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  28984. /**
  28985. * Bind a specific block at a given index in a specific shader program
  28986. * @param pipelineContext defines the pipeline context to use
  28987. * @param blockName defines the block name
  28988. * @param index defines the index where to bind the block
  28989. */
  28990. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  28991. private bindIndexBuffer;
  28992. private bindBuffer;
  28993. /**
  28994. * update the bound buffer with the given data
  28995. * @param data defines the data to update
  28996. */
  28997. updateArrayBuffer(data: Float32Array): void;
  28998. private _vertexAttribPointer;
  28999. private _bindIndexBufferWithCache;
  29000. private _bindVertexBuffersAttributes;
  29001. /**
  29002. * Records a vertex array object
  29003. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  29004. * @param vertexBuffers defines the list of vertex buffers to store
  29005. * @param indexBuffer defines the index buffer to store
  29006. * @param effect defines the effect to store
  29007. * @returns the new vertex array object
  29008. */
  29009. recordVertexArrayObject(vertexBuffers: {
  29010. [key: string]: VertexBuffer;
  29011. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  29012. /**
  29013. * Bind a specific vertex array object
  29014. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  29015. * @param vertexArrayObject defines the vertex array object to bind
  29016. * @param indexBuffer defines the index buffer to bind
  29017. */
  29018. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  29019. /**
  29020. * Bind webGl buffers directly to the webGL context
  29021. * @param vertexBuffer defines the vertex buffer to bind
  29022. * @param indexBuffer defines the index buffer to bind
  29023. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  29024. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  29025. * @param effect defines the effect associated with the vertex buffer
  29026. */
  29027. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  29028. private _unbindVertexArrayObject;
  29029. /**
  29030. * Bind a list of vertex buffers to the webGL context
  29031. * @param vertexBuffers defines the list of vertex buffers to bind
  29032. * @param indexBuffer defines the index buffer to bind
  29033. * @param effect defines the effect associated with the vertex buffers
  29034. */
  29035. bindBuffers(vertexBuffers: {
  29036. [key: string]: Nullable<VertexBuffer>;
  29037. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  29038. /**
  29039. * Unbind all instance attributes
  29040. */
  29041. unbindInstanceAttributes(): void;
  29042. /**
  29043. * Release and free the memory of a vertex array object
  29044. * @param vao defines the vertex array object to delete
  29045. */
  29046. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  29047. /** @hidden */
  29048. _releaseBuffer(buffer: DataBuffer): boolean;
  29049. /**
  29050. * Creates a webGL buffer to use with instanciation
  29051. * @param capacity defines the size of the buffer
  29052. * @returns the webGL buffer
  29053. */
  29054. createInstancesBuffer(capacity: number): DataBuffer;
  29055. /**
  29056. * Delete a webGL buffer used with instanciation
  29057. * @param buffer defines the webGL buffer to delete
  29058. */
  29059. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  29060. /**
  29061. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  29062. * @param instancesBuffer defines the webGL buffer to update and bind
  29063. * @param data defines the data to store in the buffer
  29064. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  29065. */
  29066. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  29067. /**
  29068. * Apply all cached states (depth, culling, stencil and alpha)
  29069. */
  29070. applyStates(): void;
  29071. /**
  29072. * Send a draw order
  29073. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  29074. * @param indexStart defines the starting index
  29075. * @param indexCount defines the number of index to draw
  29076. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29077. */
  29078. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  29079. /**
  29080. * Draw a list of points
  29081. * @param verticesStart defines the index of first vertex to draw
  29082. * @param verticesCount defines the count of vertices to draw
  29083. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29084. */
  29085. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29086. /**
  29087. * Draw a list of unindexed primitives
  29088. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  29089. * @param verticesStart defines the index of first vertex to draw
  29090. * @param verticesCount defines the count of vertices to draw
  29091. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29092. */
  29093. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29094. /**
  29095. * Draw a list of indexed primitives
  29096. * @param fillMode defines the primitive to use
  29097. * @param indexStart defines the starting index
  29098. * @param indexCount defines the number of index to draw
  29099. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29100. */
  29101. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  29102. /**
  29103. * Draw a list of unindexed primitives
  29104. * @param fillMode defines the primitive to use
  29105. * @param verticesStart defines the index of first vertex to draw
  29106. * @param verticesCount defines the count of vertices to draw
  29107. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29108. */
  29109. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29110. private _drawMode;
  29111. /** @hidden */
  29112. _releaseEffect(effect: Effect): void;
  29113. /** @hidden */
  29114. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  29115. /**
  29116. * Create a new effect (used to store vertex/fragment shaders)
  29117. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  29118. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  29119. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  29120. * @param samplers defines an array of string used to represent textures
  29121. * @param defines defines the string containing the defines to use to compile the shaders
  29122. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  29123. * @param onCompiled defines a function to call when the effect creation is successful
  29124. * @param onError defines a function to call when the effect creation has failed
  29125. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  29126. * @returns the new Effect
  29127. */
  29128. 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;
  29129. private _compileShader;
  29130. private _compileRawShader;
  29131. /**
  29132. * Directly creates a webGL program
  29133. * @param pipelineContext defines the pipeline context to attach to
  29134. * @param vertexCode defines the vertex shader code to use
  29135. * @param fragmentCode defines the fragment shader code to use
  29136. * @param context defines the webGL context to use (if not set, the current one will be used)
  29137. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  29138. * @returns the new webGL program
  29139. */
  29140. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  29141. /**
  29142. * Creates a webGL program
  29143. * @param pipelineContext defines the pipeline context to attach to
  29144. * @param vertexCode defines the vertex shader code to use
  29145. * @param fragmentCode defines the fragment shader code to use
  29146. * @param defines defines the string containing the defines to use to compile the shaders
  29147. * @param context defines the webGL context to use (if not set, the current one will be used)
  29148. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  29149. * @returns the new webGL program
  29150. */
  29151. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  29152. /**
  29153. * Creates a new pipeline context
  29154. * @returns the new pipeline
  29155. */
  29156. createPipelineContext(): WebGLPipelineContext;
  29157. private _createShaderProgram;
  29158. private _finalizePipelineContext;
  29159. /** @hidden */
  29160. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  29161. /** @hidden */
  29162. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  29163. /** @hidden */
  29164. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  29165. /**
  29166. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  29167. * @param pipelineContext defines the pipeline context to use
  29168. * @param uniformsNames defines the list of uniform names
  29169. * @returns an array of webGL uniform locations
  29170. */
  29171. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  29172. /**
  29173. * Gets the lsit of active attributes for a given webGL program
  29174. * @param pipelineContext defines the pipeline context to use
  29175. * @param attributesNames defines the list of attribute names to get
  29176. * @returns an array of indices indicating the offset of each attribute
  29177. */
  29178. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  29179. /**
  29180. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  29181. * @param effect defines the effect to activate
  29182. */
  29183. enableEffect(effect: Nullable<Effect>): void;
  29184. /**
  29185. * Set the value of an uniform to an array of int32
  29186. * @param uniform defines the webGL uniform location where to store the value
  29187. * @param array defines the array of int32 to store
  29188. */
  29189. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29190. /**
  29191. * Set the value of an uniform to an array of int32 (stored as vec2)
  29192. * @param uniform defines the webGL uniform location where to store the value
  29193. * @param array defines the array of int32 to store
  29194. */
  29195. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29196. /**
  29197. * Set the value of an uniform to an array of int32 (stored as vec3)
  29198. * @param uniform defines the webGL uniform location where to store the value
  29199. * @param array defines the array of int32 to store
  29200. */
  29201. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29202. /**
  29203. * Set the value of an uniform to an array of int32 (stored as vec4)
  29204. * @param uniform defines the webGL uniform location where to store the value
  29205. * @param array defines the array of int32 to store
  29206. */
  29207. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29208. /**
  29209. * Set the value of an uniform to an array of float32
  29210. * @param uniform defines the webGL uniform location where to store the value
  29211. * @param array defines the array of float32 to store
  29212. */
  29213. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29214. /**
  29215. * Set the value of an uniform to an array of float32 (stored as vec2)
  29216. * @param uniform defines the webGL uniform location where to store the value
  29217. * @param array defines the array of float32 to store
  29218. */
  29219. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29220. /**
  29221. * Set the value of an uniform to an array of float32 (stored as vec3)
  29222. * @param uniform defines the webGL uniform location where to store the value
  29223. * @param array defines the array of float32 to store
  29224. */
  29225. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29226. /**
  29227. * Set the value of an uniform to an array of float32 (stored as vec4)
  29228. * @param uniform defines the webGL uniform location where to store the value
  29229. * @param array defines the array of float32 to store
  29230. */
  29231. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29232. /**
  29233. * Set the value of an uniform to an array of number
  29234. * @param uniform defines the webGL uniform location where to store the value
  29235. * @param array defines the array of number to store
  29236. */
  29237. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29238. /**
  29239. * Set the value of an uniform to an array of number (stored as vec2)
  29240. * @param uniform defines the webGL uniform location where to store the value
  29241. * @param array defines the array of number to store
  29242. */
  29243. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29244. /**
  29245. * Set the value of an uniform to an array of number (stored as vec3)
  29246. * @param uniform defines the webGL uniform location where to store the value
  29247. * @param array defines the array of number to store
  29248. */
  29249. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29250. /**
  29251. * Set the value of an uniform to an array of number (stored as vec4)
  29252. * @param uniform defines the webGL uniform location where to store the value
  29253. * @param array defines the array of number to store
  29254. */
  29255. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29256. /**
  29257. * Set the value of an uniform to an array of float32 (stored as matrices)
  29258. * @param uniform defines the webGL uniform location where to store the value
  29259. * @param matrices defines the array of float32 to store
  29260. */
  29261. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  29262. /**
  29263. * Set the value of an uniform to a matrix
  29264. * @param uniform defines the webGL uniform location where to store the value
  29265. * @param matrix defines the matrix to store
  29266. */
  29267. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  29268. /**
  29269. * Set the value of an uniform to a matrix (3x3)
  29270. * @param uniform defines the webGL uniform location where to store the value
  29271. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  29272. */
  29273. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  29274. /**
  29275. * Set the value of an uniform to a matrix (2x2)
  29276. * @param uniform defines the webGL uniform location where to store the value
  29277. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  29278. */
  29279. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  29280. /**
  29281. * Set the value of an uniform to a number (int)
  29282. * @param uniform defines the webGL uniform location where to store the value
  29283. * @param value defines the int number to store
  29284. */
  29285. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  29286. /**
  29287. * Set the value of an uniform to a number (float)
  29288. * @param uniform defines the webGL uniform location where to store the value
  29289. * @param value defines the float number to store
  29290. */
  29291. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  29292. /**
  29293. * Set the value of an uniform to a vec2
  29294. * @param uniform defines the webGL uniform location where to store the value
  29295. * @param x defines the 1st component of the value
  29296. * @param y defines the 2nd component of the value
  29297. */
  29298. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  29299. /**
  29300. * Set the value of an uniform to a vec3
  29301. * @param uniform defines the webGL uniform location where to store the value
  29302. * @param x defines the 1st component of the value
  29303. * @param y defines the 2nd component of the value
  29304. * @param z defines the 3rd component of the value
  29305. */
  29306. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  29307. /**
  29308. * Set the value of an uniform to a boolean
  29309. * @param uniform defines the webGL uniform location where to store the value
  29310. * @param bool defines the boolean to store
  29311. */
  29312. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  29313. /**
  29314. * Set the value of an uniform to a vec4
  29315. * @param uniform defines the webGL uniform location where to store the value
  29316. * @param x defines the 1st component of the value
  29317. * @param y defines the 2nd component of the value
  29318. * @param z defines the 3rd component of the value
  29319. * @param w defines the 4th component of the value
  29320. */
  29321. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  29322. /**
  29323. * Set the value of an uniform to a Color3
  29324. * @param uniform defines the webGL uniform location where to store the value
  29325. * @param color3 defines the color to store
  29326. */
  29327. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  29328. /**
  29329. * Set the value of an uniform to a Color3 and an alpha value
  29330. * @param uniform defines the webGL uniform location where to store the value
  29331. * @param color3 defines the color to store
  29332. * @param alpha defines the alpha component to store
  29333. */
  29334. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  29335. /**
  29336. * Sets a Color4 on a uniform variable
  29337. * @param uniform defines the uniform location
  29338. * @param color4 defines the value to be set
  29339. */
  29340. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  29341. /**
  29342. * Set various states to the webGL context
  29343. * @param culling defines backface culling state
  29344. * @param zOffset defines the value to apply to zOffset (0 by default)
  29345. * @param force defines if states must be applied even if cache is up to date
  29346. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  29347. */
  29348. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  29349. /**
  29350. * Set the z offset to apply to current rendering
  29351. * @param value defines the offset to apply
  29352. */
  29353. setZOffset(value: number): void;
  29354. /**
  29355. * Gets the current value of the zOffset
  29356. * @returns the current zOffset state
  29357. */
  29358. getZOffset(): number;
  29359. /**
  29360. * Enable or disable depth buffering
  29361. * @param enable defines the state to set
  29362. */
  29363. setDepthBuffer(enable: boolean): void;
  29364. /**
  29365. * Gets a boolean indicating if depth writing is enabled
  29366. * @returns the current depth writing state
  29367. */
  29368. getDepthWrite(): boolean;
  29369. /**
  29370. * Enable or disable depth writing
  29371. * @param enable defines the state to set
  29372. */
  29373. setDepthWrite(enable: boolean): void;
  29374. /**
  29375. * Enable or disable color writing
  29376. * @param enable defines the state to set
  29377. */
  29378. setColorWrite(enable: boolean): void;
  29379. /**
  29380. * Gets a boolean indicating if color writing is enabled
  29381. * @returns the current color writing state
  29382. */
  29383. getColorWrite(): boolean;
  29384. /**
  29385. * Sets alpha constants used by some alpha blending modes
  29386. * @param r defines the red component
  29387. * @param g defines the green component
  29388. * @param b defines the blue component
  29389. * @param a defines the alpha component
  29390. */
  29391. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  29392. /**
  29393. * Sets the current alpha mode
  29394. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  29395. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  29396. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  29397. */
  29398. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  29399. /**
  29400. * Gets the current alpha mode
  29401. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  29402. * @returns the current alpha mode
  29403. */
  29404. getAlphaMode(): number;
  29405. /**
  29406. * Clears the list of texture accessible through engine.
  29407. * This can help preventing texture load conflict due to name collision.
  29408. */
  29409. clearInternalTexturesCache(): void;
  29410. /**
  29411. * Force the entire cache to be cleared
  29412. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  29413. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  29414. */
  29415. wipeCaches(bruteForce?: boolean): void;
  29416. /**
  29417. * Set the compressed texture format to use, based on the formats you have, and the formats
  29418. * supported by the hardware / browser.
  29419. *
  29420. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  29421. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  29422. * to API arguments needed to compressed textures. This puts the burden on the container
  29423. * generator to house the arcane code for determining these for current & future formats.
  29424. *
  29425. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  29426. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  29427. *
  29428. * Note: The result of this call is not taken into account when a texture is base64.
  29429. *
  29430. * @param formatsAvailable defines the list of those format families you have created
  29431. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  29432. *
  29433. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  29434. * @returns The extension selected.
  29435. */
  29436. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  29437. /** @hidden */
  29438. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  29439. min: number;
  29440. mag: number;
  29441. };
  29442. /** @hidden */
  29443. _createTexture(): WebGLTexture;
  29444. /**
  29445. * Usually called from Texture.ts.
  29446. * Passed information to create a WebGLTexture
  29447. * @param urlArg defines a value which contains one of the following:
  29448. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  29449. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  29450. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  29451. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  29452. * @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)
  29453. * @param scene needed for loading to the correct scene
  29454. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  29455. * @param onLoad optional callback to be called upon successful completion
  29456. * @param onError optional callback to be called upon failure
  29457. * @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
  29458. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  29459. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  29460. * @param forcedExtension defines the extension to use to pick the right loader
  29461. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  29462. * @returns a InternalTexture for assignment back into BABYLON.Texture
  29463. */
  29464. 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;
  29465. private _rescaleTexture;
  29466. private _unpackFlipYCached;
  29467. /**
  29468. * In case you are sharing the context with other applications, it might
  29469. * be interested to not cache the unpack flip y state to ensure a consistent
  29470. * value would be set.
  29471. */
  29472. enableUnpackFlipYCached: boolean;
  29473. /** @hidden */
  29474. _unpackFlipY(value: boolean): void;
  29475. /** @hidden */
  29476. _getUnpackAlignement(): number;
  29477. /**
  29478. * Creates a dynamic texture
  29479. * @param width defines the width of the texture
  29480. * @param height defines the height of the texture
  29481. * @param generateMipMaps defines if the engine should generate the mip levels
  29482. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  29483. * @returns the dynamic texture inside an InternalTexture
  29484. */
  29485. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  29486. /**
  29487. * Update the sampling mode of a given texture
  29488. * @param samplingMode defines the required sampling mode
  29489. * @param texture defines the texture to update
  29490. */
  29491. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  29492. /**
  29493. * Update the content of a dynamic texture
  29494. * @param texture defines the texture to update
  29495. * @param canvas defines the canvas containing the source
  29496. * @param invertY defines if data must be stored with Y axis inverted
  29497. * @param premulAlpha defines if alpha is stored as premultiplied
  29498. * @param format defines the format of the data
  29499. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  29500. */
  29501. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  29502. /**
  29503. * Update a video texture
  29504. * @param texture defines the texture to update
  29505. * @param video defines the video element to use
  29506. * @param invertY defines if data must be stored with Y axis inverted
  29507. */
  29508. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  29509. /**
  29510. * Updates a depth texture Comparison Mode and Function.
  29511. * If the comparison Function is equal to 0, the mode will be set to none.
  29512. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  29513. * @param texture The texture to set the comparison function for
  29514. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  29515. */
  29516. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  29517. /** @hidden */
  29518. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  29519. width: number;
  29520. height: number;
  29521. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  29522. /**
  29523. * Creates a depth stencil texture.
  29524. * This is only available in WebGL 2 or with the depth texture extension available.
  29525. * @param size The size of face edge in the texture.
  29526. * @param options The options defining the texture.
  29527. * @returns The texture
  29528. */
  29529. createDepthStencilTexture(size: number | {
  29530. width: number;
  29531. height: number;
  29532. }, options: DepthTextureCreationOptions): InternalTexture;
  29533. /**
  29534. * Creates a depth stencil texture.
  29535. * This is only available in WebGL 2 or with the depth texture extension available.
  29536. * @param size The size of face edge in the texture.
  29537. * @param options The options defining the texture.
  29538. * @returns The texture
  29539. */
  29540. private _createDepthStencilTexture;
  29541. /**
  29542. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  29543. * @param renderTarget The render target to set the frame buffer for
  29544. */
  29545. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  29546. /**
  29547. * Creates a new render target texture
  29548. * @param size defines the size of the texture
  29549. * @param options defines the options used to create the texture
  29550. * @returns a new render target texture stored in an InternalTexture
  29551. */
  29552. createRenderTargetTexture(size: number | {
  29553. width: number;
  29554. height: number;
  29555. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  29556. /** @hidden */
  29557. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  29558. /**
  29559. * Updates the sample count of a render target texture
  29560. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  29561. * @param texture defines the texture to update
  29562. * @param samples defines the sample count to set
  29563. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  29564. */
  29565. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  29566. /** @hidden */
  29567. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29568. /** @hidden */
  29569. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29570. /** @hidden */
  29571. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29572. /** @hidden */
  29573. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  29574. /**
  29575. * @hidden
  29576. */
  29577. _setCubeMapTextureParams(loadMipmap: boolean): void;
  29578. private _prepareWebGLTextureContinuation;
  29579. private _prepareWebGLTexture;
  29580. /** @hidden */
  29581. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  29582. /** @hidden */
  29583. _releaseFramebufferObjects(texture: InternalTexture): void;
  29584. /** @hidden */
  29585. _releaseTexture(texture: InternalTexture): void;
  29586. private setProgram;
  29587. private _boundUniforms;
  29588. /**
  29589. * Binds an effect to the webGL context
  29590. * @param effect defines the effect to bind
  29591. */
  29592. bindSamplers(effect: Effect): void;
  29593. private _activateCurrentTexture;
  29594. /** @hidden */
  29595. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  29596. /** @hidden */
  29597. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  29598. /**
  29599. * Sets a texture to the webGL context from a postprocess
  29600. * @param channel defines the channel to use
  29601. * @param postProcess defines the source postprocess
  29602. */
  29603. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  29604. /**
  29605. * Binds the output of the passed in post process to the texture channel specified
  29606. * @param channel The channel the texture should be bound to
  29607. * @param postProcess The post process which's output should be bound
  29608. */
  29609. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  29610. /**
  29611. * Unbind all textures from the webGL context
  29612. */
  29613. unbindAllTextures(): void;
  29614. /**
  29615. * Sets a texture to the according uniform.
  29616. * @param channel The texture channel
  29617. * @param uniform The uniform to set
  29618. * @param texture The texture to apply
  29619. */
  29620. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  29621. /**
  29622. * Sets a depth stencil texture from a render target to the according uniform.
  29623. * @param channel The texture channel
  29624. * @param uniform The uniform to set
  29625. * @param texture The render target texture containing the depth stencil texture to apply
  29626. */
  29627. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  29628. private _bindSamplerUniformToChannel;
  29629. private _getTextureWrapMode;
  29630. private _setTexture;
  29631. /**
  29632. * Sets an array of texture to the webGL context
  29633. * @param channel defines the channel where the texture array must be set
  29634. * @param uniform defines the associated uniform location
  29635. * @param textures defines the array of textures to bind
  29636. */
  29637. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  29638. /** @hidden */
  29639. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  29640. private _setTextureParameterFloat;
  29641. private _setTextureParameterInteger;
  29642. /**
  29643. * Reads pixels from the current frame buffer. Please note that this function can be slow
  29644. * @param x defines the x coordinate of the rectangle where pixels must be read
  29645. * @param y defines the y coordinate of the rectangle where pixels must be read
  29646. * @param width defines the width of the rectangle where pixels must be read
  29647. * @param height defines the height of the rectangle where pixels must be read
  29648. * @returns a Uint8Array containing RGBA colors
  29649. */
  29650. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  29651. /**
  29652. * Add an externaly attached data from its key.
  29653. * This method call will fail and return false, if such key already exists.
  29654. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  29655. * @param key the unique key that identifies the data
  29656. * @param data the data object to associate to the key for this Engine instance
  29657. * @return true if no such key were already present and the data was added successfully, false otherwise
  29658. */
  29659. addExternalData<T>(key: string, data: T): boolean;
  29660. /**
  29661. * Get an externaly attached data from its key
  29662. * @param key the unique key that identifies the data
  29663. * @return the associated data, if present (can be null), or undefined if not present
  29664. */
  29665. getExternalData<T>(key: string): T;
  29666. /**
  29667. * Get an externaly attached data from its key, create it using a factory if it's not already present
  29668. * @param key the unique key that identifies the data
  29669. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  29670. * @return the associated data, can be null if the factory returned null.
  29671. */
  29672. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  29673. /**
  29674. * Remove an externaly attached data from the Engine instance
  29675. * @param key the unique key that identifies the data
  29676. * @return true if the data was successfully removed, false if it doesn't exist
  29677. */
  29678. removeExternalData(key: string): boolean;
  29679. /**
  29680. * Unbind all vertex attributes from the webGL context
  29681. */
  29682. unbindAllAttributes(): void;
  29683. /**
  29684. * 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
  29685. */
  29686. releaseEffects(): void;
  29687. /**
  29688. * Dispose and release all associated resources
  29689. */
  29690. dispose(): void;
  29691. /**
  29692. * Display the loading screen
  29693. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29694. */
  29695. displayLoadingUI(): void;
  29696. /**
  29697. * Hide the loading screen
  29698. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29699. */
  29700. hideLoadingUI(): void;
  29701. /**
  29702. * Gets the current loading screen object
  29703. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29704. */
  29705. /**
  29706. * Sets the current loading screen object
  29707. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29708. */
  29709. loadingScreen: ILoadingScreen;
  29710. /**
  29711. * Sets the current loading screen text
  29712. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29713. */
  29714. loadingUIText: string;
  29715. /**
  29716. * Sets the current loading screen background color
  29717. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29718. */
  29719. loadingUIBackgroundColor: string;
  29720. /**
  29721. * Attach a new callback raised when context lost event is fired
  29722. * @param callback defines the callback to call
  29723. */
  29724. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  29725. /**
  29726. * Attach a new callback raised when context restored event is fired
  29727. * @param callback defines the callback to call
  29728. */
  29729. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  29730. /**
  29731. * Gets the source code of the vertex shader associated with a specific webGL program
  29732. * @param program defines the program to use
  29733. * @returns a string containing the source code of the vertex shader associated with the program
  29734. */
  29735. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  29736. /**
  29737. * Gets the source code of the fragment shader associated with a specific webGL program
  29738. * @param program defines the program to use
  29739. * @returns a string containing the source code of the fragment shader associated with the program
  29740. */
  29741. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  29742. /**
  29743. * Get the current error code of the webGL context
  29744. * @returns the error code
  29745. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  29746. */
  29747. getError(): number;
  29748. /**
  29749. * Gets the current framerate
  29750. * @returns a number representing the framerate
  29751. */
  29752. getFps(): number;
  29753. /**
  29754. * Gets the time spent between current and previous frame
  29755. * @returns a number representing the delta time in ms
  29756. */
  29757. getDeltaTime(): number;
  29758. private _measureFps;
  29759. /** @hidden */
  29760. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  29761. private _canRenderToFloatFramebuffer;
  29762. private _canRenderToHalfFloatFramebuffer;
  29763. private _canRenderToFramebuffer;
  29764. /** @hidden */
  29765. _getWebGLTextureType(type: number): number;
  29766. /** @hidden */
  29767. _getInternalFormat(format: number): number;
  29768. /** @hidden */
  29769. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  29770. /** @hidden */
  29771. _getRGBAMultiSampleBufferFormat(type: number): number;
  29772. /** @hidden */
  29773. _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;
  29774. /** @hidden */
  29775. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  29776. /**
  29777. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  29778. * @returns true if the engine can be created
  29779. * @ignorenaming
  29780. */
  29781. static isSupported(): boolean;
  29782. }
  29783. }
  29784. declare module "babylonjs/Materials/effect" {
  29785. import { Observable } from "babylonjs/Misc/observable";
  29786. import { Nullable } from "babylonjs/types";
  29787. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  29788. import { IDisposable } from "babylonjs/scene";
  29789. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  29790. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  29791. import { Engine } from "babylonjs/Engines/engine";
  29792. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  29793. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29794. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  29795. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  29796. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29797. /**
  29798. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  29799. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  29800. */
  29801. export class EffectFallbacks {
  29802. private _defines;
  29803. private _currentRank;
  29804. private _maxRank;
  29805. private _mesh;
  29806. /**
  29807. * Removes the fallback from the bound mesh.
  29808. */
  29809. unBindMesh(): void;
  29810. /**
  29811. * Adds a fallback on the specified property.
  29812. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  29813. * @param define The name of the define in the shader
  29814. */
  29815. addFallback(rank: number, define: string): void;
  29816. /**
  29817. * Sets the mesh to use CPU skinning when needing to fallback.
  29818. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  29819. * @param mesh The mesh to use the fallbacks.
  29820. */
  29821. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  29822. /**
  29823. * Checks to see if more fallbacks are still availible.
  29824. */
  29825. readonly isMoreFallbacks: boolean;
  29826. /**
  29827. * Removes the defines that shoould be removed when falling back.
  29828. * @param currentDefines defines the current define statements for the shader.
  29829. * @param effect defines the current effect we try to compile
  29830. * @returns The resulting defines with defines of the current rank removed.
  29831. */
  29832. reduce(currentDefines: string, effect: Effect): string;
  29833. }
  29834. /**
  29835. * Options to be used when creating an effect.
  29836. */
  29837. export class EffectCreationOptions {
  29838. /**
  29839. * Atrributes that will be used in the shader.
  29840. */
  29841. attributes: string[];
  29842. /**
  29843. * Uniform varible names that will be set in the shader.
  29844. */
  29845. uniformsNames: string[];
  29846. /**
  29847. * Uniform buffer varible names that will be set in the shader.
  29848. */
  29849. uniformBuffersNames: string[];
  29850. /**
  29851. * Sampler texture variable names that will be set in the shader.
  29852. */
  29853. samplers: string[];
  29854. /**
  29855. * Define statements that will be set in the shader.
  29856. */
  29857. defines: any;
  29858. /**
  29859. * Possible fallbacks for this effect to improve performance when needed.
  29860. */
  29861. fallbacks: Nullable<EffectFallbacks>;
  29862. /**
  29863. * Callback that will be called when the shader is compiled.
  29864. */
  29865. onCompiled: Nullable<(effect: Effect) => void>;
  29866. /**
  29867. * Callback that will be called if an error occurs during shader compilation.
  29868. */
  29869. onError: Nullable<(effect: Effect, errors: string) => void>;
  29870. /**
  29871. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29872. */
  29873. indexParameters: any;
  29874. /**
  29875. * Max number of lights that can be used in the shader.
  29876. */
  29877. maxSimultaneousLights: number;
  29878. /**
  29879. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  29880. */
  29881. transformFeedbackVaryings: Nullable<string[]>;
  29882. }
  29883. /**
  29884. * Effect containing vertex and fragment shader that can be executed on an object.
  29885. */
  29886. export class Effect implements IDisposable {
  29887. /**
  29888. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29889. */
  29890. static ShadersRepository: string;
  29891. /**
  29892. * Name of the effect.
  29893. */
  29894. name: any;
  29895. /**
  29896. * String container all the define statements that should be set on the shader.
  29897. */
  29898. defines: string;
  29899. /**
  29900. * Callback that will be called when the shader is compiled.
  29901. */
  29902. onCompiled: Nullable<(effect: Effect) => void>;
  29903. /**
  29904. * Callback that will be called if an error occurs during shader compilation.
  29905. */
  29906. onError: Nullable<(effect: Effect, errors: string) => void>;
  29907. /**
  29908. * Callback that will be called when effect is bound.
  29909. */
  29910. onBind: Nullable<(effect: Effect) => void>;
  29911. /**
  29912. * Unique ID of the effect.
  29913. */
  29914. uniqueId: number;
  29915. /**
  29916. * Observable that will be called when the shader is compiled.
  29917. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  29918. */
  29919. onCompileObservable: Observable<Effect>;
  29920. /**
  29921. * Observable that will be called if an error occurs during shader compilation.
  29922. */
  29923. onErrorObservable: Observable<Effect>;
  29924. /** @hidden */
  29925. _onBindObservable: Nullable<Observable<Effect>>;
  29926. /**
  29927. * Observable that will be called when effect is bound.
  29928. */
  29929. readonly onBindObservable: Observable<Effect>;
  29930. /** @hidden */
  29931. _bonesComputationForcedToCPU: boolean;
  29932. private static _uniqueIdSeed;
  29933. private _engine;
  29934. private _uniformBuffersNames;
  29935. private _uniformsNames;
  29936. private _samplerList;
  29937. private _samplers;
  29938. private _isReady;
  29939. private _compilationError;
  29940. private _attributesNames;
  29941. private _attributes;
  29942. private _uniforms;
  29943. /**
  29944. * Key for the effect.
  29945. * @hidden
  29946. */
  29947. _key: string;
  29948. private _indexParameters;
  29949. private _fallbacks;
  29950. private _vertexSourceCode;
  29951. private _fragmentSourceCode;
  29952. private _vertexSourceCodeOverride;
  29953. private _fragmentSourceCodeOverride;
  29954. private _transformFeedbackVaryings;
  29955. /**
  29956. * Compiled shader to webGL program.
  29957. * @hidden
  29958. */
  29959. _pipelineContext: Nullable<IPipelineContext>;
  29960. private _valueCache;
  29961. private static _baseCache;
  29962. /**
  29963. * Instantiates an effect.
  29964. * An effect can be used to create/manage/execute vertex and fragment shaders.
  29965. * @param baseName Name of the effect.
  29966. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  29967. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  29968. * @param samplers List of sampler variables that will be passed to the shader.
  29969. * @param engine Engine to be used to render the effect
  29970. * @param defines Define statements to be added to the shader.
  29971. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  29972. * @param onCompiled Callback that will be called when the shader is compiled.
  29973. * @param onError Callback that will be called if an error occurs during shader compilation.
  29974. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29975. */
  29976. 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);
  29977. /**
  29978. * Unique key for this effect
  29979. */
  29980. readonly key: string;
  29981. /**
  29982. * If the effect has been compiled and prepared.
  29983. * @returns if the effect is compiled and prepared.
  29984. */
  29985. isReady(): boolean;
  29986. /**
  29987. * The engine the effect was initialized with.
  29988. * @returns the engine.
  29989. */
  29990. getEngine(): Engine;
  29991. /**
  29992. * The pipeline context for this effect
  29993. * @returns the associated pipeline context
  29994. */
  29995. getPipelineContext(): Nullable<IPipelineContext>;
  29996. /**
  29997. * The set of names of attribute variables for the shader.
  29998. * @returns An array of attribute names.
  29999. */
  30000. getAttributesNames(): string[];
  30001. /**
  30002. * Returns the attribute at the given index.
  30003. * @param index The index of the attribute.
  30004. * @returns The location of the attribute.
  30005. */
  30006. getAttributeLocation(index: number): number;
  30007. /**
  30008. * Returns the attribute based on the name of the variable.
  30009. * @param name of the attribute to look up.
  30010. * @returns the attribute location.
  30011. */
  30012. getAttributeLocationByName(name: string): number;
  30013. /**
  30014. * The number of attributes.
  30015. * @returns the numnber of attributes.
  30016. */
  30017. getAttributesCount(): number;
  30018. /**
  30019. * Gets the index of a uniform variable.
  30020. * @param uniformName of the uniform to look up.
  30021. * @returns the index.
  30022. */
  30023. getUniformIndex(uniformName: string): number;
  30024. /**
  30025. * Returns the attribute based on the name of the variable.
  30026. * @param uniformName of the uniform to look up.
  30027. * @returns the location of the uniform.
  30028. */
  30029. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  30030. /**
  30031. * Returns an array of sampler variable names
  30032. * @returns The array of sampler variable neames.
  30033. */
  30034. getSamplers(): string[];
  30035. /**
  30036. * The error from the last compilation.
  30037. * @returns the error string.
  30038. */
  30039. getCompilationError(): string;
  30040. /**
  30041. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  30042. * @param func The callback to be used.
  30043. */
  30044. executeWhenCompiled(func: (effect: Effect) => void): void;
  30045. private _checkIsReady;
  30046. /** @hidden */
  30047. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  30048. /** @hidden */
  30049. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  30050. /** @hidden */
  30051. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  30052. private _processShaderConversion;
  30053. private _processIncludes;
  30054. private _processPrecision;
  30055. /**
  30056. * Recompiles the webGL program
  30057. * @param vertexSourceCode The source code for the vertex shader.
  30058. * @param fragmentSourceCode The source code for the fragment shader.
  30059. * @param onCompiled Callback called when completed.
  30060. * @param onError Callback called on error.
  30061. * @hidden
  30062. */
  30063. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  30064. /**
  30065. * Prepares the effect
  30066. * @hidden
  30067. */
  30068. _prepareEffect(): void;
  30069. /**
  30070. * Checks if the effect is supported. (Must be called after compilation)
  30071. */
  30072. readonly isSupported: boolean;
  30073. /**
  30074. * Binds a texture to the engine to be used as output of the shader.
  30075. * @param channel Name of the output variable.
  30076. * @param texture Texture to bind.
  30077. * @hidden
  30078. */
  30079. _bindTexture(channel: string, texture: InternalTexture): void;
  30080. /**
  30081. * Sets a texture on the engine to be used in the shader.
  30082. * @param channel Name of the sampler variable.
  30083. * @param texture Texture to set.
  30084. */
  30085. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  30086. /**
  30087. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  30088. * @param channel Name of the sampler variable.
  30089. * @param texture Texture to set.
  30090. */
  30091. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  30092. /**
  30093. * Sets an array of textures on the engine to be used in the shader.
  30094. * @param channel Name of the variable.
  30095. * @param textures Textures to set.
  30096. */
  30097. setTextureArray(channel: string, textures: BaseTexture[]): void;
  30098. /**
  30099. * 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)
  30100. * @param channel Name of the sampler variable.
  30101. * @param postProcess Post process to get the input texture from.
  30102. */
  30103. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  30104. /**
  30105. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  30106. * 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)
  30107. * @param channel Name of the sampler variable.
  30108. * @param postProcess Post process to get the output texture from.
  30109. */
  30110. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  30111. /** @hidden */
  30112. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  30113. /** @hidden */
  30114. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  30115. /** @hidden */
  30116. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  30117. /** @hidden */
  30118. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  30119. /**
  30120. * Binds a buffer to a uniform.
  30121. * @param buffer Buffer to bind.
  30122. * @param name Name of the uniform variable to bind to.
  30123. */
  30124. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  30125. /**
  30126. * Binds block to a uniform.
  30127. * @param blockName Name of the block to bind.
  30128. * @param index Index to bind.
  30129. */
  30130. bindUniformBlock(blockName: string, index: number): void;
  30131. /**
  30132. * Sets an interger value on a uniform variable.
  30133. * @param uniformName Name of the variable.
  30134. * @param value Value to be set.
  30135. * @returns this effect.
  30136. */
  30137. setInt(uniformName: string, value: number): Effect;
  30138. /**
  30139. * Sets an int array on a uniform variable.
  30140. * @param uniformName Name of the variable.
  30141. * @param array array to be set.
  30142. * @returns this effect.
  30143. */
  30144. setIntArray(uniformName: string, array: Int32Array): Effect;
  30145. /**
  30146. * 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)
  30147. * @param uniformName Name of the variable.
  30148. * @param array array to be set.
  30149. * @returns this effect.
  30150. */
  30151. setIntArray2(uniformName: string, array: Int32Array): Effect;
  30152. /**
  30153. * 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)
  30154. * @param uniformName Name of the variable.
  30155. * @param array array to be set.
  30156. * @returns this effect.
  30157. */
  30158. setIntArray3(uniformName: string, array: Int32Array): Effect;
  30159. /**
  30160. * 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)
  30161. * @param uniformName Name of the variable.
  30162. * @param array array to be set.
  30163. * @returns this effect.
  30164. */
  30165. setIntArray4(uniformName: string, array: Int32Array): Effect;
  30166. /**
  30167. * Sets an float array on a uniform variable.
  30168. * @param uniformName Name of the variable.
  30169. * @param array array to be set.
  30170. * @returns this effect.
  30171. */
  30172. setFloatArray(uniformName: string, array: Float32Array): Effect;
  30173. /**
  30174. * 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)
  30175. * @param uniformName Name of the variable.
  30176. * @param array array to be set.
  30177. * @returns this effect.
  30178. */
  30179. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  30180. /**
  30181. * 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)
  30182. * @param uniformName Name of the variable.
  30183. * @param array array to be set.
  30184. * @returns this effect.
  30185. */
  30186. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  30187. /**
  30188. * 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)
  30189. * @param uniformName Name of the variable.
  30190. * @param array array to be set.
  30191. * @returns this effect.
  30192. */
  30193. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  30194. /**
  30195. * Sets an array on a uniform variable.
  30196. * @param uniformName Name of the variable.
  30197. * @param array array to be set.
  30198. * @returns this effect.
  30199. */
  30200. setArray(uniformName: string, array: number[]): Effect;
  30201. /**
  30202. * 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)
  30203. * @param uniformName Name of the variable.
  30204. * @param array array to be set.
  30205. * @returns this effect.
  30206. */
  30207. setArray2(uniformName: string, array: number[]): Effect;
  30208. /**
  30209. * 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)
  30210. * @param uniformName Name of the variable.
  30211. * @param array array to be set.
  30212. * @returns this effect.
  30213. */
  30214. setArray3(uniformName: string, array: number[]): Effect;
  30215. /**
  30216. * 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)
  30217. * @param uniformName Name of the variable.
  30218. * @param array array to be set.
  30219. * @returns this effect.
  30220. */
  30221. setArray4(uniformName: string, array: number[]): Effect;
  30222. /**
  30223. * Sets matrices on a uniform variable.
  30224. * @param uniformName Name of the variable.
  30225. * @param matrices matrices to be set.
  30226. * @returns this effect.
  30227. */
  30228. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  30229. /**
  30230. * Sets matrix on a uniform variable.
  30231. * @param uniformName Name of the variable.
  30232. * @param matrix matrix to be set.
  30233. * @returns this effect.
  30234. */
  30235. setMatrix(uniformName: string, matrix: Matrix): Effect;
  30236. /**
  30237. * 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)
  30238. * @param uniformName Name of the variable.
  30239. * @param matrix matrix to be set.
  30240. * @returns this effect.
  30241. */
  30242. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  30243. /**
  30244. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  30245. * @param uniformName Name of the variable.
  30246. * @param matrix matrix to be set.
  30247. * @returns this effect.
  30248. */
  30249. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  30250. /**
  30251. * Sets a float on a uniform variable.
  30252. * @param uniformName Name of the variable.
  30253. * @param value value to be set.
  30254. * @returns this effect.
  30255. */
  30256. setFloat(uniformName: string, value: number): Effect;
  30257. /**
  30258. * Sets a boolean on a uniform variable.
  30259. * @param uniformName Name of the variable.
  30260. * @param bool value to be set.
  30261. * @returns this effect.
  30262. */
  30263. setBool(uniformName: string, bool: boolean): Effect;
  30264. /**
  30265. * Sets a Vector2 on a uniform variable.
  30266. * @param uniformName Name of the variable.
  30267. * @param vector2 vector2 to be set.
  30268. * @returns this effect.
  30269. */
  30270. setVector2(uniformName: string, vector2: Vector2): Effect;
  30271. /**
  30272. * Sets a float2 on a uniform variable.
  30273. * @param uniformName Name of the variable.
  30274. * @param x First float in float2.
  30275. * @param y Second float in float2.
  30276. * @returns this effect.
  30277. */
  30278. setFloat2(uniformName: string, x: number, y: number): Effect;
  30279. /**
  30280. * Sets a Vector3 on a uniform variable.
  30281. * @param uniformName Name of the variable.
  30282. * @param vector3 Value to be set.
  30283. * @returns this effect.
  30284. */
  30285. setVector3(uniformName: string, vector3: Vector3): Effect;
  30286. /**
  30287. * Sets a float3 on a uniform variable.
  30288. * @param uniformName Name of the variable.
  30289. * @param x First float in float3.
  30290. * @param y Second float in float3.
  30291. * @param z Third float in float3.
  30292. * @returns this effect.
  30293. */
  30294. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  30295. /**
  30296. * Sets a Vector4 on a uniform variable.
  30297. * @param uniformName Name of the variable.
  30298. * @param vector4 Value to be set.
  30299. * @returns this effect.
  30300. */
  30301. setVector4(uniformName: string, vector4: Vector4): Effect;
  30302. /**
  30303. * Sets a float4 on a uniform variable.
  30304. * @param uniformName Name of the variable.
  30305. * @param x First float in float4.
  30306. * @param y Second float in float4.
  30307. * @param z Third float in float4.
  30308. * @param w Fourth float in float4.
  30309. * @returns this effect.
  30310. */
  30311. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  30312. /**
  30313. * Sets a Color3 on a uniform variable.
  30314. * @param uniformName Name of the variable.
  30315. * @param color3 Value to be set.
  30316. * @returns this effect.
  30317. */
  30318. setColor3(uniformName: string, color3: Color3): Effect;
  30319. /**
  30320. * Sets a Color4 on a uniform variable.
  30321. * @param uniformName Name of the variable.
  30322. * @param color3 Value to be set.
  30323. * @param alpha Alpha value to be set.
  30324. * @returns this effect.
  30325. */
  30326. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  30327. /**
  30328. * Sets a Color4 on a uniform variable
  30329. * @param uniformName defines the name of the variable
  30330. * @param color4 defines the value to be set
  30331. * @returns this effect.
  30332. */
  30333. setDirectColor4(uniformName: string, color4: Color4): Effect;
  30334. /** Release all associated resources */
  30335. dispose(): void;
  30336. /**
  30337. * This function will add a new shader to the shader store
  30338. * @param name the name of the shader
  30339. * @param pixelShader optional pixel shader content
  30340. * @param vertexShader optional vertex shader content
  30341. */
  30342. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  30343. /**
  30344. * Store of each shader (The can be looked up using effect.key)
  30345. */
  30346. static ShadersStore: {
  30347. [key: string]: string;
  30348. };
  30349. /**
  30350. * Store of each included file for a shader (The can be looked up using effect.key)
  30351. */
  30352. static IncludesShadersStore: {
  30353. [key: string]: string;
  30354. };
  30355. /**
  30356. * Resets the cache of effects.
  30357. */
  30358. static ResetCache(): void;
  30359. }
  30360. }
  30361. declare module "babylonjs/Materials/colorCurves" {
  30362. import { Effect } from "babylonjs/Materials/effect";
  30363. /**
  30364. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  30365. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  30366. * 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;
  30367. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  30368. */
  30369. export class ColorCurves {
  30370. private _dirty;
  30371. private _tempColor;
  30372. private _globalCurve;
  30373. private _highlightsCurve;
  30374. private _midtonesCurve;
  30375. private _shadowsCurve;
  30376. private _positiveCurve;
  30377. private _negativeCurve;
  30378. private _globalHue;
  30379. private _globalDensity;
  30380. private _globalSaturation;
  30381. private _globalExposure;
  30382. /**
  30383. * Gets the global Hue value.
  30384. * 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).
  30385. */
  30386. /**
  30387. * Sets the global Hue value.
  30388. * 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).
  30389. */
  30390. globalHue: number;
  30391. /**
  30392. * Gets the global Density value.
  30393. * 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.
  30394. * Values less than zero provide a filter of opposite hue.
  30395. */
  30396. /**
  30397. * Sets the global Density value.
  30398. * 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.
  30399. * Values less than zero provide a filter of opposite hue.
  30400. */
  30401. globalDensity: number;
  30402. /**
  30403. * Gets the global Saturation value.
  30404. * 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.
  30405. */
  30406. /**
  30407. * Sets the global Saturation value.
  30408. * 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.
  30409. */
  30410. globalSaturation: number;
  30411. /**
  30412. * Gets the global Exposure value.
  30413. * 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.
  30414. */
  30415. /**
  30416. * Sets the global Exposure value.
  30417. * 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.
  30418. */
  30419. globalExposure: number;
  30420. private _highlightsHue;
  30421. private _highlightsDensity;
  30422. private _highlightsSaturation;
  30423. private _highlightsExposure;
  30424. /**
  30425. * Gets the highlights Hue value.
  30426. * 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).
  30427. */
  30428. /**
  30429. * Sets the highlights Hue value.
  30430. * 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).
  30431. */
  30432. highlightsHue: number;
  30433. /**
  30434. * Gets the highlights Density value.
  30435. * 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.
  30436. * Values less than zero provide a filter of opposite hue.
  30437. */
  30438. /**
  30439. * Sets the highlights Density value.
  30440. * 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.
  30441. * Values less than zero provide a filter of opposite hue.
  30442. */
  30443. highlightsDensity: number;
  30444. /**
  30445. * Gets the highlights Saturation value.
  30446. * 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.
  30447. */
  30448. /**
  30449. * Sets the highlights Saturation value.
  30450. * 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.
  30451. */
  30452. highlightsSaturation: number;
  30453. /**
  30454. * Gets the highlights Exposure value.
  30455. * 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.
  30456. */
  30457. /**
  30458. * Sets the highlights Exposure value.
  30459. * 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.
  30460. */
  30461. highlightsExposure: number;
  30462. private _midtonesHue;
  30463. private _midtonesDensity;
  30464. private _midtonesSaturation;
  30465. private _midtonesExposure;
  30466. /**
  30467. * Gets the midtones Hue value.
  30468. * 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).
  30469. */
  30470. /**
  30471. * Sets the midtones Hue value.
  30472. * 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).
  30473. */
  30474. midtonesHue: number;
  30475. /**
  30476. * Gets the midtones Density value.
  30477. * 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.
  30478. * Values less than zero provide a filter of opposite hue.
  30479. */
  30480. /**
  30481. * Sets the midtones Density value.
  30482. * 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.
  30483. * Values less than zero provide a filter of opposite hue.
  30484. */
  30485. midtonesDensity: number;
  30486. /**
  30487. * Gets the midtones Saturation value.
  30488. * 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.
  30489. */
  30490. /**
  30491. * Sets the midtones Saturation value.
  30492. * 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.
  30493. */
  30494. midtonesSaturation: number;
  30495. /**
  30496. * Gets the midtones Exposure value.
  30497. * 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.
  30498. */
  30499. /**
  30500. * Sets the midtones Exposure value.
  30501. * 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.
  30502. */
  30503. midtonesExposure: number;
  30504. private _shadowsHue;
  30505. private _shadowsDensity;
  30506. private _shadowsSaturation;
  30507. private _shadowsExposure;
  30508. /**
  30509. * Gets the shadows Hue value.
  30510. * 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).
  30511. */
  30512. /**
  30513. * Sets the shadows Hue value.
  30514. * 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).
  30515. */
  30516. shadowsHue: number;
  30517. /**
  30518. * Gets the shadows Density value.
  30519. * 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.
  30520. * Values less than zero provide a filter of opposite hue.
  30521. */
  30522. /**
  30523. * Sets the shadows Density value.
  30524. * 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.
  30525. * Values less than zero provide a filter of opposite hue.
  30526. */
  30527. shadowsDensity: number;
  30528. /**
  30529. * Gets the shadows Saturation value.
  30530. * 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.
  30531. */
  30532. /**
  30533. * Sets the shadows Saturation value.
  30534. * 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.
  30535. */
  30536. shadowsSaturation: number;
  30537. /**
  30538. * Gets the shadows Exposure value.
  30539. * 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.
  30540. */
  30541. /**
  30542. * Sets the shadows Exposure value.
  30543. * 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.
  30544. */
  30545. shadowsExposure: number;
  30546. /**
  30547. * Returns the class name
  30548. * @returns The class name
  30549. */
  30550. getClassName(): string;
  30551. /**
  30552. * Binds the color curves to the shader.
  30553. * @param colorCurves The color curve to bind
  30554. * @param effect The effect to bind to
  30555. * @param positiveUniform The positive uniform shader parameter
  30556. * @param neutralUniform The neutral uniform shader parameter
  30557. * @param negativeUniform The negative uniform shader parameter
  30558. */
  30559. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  30560. /**
  30561. * Prepare the list of uniforms associated with the ColorCurves effects.
  30562. * @param uniformsList The list of uniforms used in the effect
  30563. */
  30564. static PrepareUniforms(uniformsList: string[]): void;
  30565. /**
  30566. * Returns color grading data based on a hue, density, saturation and exposure value.
  30567. * @param filterHue The hue of the color filter.
  30568. * @param filterDensity The density of the color filter.
  30569. * @param saturation The saturation.
  30570. * @param exposure The exposure.
  30571. * @param result The result data container.
  30572. */
  30573. private getColorGradingDataToRef;
  30574. /**
  30575. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  30576. * @param value The input slider value in range [-100,100].
  30577. * @returns Adjusted value.
  30578. */
  30579. private static applyColorGradingSliderNonlinear;
  30580. /**
  30581. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  30582. * @param hue The hue (H) input.
  30583. * @param saturation The saturation (S) input.
  30584. * @param brightness The brightness (B) input.
  30585. * @result An RGBA color represented as Vector4.
  30586. */
  30587. private static fromHSBToRef;
  30588. /**
  30589. * Returns a value clamped between min and max
  30590. * @param value The value to clamp
  30591. * @param min The minimum of value
  30592. * @param max The maximum of value
  30593. * @returns The clamped value.
  30594. */
  30595. private static clamp;
  30596. /**
  30597. * Clones the current color curve instance.
  30598. * @return The cloned curves
  30599. */
  30600. clone(): ColorCurves;
  30601. /**
  30602. * Serializes the current color curve instance to a json representation.
  30603. * @return a JSON representation
  30604. */
  30605. serialize(): any;
  30606. /**
  30607. * Parses the color curve from a json representation.
  30608. * @param source the JSON source to parse
  30609. * @return The parsed curves
  30610. */
  30611. static Parse(source: any): ColorCurves;
  30612. }
  30613. }
  30614. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  30615. import { Observable } from "babylonjs/Misc/observable";
  30616. import { Nullable } from "babylonjs/types";
  30617. import { Color4 } from "babylonjs/Maths/math";
  30618. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  30619. import { Effect } from "babylonjs/Materials/effect";
  30620. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30621. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  30622. /**
  30623. * Interface to follow in your material defines to integrate easily the
  30624. * Image proccessing functions.
  30625. * @hidden
  30626. */
  30627. export interface IImageProcessingConfigurationDefines {
  30628. IMAGEPROCESSING: boolean;
  30629. VIGNETTE: boolean;
  30630. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30631. VIGNETTEBLENDMODEOPAQUE: boolean;
  30632. TONEMAPPING: boolean;
  30633. TONEMAPPING_ACES: boolean;
  30634. CONTRAST: boolean;
  30635. EXPOSURE: boolean;
  30636. COLORCURVES: boolean;
  30637. COLORGRADING: boolean;
  30638. COLORGRADING3D: boolean;
  30639. SAMPLER3DGREENDEPTH: boolean;
  30640. SAMPLER3DBGRMAP: boolean;
  30641. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30642. }
  30643. /**
  30644. * @hidden
  30645. */
  30646. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  30647. IMAGEPROCESSING: boolean;
  30648. VIGNETTE: boolean;
  30649. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30650. VIGNETTEBLENDMODEOPAQUE: boolean;
  30651. TONEMAPPING: boolean;
  30652. TONEMAPPING_ACES: boolean;
  30653. CONTRAST: boolean;
  30654. COLORCURVES: boolean;
  30655. COLORGRADING: boolean;
  30656. COLORGRADING3D: boolean;
  30657. SAMPLER3DGREENDEPTH: boolean;
  30658. SAMPLER3DBGRMAP: boolean;
  30659. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30660. EXPOSURE: boolean;
  30661. constructor();
  30662. }
  30663. /**
  30664. * This groups together the common properties used for image processing either in direct forward pass
  30665. * or through post processing effect depending on the use of the image processing pipeline in your scene
  30666. * or not.
  30667. */
  30668. export class ImageProcessingConfiguration {
  30669. /**
  30670. * Default tone mapping applied in BabylonJS.
  30671. */
  30672. static readonly TONEMAPPING_STANDARD: number;
  30673. /**
  30674. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  30675. * to other engines rendering to increase portability.
  30676. */
  30677. static readonly TONEMAPPING_ACES: number;
  30678. /**
  30679. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  30680. */
  30681. colorCurves: Nullable<ColorCurves>;
  30682. private _colorCurvesEnabled;
  30683. /**
  30684. * Gets wether the color curves effect is enabled.
  30685. */
  30686. /**
  30687. * Sets wether the color curves effect is enabled.
  30688. */
  30689. colorCurvesEnabled: boolean;
  30690. private _colorGradingTexture;
  30691. /**
  30692. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  30693. */
  30694. /**
  30695. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  30696. */
  30697. colorGradingTexture: Nullable<BaseTexture>;
  30698. private _colorGradingEnabled;
  30699. /**
  30700. * Gets wether the color grading effect is enabled.
  30701. */
  30702. /**
  30703. * Sets wether the color grading effect is enabled.
  30704. */
  30705. colorGradingEnabled: boolean;
  30706. private _colorGradingWithGreenDepth;
  30707. /**
  30708. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  30709. */
  30710. /**
  30711. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  30712. */
  30713. colorGradingWithGreenDepth: boolean;
  30714. private _colorGradingBGR;
  30715. /**
  30716. * Gets wether the color grading texture contains BGR values.
  30717. */
  30718. /**
  30719. * Sets wether the color grading texture contains BGR values.
  30720. */
  30721. colorGradingBGR: boolean;
  30722. /** @hidden */
  30723. _exposure: number;
  30724. /**
  30725. * Gets the Exposure used in the effect.
  30726. */
  30727. /**
  30728. * Sets the Exposure used in the effect.
  30729. */
  30730. exposure: number;
  30731. private _toneMappingEnabled;
  30732. /**
  30733. * Gets wether the tone mapping effect is enabled.
  30734. */
  30735. /**
  30736. * Sets wether the tone mapping effect is enabled.
  30737. */
  30738. toneMappingEnabled: boolean;
  30739. private _toneMappingType;
  30740. /**
  30741. * Gets the type of tone mapping effect.
  30742. */
  30743. /**
  30744. * Sets the type of tone mapping effect used in BabylonJS.
  30745. */
  30746. toneMappingType: number;
  30747. protected _contrast: number;
  30748. /**
  30749. * Gets the contrast used in the effect.
  30750. */
  30751. /**
  30752. * Sets the contrast used in the effect.
  30753. */
  30754. contrast: number;
  30755. /**
  30756. * Vignette stretch size.
  30757. */
  30758. vignetteStretch: number;
  30759. /**
  30760. * Vignette centre X Offset.
  30761. */
  30762. vignetteCentreX: number;
  30763. /**
  30764. * Vignette centre Y Offset.
  30765. */
  30766. vignetteCentreY: number;
  30767. /**
  30768. * Vignette weight or intensity of the vignette effect.
  30769. */
  30770. vignetteWeight: number;
  30771. /**
  30772. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  30773. * if vignetteEnabled is set to true.
  30774. */
  30775. vignetteColor: Color4;
  30776. /**
  30777. * Camera field of view used by the Vignette effect.
  30778. */
  30779. vignetteCameraFov: number;
  30780. private _vignetteBlendMode;
  30781. /**
  30782. * Gets the vignette blend mode allowing different kind of effect.
  30783. */
  30784. /**
  30785. * Sets the vignette blend mode allowing different kind of effect.
  30786. */
  30787. vignetteBlendMode: number;
  30788. private _vignetteEnabled;
  30789. /**
  30790. * Gets wether the vignette effect is enabled.
  30791. */
  30792. /**
  30793. * Sets wether the vignette effect is enabled.
  30794. */
  30795. vignetteEnabled: boolean;
  30796. private _applyByPostProcess;
  30797. /**
  30798. * Gets wether the image processing is applied through a post process or not.
  30799. */
  30800. /**
  30801. * Sets wether the image processing is applied through a post process or not.
  30802. */
  30803. applyByPostProcess: boolean;
  30804. private _isEnabled;
  30805. /**
  30806. * Gets wether the image processing is enabled or not.
  30807. */
  30808. /**
  30809. * Sets wether the image processing is enabled or not.
  30810. */
  30811. isEnabled: boolean;
  30812. /**
  30813. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  30814. */
  30815. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  30816. /**
  30817. * Method called each time the image processing information changes requires to recompile the effect.
  30818. */
  30819. protected _updateParameters(): void;
  30820. /**
  30821. * Gets the current class name.
  30822. * @return "ImageProcessingConfiguration"
  30823. */
  30824. getClassName(): string;
  30825. /**
  30826. * Prepare the list of uniforms associated with the Image Processing effects.
  30827. * @param uniforms The list of uniforms used in the effect
  30828. * @param defines the list of defines currently in use
  30829. */
  30830. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  30831. /**
  30832. * Prepare the list of samplers associated with the Image Processing effects.
  30833. * @param samplersList The list of uniforms used in the effect
  30834. * @param defines the list of defines currently in use
  30835. */
  30836. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  30837. /**
  30838. * Prepare the list of defines associated to the shader.
  30839. * @param defines the list of defines to complete
  30840. * @param forPostProcess Define if we are currently in post process mode or not
  30841. */
  30842. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  30843. /**
  30844. * Returns true if all the image processing information are ready.
  30845. * @returns True if ready, otherwise, false
  30846. */
  30847. isReady(): boolean;
  30848. /**
  30849. * Binds the image processing to the shader.
  30850. * @param effect The effect to bind to
  30851. * @param aspectRatio Define the current aspect ratio of the effect
  30852. */
  30853. bind(effect: Effect, aspectRatio?: number): void;
  30854. /**
  30855. * Clones the current image processing instance.
  30856. * @return The cloned image processing
  30857. */
  30858. clone(): ImageProcessingConfiguration;
  30859. /**
  30860. * Serializes the current image processing instance to a json representation.
  30861. * @return a JSON representation
  30862. */
  30863. serialize(): any;
  30864. /**
  30865. * Parses the image processing from a json representation.
  30866. * @param source the JSON source to parse
  30867. * @return The parsed image processing
  30868. */
  30869. static Parse(source: any): ImageProcessingConfiguration;
  30870. private static _VIGNETTEMODE_MULTIPLY;
  30871. private static _VIGNETTEMODE_OPAQUE;
  30872. /**
  30873. * Used to apply the vignette as a mix with the pixel color.
  30874. */
  30875. static readonly VIGNETTEMODE_MULTIPLY: number;
  30876. /**
  30877. * Used to apply the vignette as a replacement of the pixel color.
  30878. */
  30879. static readonly VIGNETTEMODE_OPAQUE: number;
  30880. }
  30881. }
  30882. declare module "babylonjs/Materials/fresnelParameters" {
  30883. import { Color3 } from "babylonjs/Maths/math";
  30884. /**
  30885. * This represents all the required information to add a fresnel effect on a material:
  30886. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30887. */
  30888. export class FresnelParameters {
  30889. private _isEnabled;
  30890. /**
  30891. * Define if the fresnel effect is enable or not.
  30892. */
  30893. isEnabled: boolean;
  30894. /**
  30895. * Define the color used on edges (grazing angle)
  30896. */
  30897. leftColor: Color3;
  30898. /**
  30899. * Define the color used on center
  30900. */
  30901. rightColor: Color3;
  30902. /**
  30903. * Define bias applied to computed fresnel term
  30904. */
  30905. bias: number;
  30906. /**
  30907. * Defined the power exponent applied to fresnel term
  30908. */
  30909. power: number;
  30910. /**
  30911. * Clones the current fresnel and its valuues
  30912. * @returns a clone fresnel configuration
  30913. */
  30914. clone(): FresnelParameters;
  30915. /**
  30916. * Serializes the current fresnel parameters to a JSON representation.
  30917. * @return the JSON serialization
  30918. */
  30919. serialize(): any;
  30920. /**
  30921. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  30922. * @param parsedFresnelParameters Define the JSON representation
  30923. * @returns the parsed parameters
  30924. */
  30925. static Parse(parsedFresnelParameters: any): FresnelParameters;
  30926. }
  30927. }
  30928. declare module "babylonjs/Misc/decorators" {
  30929. import { Nullable } from "babylonjs/types";
  30930. import { Scene } from "babylonjs/scene";
  30931. import { IAnimatable } from "babylonjs/Misc/tools";
  30932. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  30933. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30934. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30935. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30936. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30937. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30938. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30939. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30940. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30941. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30942. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30943. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30944. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30945. /**
  30946. * Decorator used to define property that can be serialized as reference to a camera
  30947. * @param sourceName defines the name of the property to decorate
  30948. */
  30949. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30950. /**
  30951. * Class used to help serialization objects
  30952. */
  30953. export class SerializationHelper {
  30954. /** hidden */
  30955. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  30956. /** hidden */
  30957. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  30958. /** hidden */
  30959. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  30960. /** hidden */
  30961. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  30962. /**
  30963. * Appends the serialized animations from the source animations
  30964. * @param source Source containing the animations
  30965. * @param destination Target to store the animations
  30966. */
  30967. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30968. /**
  30969. * Static function used to serialized a specific entity
  30970. * @param entity defines the entity to serialize
  30971. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  30972. * @returns a JSON compatible object representing the serialization of the entity
  30973. */
  30974. static Serialize<T>(entity: T, serializationObject?: any): any;
  30975. /**
  30976. * Creates a new entity from a serialization data object
  30977. * @param creationFunction defines a function used to instanciated the new entity
  30978. * @param source defines the source serialization data
  30979. * @param scene defines the hosting scene
  30980. * @param rootUrl defines the root url for resources
  30981. * @returns a new entity
  30982. */
  30983. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  30984. /**
  30985. * Clones an object
  30986. * @param creationFunction defines the function used to instanciate the new object
  30987. * @param source defines the source object
  30988. * @returns the cloned object
  30989. */
  30990. static Clone<T>(creationFunction: () => T, source: T): T;
  30991. /**
  30992. * Instanciates a new object based on a source one (some data will be shared between both object)
  30993. * @param creationFunction defines the function used to instanciate the new object
  30994. * @param source defines the source object
  30995. * @returns the new object
  30996. */
  30997. static Instanciate<T>(creationFunction: () => T, source: T): T;
  30998. }
  30999. }
  31000. declare module "babylonjs/Cameras/camera" {
  31001. import { SmartArray } from "babylonjs/Misc/smartArray";
  31002. import { Observable } from "babylonjs/Misc/observable";
  31003. import { Nullable } from "babylonjs/types";
  31004. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  31005. import { Scene } from "babylonjs/scene";
  31006. import { Matrix, Vector3, Viewport } from "babylonjs/Maths/math";
  31007. import { Node } from "babylonjs/node";
  31008. import { Mesh } from "babylonjs/Meshes/mesh";
  31009. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  31010. import { ICullable } from "babylonjs/Culling/boundingInfo";
  31011. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  31012. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  31013. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  31014. import { Ray } from "babylonjs/Culling/ray";
  31015. /**
  31016. * This is the base class of all the camera used in the application.
  31017. * @see http://doc.babylonjs.com/features/cameras
  31018. */
  31019. export class Camera extends Node {
  31020. /** @hidden */
  31021. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  31022. /**
  31023. * This is the default projection mode used by the cameras.
  31024. * It helps recreating a feeling of perspective and better appreciate depth.
  31025. * This is the best way to simulate real life cameras.
  31026. */
  31027. static readonly PERSPECTIVE_CAMERA: number;
  31028. /**
  31029. * This helps creating camera with an orthographic mode.
  31030. * 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.
  31031. */
  31032. static readonly ORTHOGRAPHIC_CAMERA: number;
  31033. /**
  31034. * This is the default FOV mode for perspective cameras.
  31035. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  31036. */
  31037. static readonly FOVMODE_VERTICAL_FIXED: number;
  31038. /**
  31039. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  31040. */
  31041. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  31042. /**
  31043. * This specifies ther is no need for a camera rig.
  31044. * Basically only one eye is rendered corresponding to the camera.
  31045. */
  31046. static readonly RIG_MODE_NONE: number;
  31047. /**
  31048. * Simulates a camera Rig with one blue eye and one red eye.
  31049. * This can be use with 3d blue and red glasses.
  31050. */
  31051. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  31052. /**
  31053. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  31054. */
  31055. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  31056. /**
  31057. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  31058. */
  31059. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  31060. /**
  31061. * Defines that both eyes of the camera will be rendered over under each other.
  31062. */
  31063. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  31064. /**
  31065. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  31066. */
  31067. static readonly RIG_MODE_VR: number;
  31068. /**
  31069. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  31070. */
  31071. static readonly RIG_MODE_WEBVR: number;
  31072. /**
  31073. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  31074. */
  31075. static readonly RIG_MODE_CUSTOM: number;
  31076. /**
  31077. * Defines if by default attaching controls should prevent the default javascript event to continue.
  31078. */
  31079. static ForceAttachControlToAlwaysPreventDefault: boolean;
  31080. /**
  31081. * Define the input manager associated with the camera.
  31082. */
  31083. inputs: CameraInputsManager<Camera>;
  31084. /** @hidden */
  31085. _position: Vector3;
  31086. /**
  31087. * Define the current local position of the camera in the scene
  31088. */
  31089. position: Vector3;
  31090. /**
  31091. * The vector the camera should consider as up.
  31092. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  31093. */
  31094. upVector: Vector3;
  31095. /**
  31096. * Define the current limit on the left side for an orthographic camera
  31097. * In scene unit
  31098. */
  31099. orthoLeft: Nullable<number>;
  31100. /**
  31101. * Define the current limit on the right side for an orthographic camera
  31102. * In scene unit
  31103. */
  31104. orthoRight: Nullable<number>;
  31105. /**
  31106. * Define the current limit on the bottom side for an orthographic camera
  31107. * In scene unit
  31108. */
  31109. orthoBottom: Nullable<number>;
  31110. /**
  31111. * Define the current limit on the top side for an orthographic camera
  31112. * In scene unit
  31113. */
  31114. orthoTop: Nullable<number>;
  31115. /**
  31116. * Field Of View is set in Radians. (default is 0.8)
  31117. */
  31118. fov: number;
  31119. /**
  31120. * Define the minimum distance the camera can see from.
  31121. * This is important to note that the depth buffer are not infinite and the closer it starts
  31122. * the more your scene might encounter depth fighting issue.
  31123. */
  31124. minZ: number;
  31125. /**
  31126. * Define the maximum distance the camera can see to.
  31127. * This is important to note that the depth buffer are not infinite and the further it end
  31128. * the more your scene might encounter depth fighting issue.
  31129. */
  31130. maxZ: number;
  31131. /**
  31132. * Define the default inertia of the camera.
  31133. * This helps giving a smooth feeling to the camera movement.
  31134. */
  31135. inertia: number;
  31136. /**
  31137. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  31138. */
  31139. mode: number;
  31140. /**
  31141. * Define wether the camera is intermediate.
  31142. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  31143. */
  31144. isIntermediate: boolean;
  31145. /**
  31146. * Define the viewport of the camera.
  31147. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  31148. */
  31149. viewport: Viewport;
  31150. /**
  31151. * Restricts the camera to viewing objects with the same layerMask.
  31152. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  31153. */
  31154. layerMask: number;
  31155. /**
  31156. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  31157. */
  31158. fovMode: number;
  31159. /**
  31160. * Rig mode of the camera.
  31161. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  31162. * This is normally controlled byt the camera themselves as internal use.
  31163. */
  31164. cameraRigMode: number;
  31165. /**
  31166. * Defines the distance between both "eyes" in case of a RIG
  31167. */
  31168. interaxialDistance: number;
  31169. /**
  31170. * Defines if stereoscopic rendering is done side by side or over under.
  31171. */
  31172. isStereoscopicSideBySide: boolean;
  31173. /**
  31174. * 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
  31175. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  31176. * else in the scene.
  31177. */
  31178. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  31179. /**
  31180. * When set, the camera will render to this render target instead of the default canvas
  31181. */
  31182. outputRenderTarget: Nullable<RenderTargetTexture>;
  31183. /**
  31184. * Observable triggered when the camera view matrix has changed.
  31185. */
  31186. onViewMatrixChangedObservable: Observable<Camera>;
  31187. /**
  31188. * Observable triggered when the camera Projection matrix has changed.
  31189. */
  31190. onProjectionMatrixChangedObservable: Observable<Camera>;
  31191. /**
  31192. * Observable triggered when the inputs have been processed.
  31193. */
  31194. onAfterCheckInputsObservable: Observable<Camera>;
  31195. /**
  31196. * Observable triggered when reset has been called and applied to the camera.
  31197. */
  31198. onRestoreStateObservable: Observable<Camera>;
  31199. /** @hidden */
  31200. _cameraRigParams: any;
  31201. /** @hidden */
  31202. _rigCameras: Camera[];
  31203. /** @hidden */
  31204. _rigPostProcess: Nullable<PostProcess>;
  31205. protected _webvrViewMatrix: Matrix;
  31206. /** @hidden */
  31207. _skipRendering: boolean;
  31208. /** @hidden */
  31209. _projectionMatrix: Matrix;
  31210. /** @hidden */
  31211. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  31212. /** @hidden */
  31213. _activeMeshes: SmartArray<AbstractMesh>;
  31214. protected _globalPosition: Vector3;
  31215. /** hidden */
  31216. _computedViewMatrix: Matrix;
  31217. private _doNotComputeProjectionMatrix;
  31218. private _transformMatrix;
  31219. private _frustumPlanes;
  31220. private _refreshFrustumPlanes;
  31221. private _storedFov;
  31222. private _stateStored;
  31223. /**
  31224. * Instantiates a new camera object.
  31225. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  31226. * @see http://doc.babylonjs.com/features/cameras
  31227. * @param name Defines the name of the camera in the scene
  31228. * @param position Defines the position of the camera
  31229. * @param scene Defines the scene the camera belongs too
  31230. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  31231. */
  31232. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  31233. /**
  31234. * Store current camera state (fov, position, etc..)
  31235. * @returns the camera
  31236. */
  31237. storeState(): Camera;
  31238. /**
  31239. * Restores the camera state values if it has been stored. You must call storeState() first
  31240. */
  31241. protected _restoreStateValues(): boolean;
  31242. /**
  31243. * Restored camera state. You must call storeState() first.
  31244. * @returns true if restored and false otherwise
  31245. */
  31246. restoreState(): boolean;
  31247. /**
  31248. * Gets the class name of the camera.
  31249. * @returns the class name
  31250. */
  31251. getClassName(): string;
  31252. /** @hidden */
  31253. readonly _isCamera: boolean;
  31254. /**
  31255. * Gets a string representation of the camera useful for debug purpose.
  31256. * @param fullDetails Defines that a more verboe level of logging is required
  31257. * @returns the string representation
  31258. */
  31259. toString(fullDetails?: boolean): string;
  31260. /**
  31261. * Gets the current world space position of the camera.
  31262. */
  31263. readonly globalPosition: Vector3;
  31264. /**
  31265. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  31266. * @returns the active meshe list
  31267. */
  31268. getActiveMeshes(): SmartArray<AbstractMesh>;
  31269. /**
  31270. * Check wether a mesh is part of the current active mesh list of the camera
  31271. * @param mesh Defines the mesh to check
  31272. * @returns true if active, false otherwise
  31273. */
  31274. isActiveMesh(mesh: Mesh): boolean;
  31275. /**
  31276. * Is this camera ready to be used/rendered
  31277. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  31278. * @return true if the camera is ready
  31279. */
  31280. isReady(completeCheck?: boolean): boolean;
  31281. /** @hidden */
  31282. _initCache(): void;
  31283. /** @hidden */
  31284. _updateCache(ignoreParentClass?: boolean): void;
  31285. /** @hidden */
  31286. _isSynchronized(): boolean;
  31287. /** @hidden */
  31288. _isSynchronizedViewMatrix(): boolean;
  31289. /** @hidden */
  31290. _isSynchronizedProjectionMatrix(): boolean;
  31291. /**
  31292. * Attach the input controls to a specific dom element to get the input from.
  31293. * @param element Defines the element the controls should be listened from
  31294. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  31295. */
  31296. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  31297. /**
  31298. * Detach the current controls from the specified dom element.
  31299. * @param element Defines the element to stop listening the inputs from
  31300. */
  31301. detachControl(element: HTMLElement): void;
  31302. /**
  31303. * Update the camera state according to the different inputs gathered during the frame.
  31304. */
  31305. update(): void;
  31306. /** @hidden */
  31307. _checkInputs(): void;
  31308. /** @hidden */
  31309. readonly rigCameras: Camera[];
  31310. /**
  31311. * Gets the post process used by the rig cameras
  31312. */
  31313. readonly rigPostProcess: Nullable<PostProcess>;
  31314. /**
  31315. * Internal, gets the first post proces.
  31316. * @returns the first post process to be run on this camera.
  31317. */
  31318. _getFirstPostProcess(): Nullable<PostProcess>;
  31319. private _cascadePostProcessesToRigCams;
  31320. /**
  31321. * Attach a post process to the camera.
  31322. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  31323. * @param postProcess The post process to attach to the camera
  31324. * @param insertAt The position of the post process in case several of them are in use in the scene
  31325. * @returns the position the post process has been inserted at
  31326. */
  31327. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  31328. /**
  31329. * Detach a post process to the camera.
  31330. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  31331. * @param postProcess The post process to detach from the camera
  31332. */
  31333. detachPostProcess(postProcess: PostProcess): void;
  31334. /**
  31335. * Gets the current world matrix of the camera
  31336. */
  31337. getWorldMatrix(): Matrix;
  31338. /** @hidden */
  31339. _getViewMatrix(): Matrix;
  31340. /**
  31341. * Gets the current view matrix of the camera.
  31342. * @param force forces the camera to recompute the matrix without looking at the cached state
  31343. * @returns the view matrix
  31344. */
  31345. getViewMatrix(force?: boolean): Matrix;
  31346. /**
  31347. * Freeze the projection matrix.
  31348. * It will prevent the cache check of the camera projection compute and can speed up perf
  31349. * if no parameter of the camera are meant to change
  31350. * @param projection Defines manually a projection if necessary
  31351. */
  31352. freezeProjectionMatrix(projection?: Matrix): void;
  31353. /**
  31354. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  31355. */
  31356. unfreezeProjectionMatrix(): void;
  31357. /**
  31358. * Gets the current projection matrix of the camera.
  31359. * @param force forces the camera to recompute the matrix without looking at the cached state
  31360. * @returns the projection matrix
  31361. */
  31362. getProjectionMatrix(force?: boolean): Matrix;
  31363. /**
  31364. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  31365. * @returns a Matrix
  31366. */
  31367. getTransformationMatrix(): Matrix;
  31368. private _updateFrustumPlanes;
  31369. /**
  31370. * Checks if a cullable object (mesh...) is in the camera frustum
  31371. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  31372. * @param target The object to check
  31373. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  31374. * @returns true if the object is in frustum otherwise false
  31375. */
  31376. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  31377. /**
  31378. * Checks if a cullable object (mesh...) is in the camera frustum
  31379. * Unlike isInFrustum this cheks the full bounding box
  31380. * @param target The object to check
  31381. * @returns true if the object is in frustum otherwise false
  31382. */
  31383. isCompletelyInFrustum(target: ICullable): boolean;
  31384. /**
  31385. * Gets a ray in the forward direction from the camera.
  31386. * @param length Defines the length of the ray to create
  31387. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  31388. * @param origin Defines the start point of the ray which defaults to the camera position
  31389. * @returns the forward ray
  31390. */
  31391. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  31392. /**
  31393. * Releases resources associated with this node.
  31394. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  31395. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  31396. */
  31397. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  31398. /** @hidden */
  31399. _isLeftCamera: boolean;
  31400. /**
  31401. * Gets the left camera of a rig setup in case of Rigged Camera
  31402. */
  31403. readonly isLeftCamera: boolean;
  31404. /** @hidden */
  31405. _isRightCamera: boolean;
  31406. /**
  31407. * Gets the right camera of a rig setup in case of Rigged Camera
  31408. */
  31409. readonly isRightCamera: boolean;
  31410. /**
  31411. * Gets the left camera of a rig setup in case of Rigged Camera
  31412. */
  31413. readonly leftCamera: Nullable<FreeCamera>;
  31414. /**
  31415. * Gets the right camera of a rig setup in case of Rigged Camera
  31416. */
  31417. readonly rightCamera: Nullable<FreeCamera>;
  31418. /**
  31419. * Gets the left camera target of a rig setup in case of Rigged Camera
  31420. * @returns the target position
  31421. */
  31422. getLeftTarget(): Nullable<Vector3>;
  31423. /**
  31424. * Gets the right camera target of a rig setup in case of Rigged Camera
  31425. * @returns the target position
  31426. */
  31427. getRightTarget(): Nullable<Vector3>;
  31428. /**
  31429. * @hidden
  31430. */
  31431. setCameraRigMode(mode: number, rigParams: any): void;
  31432. /** @hidden */
  31433. static _setStereoscopicRigMode(camera: Camera): void;
  31434. /** @hidden */
  31435. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  31436. /** @hidden */
  31437. static _setVRRigMode(camera: Camera, rigParams: any): void;
  31438. /** @hidden */
  31439. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  31440. /** @hidden */
  31441. _getVRProjectionMatrix(): Matrix;
  31442. protected _updateCameraRotationMatrix(): void;
  31443. protected _updateWebVRCameraRotationMatrix(): void;
  31444. /**
  31445. * This function MUST be overwritten by the different WebVR cameras available.
  31446. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  31447. * @hidden
  31448. */
  31449. _getWebVRProjectionMatrix(): Matrix;
  31450. /**
  31451. * This function MUST be overwritten by the different WebVR cameras available.
  31452. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  31453. * @hidden
  31454. */
  31455. _getWebVRViewMatrix(): Matrix;
  31456. /** @hidden */
  31457. setCameraRigParameter(name: string, value: any): void;
  31458. /**
  31459. * needs to be overridden by children so sub has required properties to be copied
  31460. * @hidden
  31461. */
  31462. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  31463. /**
  31464. * May need to be overridden by children
  31465. * @hidden
  31466. */
  31467. _updateRigCameras(): void;
  31468. /** @hidden */
  31469. _setupInputs(): void;
  31470. /**
  31471. * Serialiaze the camera setup to a json represention
  31472. * @returns the JSON representation
  31473. */
  31474. serialize(): any;
  31475. /**
  31476. * Clones the current camera.
  31477. * @param name The cloned camera name
  31478. * @returns the cloned camera
  31479. */
  31480. clone(name: string): Camera;
  31481. /**
  31482. * Gets the direction of the camera relative to a given local axis.
  31483. * @param localAxis Defines the reference axis to provide a relative direction.
  31484. * @return the direction
  31485. */
  31486. getDirection(localAxis: Vector3): Vector3;
  31487. /**
  31488. * Gets the direction of the camera relative to a given local axis into a passed vector.
  31489. * @param localAxis Defines the reference axis to provide a relative direction.
  31490. * @param result Defines the vector to store the result in
  31491. */
  31492. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  31493. /**
  31494. * Gets a camera constructor for a given camera type
  31495. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  31496. * @param name The name of the camera the result will be able to instantiate
  31497. * @param scene The scene the result will construct the camera in
  31498. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  31499. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  31500. * @returns a factory method to construc the camera
  31501. */
  31502. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  31503. /**
  31504. * Compute the world matrix of the camera.
  31505. * @returns the camera workd matrix
  31506. */
  31507. computeWorldMatrix(): Matrix;
  31508. /**
  31509. * Parse a JSON and creates the camera from the parsed information
  31510. * @param parsedCamera The JSON to parse
  31511. * @param scene The scene to instantiate the camera in
  31512. * @returns the newly constructed camera
  31513. */
  31514. static Parse(parsedCamera: any, scene: Scene): Camera;
  31515. }
  31516. }
  31517. declare module "babylonjs/Misc/tools" {
  31518. import { FloatArray, IndicesArray, Nullable } from "babylonjs/types";
  31519. import { Color4, Color3, Vector2, Vector3 } from "babylonjs/Maths/math";
  31520. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  31521. import { Observable } from "babylonjs/Misc/observable";
  31522. import { DomManagement } from "babylonjs/Misc/domManagement";
  31523. import { WebRequest } from "babylonjs/Misc/webRequest";
  31524. import { Camera } from "babylonjs/Cameras/camera";
  31525. import { Engine } from "babylonjs/Engines/engine";
  31526. import { Animation } from "babylonjs/Animations/animation";
  31527. /**
  31528. * Interface for any object that can request an animation frame
  31529. */
  31530. export interface ICustomAnimationFrameRequester {
  31531. /**
  31532. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  31533. */
  31534. renderFunction?: Function;
  31535. /**
  31536. * Called to request the next frame to render to
  31537. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  31538. */
  31539. requestAnimationFrame: Function;
  31540. /**
  31541. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  31542. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  31543. */
  31544. requestID?: number;
  31545. }
  31546. /**
  31547. * Interface containing an array of animations
  31548. */
  31549. export interface IAnimatable {
  31550. /**
  31551. * Array of animations
  31552. */
  31553. animations: Nullable<Array<Animation>>;
  31554. }
  31555. /** Interface used by value gradients (color, factor, ...) */
  31556. export interface IValueGradient {
  31557. /**
  31558. * Gets or sets the gradient value (between 0 and 1)
  31559. */
  31560. gradient: number;
  31561. }
  31562. /** Class used to store color4 gradient */
  31563. export class ColorGradient implements IValueGradient {
  31564. /**
  31565. * Gets or sets the gradient value (between 0 and 1)
  31566. */
  31567. gradient: number;
  31568. /**
  31569. * Gets or sets first associated color
  31570. */
  31571. color1: Color4;
  31572. /**
  31573. * Gets or sets second associated color
  31574. */
  31575. color2?: Color4;
  31576. /**
  31577. * Will get a color picked randomly between color1 and color2.
  31578. * If color2 is undefined then color1 will be used
  31579. * @param result defines the target Color4 to store the result in
  31580. */
  31581. getColorToRef(result: Color4): void;
  31582. }
  31583. /** Class used to store color 3 gradient */
  31584. export class Color3Gradient implements IValueGradient {
  31585. /**
  31586. * Gets or sets the gradient value (between 0 and 1)
  31587. */
  31588. gradient: number;
  31589. /**
  31590. * Gets or sets the associated color
  31591. */
  31592. color: Color3;
  31593. }
  31594. /** Class used to store factor gradient */
  31595. export class FactorGradient implements IValueGradient {
  31596. /**
  31597. * Gets or sets the gradient value (between 0 and 1)
  31598. */
  31599. gradient: number;
  31600. /**
  31601. * Gets or sets first associated factor
  31602. */
  31603. factor1: number;
  31604. /**
  31605. * Gets or sets second associated factor
  31606. */
  31607. factor2?: number;
  31608. /**
  31609. * Will get a number picked randomly between factor1 and factor2.
  31610. * If factor2 is undefined then factor1 will be used
  31611. * @returns the picked number
  31612. */
  31613. getFactor(): number;
  31614. }
  31615. /**
  31616. * @ignore
  31617. * Application error to support additional information when loading a file
  31618. */
  31619. export class LoadFileError extends Error {
  31620. /** defines the optional web request */
  31621. request?: WebRequest | undefined;
  31622. private static _setPrototypeOf;
  31623. /**
  31624. * Creates a new LoadFileError
  31625. * @param message defines the message of the error
  31626. * @param request defines the optional web request
  31627. */
  31628. constructor(message: string,
  31629. /** defines the optional web request */
  31630. request?: WebRequest | undefined);
  31631. }
  31632. /**
  31633. * Class used to define a retry strategy when error happens while loading assets
  31634. */
  31635. export class RetryStrategy {
  31636. /**
  31637. * Function used to defines an exponential back off strategy
  31638. * @param maxRetries defines the maximum number of retries (3 by default)
  31639. * @param baseInterval defines the interval between retries
  31640. * @returns the strategy function to use
  31641. */
  31642. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  31643. }
  31644. /**
  31645. * File request interface
  31646. */
  31647. export interface IFileRequest {
  31648. /**
  31649. * Raised when the request is complete (success or error).
  31650. */
  31651. onCompleteObservable: Observable<IFileRequest>;
  31652. /**
  31653. * Aborts the request for a file.
  31654. */
  31655. abort: () => void;
  31656. }
  31657. /**
  31658. * Class containing a set of static utilities functions
  31659. */
  31660. export class Tools {
  31661. /**
  31662. * Gets or sets the base URL to use to load assets
  31663. */
  31664. static BaseUrl: string;
  31665. /**
  31666. * Enable/Disable Custom HTTP Request Headers globally.
  31667. * default = false
  31668. * @see CustomRequestHeaders
  31669. */
  31670. static UseCustomRequestHeaders: boolean;
  31671. /**
  31672. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  31673. * i.e. when loading files, where the server/service expects an Authorization header
  31674. */
  31675. static CustomRequestHeaders: {
  31676. [key: string]: string;
  31677. };
  31678. /**
  31679. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  31680. */
  31681. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  31682. /**
  31683. * Default behaviour for cors in the application.
  31684. * It can be a string if the expected behavior is identical in the entire app.
  31685. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  31686. */
  31687. static CorsBehavior: string | ((url: string | string[]) => string);
  31688. /**
  31689. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  31690. * @ignorenaming
  31691. */
  31692. static UseFallbackTexture: boolean;
  31693. /**
  31694. * Use this object to register external classes like custom textures or material
  31695. * to allow the laoders to instantiate them
  31696. */
  31697. static RegisteredExternalClasses: {
  31698. [key: string]: Object;
  31699. };
  31700. /**
  31701. * Texture content used if a texture cannot loaded
  31702. * @ignorenaming
  31703. */
  31704. static fallbackTexture: string;
  31705. /**
  31706. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  31707. * @param u defines the coordinate on X axis
  31708. * @param v defines the coordinate on Y axis
  31709. * @param width defines the width of the source data
  31710. * @param height defines the height of the source data
  31711. * @param pixels defines the source byte array
  31712. * @param color defines the output color
  31713. */
  31714. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  31715. /**
  31716. * Interpolates between a and b via alpha
  31717. * @param a The lower value (returned when alpha = 0)
  31718. * @param b The upper value (returned when alpha = 1)
  31719. * @param alpha The interpolation-factor
  31720. * @return The mixed value
  31721. */
  31722. static Mix(a: number, b: number, alpha: number): number;
  31723. /**
  31724. * Tries to instantiate a new object from a given class name
  31725. * @param className defines the class name to instantiate
  31726. * @returns the new object or null if the system was not able to do the instantiation
  31727. */
  31728. static Instantiate(className: string): any;
  31729. /**
  31730. * Provides a slice function that will work even on IE
  31731. * @param data defines the array to slice
  31732. * @param start defines the start of the data (optional)
  31733. * @param end defines the end of the data (optional)
  31734. * @returns the new sliced array
  31735. */
  31736. static Slice<T>(data: T, start?: number, end?: number): T;
  31737. /**
  31738. * Polyfill for setImmediate
  31739. * @param action defines the action to execute after the current execution block
  31740. */
  31741. static SetImmediate(action: () => void): void;
  31742. /**
  31743. * Function indicating if a number is an exponent of 2
  31744. * @param value defines the value to test
  31745. * @returns true if the value is an exponent of 2
  31746. */
  31747. static IsExponentOfTwo(value: number): boolean;
  31748. private static _tmpFloatArray;
  31749. /**
  31750. * Returns the nearest 32-bit single precision float representation of a Number
  31751. * @param value A Number. If the parameter is of a different type, it will get converted
  31752. * to a number or to NaN if it cannot be converted
  31753. * @returns number
  31754. */
  31755. static FloatRound(value: number): number;
  31756. /**
  31757. * Find the next highest power of two.
  31758. * @param x Number to start search from.
  31759. * @return Next highest power of two.
  31760. */
  31761. static CeilingPOT(x: number): number;
  31762. /**
  31763. * Find the next lowest power of two.
  31764. * @param x Number to start search from.
  31765. * @return Next lowest power of two.
  31766. */
  31767. static FloorPOT(x: number): number;
  31768. /**
  31769. * Find the nearest power of two.
  31770. * @param x Number to start search from.
  31771. * @return Next nearest power of two.
  31772. */
  31773. static NearestPOT(x: number): number;
  31774. /**
  31775. * Get the closest exponent of two
  31776. * @param value defines the value to approximate
  31777. * @param max defines the maximum value to return
  31778. * @param mode defines how to define the closest value
  31779. * @returns closest exponent of two of the given value
  31780. */
  31781. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  31782. /**
  31783. * Extracts the filename from a path
  31784. * @param path defines the path to use
  31785. * @returns the filename
  31786. */
  31787. static GetFilename(path: string): string;
  31788. /**
  31789. * Extracts the "folder" part of a path (everything before the filename).
  31790. * @param uri The URI to extract the info from
  31791. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  31792. * @returns The "folder" part of the path
  31793. */
  31794. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  31795. /**
  31796. * Extracts text content from a DOM element hierarchy
  31797. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  31798. */
  31799. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  31800. /**
  31801. * Convert an angle in radians to degrees
  31802. * @param angle defines the angle to convert
  31803. * @returns the angle in degrees
  31804. */
  31805. static ToDegrees(angle: number): number;
  31806. /**
  31807. * Convert an angle in degrees to radians
  31808. * @param angle defines the angle to convert
  31809. * @returns the angle in radians
  31810. */
  31811. static ToRadians(angle: number): number;
  31812. /**
  31813. * Encode a buffer to a base64 string
  31814. * @param buffer defines the buffer to encode
  31815. * @returns the encoded string
  31816. */
  31817. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  31818. /**
  31819. * Extracts minimum and maximum values from a list of indexed positions
  31820. * @param positions defines the positions to use
  31821. * @param indices defines the indices to the positions
  31822. * @param indexStart defines the start index
  31823. * @param indexCount defines the end index
  31824. * @param bias defines bias value to add to the result
  31825. * @return minimum and maximum values
  31826. */
  31827. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  31828. minimum: Vector3;
  31829. maximum: Vector3;
  31830. };
  31831. /**
  31832. * Extracts minimum and maximum values from a list of positions
  31833. * @param positions defines the positions to use
  31834. * @param start defines the start index in the positions array
  31835. * @param count defines the number of positions to handle
  31836. * @param bias defines bias value to add to the result
  31837. * @param stride defines the stride size to use (distance between two positions in the positions array)
  31838. * @return minimum and maximum values
  31839. */
  31840. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  31841. minimum: Vector3;
  31842. maximum: Vector3;
  31843. };
  31844. /**
  31845. * Returns an array if obj is not an array
  31846. * @param obj defines the object to evaluate as an array
  31847. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  31848. * @returns either obj directly if obj is an array or a new array containing obj
  31849. */
  31850. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  31851. /**
  31852. * Gets the pointer prefix to use
  31853. * @returns "pointer" if touch is enabled. Else returns "mouse"
  31854. */
  31855. static GetPointerPrefix(): string;
  31856. /**
  31857. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  31858. * @param func - the function to be called
  31859. * @param requester - the object that will request the next frame. Falls back to window.
  31860. * @returns frame number
  31861. */
  31862. static QueueNewFrame(func: () => void, requester?: any): number;
  31863. /**
  31864. * Ask the browser to promote the current element to fullscreen rendering mode
  31865. * @param element defines the DOM element to promote
  31866. */
  31867. static RequestFullscreen(element: HTMLElement): void;
  31868. /**
  31869. * Asks the browser to exit fullscreen mode
  31870. */
  31871. static ExitFullscreen(): void;
  31872. /**
  31873. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  31874. * @param url define the url we are trying
  31875. * @param element define the dom element where to configure the cors policy
  31876. */
  31877. static SetCorsBehavior(url: string | string[], element: {
  31878. crossOrigin: string | null;
  31879. }): void;
  31880. /**
  31881. * Removes unwanted characters from an url
  31882. * @param url defines the url to clean
  31883. * @returns the cleaned url
  31884. */
  31885. static CleanUrl(url: string): string;
  31886. /**
  31887. * Gets or sets a function used to pre-process url before using them to load assets
  31888. */
  31889. static PreprocessUrl: (url: string) => string;
  31890. /**
  31891. * Loads an image as an HTMLImageElement.
  31892. * @param input url string, ArrayBuffer, or Blob to load
  31893. * @param onLoad callback called when the image successfully loads
  31894. * @param onError callback called when the image fails to load
  31895. * @param offlineProvider offline provider for caching
  31896. * @returns the HTMLImageElement of the loaded image
  31897. */
  31898. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  31899. /**
  31900. * Loads a file
  31901. * @param url url string, ArrayBuffer, or Blob to load
  31902. * @param onSuccess callback called when the file successfully loads
  31903. * @param onProgress callback called while file is loading (if the server supports this mode)
  31904. * @param offlineProvider defines the offline provider for caching
  31905. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  31906. * @param onError callback called when the file fails to load
  31907. * @returns a file request object
  31908. */
  31909. 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;
  31910. /**
  31911. * Load a script (identified by an url). When the url returns, the
  31912. * content of this file is added into a new script element, attached to the DOM (body element)
  31913. * @param scriptUrl defines the url of the script to laod
  31914. * @param onSuccess defines the callback called when the script is loaded
  31915. * @param onError defines the callback to call if an error occurs
  31916. * @param scriptId defines the id of the script element
  31917. */
  31918. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  31919. /**
  31920. * Load an asynchronous script (identified by an url). When the url returns, the
  31921. * content of this file is added into a new script element, attached to the DOM (body element)
  31922. * @param scriptUrl defines the url of the script to laod
  31923. * @param scriptId defines the id of the script element
  31924. * @returns a promise request object
  31925. */
  31926. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Nullable<Promise<boolean>>;
  31927. /**
  31928. * Loads a file from a blob
  31929. * @param fileToLoad defines the blob to use
  31930. * @param callback defines the callback to call when data is loaded
  31931. * @param progressCallback defines the callback to call during loading process
  31932. * @returns a file request object
  31933. */
  31934. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  31935. /**
  31936. * Loads a file
  31937. * @param fileToLoad defines the file to load
  31938. * @param callback defines the callback to call when data is loaded
  31939. * @param progressCallBack defines the callback to call during loading process
  31940. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  31941. * @returns a file request object
  31942. */
  31943. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  31944. /**
  31945. * Creates a data url from a given string content
  31946. * @param content defines the content to convert
  31947. * @returns the new data url link
  31948. */
  31949. static FileAsURL(content: string): string;
  31950. /**
  31951. * Format the given number to a specific decimal format
  31952. * @param value defines the number to format
  31953. * @param decimals defines the number of decimals to use
  31954. * @returns the formatted string
  31955. */
  31956. static Format(value: number, decimals?: number): string;
  31957. /**
  31958. * Checks if a given vector is inside a specific range
  31959. * @param v defines the vector to test
  31960. * @param min defines the minimum range
  31961. * @param max defines the maximum range
  31962. */
  31963. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  31964. /**
  31965. * Tries to copy an object by duplicating every property
  31966. * @param source defines the source object
  31967. * @param destination defines the target object
  31968. * @param doNotCopyList defines a list of properties to avoid
  31969. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  31970. */
  31971. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  31972. /**
  31973. * Gets a boolean indicating if the given object has no own property
  31974. * @param obj defines the object to test
  31975. * @returns true if object has no own property
  31976. */
  31977. static IsEmpty(obj: any): boolean;
  31978. /**
  31979. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  31980. * @param str Source string
  31981. * @param suffix Suffix to search for in the source string
  31982. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  31983. */
  31984. static EndsWith(str: string, suffix: string): boolean;
  31985. /**
  31986. * Function used to register events at window level
  31987. * @param events defines the events to register
  31988. */
  31989. static RegisterTopRootEvents(events: {
  31990. name: string;
  31991. handler: Nullable<(e: FocusEvent) => any>;
  31992. }[]): void;
  31993. /**
  31994. * Function used to unregister events from window level
  31995. * @param events defines the events to unregister
  31996. */
  31997. static UnregisterTopRootEvents(events: {
  31998. name: string;
  31999. handler: Nullable<(e: FocusEvent) => any>;
  32000. }[]): void;
  32001. /**
  32002. * @ignore
  32003. */
  32004. static _ScreenshotCanvas: HTMLCanvasElement;
  32005. /**
  32006. * Dumps the current bound framebuffer
  32007. * @param width defines the rendering width
  32008. * @param height defines the rendering height
  32009. * @param engine defines the hosting engine
  32010. * @param successCallback defines the callback triggered once the data are available
  32011. * @param mimeType defines the mime type of the result
  32012. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  32013. */
  32014. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  32015. /**
  32016. * Converts the canvas data to blob.
  32017. * This acts as a polyfill for browsers not supporting the to blob function.
  32018. * @param canvas Defines the canvas to extract the data from
  32019. * @param successCallback Defines the callback triggered once the data are available
  32020. * @param mimeType Defines the mime type of the result
  32021. */
  32022. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  32023. /**
  32024. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  32025. * @param successCallback defines the callback triggered once the data are available
  32026. * @param mimeType defines the mime type of the result
  32027. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  32028. */
  32029. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  32030. /**
  32031. * Downloads a blob in the browser
  32032. * @param blob defines the blob to download
  32033. * @param fileName defines the name of the downloaded file
  32034. */
  32035. static Download(blob: Blob, fileName: string): void;
  32036. /**
  32037. * Captures a screenshot of the current rendering
  32038. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32039. * @param engine defines the rendering engine
  32040. * @param camera defines the source camera
  32041. * @param size This parameter can be set to a single number or to an object with the
  32042. * following (optional) properties: precision, width, height. If a single number is passed,
  32043. * it will be used for both width and height. If an object is passed, the screenshot size
  32044. * will be derived from the parameters. The precision property is a multiplier allowing
  32045. * rendering at a higher or lower resolution
  32046. * @param successCallback defines the callback receives a single parameter which contains the
  32047. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32048. * src parameter of an <img> to display it
  32049. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  32050. * Check your browser for supported MIME types
  32051. */
  32052. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  32053. /**
  32054. * Generates an image screenshot from the specified camera.
  32055. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32056. * @param engine The engine to use for rendering
  32057. * @param camera The camera to use for rendering
  32058. * @param size This parameter can be set to a single number or to an object with the
  32059. * following (optional) properties: precision, width, height. If a single number is passed,
  32060. * it will be used for both width and height. If an object is passed, the screenshot size
  32061. * will be derived from the parameters. The precision property is a multiplier allowing
  32062. * rendering at a higher or lower resolution
  32063. * @param successCallback The callback receives a single parameter which contains the
  32064. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32065. * src parameter of an <img> to display it
  32066. * @param mimeType The MIME type of the screenshot image (default: image/png).
  32067. * Check your browser for supported MIME types
  32068. * @param samples Texture samples (default: 1)
  32069. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  32070. * @param fileName A name for for the downloaded file.
  32071. */
  32072. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  32073. /**
  32074. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  32075. * Be aware Math.random() could cause collisions, but:
  32076. * "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"
  32077. * @returns a pseudo random id
  32078. */
  32079. static RandomId(): string;
  32080. /**
  32081. * Test if the given uri is a base64 string
  32082. * @param uri The uri to test
  32083. * @return True if the uri is a base64 string or false otherwise
  32084. */
  32085. static IsBase64(uri: string): boolean;
  32086. /**
  32087. * Decode the given base64 uri.
  32088. * @param uri The uri to decode
  32089. * @return The decoded base64 data.
  32090. */
  32091. static DecodeBase64(uri: string): ArrayBuffer;
  32092. /**
  32093. * Gets the absolute url.
  32094. * @param url the input url
  32095. * @return the absolute url
  32096. */
  32097. static GetAbsoluteUrl(url: string): string;
  32098. /**
  32099. * No log
  32100. */
  32101. static readonly NoneLogLevel: number;
  32102. /**
  32103. * Only message logs
  32104. */
  32105. static readonly MessageLogLevel: number;
  32106. /**
  32107. * Only warning logs
  32108. */
  32109. static readonly WarningLogLevel: number;
  32110. /**
  32111. * Only error logs
  32112. */
  32113. static readonly ErrorLogLevel: number;
  32114. /**
  32115. * All logs
  32116. */
  32117. static readonly AllLogLevel: number;
  32118. /**
  32119. * Gets a value indicating the number of loading errors
  32120. * @ignorenaming
  32121. */
  32122. static readonly errorsCount: number;
  32123. /**
  32124. * Callback called when a new log is added
  32125. */
  32126. static OnNewCacheEntry: (entry: string) => void;
  32127. /**
  32128. * Log a message to the console
  32129. * @param message defines the message to log
  32130. */
  32131. static Log(message: string): void;
  32132. /**
  32133. * Write a warning message to the console
  32134. * @param message defines the message to log
  32135. */
  32136. static Warn(message: string): void;
  32137. /**
  32138. * Write an error message to the console
  32139. * @param message defines the message to log
  32140. */
  32141. static Error(message: string): void;
  32142. /**
  32143. * Gets current log cache (list of logs)
  32144. */
  32145. static readonly LogCache: string;
  32146. /**
  32147. * Clears the log cache
  32148. */
  32149. static ClearLogCache(): void;
  32150. /**
  32151. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  32152. */
  32153. static LogLevels: number;
  32154. /**
  32155. * Checks if the loaded document was accessed via `file:`-Protocol.
  32156. * @returns boolean
  32157. */
  32158. static IsFileURL(): boolean;
  32159. /**
  32160. * Checks if the window object exists
  32161. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  32162. */
  32163. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  32164. /**
  32165. * No performance log
  32166. */
  32167. static readonly PerformanceNoneLogLevel: number;
  32168. /**
  32169. * Use user marks to log performance
  32170. */
  32171. static readonly PerformanceUserMarkLogLevel: number;
  32172. /**
  32173. * Log performance to the console
  32174. */
  32175. static readonly PerformanceConsoleLogLevel: number;
  32176. private static _performance;
  32177. /**
  32178. * Sets the current performance log level
  32179. */
  32180. static PerformanceLogLevel: number;
  32181. private static _StartPerformanceCounterDisabled;
  32182. private static _EndPerformanceCounterDisabled;
  32183. private static _StartUserMark;
  32184. private static _EndUserMark;
  32185. private static _StartPerformanceConsole;
  32186. private static _EndPerformanceConsole;
  32187. /**
  32188. * Starts a performance counter
  32189. */
  32190. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32191. /**
  32192. * Ends a specific performance coutner
  32193. */
  32194. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32195. /**
  32196. * Gets either window.performance.now() if supported or Date.now() else
  32197. */
  32198. static readonly Now: number;
  32199. /**
  32200. * This method will return the name of the class used to create the instance of the given object.
  32201. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  32202. * @param object the object to get the class name from
  32203. * @param isType defines if the object is actually a type
  32204. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  32205. */
  32206. static GetClassName(object: any, isType?: boolean): string;
  32207. /**
  32208. * Gets the first element of an array satisfying a given predicate
  32209. * @param array defines the array to browse
  32210. * @param predicate defines the predicate to use
  32211. * @returns null if not found or the element
  32212. */
  32213. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  32214. /**
  32215. * This method will return the name of the full name of the class, including its owning module (if any).
  32216. * 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).
  32217. * @param object the object to get the class name from
  32218. * @param isType defines if the object is actually a type
  32219. * @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.
  32220. * @ignorenaming
  32221. */
  32222. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  32223. /**
  32224. * Returns a promise that resolves after the given amount of time.
  32225. * @param delay Number of milliseconds to delay
  32226. * @returns Promise that resolves after the given amount of time
  32227. */
  32228. static DelayAsync(delay: number): Promise<void>;
  32229. /**
  32230. * Gets the current gradient from an array of IValueGradient
  32231. * @param ratio defines the current ratio to get
  32232. * @param gradients defines the array of IValueGradient
  32233. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  32234. */
  32235. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  32236. }
  32237. /**
  32238. * This class is used to track a performance counter which is number based.
  32239. * The user has access to many properties which give statistics of different nature.
  32240. *
  32241. * The implementer can track two kinds of Performance Counter: time and count.
  32242. * 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.
  32243. * 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.
  32244. */
  32245. export class PerfCounter {
  32246. /**
  32247. * Gets or sets a global boolean to turn on and off all the counters
  32248. */
  32249. static Enabled: boolean;
  32250. /**
  32251. * Returns the smallest value ever
  32252. */
  32253. readonly min: number;
  32254. /**
  32255. * Returns the biggest value ever
  32256. */
  32257. readonly max: number;
  32258. /**
  32259. * Returns the average value since the performance counter is running
  32260. */
  32261. readonly average: number;
  32262. /**
  32263. * Returns the average value of the last second the counter was monitored
  32264. */
  32265. readonly lastSecAverage: number;
  32266. /**
  32267. * Returns the current value
  32268. */
  32269. readonly current: number;
  32270. /**
  32271. * Gets the accumulated total
  32272. */
  32273. readonly total: number;
  32274. /**
  32275. * Gets the total value count
  32276. */
  32277. readonly count: number;
  32278. /**
  32279. * Creates a new counter
  32280. */
  32281. constructor();
  32282. /**
  32283. * Call this method to start monitoring a new frame.
  32284. * 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.
  32285. */
  32286. fetchNewFrame(): void;
  32287. /**
  32288. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  32289. * @param newCount the count value to add to the monitored count
  32290. * @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.
  32291. */
  32292. addCount(newCount: number, fetchResult: boolean): void;
  32293. /**
  32294. * Start monitoring this performance counter
  32295. */
  32296. beginMonitoring(): void;
  32297. /**
  32298. * Compute the time lapsed since the previous beginMonitoring() call.
  32299. * @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
  32300. */
  32301. endMonitoring(newFrame?: boolean): void;
  32302. private _fetchResult;
  32303. private _startMonitoringTime;
  32304. private _min;
  32305. private _max;
  32306. private _average;
  32307. private _current;
  32308. private _totalValueCount;
  32309. private _totalAccumulated;
  32310. private _lastSecAverage;
  32311. private _lastSecAccumulated;
  32312. private _lastSecTime;
  32313. private _lastSecValueCount;
  32314. }
  32315. /**
  32316. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  32317. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  32318. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  32319. * @param name The name of the class, case should be preserved
  32320. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  32321. */
  32322. export function className(name: string, module?: string): (target: Object) => void;
  32323. /**
  32324. * An implementation of a loop for asynchronous functions.
  32325. */
  32326. export class AsyncLoop {
  32327. /**
  32328. * Defines the number of iterations for the loop
  32329. */
  32330. iterations: number;
  32331. /**
  32332. * Defines the current index of the loop.
  32333. */
  32334. index: number;
  32335. private _done;
  32336. private _fn;
  32337. private _successCallback;
  32338. /**
  32339. * Constructor.
  32340. * @param iterations the number of iterations.
  32341. * @param func the function to run each iteration
  32342. * @param successCallback the callback that will be called upon succesful execution
  32343. * @param offset starting offset.
  32344. */
  32345. constructor(
  32346. /**
  32347. * Defines the number of iterations for the loop
  32348. */
  32349. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  32350. /**
  32351. * Execute the next iteration. Must be called after the last iteration was finished.
  32352. */
  32353. executeNext(): void;
  32354. /**
  32355. * Break the loop and run the success callback.
  32356. */
  32357. breakLoop(): void;
  32358. /**
  32359. * Create and run an async loop.
  32360. * @param iterations the number of iterations.
  32361. * @param fn the function to run each iteration
  32362. * @param successCallback the callback that will be called upon succesful execution
  32363. * @param offset starting offset.
  32364. * @returns the created async loop object
  32365. */
  32366. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  32367. /**
  32368. * A for-loop that will run a given number of iterations synchronous and the rest async.
  32369. * @param iterations total number of iterations
  32370. * @param syncedIterations number of synchronous iterations in each async iteration.
  32371. * @param fn the function to call each iteration.
  32372. * @param callback a success call back that will be called when iterating stops.
  32373. * @param breakFunction a break condition (optional)
  32374. * @param timeout timeout settings for the setTimeout function. default - 0.
  32375. * @returns the created async loop object
  32376. */
  32377. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  32378. }
  32379. }
  32380. declare module "babylonjs/Collisions/collisionCoordinator" {
  32381. import { Nullable } from "babylonjs/types";
  32382. import { Scene } from "babylonjs/scene";
  32383. import { Vector3 } from "babylonjs/Maths/math";
  32384. import { Collider } from "babylonjs/Collisions/collider";
  32385. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32386. /** @hidden */
  32387. export interface ICollisionCoordinator {
  32388. createCollider(): Collider;
  32389. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32390. init(scene: Scene): void;
  32391. }
  32392. /** @hidden */
  32393. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  32394. private _scene;
  32395. private _scaledPosition;
  32396. private _scaledVelocity;
  32397. private _finalPosition;
  32398. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32399. createCollider(): Collider;
  32400. init(scene: Scene): void;
  32401. private _collideWithWorld;
  32402. }
  32403. }
  32404. declare module "babylonjs/Inputs/scene.inputManager" {
  32405. import { Nullable } from "babylonjs/types";
  32406. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  32407. import { Vector2 } from "babylonjs/Maths/math";
  32408. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32409. import { Scene } from "babylonjs/scene";
  32410. /**
  32411. * Class used to manage all inputs for the scene.
  32412. */
  32413. export class InputManager {
  32414. /** The distance in pixel that you have to move to prevent some events */
  32415. static DragMovementThreshold: number;
  32416. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  32417. static LongPressDelay: number;
  32418. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  32419. static DoubleClickDelay: number;
  32420. /** If you need to check double click without raising a single click at first click, enable this flag */
  32421. static ExclusiveDoubleClickMode: boolean;
  32422. private _wheelEventName;
  32423. private _onPointerMove;
  32424. private _onPointerDown;
  32425. private _onPointerUp;
  32426. private _initClickEvent;
  32427. private _initActionManager;
  32428. private _delayedSimpleClick;
  32429. private _delayedSimpleClickTimeout;
  32430. private _previousDelayedSimpleClickTimeout;
  32431. private _meshPickProceed;
  32432. private _previousButtonPressed;
  32433. private _currentPickResult;
  32434. private _previousPickResult;
  32435. private _totalPointersPressed;
  32436. private _doubleClickOccured;
  32437. private _pointerOverMesh;
  32438. private _pickedDownMesh;
  32439. private _pickedUpMesh;
  32440. private _pointerX;
  32441. private _pointerY;
  32442. private _unTranslatedPointerX;
  32443. private _unTranslatedPointerY;
  32444. private _startingPointerPosition;
  32445. private _previousStartingPointerPosition;
  32446. private _startingPointerTime;
  32447. private _previousStartingPointerTime;
  32448. private _pointerCaptures;
  32449. private _onKeyDown;
  32450. private _onKeyUp;
  32451. private _onCanvasFocusObserver;
  32452. private _onCanvasBlurObserver;
  32453. private _scene;
  32454. /**
  32455. * Creates a new InputManager
  32456. * @param scene defines the hosting scene
  32457. */
  32458. constructor(scene: Scene);
  32459. /**
  32460. * Gets the mesh that is currently under the pointer
  32461. */
  32462. readonly meshUnderPointer: Nullable<AbstractMesh>;
  32463. /**
  32464. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  32465. */
  32466. readonly unTranslatedPointer: Vector2;
  32467. /**
  32468. * Gets or sets the current on-screen X position of the pointer
  32469. */
  32470. pointerX: number;
  32471. /**
  32472. * Gets or sets the current on-screen Y position of the pointer
  32473. */
  32474. pointerY: number;
  32475. private _updatePointerPosition;
  32476. private _processPointerMove;
  32477. private _setRayOnPointerInfo;
  32478. private _checkPrePointerObservable;
  32479. /**
  32480. * Use this method to simulate a pointer move on a mesh
  32481. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32482. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32483. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32484. */
  32485. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  32486. /**
  32487. * Use this method to simulate a pointer down on a mesh
  32488. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32489. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32490. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32491. */
  32492. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  32493. private _processPointerDown;
  32494. /** @hidden */
  32495. _isPointerSwiping(): boolean;
  32496. /**
  32497. * Use this method to simulate a pointer up on a mesh
  32498. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32499. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32500. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32501. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  32502. */
  32503. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  32504. private _processPointerUp;
  32505. /**
  32506. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  32507. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  32508. * @returns true if the pointer was captured
  32509. */
  32510. isPointerCaptured(pointerId?: number): boolean;
  32511. /**
  32512. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  32513. * @param attachUp defines if you want to attach events to pointerup
  32514. * @param attachDown defines if you want to attach events to pointerdown
  32515. * @param attachMove defines if you want to attach events to pointermove
  32516. */
  32517. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  32518. /**
  32519. * Detaches all event handlers
  32520. */
  32521. detachControl(): void;
  32522. /**
  32523. * Force the value of meshUnderPointer
  32524. * @param mesh defines the mesh to use
  32525. */
  32526. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  32527. /**
  32528. * Gets the mesh under the pointer
  32529. * @returns a Mesh or null if no mesh is under the pointer
  32530. */
  32531. getPointerOverMesh(): Nullable<AbstractMesh>;
  32532. }
  32533. }
  32534. declare module "babylonjs/Animations/animationGroup" {
  32535. import { Animatable } from "babylonjs/Animations/animatable";
  32536. import { Animation } from "babylonjs/Animations/animation";
  32537. import { Scene, IDisposable } from "babylonjs/scene";
  32538. import { Observable } from "babylonjs/Misc/observable";
  32539. import { Nullable } from "babylonjs/types";
  32540. import "babylonjs/Animations/animatable";
  32541. /**
  32542. * This class defines the direct association between an animation and a target
  32543. */
  32544. export class TargetedAnimation {
  32545. /**
  32546. * Animation to perform
  32547. */
  32548. animation: Animation;
  32549. /**
  32550. * Target to animate
  32551. */
  32552. target: any;
  32553. /**
  32554. * Serialize the object
  32555. * @returns the JSON object representing the current entity
  32556. */
  32557. serialize(): any;
  32558. }
  32559. /**
  32560. * Use this class to create coordinated animations on multiple targets
  32561. */
  32562. export class AnimationGroup implements IDisposable {
  32563. /** The name of the animation group */
  32564. name: string;
  32565. private _scene;
  32566. private _targetedAnimations;
  32567. private _animatables;
  32568. private _from;
  32569. private _to;
  32570. private _isStarted;
  32571. private _isPaused;
  32572. private _speedRatio;
  32573. private _loopAnimation;
  32574. /**
  32575. * Gets or sets the unique id of the node
  32576. */
  32577. uniqueId: number;
  32578. /**
  32579. * This observable will notify when one animation have ended
  32580. */
  32581. onAnimationEndObservable: Observable<TargetedAnimation>;
  32582. /**
  32583. * Observer raised when one animation loops
  32584. */
  32585. onAnimationLoopObservable: Observable<TargetedAnimation>;
  32586. /**
  32587. * This observable will notify when all animations have ended.
  32588. */
  32589. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  32590. /**
  32591. * This observable will notify when all animations have paused.
  32592. */
  32593. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  32594. /**
  32595. * This observable will notify when all animations are playing.
  32596. */
  32597. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  32598. /**
  32599. * Gets the first frame
  32600. */
  32601. readonly from: number;
  32602. /**
  32603. * Gets the last frame
  32604. */
  32605. readonly to: number;
  32606. /**
  32607. * Define if the animations are started
  32608. */
  32609. readonly isStarted: boolean;
  32610. /**
  32611. * Gets a value indicating that the current group is playing
  32612. */
  32613. readonly isPlaying: boolean;
  32614. /**
  32615. * Gets or sets the speed ratio to use for all animations
  32616. */
  32617. /**
  32618. * Gets or sets the speed ratio to use for all animations
  32619. */
  32620. speedRatio: number;
  32621. /**
  32622. * Gets or sets if all animations should loop or not
  32623. */
  32624. loopAnimation: boolean;
  32625. /**
  32626. * Gets the targeted animations for this animation group
  32627. */
  32628. readonly targetedAnimations: Array<TargetedAnimation>;
  32629. /**
  32630. * returning the list of animatables controlled by this animation group.
  32631. */
  32632. readonly animatables: Array<Animatable>;
  32633. /**
  32634. * Instantiates a new Animation Group.
  32635. * This helps managing several animations at once.
  32636. * @see http://doc.babylonjs.com/how_to/group
  32637. * @param name Defines the name of the group
  32638. * @param scene Defines the scene the group belongs to
  32639. */
  32640. constructor(
  32641. /** The name of the animation group */
  32642. name: string, scene?: Nullable<Scene>);
  32643. /**
  32644. * Add an animation (with its target) in the group
  32645. * @param animation defines the animation we want to add
  32646. * @param target defines the target of the animation
  32647. * @returns the TargetedAnimation object
  32648. */
  32649. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  32650. /**
  32651. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  32652. * It can add constant keys at begin or end
  32653. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  32654. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  32655. * @returns the animation group
  32656. */
  32657. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  32658. /**
  32659. * Start all animations on given targets
  32660. * @param loop defines if animations must loop
  32661. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  32662. * @param from defines the from key (optional)
  32663. * @param to defines the to key (optional)
  32664. * @returns the current animation group
  32665. */
  32666. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  32667. /**
  32668. * Pause all animations
  32669. * @returns the animation group
  32670. */
  32671. pause(): AnimationGroup;
  32672. /**
  32673. * Play all animations to initial state
  32674. * This function will start() the animations if they were not started or will restart() them if they were paused
  32675. * @param loop defines if animations must loop
  32676. * @returns the animation group
  32677. */
  32678. play(loop?: boolean): AnimationGroup;
  32679. /**
  32680. * Reset all animations to initial state
  32681. * @returns the animation group
  32682. */
  32683. reset(): AnimationGroup;
  32684. /**
  32685. * Restart animations from key 0
  32686. * @returns the animation group
  32687. */
  32688. restart(): AnimationGroup;
  32689. /**
  32690. * Stop all animations
  32691. * @returns the animation group
  32692. */
  32693. stop(): AnimationGroup;
  32694. /**
  32695. * Set animation weight for all animatables
  32696. * @param weight defines the weight to use
  32697. * @return the animationGroup
  32698. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32699. */
  32700. setWeightForAllAnimatables(weight: number): AnimationGroup;
  32701. /**
  32702. * Synchronize and normalize all animatables with a source animatable
  32703. * @param root defines the root animatable to synchronize with
  32704. * @return the animationGroup
  32705. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32706. */
  32707. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  32708. /**
  32709. * Goes to a specific frame in this animation group
  32710. * @param frame the frame number to go to
  32711. * @return the animationGroup
  32712. */
  32713. goToFrame(frame: number): AnimationGroup;
  32714. /**
  32715. * Dispose all associated resources
  32716. */
  32717. dispose(): void;
  32718. private _checkAnimationGroupEnded;
  32719. /**
  32720. * Clone the current animation group and returns a copy
  32721. * @param newName defines the name of the new group
  32722. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  32723. * @returns the new aniamtion group
  32724. */
  32725. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  32726. /**
  32727. * Serializes the animationGroup to an object
  32728. * @returns Serialized object
  32729. */
  32730. serialize(): any;
  32731. /**
  32732. * Returns a new AnimationGroup object parsed from the source provided.
  32733. * @param parsedAnimationGroup defines the source
  32734. * @param scene defines the scene that will receive the animationGroup
  32735. * @returns a new AnimationGroup
  32736. */
  32737. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  32738. /**
  32739. * Returns the string "AnimationGroup"
  32740. * @returns "AnimationGroup"
  32741. */
  32742. getClassName(): string;
  32743. /**
  32744. * Creates a detailled string about the object
  32745. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  32746. * @returns a string representing the object
  32747. */
  32748. toString(fullDetails?: boolean): string;
  32749. }
  32750. }
  32751. declare module "babylonjs/scene" {
  32752. import { Nullable } from "babylonjs/types";
  32753. import { IAnimatable, IFileRequest, PerfCounter } from "babylonjs/Misc/tools";
  32754. import { Observable } from "babylonjs/Misc/observable";
  32755. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  32756. import { Color4, Color3, Plane, Vector2, Vector3, Matrix } from "babylonjs/Maths/math";
  32757. import { Geometry } from "babylonjs/Meshes/geometry";
  32758. import { TransformNode } from "babylonjs/Meshes/transformNode";
  32759. import { SubMesh } from "babylonjs/Meshes/subMesh";
  32760. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32761. import { Mesh } from "babylonjs/Meshes/mesh";
  32762. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  32763. import { Bone } from "babylonjs/Bones/bone";
  32764. import { Skeleton } from "babylonjs/Bones/skeleton";
  32765. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  32766. import { Camera } from "babylonjs/Cameras/camera";
  32767. import { AbstractScene } from "babylonjs/abstractScene";
  32768. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  32769. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  32770. import { Material } from "babylonjs/Materials/material";
  32771. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  32772. import { Effect } from "babylonjs/Materials/effect";
  32773. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  32774. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  32775. import { Light } from "babylonjs/Lights/light";
  32776. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  32777. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  32778. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  32779. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  32780. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  32781. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  32782. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  32783. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  32784. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  32785. import { Engine } from "babylonjs/Engines/engine";
  32786. import { Node } from "babylonjs/node";
  32787. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  32788. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  32789. import { WebRequest } from "babylonjs/Misc/webRequest";
  32790. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  32791. import { Ray } from "babylonjs/Culling/ray";
  32792. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  32793. import { Animation } from "babylonjs/Animations/animation";
  32794. import { Animatable } from "babylonjs/Animations/animatable";
  32795. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  32796. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  32797. import { Collider } from "babylonjs/Collisions/collider";
  32798. /**
  32799. * Define an interface for all classes that will hold resources
  32800. */
  32801. export interface IDisposable {
  32802. /**
  32803. * Releases all held resources
  32804. */
  32805. dispose(): void;
  32806. }
  32807. /** Interface defining initialization parameters for Scene class */
  32808. export interface SceneOptions {
  32809. /**
  32810. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  32811. * It will improve performance when the number of geometries becomes important.
  32812. */
  32813. useGeometryUniqueIdsMap?: boolean;
  32814. /**
  32815. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  32816. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32817. */
  32818. useMaterialMeshMap?: boolean;
  32819. /**
  32820. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  32821. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32822. */
  32823. useClonedMeshhMap?: boolean;
  32824. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  32825. virtual?: boolean;
  32826. }
  32827. /**
  32828. * Represents a scene to be rendered by the engine.
  32829. * @see http://doc.babylonjs.com/features/scene
  32830. */
  32831. export class Scene extends AbstractScene implements IAnimatable {
  32832. private static _uniqueIdCounter;
  32833. /** The fog is deactivated */
  32834. static readonly FOGMODE_NONE: number;
  32835. /** The fog density is following an exponential function */
  32836. static readonly FOGMODE_EXP: number;
  32837. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  32838. static readonly FOGMODE_EXP2: number;
  32839. /** The fog density is following a linear function. */
  32840. static readonly FOGMODE_LINEAR: number;
  32841. /**
  32842. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  32843. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32844. */
  32845. static MinDeltaTime: number;
  32846. /**
  32847. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  32848. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32849. */
  32850. static MaxDeltaTime: number;
  32851. /**
  32852. * Factory used to create the default material.
  32853. * @param name The name of the material to create
  32854. * @param scene The scene to create the material for
  32855. * @returns The default material
  32856. */
  32857. static DefaultMaterialFactory(scene: Scene): Material;
  32858. /**
  32859. * Factory used to create the a collision coordinator.
  32860. * @returns The collision coordinator
  32861. */
  32862. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  32863. /** @hidden */
  32864. _inputManager: InputManager;
  32865. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  32866. cameraToUseForPointers: Nullable<Camera>;
  32867. /** @hidden */
  32868. readonly _isScene: boolean;
  32869. /**
  32870. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  32871. */
  32872. autoClear: boolean;
  32873. /**
  32874. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  32875. */
  32876. autoClearDepthAndStencil: boolean;
  32877. /**
  32878. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  32879. */
  32880. clearColor: Color4;
  32881. /**
  32882. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  32883. */
  32884. ambientColor: Color3;
  32885. /**
  32886. * This is use to store the default BRDF lookup for PBR materials in your scene.
  32887. * It should only be one of the following (if not the default embedded one):
  32888. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  32889. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  32890. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  32891. * The material properties need to be setup according to the type of texture in use.
  32892. */
  32893. environmentBRDFTexture: BaseTexture;
  32894. /** @hidden */
  32895. protected _environmentTexture: Nullable<BaseTexture>;
  32896. /**
  32897. * Texture used in all pbr material as the reflection texture.
  32898. * As in the majority of the scene they are the same (exception for multi room and so on),
  32899. * this is easier to reference from here than from all the materials.
  32900. */
  32901. /**
  32902. * Texture used in all pbr material as the reflection texture.
  32903. * As in the majority of the scene they are the same (exception for multi room and so on),
  32904. * this is easier to set here than in all the materials.
  32905. */
  32906. environmentTexture: Nullable<BaseTexture>;
  32907. /** @hidden */
  32908. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  32909. /**
  32910. * Default image processing configuration used either in the rendering
  32911. * Forward main pass or through the imageProcessingPostProcess if present.
  32912. * As in the majority of the scene they are the same (exception for multi camera),
  32913. * this is easier to reference from here than from all the materials and post process.
  32914. *
  32915. * No setter as we it is a shared configuration, you can set the values instead.
  32916. */
  32917. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  32918. private _forceWireframe;
  32919. /**
  32920. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  32921. */
  32922. forceWireframe: boolean;
  32923. private _forcePointsCloud;
  32924. /**
  32925. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  32926. */
  32927. forcePointsCloud: boolean;
  32928. /**
  32929. * Gets or sets the active clipplane 1
  32930. */
  32931. clipPlane: Nullable<Plane>;
  32932. /**
  32933. * Gets or sets the active clipplane 2
  32934. */
  32935. clipPlane2: Nullable<Plane>;
  32936. /**
  32937. * Gets or sets the active clipplane 3
  32938. */
  32939. clipPlane3: Nullable<Plane>;
  32940. /**
  32941. * Gets or sets the active clipplane 4
  32942. */
  32943. clipPlane4: Nullable<Plane>;
  32944. /**
  32945. * Gets or sets a boolean indicating if animations are enabled
  32946. */
  32947. animationsEnabled: boolean;
  32948. private _animationPropertiesOverride;
  32949. /**
  32950. * Gets or sets the animation properties override
  32951. */
  32952. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  32953. /**
  32954. * Gets or sets a boolean indicating if a constant deltatime has to be used
  32955. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  32956. */
  32957. useConstantAnimationDeltaTime: boolean;
  32958. /**
  32959. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  32960. * Please note that it requires to run a ray cast through the scene on every frame
  32961. */
  32962. constantlyUpdateMeshUnderPointer: boolean;
  32963. /**
  32964. * Defines the HTML cursor to use when hovering over interactive elements
  32965. */
  32966. hoverCursor: string;
  32967. /**
  32968. * Defines the HTML default cursor to use (empty by default)
  32969. */
  32970. defaultCursor: string;
  32971. /**
  32972. * This is used to call preventDefault() on pointer down
  32973. * in order to block unwanted artifacts like system double clicks
  32974. */
  32975. preventDefaultOnPointerDown: boolean;
  32976. /**
  32977. * This is used to call preventDefault() on pointer up
  32978. * in order to block unwanted artifacts like system double clicks
  32979. */
  32980. preventDefaultOnPointerUp: boolean;
  32981. /**
  32982. * Gets or sets user defined metadata
  32983. */
  32984. metadata: any;
  32985. /**
  32986. * For internal use only. Please do not use.
  32987. */
  32988. reservedDataStore: any;
  32989. /**
  32990. * Gets the name of the plugin used to load this scene (null by default)
  32991. */
  32992. loadingPluginName: string;
  32993. /**
  32994. * Use this array to add regular expressions used to disable offline support for specific urls
  32995. */
  32996. disableOfflineSupportExceptionRules: RegExp[];
  32997. /**
  32998. * An event triggered when the scene is disposed.
  32999. */
  33000. onDisposeObservable: Observable<Scene>;
  33001. private _onDisposeObserver;
  33002. /** Sets a function to be executed when this scene is disposed. */
  33003. onDispose: () => void;
  33004. /**
  33005. * An event triggered before rendering the scene (right after animations and physics)
  33006. */
  33007. onBeforeRenderObservable: Observable<Scene>;
  33008. private _onBeforeRenderObserver;
  33009. /** Sets a function to be executed before rendering this scene */
  33010. beforeRender: Nullable<() => void>;
  33011. /**
  33012. * An event triggered after rendering the scene
  33013. */
  33014. onAfterRenderObservable: Observable<Scene>;
  33015. private _onAfterRenderObserver;
  33016. /** Sets a function to be executed after rendering this scene */
  33017. afterRender: Nullable<() => void>;
  33018. /**
  33019. * An event triggered before animating the scene
  33020. */
  33021. onBeforeAnimationsObservable: Observable<Scene>;
  33022. /**
  33023. * An event triggered after animations processing
  33024. */
  33025. onAfterAnimationsObservable: Observable<Scene>;
  33026. /**
  33027. * An event triggered before draw calls are ready to be sent
  33028. */
  33029. onBeforeDrawPhaseObservable: Observable<Scene>;
  33030. /**
  33031. * An event triggered after draw calls have been sent
  33032. */
  33033. onAfterDrawPhaseObservable: Observable<Scene>;
  33034. /**
  33035. * An event triggered when the scene is ready
  33036. */
  33037. onReadyObservable: Observable<Scene>;
  33038. /**
  33039. * An event triggered before rendering a camera
  33040. */
  33041. onBeforeCameraRenderObservable: Observable<Camera>;
  33042. private _onBeforeCameraRenderObserver;
  33043. /** Sets a function to be executed before rendering a camera*/
  33044. beforeCameraRender: () => void;
  33045. /**
  33046. * An event triggered after rendering a camera
  33047. */
  33048. onAfterCameraRenderObservable: Observable<Camera>;
  33049. private _onAfterCameraRenderObserver;
  33050. /** Sets a function to be executed after rendering a camera*/
  33051. afterCameraRender: () => void;
  33052. /**
  33053. * An event triggered when active meshes evaluation is about to start
  33054. */
  33055. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  33056. /**
  33057. * An event triggered when active meshes evaluation is done
  33058. */
  33059. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  33060. /**
  33061. * An event triggered when particles rendering is about to start
  33062. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  33063. */
  33064. onBeforeParticlesRenderingObservable: Observable<Scene>;
  33065. /**
  33066. * An event triggered when particles rendering is done
  33067. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  33068. */
  33069. onAfterParticlesRenderingObservable: Observable<Scene>;
  33070. /**
  33071. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  33072. */
  33073. onDataLoadedObservable: Observable<Scene>;
  33074. /**
  33075. * An event triggered when a camera is created
  33076. */
  33077. onNewCameraAddedObservable: Observable<Camera>;
  33078. /**
  33079. * An event triggered when a camera is removed
  33080. */
  33081. onCameraRemovedObservable: Observable<Camera>;
  33082. /**
  33083. * An event triggered when a light is created
  33084. */
  33085. onNewLightAddedObservable: Observable<Light>;
  33086. /**
  33087. * An event triggered when a light is removed
  33088. */
  33089. onLightRemovedObservable: Observable<Light>;
  33090. /**
  33091. * An event triggered when a geometry is created
  33092. */
  33093. onNewGeometryAddedObservable: Observable<Geometry>;
  33094. /**
  33095. * An event triggered when a geometry is removed
  33096. */
  33097. onGeometryRemovedObservable: Observable<Geometry>;
  33098. /**
  33099. * An event triggered when a transform node is created
  33100. */
  33101. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  33102. /**
  33103. * An event triggered when a transform node is removed
  33104. */
  33105. onTransformNodeRemovedObservable: Observable<TransformNode>;
  33106. /**
  33107. * An event triggered when a mesh is created
  33108. */
  33109. onNewMeshAddedObservable: Observable<AbstractMesh>;
  33110. /**
  33111. * An event triggered when a mesh is removed
  33112. */
  33113. onMeshRemovedObservable: Observable<AbstractMesh>;
  33114. /**
  33115. * An event triggered when a skeleton is created
  33116. */
  33117. onNewSkeletonAddedObservable: Observable<Skeleton>;
  33118. /**
  33119. * An event triggered when a skeleton is removed
  33120. */
  33121. onSkeletonRemovedObservable: Observable<Skeleton>;
  33122. /**
  33123. * An event triggered when a material is created
  33124. */
  33125. onNewMaterialAddedObservable: Observable<Material>;
  33126. /**
  33127. * An event triggered when a material is removed
  33128. */
  33129. onMaterialRemovedObservable: Observable<Material>;
  33130. /**
  33131. * An event triggered when a texture is created
  33132. */
  33133. onNewTextureAddedObservable: Observable<BaseTexture>;
  33134. /**
  33135. * An event triggered when a texture is removed
  33136. */
  33137. onTextureRemovedObservable: Observable<BaseTexture>;
  33138. /**
  33139. * An event triggered when render targets are about to be rendered
  33140. * Can happen multiple times per frame.
  33141. */
  33142. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  33143. /**
  33144. * An event triggered when render targets were rendered.
  33145. * Can happen multiple times per frame.
  33146. */
  33147. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  33148. /**
  33149. * An event triggered before calculating deterministic simulation step
  33150. */
  33151. onBeforeStepObservable: Observable<Scene>;
  33152. /**
  33153. * An event triggered after calculating deterministic simulation step
  33154. */
  33155. onAfterStepObservable: Observable<Scene>;
  33156. /**
  33157. * An event triggered when the activeCamera property is updated
  33158. */
  33159. onActiveCameraChanged: Observable<Scene>;
  33160. /**
  33161. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  33162. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33163. * 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)
  33164. */
  33165. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33166. /**
  33167. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  33168. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33169. * 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)
  33170. */
  33171. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33172. /**
  33173. * This Observable will when a mesh has been imported into the scene.
  33174. */
  33175. onMeshImportedObservable: Observable<AbstractMesh>;
  33176. /**
  33177. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  33178. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  33179. */
  33180. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  33181. /** @hidden */
  33182. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  33183. /**
  33184. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  33185. */
  33186. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  33187. /**
  33188. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  33189. */
  33190. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  33191. /**
  33192. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  33193. */
  33194. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  33195. /** Callback called when a pointer move is detected */
  33196. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  33197. /** Callback called when a pointer down is detected */
  33198. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  33199. /** Callback called when a pointer up is detected */
  33200. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  33201. /** Callback called when a pointer pick is detected */
  33202. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  33203. /**
  33204. * 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).
  33205. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  33206. */
  33207. onPrePointerObservable: Observable<PointerInfoPre>;
  33208. /**
  33209. * Observable event triggered each time an input event is received from the rendering canvas
  33210. */
  33211. onPointerObservable: Observable<PointerInfo>;
  33212. /**
  33213. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  33214. */
  33215. readonly unTranslatedPointer: Vector2;
  33216. /**
  33217. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  33218. */
  33219. static DragMovementThreshold: number;
  33220. /**
  33221. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  33222. */
  33223. static LongPressDelay: number;
  33224. /**
  33225. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  33226. */
  33227. static DoubleClickDelay: number;
  33228. /** If you need to check double click without raising a single click at first click, enable this flag */
  33229. static ExclusiveDoubleClickMode: boolean;
  33230. /** @hidden */
  33231. _mirroredCameraPosition: Nullable<Vector3>;
  33232. /**
  33233. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  33234. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  33235. */
  33236. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  33237. /**
  33238. * Observable event triggered each time an keyboard event is received from the hosting window
  33239. */
  33240. onKeyboardObservable: Observable<KeyboardInfo>;
  33241. private _useRightHandedSystem;
  33242. /**
  33243. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  33244. */
  33245. useRightHandedSystem: boolean;
  33246. private _timeAccumulator;
  33247. private _currentStepId;
  33248. private _currentInternalStep;
  33249. /**
  33250. * Sets the step Id used by deterministic lock step
  33251. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33252. * @param newStepId defines the step Id
  33253. */
  33254. setStepId(newStepId: number): void;
  33255. /**
  33256. * Gets the step Id used by deterministic lock step
  33257. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33258. * @returns the step Id
  33259. */
  33260. getStepId(): number;
  33261. /**
  33262. * Gets the internal step used by deterministic lock step
  33263. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33264. * @returns the internal step
  33265. */
  33266. getInternalStep(): number;
  33267. private _fogEnabled;
  33268. /**
  33269. * Gets or sets a boolean indicating if fog is enabled on this scene
  33270. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33271. * (Default is true)
  33272. */
  33273. fogEnabled: boolean;
  33274. private _fogMode;
  33275. /**
  33276. * Gets or sets the fog mode to use
  33277. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33278. * | mode | value |
  33279. * | --- | --- |
  33280. * | FOGMODE_NONE | 0 |
  33281. * | FOGMODE_EXP | 1 |
  33282. * | FOGMODE_EXP2 | 2 |
  33283. * | FOGMODE_LINEAR | 3 |
  33284. */
  33285. fogMode: number;
  33286. /**
  33287. * Gets or sets the fog color to use
  33288. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33289. * (Default is Color3(0.2, 0.2, 0.3))
  33290. */
  33291. fogColor: Color3;
  33292. /**
  33293. * Gets or sets the fog density to use
  33294. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33295. * (Default is 0.1)
  33296. */
  33297. fogDensity: number;
  33298. /**
  33299. * Gets or sets the fog start distance to use
  33300. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33301. * (Default is 0)
  33302. */
  33303. fogStart: number;
  33304. /**
  33305. * Gets or sets the fog end distance to use
  33306. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33307. * (Default is 1000)
  33308. */
  33309. fogEnd: number;
  33310. private _shadowsEnabled;
  33311. /**
  33312. * Gets or sets a boolean indicating if shadows are enabled on this scene
  33313. */
  33314. shadowsEnabled: boolean;
  33315. private _lightsEnabled;
  33316. /**
  33317. * Gets or sets a boolean indicating if lights are enabled on this scene
  33318. */
  33319. lightsEnabled: boolean;
  33320. /** All of the active cameras added to this scene. */
  33321. activeCameras: Camera[];
  33322. /** @hidden */
  33323. _activeCamera: Nullable<Camera>;
  33324. /** Gets or sets the current active camera */
  33325. activeCamera: Nullable<Camera>;
  33326. private _defaultMaterial;
  33327. /** The default material used on meshes when no material is affected */
  33328. /** The default material used on meshes when no material is affected */
  33329. defaultMaterial: Material;
  33330. private _texturesEnabled;
  33331. /**
  33332. * Gets or sets a boolean indicating if textures are enabled on this scene
  33333. */
  33334. texturesEnabled: boolean;
  33335. /**
  33336. * Gets or sets a boolean indicating if particles are enabled on this scene
  33337. */
  33338. particlesEnabled: boolean;
  33339. /**
  33340. * Gets or sets a boolean indicating if sprites are enabled on this scene
  33341. */
  33342. spritesEnabled: boolean;
  33343. private _skeletonsEnabled;
  33344. /**
  33345. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  33346. */
  33347. skeletonsEnabled: boolean;
  33348. /**
  33349. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  33350. */
  33351. lensFlaresEnabled: boolean;
  33352. /**
  33353. * Gets or sets a boolean indicating if collisions are enabled on this scene
  33354. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33355. */
  33356. collisionsEnabled: boolean;
  33357. private _collisionCoordinator;
  33358. /** @hidden */
  33359. readonly collisionCoordinator: ICollisionCoordinator;
  33360. /**
  33361. * Defines the gravity applied to this scene (used only for collisions)
  33362. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33363. */
  33364. gravity: Vector3;
  33365. /**
  33366. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  33367. */
  33368. postProcessesEnabled: boolean;
  33369. /**
  33370. * The list of postprocesses added to the scene
  33371. */
  33372. postProcesses: PostProcess[];
  33373. /**
  33374. * Gets the current postprocess manager
  33375. */
  33376. postProcessManager: PostProcessManager;
  33377. /**
  33378. * Gets or sets a boolean indicating if render targets are enabled on this scene
  33379. */
  33380. renderTargetsEnabled: boolean;
  33381. /**
  33382. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  33383. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  33384. */
  33385. dumpNextRenderTargets: boolean;
  33386. /**
  33387. * The list of user defined render targets added to the scene
  33388. */
  33389. customRenderTargets: RenderTargetTexture[];
  33390. /**
  33391. * Defines if texture loading must be delayed
  33392. * If true, textures will only be loaded when they need to be rendered
  33393. */
  33394. useDelayedTextureLoading: boolean;
  33395. /**
  33396. * Gets the list of meshes imported to the scene through SceneLoader
  33397. */
  33398. importedMeshesFiles: String[];
  33399. /**
  33400. * Gets or sets a boolean indicating if probes are enabled on this scene
  33401. */
  33402. probesEnabled: boolean;
  33403. /**
  33404. * Gets or sets the current offline provider to use to store scene data
  33405. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  33406. */
  33407. offlineProvider: IOfflineProvider;
  33408. /**
  33409. * Gets or sets the action manager associated with the scene
  33410. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  33411. */
  33412. actionManager: AbstractActionManager;
  33413. private _meshesForIntersections;
  33414. /**
  33415. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  33416. */
  33417. proceduralTexturesEnabled: boolean;
  33418. private _engine;
  33419. private _totalVertices;
  33420. /** @hidden */
  33421. _activeIndices: PerfCounter;
  33422. /** @hidden */
  33423. _activeParticles: PerfCounter;
  33424. /** @hidden */
  33425. _activeBones: PerfCounter;
  33426. private _animationRatio;
  33427. /** @hidden */
  33428. _animationTimeLast: number;
  33429. /** @hidden */
  33430. _animationTime: number;
  33431. /**
  33432. * Gets or sets a general scale for animation speed
  33433. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  33434. */
  33435. animationTimeScale: number;
  33436. /** @hidden */
  33437. _cachedMaterial: Nullable<Material>;
  33438. /** @hidden */
  33439. _cachedEffect: Nullable<Effect>;
  33440. /** @hidden */
  33441. _cachedVisibility: Nullable<number>;
  33442. private _renderId;
  33443. private _frameId;
  33444. private _executeWhenReadyTimeoutId;
  33445. private _intermediateRendering;
  33446. private _viewUpdateFlag;
  33447. private _projectionUpdateFlag;
  33448. /** @hidden */
  33449. _toBeDisposed: Nullable<IDisposable>[];
  33450. private _activeRequests;
  33451. /** @hidden */
  33452. _pendingData: any[];
  33453. private _isDisposed;
  33454. /**
  33455. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  33456. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  33457. */
  33458. dispatchAllSubMeshesOfActiveMeshes: boolean;
  33459. private _activeMeshes;
  33460. private _processedMaterials;
  33461. private _renderTargets;
  33462. /** @hidden */
  33463. _activeParticleSystems: SmartArray<IParticleSystem>;
  33464. private _activeSkeletons;
  33465. private _softwareSkinnedMeshes;
  33466. private _renderingManager;
  33467. /** @hidden */
  33468. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  33469. private _transformMatrix;
  33470. private _sceneUbo;
  33471. /** @hidden */
  33472. _viewMatrix: Matrix;
  33473. private _projectionMatrix;
  33474. /** @hidden */
  33475. _forcedViewPosition: Nullable<Vector3>;
  33476. /** @hidden */
  33477. _frustumPlanes: Plane[];
  33478. /**
  33479. * Gets the list of frustum planes (built from the active camera)
  33480. */
  33481. readonly frustumPlanes: Plane[];
  33482. /**
  33483. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  33484. * This is useful if there are more lights that the maximum simulteanous authorized
  33485. */
  33486. requireLightSorting: boolean;
  33487. /** @hidden */
  33488. readonly useMaterialMeshMap: boolean;
  33489. /** @hidden */
  33490. readonly useClonedMeshhMap: boolean;
  33491. private _externalData;
  33492. private _uid;
  33493. /**
  33494. * @hidden
  33495. * Backing store of defined scene components.
  33496. */
  33497. _components: ISceneComponent[];
  33498. /**
  33499. * @hidden
  33500. * Backing store of defined scene components.
  33501. */
  33502. _serializableComponents: ISceneSerializableComponent[];
  33503. /**
  33504. * List of components to register on the next registration step.
  33505. */
  33506. private _transientComponents;
  33507. /**
  33508. * Registers the transient components if needed.
  33509. */
  33510. private _registerTransientComponents;
  33511. /**
  33512. * @hidden
  33513. * Add a component to the scene.
  33514. * Note that the ccomponent could be registered on th next frame if this is called after
  33515. * the register component stage.
  33516. * @param component Defines the component to add to the scene
  33517. */
  33518. _addComponent(component: ISceneComponent): void;
  33519. /**
  33520. * @hidden
  33521. * Gets a component from the scene.
  33522. * @param name defines the name of the component to retrieve
  33523. * @returns the component or null if not present
  33524. */
  33525. _getComponent(name: string): Nullable<ISceneComponent>;
  33526. /**
  33527. * @hidden
  33528. * Defines the actions happening before camera updates.
  33529. */
  33530. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  33531. /**
  33532. * @hidden
  33533. * Defines the actions happening before clear the canvas.
  33534. */
  33535. _beforeClearStage: Stage<SimpleStageAction>;
  33536. /**
  33537. * @hidden
  33538. * Defines the actions when collecting render targets for the frame.
  33539. */
  33540. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33541. /**
  33542. * @hidden
  33543. * Defines the actions happening for one camera in the frame.
  33544. */
  33545. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33546. /**
  33547. * @hidden
  33548. * Defines the actions happening during the per mesh ready checks.
  33549. */
  33550. _isReadyForMeshStage: Stage<MeshStageAction>;
  33551. /**
  33552. * @hidden
  33553. * Defines the actions happening before evaluate active mesh checks.
  33554. */
  33555. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  33556. /**
  33557. * @hidden
  33558. * Defines the actions happening during the evaluate sub mesh checks.
  33559. */
  33560. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  33561. /**
  33562. * @hidden
  33563. * Defines the actions happening during the active mesh stage.
  33564. */
  33565. _activeMeshStage: Stage<ActiveMeshStageAction>;
  33566. /**
  33567. * @hidden
  33568. * Defines the actions happening during the per camera render target step.
  33569. */
  33570. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  33571. /**
  33572. * @hidden
  33573. * Defines the actions happening just before the active camera is drawing.
  33574. */
  33575. _beforeCameraDrawStage: Stage<CameraStageAction>;
  33576. /**
  33577. * @hidden
  33578. * Defines the actions happening just before a render target is drawing.
  33579. */
  33580. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33581. /**
  33582. * @hidden
  33583. * Defines the actions happening just before a rendering group is drawing.
  33584. */
  33585. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33586. /**
  33587. * @hidden
  33588. * Defines the actions happening just before a mesh is drawing.
  33589. */
  33590. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33591. /**
  33592. * @hidden
  33593. * Defines the actions happening just after a mesh has been drawn.
  33594. */
  33595. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33596. /**
  33597. * @hidden
  33598. * Defines the actions happening just after a rendering group has been drawn.
  33599. */
  33600. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33601. /**
  33602. * @hidden
  33603. * Defines the actions happening just after the active camera has been drawn.
  33604. */
  33605. _afterCameraDrawStage: Stage<CameraStageAction>;
  33606. /**
  33607. * @hidden
  33608. * Defines the actions happening just after a render target has been drawn.
  33609. */
  33610. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33611. /**
  33612. * @hidden
  33613. * Defines the actions happening just after rendering all cameras and computing intersections.
  33614. */
  33615. _afterRenderStage: Stage<SimpleStageAction>;
  33616. /**
  33617. * @hidden
  33618. * Defines the actions happening when a pointer move event happens.
  33619. */
  33620. _pointerMoveStage: Stage<PointerMoveStageAction>;
  33621. /**
  33622. * @hidden
  33623. * Defines the actions happening when a pointer down event happens.
  33624. */
  33625. _pointerDownStage: Stage<PointerUpDownStageAction>;
  33626. /**
  33627. * @hidden
  33628. * Defines the actions happening when a pointer up event happens.
  33629. */
  33630. _pointerUpStage: Stage<PointerUpDownStageAction>;
  33631. /**
  33632. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  33633. */
  33634. private geometriesByUniqueId;
  33635. /**
  33636. * Creates a new Scene
  33637. * @param engine defines the engine to use to render this scene
  33638. * @param options defines the scene options
  33639. */
  33640. constructor(engine: Engine, options?: SceneOptions);
  33641. /**
  33642. * Gets a string idenfifying the name of the class
  33643. * @returns "Scene" string
  33644. */
  33645. getClassName(): string;
  33646. private _defaultMeshCandidates;
  33647. /**
  33648. * @hidden
  33649. */
  33650. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  33651. private _defaultSubMeshCandidates;
  33652. /**
  33653. * @hidden
  33654. */
  33655. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  33656. /**
  33657. * Sets the default candidate providers for the scene.
  33658. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  33659. * and getCollidingSubMeshCandidates to their default function
  33660. */
  33661. setDefaultCandidateProviders(): void;
  33662. /**
  33663. * Gets the mesh that is currently under the pointer
  33664. */
  33665. readonly meshUnderPointer: Nullable<AbstractMesh>;
  33666. /**
  33667. * Gets or sets the current on-screen X position of the pointer
  33668. */
  33669. pointerX: number;
  33670. /**
  33671. * Gets or sets the current on-screen Y position of the pointer
  33672. */
  33673. pointerY: number;
  33674. /**
  33675. * Gets the cached material (ie. the latest rendered one)
  33676. * @returns the cached material
  33677. */
  33678. getCachedMaterial(): Nullable<Material>;
  33679. /**
  33680. * Gets the cached effect (ie. the latest rendered one)
  33681. * @returns the cached effect
  33682. */
  33683. getCachedEffect(): Nullable<Effect>;
  33684. /**
  33685. * Gets the cached visibility state (ie. the latest rendered one)
  33686. * @returns the cached visibility state
  33687. */
  33688. getCachedVisibility(): Nullable<number>;
  33689. /**
  33690. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  33691. * @param material defines the current material
  33692. * @param effect defines the current effect
  33693. * @param visibility defines the current visibility state
  33694. * @returns true if one parameter is not cached
  33695. */
  33696. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  33697. /**
  33698. * Gets the engine associated with the scene
  33699. * @returns an Engine
  33700. */
  33701. getEngine(): Engine;
  33702. /**
  33703. * Gets the total number of vertices rendered per frame
  33704. * @returns the total number of vertices rendered per frame
  33705. */
  33706. getTotalVertices(): number;
  33707. /**
  33708. * Gets the performance counter for total vertices
  33709. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33710. */
  33711. readonly totalVerticesPerfCounter: PerfCounter;
  33712. /**
  33713. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  33714. * @returns the total number of active indices rendered per frame
  33715. */
  33716. getActiveIndices(): number;
  33717. /**
  33718. * Gets the performance counter for active indices
  33719. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33720. */
  33721. readonly totalActiveIndicesPerfCounter: PerfCounter;
  33722. /**
  33723. * Gets the total number of active particles rendered per frame
  33724. * @returns the total number of active particles rendered per frame
  33725. */
  33726. getActiveParticles(): number;
  33727. /**
  33728. * Gets the performance counter for active particles
  33729. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33730. */
  33731. readonly activeParticlesPerfCounter: PerfCounter;
  33732. /**
  33733. * Gets the total number of active bones rendered per frame
  33734. * @returns the total number of active bones rendered per frame
  33735. */
  33736. getActiveBones(): number;
  33737. /**
  33738. * Gets the performance counter for active bones
  33739. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33740. */
  33741. readonly activeBonesPerfCounter: PerfCounter;
  33742. /**
  33743. * Gets the array of active meshes
  33744. * @returns an array of AbstractMesh
  33745. */
  33746. getActiveMeshes(): SmartArray<AbstractMesh>;
  33747. /**
  33748. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  33749. * @returns a number
  33750. */
  33751. getAnimationRatio(): number;
  33752. /**
  33753. * Gets an unique Id for the current render phase
  33754. * @returns a number
  33755. */
  33756. getRenderId(): number;
  33757. /**
  33758. * Gets an unique Id for the current frame
  33759. * @returns a number
  33760. */
  33761. getFrameId(): number;
  33762. /** Call this function if you want to manually increment the render Id*/
  33763. incrementRenderId(): void;
  33764. private _createUbo;
  33765. /**
  33766. * Use this method to simulate a pointer move on a mesh
  33767. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33768. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33769. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33770. * @returns the current scene
  33771. */
  33772. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33773. /**
  33774. * Use this method to simulate a pointer down on a mesh
  33775. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33776. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33777. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33778. * @returns the current scene
  33779. */
  33780. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33781. /**
  33782. * Use this method to simulate a pointer up on a mesh
  33783. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33784. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33785. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33786. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  33787. * @returns the current scene
  33788. */
  33789. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  33790. /**
  33791. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  33792. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  33793. * @returns true if the pointer was captured
  33794. */
  33795. isPointerCaptured(pointerId?: number): boolean;
  33796. /**
  33797. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  33798. * @param attachUp defines if you want to attach events to pointerup
  33799. * @param attachDown defines if you want to attach events to pointerdown
  33800. * @param attachMove defines if you want to attach events to pointermove
  33801. */
  33802. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  33803. /** Detaches all event handlers*/
  33804. detachControl(): void;
  33805. /**
  33806. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  33807. * Delay loaded resources are not taking in account
  33808. * @return true if all required resources are ready
  33809. */
  33810. isReady(): boolean;
  33811. /** Resets all cached information relative to material (including effect and visibility) */
  33812. resetCachedMaterial(): void;
  33813. /**
  33814. * Registers a function to be called before every frame render
  33815. * @param func defines the function to register
  33816. */
  33817. registerBeforeRender(func: () => void): void;
  33818. /**
  33819. * Unregisters a function called before every frame render
  33820. * @param func defines the function to unregister
  33821. */
  33822. unregisterBeforeRender(func: () => void): void;
  33823. /**
  33824. * Registers a function to be called after every frame render
  33825. * @param func defines the function to register
  33826. */
  33827. registerAfterRender(func: () => void): void;
  33828. /**
  33829. * Unregisters a function called after every frame render
  33830. * @param func defines the function to unregister
  33831. */
  33832. unregisterAfterRender(func: () => void): void;
  33833. private _executeOnceBeforeRender;
  33834. /**
  33835. * The provided function will run before render once and will be disposed afterwards.
  33836. * A timeout delay can be provided so that the function will be executed in N ms.
  33837. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  33838. * @param func The function to be executed.
  33839. * @param timeout optional delay in ms
  33840. */
  33841. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  33842. /** @hidden */
  33843. _addPendingData(data: any): void;
  33844. /** @hidden */
  33845. _removePendingData(data: any): void;
  33846. /**
  33847. * Returns the number of items waiting to be loaded
  33848. * @returns the number of items waiting to be loaded
  33849. */
  33850. getWaitingItemsCount(): number;
  33851. /**
  33852. * Returns a boolean indicating if the scene is still loading data
  33853. */
  33854. readonly isLoading: boolean;
  33855. /**
  33856. * Registers a function to be executed when the scene is ready
  33857. * @param {Function} func - the function to be executed
  33858. */
  33859. executeWhenReady(func: () => void): void;
  33860. /**
  33861. * Returns a promise that resolves when the scene is ready
  33862. * @returns A promise that resolves when the scene is ready
  33863. */
  33864. whenReadyAsync(): Promise<void>;
  33865. /** @hidden */
  33866. _checkIsReady(): void;
  33867. /**
  33868. * Gets all animatable attached to the scene
  33869. */
  33870. readonly animatables: Animatable[];
  33871. /**
  33872. * Resets the last animation time frame.
  33873. * Useful to override when animations start running when loading a scene for the first time.
  33874. */
  33875. resetLastAnimationTimeFrame(): void;
  33876. /**
  33877. * Gets the current view matrix
  33878. * @returns a Matrix
  33879. */
  33880. getViewMatrix(): Matrix;
  33881. /**
  33882. * Gets the current projection matrix
  33883. * @returns a Matrix
  33884. */
  33885. getProjectionMatrix(): Matrix;
  33886. /**
  33887. * Gets the current transform matrix
  33888. * @returns a Matrix made of View * Projection
  33889. */
  33890. getTransformMatrix(): Matrix;
  33891. /**
  33892. * Sets the current transform matrix
  33893. * @param viewL defines the View matrix to use
  33894. * @param projectionL defines the Projection matrix to use
  33895. * @param viewR defines the right View matrix to use (if provided)
  33896. * @param projectionR defines the right Projection matrix to use (if provided)
  33897. */
  33898. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  33899. /**
  33900. * Gets the uniform buffer used to store scene data
  33901. * @returns a UniformBuffer
  33902. */
  33903. getSceneUniformBuffer(): UniformBuffer;
  33904. /**
  33905. * Gets an unique (relatively to the current scene) Id
  33906. * @returns an unique number for the scene
  33907. */
  33908. getUniqueId(): number;
  33909. /**
  33910. * Add a mesh to the list of scene's meshes
  33911. * @param newMesh defines the mesh to add
  33912. * @param recursive if all child meshes should also be added to the scene
  33913. */
  33914. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  33915. /**
  33916. * Remove a mesh for the list of scene's meshes
  33917. * @param toRemove defines the mesh to remove
  33918. * @param recursive if all child meshes should also be removed from the scene
  33919. * @returns the index where the mesh was in the mesh list
  33920. */
  33921. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  33922. /**
  33923. * Add a transform node to the list of scene's transform nodes
  33924. * @param newTransformNode defines the transform node to add
  33925. */
  33926. addTransformNode(newTransformNode: TransformNode): void;
  33927. /**
  33928. * Remove a transform node for the list of scene's transform nodes
  33929. * @param toRemove defines the transform node to remove
  33930. * @returns the index where the transform node was in the transform node list
  33931. */
  33932. removeTransformNode(toRemove: TransformNode): number;
  33933. /**
  33934. * Remove a skeleton for the list of scene's skeletons
  33935. * @param toRemove defines the skeleton to remove
  33936. * @returns the index where the skeleton was in the skeleton list
  33937. */
  33938. removeSkeleton(toRemove: Skeleton): number;
  33939. /**
  33940. * Remove a morph target for the list of scene's morph targets
  33941. * @param toRemove defines the morph target to remove
  33942. * @returns the index where the morph target was in the morph target list
  33943. */
  33944. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  33945. /**
  33946. * Remove a light for the list of scene's lights
  33947. * @param toRemove defines the light to remove
  33948. * @returns the index where the light was in the light list
  33949. */
  33950. removeLight(toRemove: Light): number;
  33951. /**
  33952. * Remove a camera for the list of scene's cameras
  33953. * @param toRemove defines the camera to remove
  33954. * @returns the index where the camera was in the camera list
  33955. */
  33956. removeCamera(toRemove: Camera): number;
  33957. /**
  33958. * Remove a particle system for the list of scene's particle systems
  33959. * @param toRemove defines the particle system to remove
  33960. * @returns the index where the particle system was in the particle system list
  33961. */
  33962. removeParticleSystem(toRemove: IParticleSystem): number;
  33963. /**
  33964. * Remove a animation for the list of scene's animations
  33965. * @param toRemove defines the animation to remove
  33966. * @returns the index where the animation was in the animation list
  33967. */
  33968. removeAnimation(toRemove: Animation): number;
  33969. /**
  33970. * Will stop the animation of the given target
  33971. * @param target - the target
  33972. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  33973. * @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)
  33974. */
  33975. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  33976. /**
  33977. * Removes the given animation group from this scene.
  33978. * @param toRemove The animation group to remove
  33979. * @returns The index of the removed animation group
  33980. */
  33981. removeAnimationGroup(toRemove: AnimationGroup): number;
  33982. /**
  33983. * Removes the given multi-material from this scene.
  33984. * @param toRemove The multi-material to remove
  33985. * @returns The index of the removed multi-material
  33986. */
  33987. removeMultiMaterial(toRemove: MultiMaterial): number;
  33988. /**
  33989. * Removes the given material from this scene.
  33990. * @param toRemove The material to remove
  33991. * @returns The index of the removed material
  33992. */
  33993. removeMaterial(toRemove: Material): number;
  33994. /**
  33995. * Removes the given action manager from this scene.
  33996. * @param toRemove The action manager to remove
  33997. * @returns The index of the removed action manager
  33998. */
  33999. removeActionManager(toRemove: AbstractActionManager): number;
  34000. /**
  34001. * Removes the given texture from this scene.
  34002. * @param toRemove The texture to remove
  34003. * @returns The index of the removed texture
  34004. */
  34005. removeTexture(toRemove: BaseTexture): number;
  34006. /**
  34007. * Adds the given light to this scene
  34008. * @param newLight The light to add
  34009. */
  34010. addLight(newLight: Light): void;
  34011. /**
  34012. * Sorts the list list based on light priorities
  34013. */
  34014. sortLightsByPriority(): void;
  34015. /**
  34016. * Adds the given camera to this scene
  34017. * @param newCamera The camera to add
  34018. */
  34019. addCamera(newCamera: Camera): void;
  34020. /**
  34021. * Adds the given skeleton to this scene
  34022. * @param newSkeleton The skeleton to add
  34023. */
  34024. addSkeleton(newSkeleton: Skeleton): void;
  34025. /**
  34026. * Adds the given particle system to this scene
  34027. * @param newParticleSystem The particle system to add
  34028. */
  34029. addParticleSystem(newParticleSystem: IParticleSystem): void;
  34030. /**
  34031. * Adds the given animation to this scene
  34032. * @param newAnimation The animation to add
  34033. */
  34034. addAnimation(newAnimation: Animation): void;
  34035. /**
  34036. * Adds the given animation group to this scene.
  34037. * @param newAnimationGroup The animation group to add
  34038. */
  34039. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  34040. /**
  34041. * Adds the given multi-material to this scene
  34042. * @param newMultiMaterial The multi-material to add
  34043. */
  34044. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  34045. /**
  34046. * Adds the given material to this scene
  34047. * @param newMaterial The material to add
  34048. */
  34049. addMaterial(newMaterial: Material): void;
  34050. /**
  34051. * Adds the given morph target to this scene
  34052. * @param newMorphTargetManager The morph target to add
  34053. */
  34054. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  34055. /**
  34056. * Adds the given geometry to this scene
  34057. * @param newGeometry The geometry to add
  34058. */
  34059. addGeometry(newGeometry: Geometry): void;
  34060. /**
  34061. * Adds the given action manager to this scene
  34062. * @param newActionManager The action manager to add
  34063. */
  34064. addActionManager(newActionManager: AbstractActionManager): void;
  34065. /**
  34066. * Adds the given texture to this scene.
  34067. * @param newTexture The texture to add
  34068. */
  34069. addTexture(newTexture: BaseTexture): void;
  34070. /**
  34071. * Switch active camera
  34072. * @param newCamera defines the new active camera
  34073. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  34074. */
  34075. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  34076. /**
  34077. * sets the active camera of the scene using its ID
  34078. * @param id defines the camera's ID
  34079. * @return the new active camera or null if none found.
  34080. */
  34081. setActiveCameraByID(id: string): Nullable<Camera>;
  34082. /**
  34083. * sets the active camera of the scene using its name
  34084. * @param name defines the camera's name
  34085. * @returns the new active camera or null if none found.
  34086. */
  34087. setActiveCameraByName(name: string): Nullable<Camera>;
  34088. /**
  34089. * get an animation group using its name
  34090. * @param name defines the material's name
  34091. * @return the animation group or null if none found.
  34092. */
  34093. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  34094. /**
  34095. * Get a material using its unique id
  34096. * @param uniqueId defines the material's unique id
  34097. * @return the material or null if none found.
  34098. */
  34099. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  34100. /**
  34101. * get a material using its id
  34102. * @param id defines the material's ID
  34103. * @return the material or null if none found.
  34104. */
  34105. getMaterialByID(id: string): Nullable<Material>;
  34106. /**
  34107. * Gets a material using its name
  34108. * @param name defines the material's name
  34109. * @return the material or null if none found.
  34110. */
  34111. getMaterialByName(name: string): Nullable<Material>;
  34112. /**
  34113. * Gets a camera using its id
  34114. * @param id defines the id to look for
  34115. * @returns the camera or null if not found
  34116. */
  34117. getCameraByID(id: string): Nullable<Camera>;
  34118. /**
  34119. * Gets a camera using its unique id
  34120. * @param uniqueId defines the unique id to look for
  34121. * @returns the camera or null if not found
  34122. */
  34123. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  34124. /**
  34125. * Gets a camera using its name
  34126. * @param name defines the camera's name
  34127. * @return the camera or null if none found.
  34128. */
  34129. getCameraByName(name: string): Nullable<Camera>;
  34130. /**
  34131. * Gets a bone using its id
  34132. * @param id defines the bone's id
  34133. * @return the bone or null if not found
  34134. */
  34135. getBoneByID(id: string): Nullable<Bone>;
  34136. /**
  34137. * Gets a bone using its id
  34138. * @param name defines the bone's name
  34139. * @return the bone or null if not found
  34140. */
  34141. getBoneByName(name: string): Nullable<Bone>;
  34142. /**
  34143. * Gets a light node using its name
  34144. * @param name defines the the light's name
  34145. * @return the light or null if none found.
  34146. */
  34147. getLightByName(name: string): Nullable<Light>;
  34148. /**
  34149. * Gets a light node using its id
  34150. * @param id defines the light's id
  34151. * @return the light or null if none found.
  34152. */
  34153. getLightByID(id: string): Nullable<Light>;
  34154. /**
  34155. * Gets a light node using its scene-generated unique ID
  34156. * @param uniqueId defines the light's unique id
  34157. * @return the light or null if none found.
  34158. */
  34159. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  34160. /**
  34161. * Gets a particle system by id
  34162. * @param id defines the particle system id
  34163. * @return the corresponding system or null if none found
  34164. */
  34165. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  34166. /**
  34167. * Gets a geometry using its ID
  34168. * @param id defines the geometry's id
  34169. * @return the geometry or null if none found.
  34170. */
  34171. getGeometryByID(id: string): Nullable<Geometry>;
  34172. private _getGeometryByUniqueID;
  34173. /**
  34174. * Add a new geometry to this scene
  34175. * @param geometry defines the geometry to be added to the scene.
  34176. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  34177. * @return a boolean defining if the geometry was added or not
  34178. */
  34179. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  34180. /**
  34181. * Removes an existing geometry
  34182. * @param geometry defines the geometry to be removed from the scene
  34183. * @return a boolean defining if the geometry was removed or not
  34184. */
  34185. removeGeometry(geometry: Geometry): boolean;
  34186. /**
  34187. * Gets the list of geometries attached to the scene
  34188. * @returns an array of Geometry
  34189. */
  34190. getGeometries(): Geometry[];
  34191. /**
  34192. * Gets the first added mesh found of a given ID
  34193. * @param id defines the id to search for
  34194. * @return the mesh found or null if not found at all
  34195. */
  34196. getMeshByID(id: string): Nullable<AbstractMesh>;
  34197. /**
  34198. * Gets a list of meshes using their id
  34199. * @param id defines the id to search for
  34200. * @returns a list of meshes
  34201. */
  34202. getMeshesByID(id: string): Array<AbstractMesh>;
  34203. /**
  34204. * Gets the first added transform node found of a given ID
  34205. * @param id defines the id to search for
  34206. * @return the found transform node or null if not found at all.
  34207. */
  34208. getTransformNodeByID(id: string): Nullable<TransformNode>;
  34209. /**
  34210. * Gets a transform node with its auto-generated unique id
  34211. * @param uniqueId efines the unique id to search for
  34212. * @return the found transform node or null if not found at all.
  34213. */
  34214. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  34215. /**
  34216. * Gets a list of transform nodes using their id
  34217. * @param id defines the id to search for
  34218. * @returns a list of transform nodes
  34219. */
  34220. getTransformNodesByID(id: string): Array<TransformNode>;
  34221. /**
  34222. * Gets a mesh with its auto-generated unique id
  34223. * @param uniqueId defines the unique id to search for
  34224. * @return the found mesh or null if not found at all.
  34225. */
  34226. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  34227. /**
  34228. * Gets a the last added mesh using a given id
  34229. * @param id defines the id to search for
  34230. * @return the found mesh or null if not found at all.
  34231. */
  34232. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  34233. /**
  34234. * Gets a the last added node (Mesh, Camera, Light) using a given id
  34235. * @param id defines the id to search for
  34236. * @return the found node or null if not found at all
  34237. */
  34238. getLastEntryByID(id: string): Nullable<Node>;
  34239. /**
  34240. * Gets a node (Mesh, Camera, Light) using a given id
  34241. * @param id defines the id to search for
  34242. * @return the found node or null if not found at all
  34243. */
  34244. getNodeByID(id: string): Nullable<Node>;
  34245. /**
  34246. * Gets a node (Mesh, Camera, Light) using a given name
  34247. * @param name defines the name to search for
  34248. * @return the found node or null if not found at all.
  34249. */
  34250. getNodeByName(name: string): Nullable<Node>;
  34251. /**
  34252. * Gets a mesh using a given name
  34253. * @param name defines the name to search for
  34254. * @return the found mesh or null if not found at all.
  34255. */
  34256. getMeshByName(name: string): Nullable<AbstractMesh>;
  34257. /**
  34258. * Gets a transform node using a given name
  34259. * @param name defines the name to search for
  34260. * @return the found transform node or null if not found at all.
  34261. */
  34262. getTransformNodeByName(name: string): Nullable<TransformNode>;
  34263. /**
  34264. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  34265. * @param id defines the id to search for
  34266. * @return the found skeleton or null if not found at all.
  34267. */
  34268. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  34269. /**
  34270. * Gets a skeleton using a given auto generated unique id
  34271. * @param uniqueId defines the unique id to search for
  34272. * @return the found skeleton or null if not found at all.
  34273. */
  34274. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  34275. /**
  34276. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  34277. * @param id defines the id to search for
  34278. * @return the found skeleton or null if not found at all.
  34279. */
  34280. getSkeletonById(id: string): Nullable<Skeleton>;
  34281. /**
  34282. * Gets a skeleton using a given name
  34283. * @param name defines the name to search for
  34284. * @return the found skeleton or null if not found at all.
  34285. */
  34286. getSkeletonByName(name: string): Nullable<Skeleton>;
  34287. /**
  34288. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  34289. * @param id defines the id to search for
  34290. * @return the found morph target manager or null if not found at all.
  34291. */
  34292. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  34293. /**
  34294. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  34295. * @param id defines the id to search for
  34296. * @return the found morph target or null if not found at all.
  34297. */
  34298. getMorphTargetById(id: string): Nullable<MorphTarget>;
  34299. /**
  34300. * Gets a boolean indicating if the given mesh is active
  34301. * @param mesh defines the mesh to look for
  34302. * @returns true if the mesh is in the active list
  34303. */
  34304. isActiveMesh(mesh: AbstractMesh): boolean;
  34305. /**
  34306. * Return a unique id as a string which can serve as an identifier for the scene
  34307. */
  34308. readonly uid: string;
  34309. /**
  34310. * Add an externaly attached data from its key.
  34311. * This method call will fail and return false, if such key already exists.
  34312. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  34313. * @param key the unique key that identifies the data
  34314. * @param data the data object to associate to the key for this Engine instance
  34315. * @return true if no such key were already present and the data was added successfully, false otherwise
  34316. */
  34317. addExternalData<T>(key: string, data: T): boolean;
  34318. /**
  34319. * Get an externaly attached data from its key
  34320. * @param key the unique key that identifies the data
  34321. * @return the associated data, if present (can be null), or undefined if not present
  34322. */
  34323. getExternalData<T>(key: string): Nullable<T>;
  34324. /**
  34325. * Get an externaly attached data from its key, create it using a factory if it's not already present
  34326. * @param key the unique key that identifies the data
  34327. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  34328. * @return the associated data, can be null if the factory returned null.
  34329. */
  34330. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  34331. /**
  34332. * Remove an externaly attached data from the Engine instance
  34333. * @param key the unique key that identifies the data
  34334. * @return true if the data was successfully removed, false if it doesn't exist
  34335. */
  34336. removeExternalData(key: string): boolean;
  34337. private _evaluateSubMesh;
  34338. /**
  34339. * Clear the processed materials smart array preventing retention point in material dispose.
  34340. */
  34341. freeProcessedMaterials(): void;
  34342. private _preventFreeActiveMeshesAndRenderingGroups;
  34343. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  34344. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  34345. * when disposing several meshes in a row or a hierarchy of meshes.
  34346. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  34347. */
  34348. blockfreeActiveMeshesAndRenderingGroups: boolean;
  34349. /**
  34350. * Clear the active meshes smart array preventing retention point in mesh dispose.
  34351. */
  34352. freeActiveMeshes(): void;
  34353. /**
  34354. * Clear the info related to rendering groups preventing retention points during dispose.
  34355. */
  34356. freeRenderingGroups(): void;
  34357. /** @hidden */
  34358. _isInIntermediateRendering(): boolean;
  34359. /**
  34360. * Lambda returning the list of potentially active meshes.
  34361. */
  34362. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  34363. /**
  34364. * Lambda returning the list of potentially active sub meshes.
  34365. */
  34366. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  34367. /**
  34368. * Lambda returning the list of potentially intersecting sub meshes.
  34369. */
  34370. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  34371. /**
  34372. * Lambda returning the list of potentially colliding sub meshes.
  34373. */
  34374. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  34375. private _activeMeshesFrozen;
  34376. /**
  34377. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  34378. * @returns the current scene
  34379. */
  34380. freezeActiveMeshes(): Scene;
  34381. /**
  34382. * Use this function to restart evaluating active meshes on every frame
  34383. * @returns the current scene
  34384. */
  34385. unfreezeActiveMeshes(): Scene;
  34386. private _evaluateActiveMeshes;
  34387. private _activeMesh;
  34388. /**
  34389. * Update the transform matrix to update from the current active camera
  34390. * @param force defines a boolean used to force the update even if cache is up to date
  34391. */
  34392. updateTransformMatrix(force?: boolean): void;
  34393. private _bindFrameBuffer;
  34394. /** @hidden */
  34395. _allowPostProcessClearColor: boolean;
  34396. /** @hidden */
  34397. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  34398. private _processSubCameras;
  34399. private _checkIntersections;
  34400. /** @hidden */
  34401. _advancePhysicsEngineStep(step: number): void;
  34402. /**
  34403. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  34404. */
  34405. getDeterministicFrameTime: () => number;
  34406. /** @hidden */
  34407. _animate(): void;
  34408. /** Execute all animations (for a frame) */
  34409. animate(): void;
  34410. /**
  34411. * Render the scene
  34412. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  34413. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  34414. */
  34415. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  34416. /**
  34417. * Freeze all materials
  34418. * A frozen material will not be updatable but should be faster to render
  34419. */
  34420. freezeMaterials(): void;
  34421. /**
  34422. * Unfreeze all materials
  34423. * A frozen material will not be updatable but should be faster to render
  34424. */
  34425. unfreezeMaterials(): void;
  34426. /**
  34427. * Releases all held ressources
  34428. */
  34429. dispose(): void;
  34430. /**
  34431. * Gets if the scene is already disposed
  34432. */
  34433. readonly isDisposed: boolean;
  34434. /**
  34435. * Call this function to reduce memory footprint of the scene.
  34436. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  34437. */
  34438. clearCachedVertexData(): void;
  34439. /**
  34440. * This function will remove the local cached buffer data from texture.
  34441. * It will save memory but will prevent the texture from being rebuilt
  34442. */
  34443. cleanCachedTextureBuffer(): void;
  34444. /**
  34445. * Get the world extend vectors with an optional filter
  34446. *
  34447. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  34448. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  34449. */
  34450. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  34451. min: Vector3;
  34452. max: Vector3;
  34453. };
  34454. /**
  34455. * Creates a ray that can be used to pick in the scene
  34456. * @param x defines the x coordinate of the origin (on-screen)
  34457. * @param y defines the y coordinate of the origin (on-screen)
  34458. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34459. * @param camera defines the camera to use for the picking
  34460. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34461. * @returns a Ray
  34462. */
  34463. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  34464. /**
  34465. * Creates a ray that can be used to pick in the scene
  34466. * @param x defines the x coordinate of the origin (on-screen)
  34467. * @param y defines the y coordinate of the origin (on-screen)
  34468. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34469. * @param result defines the ray where to store the picking ray
  34470. * @param camera defines the camera to use for the picking
  34471. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34472. * @returns the current scene
  34473. */
  34474. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  34475. /**
  34476. * Creates a ray that can be used to pick in the scene
  34477. * @param x defines the x coordinate of the origin (on-screen)
  34478. * @param y defines the y coordinate of the origin (on-screen)
  34479. * @param camera defines the camera to use for the picking
  34480. * @returns a Ray
  34481. */
  34482. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  34483. /**
  34484. * Creates a ray that can be used to pick in the scene
  34485. * @param x defines the x coordinate of the origin (on-screen)
  34486. * @param y defines the y coordinate of the origin (on-screen)
  34487. * @param result defines the ray where to store the picking ray
  34488. * @param camera defines the camera to use for the picking
  34489. * @returns the current scene
  34490. */
  34491. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  34492. /** Launch a ray to try to pick a mesh in the scene
  34493. * @param x position on screen
  34494. * @param y position on screen
  34495. * @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
  34496. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  34497. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34498. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34499. * @returns a PickingInfo
  34500. */
  34501. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: (p0: Vector3, p1: Vector3, p2: Vector3) => boolean): Nullable<PickingInfo>;
  34502. /** Use the given ray to pick a mesh in the scene
  34503. * @param ray The ray to use to pick meshes
  34504. * @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
  34505. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  34506. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34507. * @returns a PickingInfo
  34508. */
  34509. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  34510. /**
  34511. * Launch a ray to try to pick a mesh in the scene
  34512. * @param x X position on screen
  34513. * @param y Y position on screen
  34514. * @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
  34515. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34516. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34517. * @returns an array of PickingInfo
  34518. */
  34519. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34520. /**
  34521. * Launch a ray to try to pick a mesh in the scene
  34522. * @param ray Ray to use
  34523. * @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
  34524. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34525. * @returns an array of PickingInfo
  34526. */
  34527. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34528. /**
  34529. * Force the value of meshUnderPointer
  34530. * @param mesh defines the mesh to use
  34531. */
  34532. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  34533. /**
  34534. * Gets the mesh under the pointer
  34535. * @returns a Mesh or null if no mesh is under the pointer
  34536. */
  34537. getPointerOverMesh(): Nullable<AbstractMesh>;
  34538. /** @hidden */
  34539. _rebuildGeometries(): void;
  34540. /** @hidden */
  34541. _rebuildTextures(): void;
  34542. private _getByTags;
  34543. /**
  34544. * Get a list of meshes by tags
  34545. * @param tagsQuery defines the tags query to use
  34546. * @param forEach defines a predicate used to filter results
  34547. * @returns an array of Mesh
  34548. */
  34549. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  34550. /**
  34551. * Get a list of cameras by tags
  34552. * @param tagsQuery defines the tags query to use
  34553. * @param forEach defines a predicate used to filter results
  34554. * @returns an array of Camera
  34555. */
  34556. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  34557. /**
  34558. * Get a list of lights by tags
  34559. * @param tagsQuery defines the tags query to use
  34560. * @param forEach defines a predicate used to filter results
  34561. * @returns an array of Light
  34562. */
  34563. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  34564. /**
  34565. * Get a list of materials by tags
  34566. * @param tagsQuery defines the tags query to use
  34567. * @param forEach defines a predicate used to filter results
  34568. * @returns an array of Material
  34569. */
  34570. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  34571. /**
  34572. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  34573. * This allowed control for front to back rendering or reversly depending of the special needs.
  34574. *
  34575. * @param renderingGroupId The rendering group id corresponding to its index
  34576. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  34577. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  34578. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  34579. */
  34580. 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;
  34581. /**
  34582. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  34583. *
  34584. * @param renderingGroupId The rendering group id corresponding to its index
  34585. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  34586. * @param depth Automatically clears depth between groups if true and autoClear is true.
  34587. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  34588. */
  34589. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  34590. /**
  34591. * Gets the current auto clear configuration for one rendering group of the rendering
  34592. * manager.
  34593. * @param index the rendering group index to get the information for
  34594. * @returns The auto clear setup for the requested rendering group
  34595. */
  34596. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  34597. private _blockMaterialDirtyMechanism;
  34598. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  34599. blockMaterialDirtyMechanism: boolean;
  34600. /**
  34601. * Will flag all materials as dirty to trigger new shader compilation
  34602. * @param flag defines the flag used to specify which material part must be marked as dirty
  34603. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  34604. */
  34605. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  34606. /** @hidden */
  34607. _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;
  34608. /** @hidden */
  34609. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34610. }
  34611. }
  34612. declare module "babylonjs/assetContainer" {
  34613. import { AbstractScene } from "babylonjs/abstractScene";
  34614. import { Scene } from "babylonjs/scene";
  34615. import { Mesh } from "babylonjs/Meshes/mesh";
  34616. /**
  34617. * Set of assets to keep when moving a scene into an asset container.
  34618. */
  34619. export class KeepAssets extends AbstractScene {
  34620. }
  34621. /**
  34622. * Container with a set of assets that can be added or removed from a scene.
  34623. */
  34624. export class AssetContainer extends AbstractScene {
  34625. /**
  34626. * The scene the AssetContainer belongs to.
  34627. */
  34628. scene: Scene;
  34629. /**
  34630. * Instantiates an AssetContainer.
  34631. * @param scene The scene the AssetContainer belongs to.
  34632. */
  34633. constructor(scene: Scene);
  34634. /**
  34635. * Adds all the assets from the container to the scene.
  34636. */
  34637. addAllToScene(): void;
  34638. /**
  34639. * Removes all the assets in the container from the scene
  34640. */
  34641. removeAllFromScene(): void;
  34642. /**
  34643. * Disposes all the assets in the container
  34644. */
  34645. dispose(): void;
  34646. private _moveAssets;
  34647. /**
  34648. * Removes all the assets contained in the scene and adds them to the container.
  34649. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  34650. */
  34651. moveAllFromScene(keepAssets?: KeepAssets): void;
  34652. /**
  34653. * 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.
  34654. * @returns the root mesh
  34655. */
  34656. createRootMesh(): Mesh;
  34657. }
  34658. }
  34659. declare module "babylonjs/abstractScene" {
  34660. import { Scene } from "babylonjs/scene";
  34661. import { Nullable } from "babylonjs/types";
  34662. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  34663. import { TransformNode } from "babylonjs/Meshes/transformNode";
  34664. import { Geometry } from "babylonjs/Meshes/geometry";
  34665. import { Skeleton } from "babylonjs/Bones/skeleton";
  34666. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  34667. import { AssetContainer } from "babylonjs/assetContainer";
  34668. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  34669. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  34670. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  34671. import { Material } from "babylonjs/Materials/material";
  34672. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  34673. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  34674. import { Camera } from "babylonjs/Cameras/camera";
  34675. import { Light } from "babylonjs/Lights/light";
  34676. import { Node } from "babylonjs/node";
  34677. import { Animation } from "babylonjs/Animations/animation";
  34678. /**
  34679. * Defines how the parser contract is defined.
  34680. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  34681. */
  34682. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  34683. /**
  34684. * Defines how the individual parser contract is defined.
  34685. * These parser can parse an individual asset
  34686. */
  34687. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  34688. /**
  34689. * Base class of the scene acting as a container for the different elements composing a scene.
  34690. * This class is dynamically extended by the different components of the scene increasing
  34691. * flexibility and reducing coupling
  34692. */
  34693. export abstract class AbstractScene {
  34694. /**
  34695. * Stores the list of available parsers in the application.
  34696. */
  34697. private static _BabylonFileParsers;
  34698. /**
  34699. * Stores the list of available individual parsers in the application.
  34700. */
  34701. private static _IndividualBabylonFileParsers;
  34702. /**
  34703. * Adds a parser in the list of available ones
  34704. * @param name Defines the name of the parser
  34705. * @param parser Defines the parser to add
  34706. */
  34707. static AddParser(name: string, parser: BabylonFileParser): void;
  34708. /**
  34709. * Gets a general parser from the list of avaialble ones
  34710. * @param name Defines the name of the parser
  34711. * @returns the requested parser or null
  34712. */
  34713. static GetParser(name: string): Nullable<BabylonFileParser>;
  34714. /**
  34715. * Adds n individual parser in the list of available ones
  34716. * @param name Defines the name of the parser
  34717. * @param parser Defines the parser to add
  34718. */
  34719. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  34720. /**
  34721. * Gets an individual parser from the list of avaialble ones
  34722. * @param name Defines the name of the parser
  34723. * @returns the requested parser or null
  34724. */
  34725. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  34726. /**
  34727. * Parser json data and populate both a scene and its associated container object
  34728. * @param jsonData Defines the data to parse
  34729. * @param scene Defines the scene to parse the data for
  34730. * @param container Defines the container attached to the parsing sequence
  34731. * @param rootUrl Defines the root url of the data
  34732. */
  34733. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  34734. /**
  34735. * Gets the list of root nodes (ie. nodes with no parent)
  34736. */
  34737. rootNodes: Node[];
  34738. /** All of the cameras added to this scene
  34739. * @see http://doc.babylonjs.com/babylon101/cameras
  34740. */
  34741. cameras: Camera[];
  34742. /**
  34743. * All of the lights added to this scene
  34744. * @see http://doc.babylonjs.com/babylon101/lights
  34745. */
  34746. lights: Light[];
  34747. /**
  34748. * All of the (abstract) meshes added to this scene
  34749. */
  34750. meshes: AbstractMesh[];
  34751. /**
  34752. * The list of skeletons added to the scene
  34753. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  34754. */
  34755. skeletons: Skeleton[];
  34756. /**
  34757. * All of the particle systems added to this scene
  34758. * @see http://doc.babylonjs.com/babylon101/particles
  34759. */
  34760. particleSystems: IParticleSystem[];
  34761. /**
  34762. * Gets a list of Animations associated with the scene
  34763. */
  34764. animations: Animation[];
  34765. /**
  34766. * All of the animation groups added to this scene
  34767. * @see http://doc.babylonjs.com/how_to/group
  34768. */
  34769. animationGroups: AnimationGroup[];
  34770. /**
  34771. * All of the multi-materials added to this scene
  34772. * @see http://doc.babylonjs.com/how_to/multi_materials
  34773. */
  34774. multiMaterials: MultiMaterial[];
  34775. /**
  34776. * All of the materials added to this scene
  34777. * In the context of a Scene, it is not supposed to be modified manually.
  34778. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  34779. * Note also that the order of the Material wihin the array is not significant and might change.
  34780. * @see http://doc.babylonjs.com/babylon101/materials
  34781. */
  34782. materials: Material[];
  34783. /**
  34784. * The list of morph target managers added to the scene
  34785. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  34786. */
  34787. morphTargetManagers: MorphTargetManager[];
  34788. /**
  34789. * The list of geometries used in the scene.
  34790. */
  34791. geometries: Geometry[];
  34792. /**
  34793. * All of the tranform nodes added to this scene
  34794. * In the context of a Scene, it is not supposed to be modified manually.
  34795. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  34796. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  34797. * @see http://doc.babylonjs.com/how_to/transformnode
  34798. */
  34799. transformNodes: TransformNode[];
  34800. /**
  34801. * ActionManagers available on the scene.
  34802. */
  34803. actionManagers: AbstractActionManager[];
  34804. /**
  34805. * Textures to keep.
  34806. */
  34807. textures: BaseTexture[];
  34808. /**
  34809. * Environment texture for the scene
  34810. */
  34811. environmentTexture: Nullable<BaseTexture>;
  34812. }
  34813. }
  34814. declare module "babylonjs/Audio/sound" {
  34815. import { Observable } from "babylonjs/Misc/observable";
  34816. import { Vector3 } from "babylonjs/Maths/math";
  34817. import { Nullable } from "babylonjs/types";
  34818. import { Scene } from "babylonjs/scene";
  34819. import { TransformNode } from "babylonjs/Meshes/transformNode";
  34820. /**
  34821. * Defines a sound that can be played in the application.
  34822. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  34823. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34824. */
  34825. export class Sound {
  34826. /**
  34827. * The name of the sound in the scene.
  34828. */
  34829. name: string;
  34830. /**
  34831. * Does the sound autoplay once loaded.
  34832. */
  34833. autoplay: boolean;
  34834. /**
  34835. * Does the sound loop after it finishes playing once.
  34836. */
  34837. loop: boolean;
  34838. /**
  34839. * Does the sound use a custom attenuation curve to simulate the falloff
  34840. * happening when the source gets further away from the camera.
  34841. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  34842. */
  34843. useCustomAttenuation: boolean;
  34844. /**
  34845. * The sound track id this sound belongs to.
  34846. */
  34847. soundTrackId: number;
  34848. /**
  34849. * Is this sound currently played.
  34850. */
  34851. isPlaying: boolean;
  34852. /**
  34853. * Is this sound currently paused.
  34854. */
  34855. isPaused: boolean;
  34856. /**
  34857. * Does this sound enables spatial sound.
  34858. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34859. */
  34860. spatialSound: boolean;
  34861. /**
  34862. * Define the reference distance the sound should be heard perfectly.
  34863. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34864. */
  34865. refDistance: number;
  34866. /**
  34867. * Define the roll off factor of spatial sounds.
  34868. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34869. */
  34870. rolloffFactor: number;
  34871. /**
  34872. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  34873. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34874. */
  34875. maxDistance: number;
  34876. /**
  34877. * Define the distance attenuation model the sound will follow.
  34878. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34879. */
  34880. distanceModel: string;
  34881. /**
  34882. * @hidden
  34883. * Back Compat
  34884. **/
  34885. onended: () => any;
  34886. /**
  34887. * Observable event when the current playing sound finishes.
  34888. */
  34889. onEndedObservable: Observable<Sound>;
  34890. private _panningModel;
  34891. private _playbackRate;
  34892. private _streaming;
  34893. private _startTime;
  34894. private _startOffset;
  34895. private _position;
  34896. /** @hidden */
  34897. _positionInEmitterSpace: boolean;
  34898. private _localDirection;
  34899. private _volume;
  34900. private _isReadyToPlay;
  34901. private _isDirectional;
  34902. private _readyToPlayCallback;
  34903. private _audioBuffer;
  34904. private _soundSource;
  34905. private _streamingSource;
  34906. private _soundPanner;
  34907. private _soundGain;
  34908. private _inputAudioNode;
  34909. private _outputAudioNode;
  34910. private _coneInnerAngle;
  34911. private _coneOuterAngle;
  34912. private _coneOuterGain;
  34913. private _scene;
  34914. private _connectedTransformNode;
  34915. private _customAttenuationFunction;
  34916. private _registerFunc;
  34917. private _isOutputConnected;
  34918. private _htmlAudioElement;
  34919. private _urlType;
  34920. /** @hidden */
  34921. static _SceneComponentInitialization: (scene: Scene) => void;
  34922. /**
  34923. * Create a sound and attach it to a scene
  34924. * @param name Name of your sound
  34925. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  34926. * @param scene defines the scene the sound belongs to
  34927. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  34928. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  34929. */
  34930. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  34931. /**
  34932. * Release the sound and its associated resources
  34933. */
  34934. dispose(): void;
  34935. /**
  34936. * Gets if the sounds is ready to be played or not.
  34937. * @returns true if ready, otherwise false
  34938. */
  34939. isReady(): boolean;
  34940. private _soundLoaded;
  34941. /**
  34942. * Sets the data of the sound from an audiobuffer
  34943. * @param audioBuffer The audioBuffer containing the data
  34944. */
  34945. setAudioBuffer(audioBuffer: AudioBuffer): void;
  34946. /**
  34947. * Updates the current sounds options such as maxdistance, loop...
  34948. * @param options A JSON object containing values named as the object properties
  34949. */
  34950. updateOptions(options: any): void;
  34951. private _createSpatialParameters;
  34952. private _updateSpatialParameters;
  34953. /**
  34954. * Switch the panning model to HRTF:
  34955. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34956. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34957. */
  34958. switchPanningModelToHRTF(): void;
  34959. /**
  34960. * Switch the panning model to Equal Power:
  34961. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34962. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34963. */
  34964. switchPanningModelToEqualPower(): void;
  34965. private _switchPanningModel;
  34966. /**
  34967. * Connect this sound to a sound track audio node like gain...
  34968. * @param soundTrackAudioNode the sound track audio node to connect to
  34969. */
  34970. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  34971. /**
  34972. * Transform this sound into a directional source
  34973. * @param coneInnerAngle Size of the inner cone in degree
  34974. * @param coneOuterAngle Size of the outer cone in degree
  34975. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  34976. */
  34977. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  34978. /**
  34979. * Gets or sets the inner angle for the directional cone.
  34980. */
  34981. /**
  34982. * Gets or sets the inner angle for the directional cone.
  34983. */
  34984. directionalConeInnerAngle: number;
  34985. /**
  34986. * Gets or sets the outer angle for the directional cone.
  34987. */
  34988. /**
  34989. * Gets or sets the outer angle for the directional cone.
  34990. */
  34991. directionalConeOuterAngle: number;
  34992. /**
  34993. * Sets the position of the emitter if spatial sound is enabled
  34994. * @param newPosition Defines the new posisiton
  34995. */
  34996. setPosition(newPosition: Vector3): void;
  34997. /**
  34998. * Sets the local direction of the emitter if spatial sound is enabled
  34999. * @param newLocalDirection Defines the new local direction
  35000. */
  35001. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  35002. private _updateDirection;
  35003. /** @hidden */
  35004. updateDistanceFromListener(): void;
  35005. /**
  35006. * Sets a new custom attenuation function for the sound.
  35007. * @param callback Defines the function used for the attenuation
  35008. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  35009. */
  35010. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  35011. /**
  35012. * Play the sound
  35013. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  35014. * @param offset (optional) Start the sound setting it at a specific time
  35015. */
  35016. play(time?: number, offset?: number): void;
  35017. private _onended;
  35018. /**
  35019. * Stop the sound
  35020. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  35021. */
  35022. stop(time?: number): void;
  35023. /**
  35024. * Put the sound in pause
  35025. */
  35026. pause(): void;
  35027. /**
  35028. * Sets a dedicated volume for this sounds
  35029. * @param newVolume Define the new volume of the sound
  35030. * @param time Define in how long the sound should be at this value
  35031. */
  35032. setVolume(newVolume: number, time?: number): void;
  35033. /**
  35034. * Set the sound play back rate
  35035. * @param newPlaybackRate Define the playback rate the sound should be played at
  35036. */
  35037. setPlaybackRate(newPlaybackRate: number): void;
  35038. /**
  35039. * Gets the volume of the sound.
  35040. * @returns the volume of the sound
  35041. */
  35042. getVolume(): number;
  35043. /**
  35044. * Attach the sound to a dedicated mesh
  35045. * @param transformNode The transform node to connect the sound with
  35046. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  35047. */
  35048. attachToMesh(transformNode: TransformNode): void;
  35049. /**
  35050. * Detach the sound from the previously attached mesh
  35051. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  35052. */
  35053. detachFromMesh(): void;
  35054. private _onRegisterAfterWorldMatrixUpdate;
  35055. /**
  35056. * Clone the current sound in the scene.
  35057. * @returns the new sound clone
  35058. */
  35059. clone(): Nullable<Sound>;
  35060. /**
  35061. * Gets the current underlying audio buffer containing the data
  35062. * @returns the audio buffer
  35063. */
  35064. getAudioBuffer(): Nullable<AudioBuffer>;
  35065. /**
  35066. * Serializes the Sound in a JSON representation
  35067. * @returns the JSON representation of the sound
  35068. */
  35069. serialize(): any;
  35070. /**
  35071. * Parse a JSON representation of a sound to innstantiate in a given scene
  35072. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  35073. * @param scene Define the scene the new parsed sound should be created in
  35074. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  35075. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  35076. * @returns the newly parsed sound
  35077. */
  35078. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  35079. }
  35080. }
  35081. declare module "babylonjs/Actions/directAudioActions" {
  35082. import { Action } from "babylonjs/Actions/action";
  35083. import { Condition } from "babylonjs/Actions/condition";
  35084. import { Sound } from "babylonjs/Audio/sound";
  35085. /**
  35086. * This defines an action helpful to play a defined sound on a triggered action.
  35087. */
  35088. export class PlaySoundAction extends Action {
  35089. private _sound;
  35090. /**
  35091. * Instantiate the action
  35092. * @param triggerOptions defines the trigger options
  35093. * @param sound defines the sound to play
  35094. * @param condition defines the trigger related conditions
  35095. */
  35096. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  35097. /** @hidden */
  35098. _prepare(): void;
  35099. /**
  35100. * Execute the action and play the sound.
  35101. */
  35102. execute(): void;
  35103. /**
  35104. * Serializes the actions and its related information.
  35105. * @param parent defines the object to serialize in
  35106. * @returns the serialized object
  35107. */
  35108. serialize(parent: any): any;
  35109. }
  35110. /**
  35111. * This defines an action helpful to stop a defined sound on a triggered action.
  35112. */
  35113. export class StopSoundAction extends Action {
  35114. private _sound;
  35115. /**
  35116. * Instantiate the action
  35117. * @param triggerOptions defines the trigger options
  35118. * @param sound defines the sound to stop
  35119. * @param condition defines the trigger related conditions
  35120. */
  35121. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  35122. /** @hidden */
  35123. _prepare(): void;
  35124. /**
  35125. * Execute the action and stop the sound.
  35126. */
  35127. execute(): void;
  35128. /**
  35129. * Serializes the actions and its related information.
  35130. * @param parent defines the object to serialize in
  35131. * @returns the serialized object
  35132. */
  35133. serialize(parent: any): any;
  35134. }
  35135. }
  35136. declare module "babylonjs/Actions/interpolateValueAction" {
  35137. import { Action } from "babylonjs/Actions/action";
  35138. import { Condition } from "babylonjs/Actions/condition";
  35139. import { Observable } from "babylonjs/Misc/observable";
  35140. /**
  35141. * This defines an action responsible to change the value of a property
  35142. * by interpolating between its current value and the newly set one once triggered.
  35143. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  35144. */
  35145. export class InterpolateValueAction extends Action {
  35146. /**
  35147. * Defines the path of the property where the value should be interpolated
  35148. */
  35149. propertyPath: string;
  35150. /**
  35151. * Defines the target value at the end of the interpolation.
  35152. */
  35153. value: any;
  35154. /**
  35155. * Defines the time it will take for the property to interpolate to the value.
  35156. */
  35157. duration: number;
  35158. /**
  35159. * Defines if the other scene animations should be stopped when the action has been triggered
  35160. */
  35161. stopOtherAnimations?: boolean;
  35162. /**
  35163. * Defines a callback raised once the interpolation animation has been done.
  35164. */
  35165. onInterpolationDone?: () => void;
  35166. /**
  35167. * Observable triggered once the interpolation animation has been done.
  35168. */
  35169. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  35170. private _target;
  35171. private _effectiveTarget;
  35172. private _property;
  35173. /**
  35174. * Instantiate the action
  35175. * @param triggerOptions defines the trigger options
  35176. * @param target defines the object containing the value to interpolate
  35177. * @param propertyPath defines the path to the property in the target object
  35178. * @param value defines the target value at the end of the interpolation
  35179. * @param duration deines the time it will take for the property to interpolate to the value.
  35180. * @param condition defines the trigger related conditions
  35181. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  35182. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  35183. */
  35184. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  35185. /** @hidden */
  35186. _prepare(): void;
  35187. /**
  35188. * Execute the action starts the value interpolation.
  35189. */
  35190. execute(): void;
  35191. /**
  35192. * Serializes the actions and its related information.
  35193. * @param parent defines the object to serialize in
  35194. * @returns the serialized object
  35195. */
  35196. serialize(parent: any): any;
  35197. }
  35198. }
  35199. declare module "babylonjs/Actions/index" {
  35200. export * from "babylonjs/Actions/action";
  35201. export * from "babylonjs/Actions/actionEvent";
  35202. export * from "babylonjs/Actions/actionManager";
  35203. export * from "babylonjs/Actions/condition";
  35204. export * from "babylonjs/Actions/directActions";
  35205. export * from "babylonjs/Actions/directAudioActions";
  35206. export * from "babylonjs/Actions/interpolateValueAction";
  35207. }
  35208. declare module "babylonjs/Animations/index" {
  35209. export * from "babylonjs/Animations/animatable";
  35210. export * from "babylonjs/Animations/animation";
  35211. export * from "babylonjs/Animations/animationGroup";
  35212. export * from "babylonjs/Animations/animationPropertiesOverride";
  35213. export * from "babylonjs/Animations/easing";
  35214. export * from "babylonjs/Animations/runtimeAnimation";
  35215. export * from "babylonjs/Animations/animationEvent";
  35216. export * from "babylonjs/Animations/animationGroup";
  35217. export * from "babylonjs/Animations/animationKey";
  35218. export * from "babylonjs/Animations/animationRange";
  35219. }
  35220. declare module "babylonjs/Audio/soundTrack" {
  35221. import { Sound } from "babylonjs/Audio/sound";
  35222. import { Analyser } from "babylonjs/Audio/analyser";
  35223. import { Scene } from "babylonjs/scene";
  35224. /**
  35225. * Options allowed during the creation of a sound track.
  35226. */
  35227. export interface ISoundTrackOptions {
  35228. /**
  35229. * The volume the sound track should take during creation
  35230. */
  35231. volume?: number;
  35232. /**
  35233. * Define if the sound track is the main sound track of the scene
  35234. */
  35235. mainTrack?: boolean;
  35236. }
  35237. /**
  35238. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  35239. * It will be also used in a future release to apply effects on a specific track.
  35240. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  35241. */
  35242. export class SoundTrack {
  35243. /**
  35244. * The unique identifier of the sound track in the scene.
  35245. */
  35246. id: number;
  35247. /**
  35248. * The list of sounds included in the sound track.
  35249. */
  35250. soundCollection: Array<Sound>;
  35251. private _outputAudioNode;
  35252. private _scene;
  35253. private _isMainTrack;
  35254. private _connectedAnalyser;
  35255. private _options;
  35256. private _isInitialized;
  35257. /**
  35258. * Creates a new sound track.
  35259. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  35260. * @param scene Define the scene the sound track belongs to
  35261. * @param options
  35262. */
  35263. constructor(scene: Scene, options?: ISoundTrackOptions);
  35264. private _initializeSoundTrackAudioGraph;
  35265. /**
  35266. * Release the sound track and its associated resources
  35267. */
  35268. dispose(): void;
  35269. /**
  35270. * Adds a sound to this sound track
  35271. * @param sound define the cound to add
  35272. * @ignoreNaming
  35273. */
  35274. AddSound(sound: Sound): void;
  35275. /**
  35276. * Removes a sound to this sound track
  35277. * @param sound define the cound to remove
  35278. * @ignoreNaming
  35279. */
  35280. RemoveSound(sound: Sound): void;
  35281. /**
  35282. * Set a global volume for the full sound track.
  35283. * @param newVolume Define the new volume of the sound track
  35284. */
  35285. setVolume(newVolume: number): void;
  35286. /**
  35287. * Switch the panning model to HRTF:
  35288. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  35289. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35290. */
  35291. switchPanningModelToHRTF(): void;
  35292. /**
  35293. * Switch the panning model to Equal Power:
  35294. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  35295. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35296. */
  35297. switchPanningModelToEqualPower(): void;
  35298. /**
  35299. * Connect the sound track to an audio analyser allowing some amazing
  35300. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  35301. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  35302. * @param analyser The analyser to connect to the engine
  35303. */
  35304. connectToAnalyser(analyser: Analyser): void;
  35305. }
  35306. }
  35307. declare module "babylonjs/Audio/audioSceneComponent" {
  35308. import { Sound } from "babylonjs/Audio/sound";
  35309. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  35310. import { Nullable } from "babylonjs/types";
  35311. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  35312. import { Scene } from "babylonjs/scene";
  35313. import { AbstractScene } from "babylonjs/abstractScene";
  35314. module "babylonjs/abstractScene" {
  35315. interface AbstractScene {
  35316. /**
  35317. * The list of sounds used in the scene.
  35318. */
  35319. sounds: Nullable<Array<Sound>>;
  35320. }
  35321. }
  35322. module "babylonjs/scene" {
  35323. interface Scene {
  35324. /**
  35325. * @hidden
  35326. * Backing field
  35327. */
  35328. _mainSoundTrack: SoundTrack;
  35329. /**
  35330. * The main sound track played by the scene.
  35331. * It cotains your primary collection of sounds.
  35332. */
  35333. mainSoundTrack: SoundTrack;
  35334. /**
  35335. * The list of sound tracks added to the scene
  35336. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35337. */
  35338. soundTracks: Nullable<Array<SoundTrack>>;
  35339. /**
  35340. * Gets a sound using a given name
  35341. * @param name defines the name to search for
  35342. * @return the found sound or null if not found at all.
  35343. */
  35344. getSoundByName(name: string): Nullable<Sound>;
  35345. /**
  35346. * Gets or sets if audio support is enabled
  35347. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35348. */
  35349. audioEnabled: boolean;
  35350. /**
  35351. * Gets or sets if audio will be output to headphones
  35352. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35353. */
  35354. headphone: boolean;
  35355. }
  35356. }
  35357. /**
  35358. * Defines the sound scene component responsible to manage any sounds
  35359. * in a given scene.
  35360. */
  35361. export class AudioSceneComponent implements ISceneSerializableComponent {
  35362. /**
  35363. * The component name helpfull to identify the component in the list of scene components.
  35364. */
  35365. readonly name: string;
  35366. /**
  35367. * The scene the component belongs to.
  35368. */
  35369. scene: Scene;
  35370. private _audioEnabled;
  35371. /**
  35372. * Gets whether audio is enabled or not.
  35373. * Please use related enable/disable method to switch state.
  35374. */
  35375. readonly audioEnabled: boolean;
  35376. private _headphone;
  35377. /**
  35378. * Gets whether audio is outputing to headphone or not.
  35379. * Please use the according Switch methods to change output.
  35380. */
  35381. readonly headphone: boolean;
  35382. /**
  35383. * Creates a new instance of the component for the given scene
  35384. * @param scene Defines the scene to register the component in
  35385. */
  35386. constructor(scene: Scene);
  35387. /**
  35388. * Registers the component in a given scene
  35389. */
  35390. register(): void;
  35391. /**
  35392. * Rebuilds the elements related to this component in case of
  35393. * context lost for instance.
  35394. */
  35395. rebuild(): void;
  35396. /**
  35397. * Serializes the component data to the specified json object
  35398. * @param serializationObject The object to serialize to
  35399. */
  35400. serialize(serializationObject: any): void;
  35401. /**
  35402. * Adds all the elements from the container to the scene
  35403. * @param container the container holding the elements
  35404. */
  35405. addFromContainer(container: AbstractScene): void;
  35406. /**
  35407. * Removes all the elements in the container from the scene
  35408. * @param container contains the elements to remove
  35409. * @param dispose if the removed element should be disposed (default: false)
  35410. */
  35411. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  35412. /**
  35413. * Disposes the component and the associated ressources.
  35414. */
  35415. dispose(): void;
  35416. /**
  35417. * Disables audio in the associated scene.
  35418. */
  35419. disableAudio(): void;
  35420. /**
  35421. * Enables audio in the associated scene.
  35422. */
  35423. enableAudio(): void;
  35424. /**
  35425. * Switch audio to headphone output.
  35426. */
  35427. switchAudioModeForHeadphones(): void;
  35428. /**
  35429. * Switch audio to normal speakers.
  35430. */
  35431. switchAudioModeForNormalSpeakers(): void;
  35432. private _afterRender;
  35433. }
  35434. }
  35435. declare module "babylonjs/Audio/weightedsound" {
  35436. import { Sound } from "babylonjs/Audio/sound";
  35437. /**
  35438. * Wraps one or more Sound objects and selects one with random weight for playback.
  35439. */
  35440. export class WeightedSound {
  35441. /** When true a Sound will be selected and played when the current playing Sound completes. */
  35442. loop: boolean;
  35443. private _coneInnerAngle;
  35444. private _coneOuterAngle;
  35445. private _volume;
  35446. /** A Sound is currently playing. */
  35447. isPlaying: boolean;
  35448. /** A Sound is currently paused. */
  35449. isPaused: boolean;
  35450. private _sounds;
  35451. private _weights;
  35452. private _currentIndex?;
  35453. /**
  35454. * Creates a new WeightedSound from the list of sounds given.
  35455. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  35456. * @param sounds Array of Sounds that will be selected from.
  35457. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  35458. */
  35459. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  35460. /**
  35461. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  35462. */
  35463. /**
  35464. * The size of cone in degress for a directional sound in which there will be no attenuation.
  35465. */
  35466. directionalConeInnerAngle: number;
  35467. /**
  35468. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35469. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35470. */
  35471. /**
  35472. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35473. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35474. */
  35475. directionalConeOuterAngle: number;
  35476. /**
  35477. * Playback volume.
  35478. */
  35479. /**
  35480. * Playback volume.
  35481. */
  35482. volume: number;
  35483. private _onended;
  35484. /**
  35485. * Suspend playback
  35486. */
  35487. pause(): void;
  35488. /**
  35489. * Stop playback
  35490. */
  35491. stop(): void;
  35492. /**
  35493. * Start playback.
  35494. * @param startOffset Position the clip head at a specific time in seconds.
  35495. */
  35496. play(startOffset?: number): void;
  35497. }
  35498. }
  35499. declare module "babylonjs/Audio/index" {
  35500. export * from "babylonjs/Audio/analyser";
  35501. export * from "babylonjs/Audio/audioEngine";
  35502. export * from "babylonjs/Audio/audioSceneComponent";
  35503. export * from "babylonjs/Audio/sound";
  35504. export * from "babylonjs/Audio/soundTrack";
  35505. export * from "babylonjs/Audio/weightedsound";
  35506. }
  35507. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  35508. import { Behavior } from "babylonjs/Behaviors/behavior";
  35509. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35510. import { BackEase } from "babylonjs/Animations/easing";
  35511. /**
  35512. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  35513. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35514. */
  35515. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  35516. /**
  35517. * Gets the name of the behavior.
  35518. */
  35519. readonly name: string;
  35520. /**
  35521. * The easing function used by animations
  35522. */
  35523. static EasingFunction: BackEase;
  35524. /**
  35525. * The easing mode used by animations
  35526. */
  35527. static EasingMode: number;
  35528. /**
  35529. * The duration of the animation, in milliseconds
  35530. */
  35531. transitionDuration: number;
  35532. /**
  35533. * Length of the distance animated by the transition when lower radius is reached
  35534. */
  35535. lowerRadiusTransitionRange: number;
  35536. /**
  35537. * Length of the distance animated by the transition when upper radius is reached
  35538. */
  35539. upperRadiusTransitionRange: number;
  35540. private _autoTransitionRange;
  35541. /**
  35542. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35543. */
  35544. /**
  35545. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35546. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  35547. */
  35548. autoTransitionRange: boolean;
  35549. private _attachedCamera;
  35550. private _onAfterCheckInputsObserver;
  35551. private _onMeshTargetChangedObserver;
  35552. /**
  35553. * Initializes the behavior.
  35554. */
  35555. init(): void;
  35556. /**
  35557. * Attaches the behavior to its arc rotate camera.
  35558. * @param camera Defines the camera to attach the behavior to
  35559. */
  35560. attach(camera: ArcRotateCamera): void;
  35561. /**
  35562. * Detaches the behavior from its current arc rotate camera.
  35563. */
  35564. detach(): void;
  35565. private _radiusIsAnimating;
  35566. private _radiusBounceTransition;
  35567. private _animatables;
  35568. private _cachedWheelPrecision;
  35569. /**
  35570. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  35571. * @param radiusLimit The limit to check against.
  35572. * @return Bool to indicate if at limit.
  35573. */
  35574. private _isRadiusAtLimit;
  35575. /**
  35576. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  35577. * @param radiusDelta The delta by which to animate to. Can be negative.
  35578. */
  35579. private _applyBoundRadiusAnimation;
  35580. /**
  35581. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  35582. */
  35583. protected _clearAnimationLocks(): void;
  35584. /**
  35585. * Stops and removes all animations that have been applied to the camera
  35586. */
  35587. stopAllAnimations(): void;
  35588. }
  35589. }
  35590. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  35591. import { Behavior } from "babylonjs/Behaviors/behavior";
  35592. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35593. import { ExponentialEase } from "babylonjs/Animations/easing";
  35594. import { Nullable } from "babylonjs/types";
  35595. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35596. import { Vector3 } from "babylonjs/Maths/math";
  35597. /**
  35598. * 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.
  35599. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35600. */
  35601. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  35602. /**
  35603. * Gets the name of the behavior.
  35604. */
  35605. readonly name: string;
  35606. private _mode;
  35607. private _radiusScale;
  35608. private _positionScale;
  35609. private _defaultElevation;
  35610. private _elevationReturnTime;
  35611. private _elevationReturnWaitTime;
  35612. private _zoomStopsAnimation;
  35613. private _framingTime;
  35614. /**
  35615. * The easing function used by animations
  35616. */
  35617. static EasingFunction: ExponentialEase;
  35618. /**
  35619. * The easing mode used by animations
  35620. */
  35621. static EasingMode: number;
  35622. /**
  35623. * Sets the current mode used by the behavior
  35624. */
  35625. /**
  35626. * Gets current mode used by the behavior.
  35627. */
  35628. mode: number;
  35629. /**
  35630. * Sets the scale applied to the radius (1 by default)
  35631. */
  35632. /**
  35633. * Gets the scale applied to the radius
  35634. */
  35635. radiusScale: number;
  35636. /**
  35637. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35638. */
  35639. /**
  35640. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35641. */
  35642. positionScale: number;
  35643. /**
  35644. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35645. * behaviour is triggered, in radians.
  35646. */
  35647. /**
  35648. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35649. * behaviour is triggered, in radians.
  35650. */
  35651. defaultElevation: number;
  35652. /**
  35653. * Sets the time (in milliseconds) taken to return to the default beta position.
  35654. * Negative value indicates camera should not return to default.
  35655. */
  35656. /**
  35657. * Gets the time (in milliseconds) taken to return to the default beta position.
  35658. * Negative value indicates camera should not return to default.
  35659. */
  35660. elevationReturnTime: number;
  35661. /**
  35662. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35663. */
  35664. /**
  35665. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35666. */
  35667. elevationReturnWaitTime: number;
  35668. /**
  35669. * Sets the flag that indicates if user zooming should stop animation.
  35670. */
  35671. /**
  35672. * Gets the flag that indicates if user zooming should stop animation.
  35673. */
  35674. zoomStopsAnimation: boolean;
  35675. /**
  35676. * Sets the transition time when framing the mesh, in milliseconds
  35677. */
  35678. /**
  35679. * Gets the transition time when framing the mesh, in milliseconds
  35680. */
  35681. framingTime: number;
  35682. /**
  35683. * Define if the behavior should automatically change the configured
  35684. * camera limits and sensibilities.
  35685. */
  35686. autoCorrectCameraLimitsAndSensibility: boolean;
  35687. private _onPrePointerObservableObserver;
  35688. private _onAfterCheckInputsObserver;
  35689. private _onMeshTargetChangedObserver;
  35690. private _attachedCamera;
  35691. private _isPointerDown;
  35692. private _lastInteractionTime;
  35693. /**
  35694. * Initializes the behavior.
  35695. */
  35696. init(): void;
  35697. /**
  35698. * Attaches the behavior to its arc rotate camera.
  35699. * @param camera Defines the camera to attach the behavior to
  35700. */
  35701. attach(camera: ArcRotateCamera): void;
  35702. /**
  35703. * Detaches the behavior from its current arc rotate camera.
  35704. */
  35705. detach(): void;
  35706. private _animatables;
  35707. private _betaIsAnimating;
  35708. private _betaTransition;
  35709. private _radiusTransition;
  35710. private _vectorTransition;
  35711. /**
  35712. * Targets the given mesh and updates zoom level accordingly.
  35713. * @param mesh The mesh to target.
  35714. * @param radius Optional. If a cached radius position already exists, overrides default.
  35715. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35716. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35717. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35718. */
  35719. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35720. /**
  35721. * Targets the given mesh with its children and updates zoom level accordingly.
  35722. * @param mesh The mesh to target.
  35723. * @param radius Optional. If a cached radius position already exists, overrides default.
  35724. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35725. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35726. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35727. */
  35728. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35729. /**
  35730. * Targets the given meshes with their children and updates zoom level accordingly.
  35731. * @param meshes The mesh to target.
  35732. * @param radius Optional. If a cached radius position already exists, overrides default.
  35733. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35734. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35735. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35736. */
  35737. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35738. /**
  35739. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  35740. * @param minimumWorld Determines the smaller position of the bounding box extend
  35741. * @param maximumWorld Determines the bigger position of the bounding box extend
  35742. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35743. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35744. */
  35745. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35746. /**
  35747. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  35748. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  35749. * frustum width.
  35750. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  35751. * to fully enclose the mesh in the viewing frustum.
  35752. */
  35753. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  35754. /**
  35755. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  35756. * is automatically returned to its default position (expected to be above ground plane).
  35757. */
  35758. private _maintainCameraAboveGround;
  35759. /**
  35760. * Returns the frustum slope based on the canvas ratio and camera FOV
  35761. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  35762. */
  35763. private _getFrustumSlope;
  35764. /**
  35765. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  35766. */
  35767. private _clearAnimationLocks;
  35768. /**
  35769. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  35770. */
  35771. private _applyUserInteraction;
  35772. /**
  35773. * Stops and removes all animations that have been applied to the camera
  35774. */
  35775. stopAllAnimations(): void;
  35776. /**
  35777. * Gets a value indicating if the user is moving the camera
  35778. */
  35779. readonly isUserIsMoving: boolean;
  35780. /**
  35781. * The camera can move all the way towards the mesh.
  35782. */
  35783. static IgnoreBoundsSizeMode: number;
  35784. /**
  35785. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  35786. */
  35787. static FitFrustumSidesMode: number;
  35788. }
  35789. }
  35790. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  35791. import { Nullable } from "babylonjs/types";
  35792. import { Camera } from "babylonjs/Cameras/camera";
  35793. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  35794. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  35795. /**
  35796. * Base class for Camera Pointer Inputs.
  35797. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  35798. * for example usage.
  35799. */
  35800. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  35801. /**
  35802. * Defines the camera the input is attached to.
  35803. */
  35804. abstract camera: Camera;
  35805. /**
  35806. * Whether keyboard modifier keys are pressed at time of last mouse event.
  35807. */
  35808. protected _altKey: boolean;
  35809. protected _ctrlKey: boolean;
  35810. protected _metaKey: boolean;
  35811. protected _shiftKey: boolean;
  35812. /**
  35813. * Which mouse buttons were pressed at time of last mouse event.
  35814. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  35815. */
  35816. protected _buttonsPressed: number;
  35817. /**
  35818. * Defines the buttons associated with the input to handle camera move.
  35819. */
  35820. buttons: number[];
  35821. /**
  35822. * Attach the input controls to a specific dom element to get the input from.
  35823. * @param element Defines the element the controls should be listened from
  35824. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35825. */
  35826. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35827. /**
  35828. * Detach the current controls from the specified dom element.
  35829. * @param element Defines the element to stop listening the inputs from
  35830. */
  35831. detachControl(element: Nullable<HTMLElement>): void;
  35832. /**
  35833. * Gets the class name of the current input.
  35834. * @returns the class name
  35835. */
  35836. getClassName(): string;
  35837. /**
  35838. * Get the friendly name associated with the input class.
  35839. * @returns the input friendly name
  35840. */
  35841. getSimpleName(): string;
  35842. /**
  35843. * Called on pointer POINTERDOUBLETAP event.
  35844. * Override this method to provide functionality on POINTERDOUBLETAP event.
  35845. */
  35846. protected onDoubleTap(type: string): void;
  35847. /**
  35848. * Called on pointer POINTERMOVE event if only a single touch is active.
  35849. * Override this method to provide functionality.
  35850. */
  35851. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  35852. /**
  35853. * Called on pointer POINTERMOVE event if multiple touches are active.
  35854. * Override this method to provide functionality.
  35855. */
  35856. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  35857. /**
  35858. * Called on JS contextmenu event.
  35859. * Override this method to provide functionality.
  35860. */
  35861. protected onContextMenu(evt: PointerEvent): void;
  35862. /**
  35863. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  35864. * press.
  35865. * Override this method to provide functionality.
  35866. */
  35867. protected onButtonDown(evt: PointerEvent): void;
  35868. /**
  35869. * Called each time a new POINTERUP event occurs. Ie, for each button
  35870. * release.
  35871. * Override this method to provide functionality.
  35872. */
  35873. protected onButtonUp(evt: PointerEvent): void;
  35874. /**
  35875. * Called when window becomes inactive.
  35876. * Override this method to provide functionality.
  35877. */
  35878. protected onLostFocus(): void;
  35879. private _pointerInput;
  35880. private _observer;
  35881. private _onLostFocus;
  35882. private pointA;
  35883. private pointB;
  35884. }
  35885. }
  35886. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  35887. import { Nullable } from "babylonjs/types";
  35888. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35889. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  35890. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  35891. /**
  35892. * Manage the pointers inputs to control an arc rotate camera.
  35893. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35894. */
  35895. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  35896. /**
  35897. * Defines the camera the input is attached to.
  35898. */
  35899. camera: ArcRotateCamera;
  35900. /**
  35901. * Gets the class name of the current input.
  35902. * @returns the class name
  35903. */
  35904. getClassName(): string;
  35905. /**
  35906. * Defines the buttons associated with the input to handle camera move.
  35907. */
  35908. buttons: number[];
  35909. /**
  35910. * Defines the pointer angular sensibility along the X axis or how fast is
  35911. * the camera rotating.
  35912. */
  35913. angularSensibilityX: number;
  35914. /**
  35915. * Defines the pointer angular sensibility along the Y axis or how fast is
  35916. * the camera rotating.
  35917. */
  35918. angularSensibilityY: number;
  35919. /**
  35920. * Defines the pointer pinch precision or how fast is the camera zooming.
  35921. */
  35922. pinchPrecision: number;
  35923. /**
  35924. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  35925. * from 0.
  35926. * It defines the percentage of current camera.radius to use as delta when
  35927. * pinch zoom is used.
  35928. */
  35929. pinchDeltaPercentage: number;
  35930. /**
  35931. * Defines the pointer panning sensibility or how fast is the camera moving.
  35932. */
  35933. panningSensibility: number;
  35934. /**
  35935. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  35936. */
  35937. multiTouchPanning: boolean;
  35938. /**
  35939. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  35940. * zoom (pinch) through multitouch.
  35941. */
  35942. multiTouchPanAndZoom: boolean;
  35943. /**
  35944. * Revers pinch action direction.
  35945. */
  35946. pinchInwards: boolean;
  35947. private _isPanClick;
  35948. private _twoFingerActivityCount;
  35949. private _isPinching;
  35950. /**
  35951. * Called on pointer POINTERMOVE event if only a single touch is active.
  35952. */
  35953. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  35954. /**
  35955. * Called on pointer POINTERDOUBLETAP event.
  35956. */
  35957. protected onDoubleTap(type: string): void;
  35958. /**
  35959. * Called on pointer POINTERMOVE event if multiple touches are active.
  35960. */
  35961. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  35962. /**
  35963. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  35964. * press.
  35965. */
  35966. protected onButtonDown(evt: PointerEvent): void;
  35967. /**
  35968. * Called each time a new POINTERUP event occurs. Ie, for each button
  35969. * release.
  35970. */
  35971. protected onButtonUp(evt: PointerEvent): void;
  35972. /**
  35973. * Called when window becomes inactive.
  35974. */
  35975. protected onLostFocus(): void;
  35976. }
  35977. }
  35978. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  35979. import { Nullable } from "babylonjs/types";
  35980. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35981. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  35982. /**
  35983. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  35984. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35985. */
  35986. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  35987. /**
  35988. * Defines the camera the input is attached to.
  35989. */
  35990. camera: ArcRotateCamera;
  35991. /**
  35992. * Defines the list of key codes associated with the up action (increase alpha)
  35993. */
  35994. keysUp: number[];
  35995. /**
  35996. * Defines the list of key codes associated with the down action (decrease alpha)
  35997. */
  35998. keysDown: number[];
  35999. /**
  36000. * Defines the list of key codes associated with the left action (increase beta)
  36001. */
  36002. keysLeft: number[];
  36003. /**
  36004. * Defines the list of key codes associated with the right action (decrease beta)
  36005. */
  36006. keysRight: number[];
  36007. /**
  36008. * Defines the list of key codes associated with the reset action.
  36009. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  36010. */
  36011. keysReset: number[];
  36012. /**
  36013. * Defines the panning sensibility of the inputs.
  36014. * (How fast is the camera paning)
  36015. */
  36016. panningSensibility: number;
  36017. /**
  36018. * Defines the zooming sensibility of the inputs.
  36019. * (How fast is the camera zooming)
  36020. */
  36021. zoomingSensibility: number;
  36022. /**
  36023. * Defines wether maintaining the alt key down switch the movement mode from
  36024. * orientation to zoom.
  36025. */
  36026. useAltToZoom: boolean;
  36027. /**
  36028. * Rotation speed of the camera
  36029. */
  36030. angularSpeed: number;
  36031. private _keys;
  36032. private _ctrlPressed;
  36033. private _altPressed;
  36034. private _onCanvasBlurObserver;
  36035. private _onKeyboardObserver;
  36036. private _engine;
  36037. private _scene;
  36038. /**
  36039. * Attach the input controls to a specific dom element to get the input from.
  36040. * @param element Defines the element the controls should be listened from
  36041. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36042. */
  36043. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36044. /**
  36045. * Detach the current controls from the specified dom element.
  36046. * @param element Defines the element to stop listening the inputs from
  36047. */
  36048. detachControl(element: Nullable<HTMLElement>): void;
  36049. /**
  36050. * Update the current camera state depending on the inputs that have been used this frame.
  36051. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36052. */
  36053. checkInputs(): void;
  36054. /**
  36055. * Gets the class name of the current intput.
  36056. * @returns the class name
  36057. */
  36058. getClassName(): string;
  36059. /**
  36060. * Get the friendly name associated with the input class.
  36061. * @returns the input friendly name
  36062. */
  36063. getSimpleName(): string;
  36064. }
  36065. }
  36066. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  36067. import { Nullable } from "babylonjs/types";
  36068. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36069. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36070. /**
  36071. * Manage the mouse wheel inputs to control an arc rotate camera.
  36072. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36073. */
  36074. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  36075. /**
  36076. * Defines the camera the input is attached to.
  36077. */
  36078. camera: ArcRotateCamera;
  36079. /**
  36080. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  36081. */
  36082. wheelPrecision: number;
  36083. /**
  36084. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  36085. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  36086. */
  36087. wheelDeltaPercentage: number;
  36088. private _wheel;
  36089. private _observer;
  36090. private computeDeltaFromMouseWheelLegacyEvent;
  36091. /**
  36092. * Attach the input controls to a specific dom element to get the input from.
  36093. * @param element Defines the element the controls should be listened from
  36094. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36095. */
  36096. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36097. /**
  36098. * Detach the current controls from the specified dom element.
  36099. * @param element Defines the element to stop listening the inputs from
  36100. */
  36101. detachControl(element: Nullable<HTMLElement>): void;
  36102. /**
  36103. * Gets the class name of the current intput.
  36104. * @returns the class name
  36105. */
  36106. getClassName(): string;
  36107. /**
  36108. * Get the friendly name associated with the input class.
  36109. * @returns the input friendly name
  36110. */
  36111. getSimpleName(): string;
  36112. }
  36113. }
  36114. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  36115. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36116. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  36117. /**
  36118. * Default Inputs manager for the ArcRotateCamera.
  36119. * It groups all the default supported inputs for ease of use.
  36120. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36121. */
  36122. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  36123. /**
  36124. * Instantiates a new ArcRotateCameraInputsManager.
  36125. * @param camera Defines the camera the inputs belong to
  36126. */
  36127. constructor(camera: ArcRotateCamera);
  36128. /**
  36129. * Add mouse wheel input support to the input manager.
  36130. * @returns the current input manager
  36131. */
  36132. addMouseWheel(): ArcRotateCameraInputsManager;
  36133. /**
  36134. * Add pointers input support to the input manager.
  36135. * @returns the current input manager
  36136. */
  36137. addPointers(): ArcRotateCameraInputsManager;
  36138. /**
  36139. * Add keyboard input support to the input manager.
  36140. * @returns the current input manager
  36141. */
  36142. addKeyboard(): ArcRotateCameraInputsManager;
  36143. }
  36144. }
  36145. declare module "babylonjs/Cameras/arcRotateCamera" {
  36146. import { Observable } from "babylonjs/Misc/observable";
  36147. import { Nullable } from "babylonjs/types";
  36148. import { Scene } from "babylonjs/scene";
  36149. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math";
  36150. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36151. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  36152. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  36153. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  36154. import { Camera } from "babylonjs/Cameras/camera";
  36155. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  36156. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  36157. import { Collider } from "babylonjs/Collisions/collider";
  36158. /**
  36159. * This represents an orbital type of camera.
  36160. *
  36161. * 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.
  36162. * 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.
  36163. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  36164. */
  36165. export class ArcRotateCamera extends TargetCamera {
  36166. /**
  36167. * Defines the rotation angle of the camera along the longitudinal axis.
  36168. */
  36169. alpha: number;
  36170. /**
  36171. * Defines the rotation angle of the camera along the latitudinal axis.
  36172. */
  36173. beta: number;
  36174. /**
  36175. * Defines the radius of the camera from it s target point.
  36176. */
  36177. radius: number;
  36178. protected _target: Vector3;
  36179. protected _targetHost: Nullable<AbstractMesh>;
  36180. /**
  36181. * Defines the target point of the camera.
  36182. * The camera looks towards it form the radius distance.
  36183. */
  36184. target: Vector3;
  36185. /**
  36186. * Define the current local position of the camera in the scene
  36187. */
  36188. position: Vector3;
  36189. protected _upVector: Vector3;
  36190. protected _upToYMatrix: Matrix;
  36191. protected _YToUpMatrix: Matrix;
  36192. /**
  36193. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  36194. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  36195. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  36196. */
  36197. upVector: Vector3;
  36198. /**
  36199. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  36200. */
  36201. setMatUp(): void;
  36202. /**
  36203. * Current inertia value on the longitudinal axis.
  36204. * The bigger this number the longer it will take for the camera to stop.
  36205. */
  36206. inertialAlphaOffset: number;
  36207. /**
  36208. * Current inertia value on the latitudinal axis.
  36209. * The bigger this number the longer it will take for the camera to stop.
  36210. */
  36211. inertialBetaOffset: number;
  36212. /**
  36213. * Current inertia value on the radius axis.
  36214. * The bigger this number the longer it will take for the camera to stop.
  36215. */
  36216. inertialRadiusOffset: number;
  36217. /**
  36218. * Minimum allowed angle on the longitudinal axis.
  36219. * This can help limiting how the Camera is able to move in the scene.
  36220. */
  36221. lowerAlphaLimit: Nullable<number>;
  36222. /**
  36223. * Maximum allowed angle on the longitudinal axis.
  36224. * This can help limiting how the Camera is able to move in the scene.
  36225. */
  36226. upperAlphaLimit: Nullable<number>;
  36227. /**
  36228. * Minimum allowed angle on the latitudinal axis.
  36229. * This can help limiting how the Camera is able to move in the scene.
  36230. */
  36231. lowerBetaLimit: number;
  36232. /**
  36233. * Maximum allowed angle on the latitudinal axis.
  36234. * This can help limiting how the Camera is able to move in the scene.
  36235. */
  36236. upperBetaLimit: number;
  36237. /**
  36238. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  36239. * This can help limiting how the Camera is able to move in the scene.
  36240. */
  36241. lowerRadiusLimit: Nullable<number>;
  36242. /**
  36243. * Maximum allowed distance of the camera to the target (The camera can not get further).
  36244. * This can help limiting how the Camera is able to move in the scene.
  36245. */
  36246. upperRadiusLimit: Nullable<number>;
  36247. /**
  36248. * Defines the current inertia value used during panning of the camera along the X axis.
  36249. */
  36250. inertialPanningX: number;
  36251. /**
  36252. * Defines the current inertia value used during panning of the camera along the Y axis.
  36253. */
  36254. inertialPanningY: number;
  36255. /**
  36256. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  36257. * Basically if your fingers moves away from more than this distance you will be considered
  36258. * in pinch mode.
  36259. */
  36260. pinchToPanMaxDistance: number;
  36261. /**
  36262. * Defines the maximum distance the camera can pan.
  36263. * This could help keeping the cammera always in your scene.
  36264. */
  36265. panningDistanceLimit: Nullable<number>;
  36266. /**
  36267. * Defines the target of the camera before paning.
  36268. */
  36269. panningOriginTarget: Vector3;
  36270. /**
  36271. * Defines the value of the inertia used during panning.
  36272. * 0 would mean stop inertia and one would mean no decelleration at all.
  36273. */
  36274. panningInertia: number;
  36275. /**
  36276. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  36277. */
  36278. angularSensibilityX: number;
  36279. /**
  36280. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  36281. */
  36282. angularSensibilityY: number;
  36283. /**
  36284. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  36285. */
  36286. pinchPrecision: number;
  36287. /**
  36288. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  36289. * It will be used instead of pinchDeltaPrecision if different from 0.
  36290. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  36291. */
  36292. pinchDeltaPercentage: number;
  36293. /**
  36294. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  36295. */
  36296. panningSensibility: number;
  36297. /**
  36298. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  36299. */
  36300. keysUp: number[];
  36301. /**
  36302. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  36303. */
  36304. keysDown: number[];
  36305. /**
  36306. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  36307. */
  36308. keysLeft: number[];
  36309. /**
  36310. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  36311. */
  36312. keysRight: number[];
  36313. /**
  36314. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  36315. */
  36316. wheelPrecision: number;
  36317. /**
  36318. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  36319. * It will be used instead of pinchDeltaPrecision if different from 0.
  36320. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  36321. */
  36322. wheelDeltaPercentage: number;
  36323. /**
  36324. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  36325. */
  36326. zoomOnFactor: number;
  36327. /**
  36328. * Defines a screen offset for the camera position.
  36329. */
  36330. targetScreenOffset: Vector2;
  36331. /**
  36332. * Allows the camera to be completely reversed.
  36333. * If false the camera can not arrive upside down.
  36334. */
  36335. allowUpsideDown: boolean;
  36336. /**
  36337. * Define if double tap/click is used to restore the previously saved state of the camera.
  36338. */
  36339. useInputToRestoreState: boolean;
  36340. /** @hidden */
  36341. _viewMatrix: Matrix;
  36342. /** @hidden */
  36343. _useCtrlForPanning: boolean;
  36344. /** @hidden */
  36345. _panningMouseButton: number;
  36346. /**
  36347. * Defines the input associated to the camera.
  36348. */
  36349. inputs: ArcRotateCameraInputsManager;
  36350. /** @hidden */
  36351. _reset: () => void;
  36352. /**
  36353. * Defines the allowed panning axis.
  36354. */
  36355. panningAxis: Vector3;
  36356. protected _localDirection: Vector3;
  36357. protected _transformedDirection: Vector3;
  36358. private _bouncingBehavior;
  36359. /**
  36360. * Gets the bouncing behavior of the camera if it has been enabled.
  36361. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36362. */
  36363. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  36364. /**
  36365. * Defines if the bouncing behavior of the camera is enabled on the camera.
  36366. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36367. */
  36368. useBouncingBehavior: boolean;
  36369. private _framingBehavior;
  36370. /**
  36371. * Gets the framing behavior of the camera if it has been enabled.
  36372. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36373. */
  36374. readonly framingBehavior: Nullable<FramingBehavior>;
  36375. /**
  36376. * Defines if the framing behavior of the camera is enabled on the camera.
  36377. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36378. */
  36379. useFramingBehavior: boolean;
  36380. private _autoRotationBehavior;
  36381. /**
  36382. * Gets the auto rotation behavior of the camera if it has been enabled.
  36383. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36384. */
  36385. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  36386. /**
  36387. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  36388. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36389. */
  36390. useAutoRotationBehavior: boolean;
  36391. /**
  36392. * Observable triggered when the mesh target has been changed on the camera.
  36393. */
  36394. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  36395. /**
  36396. * Event raised when the camera is colliding with a mesh.
  36397. */
  36398. onCollide: (collidedMesh: AbstractMesh) => void;
  36399. /**
  36400. * Defines whether the camera should check collision with the objects oh the scene.
  36401. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  36402. */
  36403. checkCollisions: boolean;
  36404. /**
  36405. * Defines the collision radius of the camera.
  36406. * This simulates a sphere around the camera.
  36407. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  36408. */
  36409. collisionRadius: Vector3;
  36410. protected _collider: Collider;
  36411. protected _previousPosition: Vector3;
  36412. protected _collisionVelocity: Vector3;
  36413. protected _newPosition: Vector3;
  36414. protected _previousAlpha: number;
  36415. protected _previousBeta: number;
  36416. protected _previousRadius: number;
  36417. protected _collisionTriggered: boolean;
  36418. protected _targetBoundingCenter: Nullable<Vector3>;
  36419. private _computationVector;
  36420. /**
  36421. * Instantiates a new ArcRotateCamera in a given scene
  36422. * @param name Defines the name of the camera
  36423. * @param alpha Defines the camera rotation along the logitudinal axis
  36424. * @param beta Defines the camera rotation along the latitudinal axis
  36425. * @param radius Defines the camera distance from its target
  36426. * @param target Defines the camera target
  36427. * @param scene Defines the scene the camera belongs to
  36428. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  36429. */
  36430. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  36431. /** @hidden */
  36432. _initCache(): void;
  36433. /** @hidden */
  36434. _updateCache(ignoreParentClass?: boolean): void;
  36435. protected _getTargetPosition(): Vector3;
  36436. private _storedAlpha;
  36437. private _storedBeta;
  36438. private _storedRadius;
  36439. private _storedTarget;
  36440. /**
  36441. * Stores the current state of the camera (alpha, beta, radius and target)
  36442. * @returns the camera itself
  36443. */
  36444. storeState(): Camera;
  36445. /**
  36446. * @hidden
  36447. * Restored camera state. You must call storeState() first
  36448. */
  36449. _restoreStateValues(): boolean;
  36450. /** @hidden */
  36451. _isSynchronizedViewMatrix(): boolean;
  36452. /**
  36453. * Attached controls to the current camera.
  36454. * @param element Defines the element the controls should be listened from
  36455. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36456. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  36457. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  36458. */
  36459. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  36460. /**
  36461. * Detach the current controls from the camera.
  36462. * The camera will stop reacting to inputs.
  36463. * @param element Defines the element to stop listening the inputs from
  36464. */
  36465. detachControl(element: HTMLElement): void;
  36466. /** @hidden */
  36467. _checkInputs(): void;
  36468. protected _checkLimits(): void;
  36469. /**
  36470. * Rebuilds angles (alpha, beta) and radius from the give position and target
  36471. */
  36472. rebuildAnglesAndRadius(): void;
  36473. /**
  36474. * Use a position to define the current camera related information like aplha, beta and radius
  36475. * @param position Defines the position to set the camera at
  36476. */
  36477. setPosition(position: Vector3): void;
  36478. /**
  36479. * Defines the target the camera should look at.
  36480. * This will automatically adapt alpha beta and radius to fit within the new target.
  36481. * @param target Defines the new target as a Vector or a mesh
  36482. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  36483. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  36484. */
  36485. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  36486. /** @hidden */
  36487. _getViewMatrix(): Matrix;
  36488. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  36489. /**
  36490. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  36491. * @param meshes Defines the mesh to zoom on
  36492. * @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)
  36493. */
  36494. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  36495. /**
  36496. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  36497. * The target will be changed but the radius
  36498. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  36499. * @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)
  36500. */
  36501. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  36502. min: Vector3;
  36503. max: Vector3;
  36504. distance: number;
  36505. }, doNotUpdateMaxZ?: boolean): void;
  36506. /**
  36507. * @override
  36508. * Override Camera.createRigCamera
  36509. */
  36510. createRigCamera(name: string, cameraIndex: number): Camera;
  36511. /**
  36512. * @hidden
  36513. * @override
  36514. * Override Camera._updateRigCameras
  36515. */
  36516. _updateRigCameras(): void;
  36517. /**
  36518. * Destroy the camera and release the current resources hold by it.
  36519. */
  36520. dispose(): void;
  36521. /**
  36522. * Gets the current object class name.
  36523. * @return the class name
  36524. */
  36525. getClassName(): string;
  36526. }
  36527. }
  36528. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  36529. import { Behavior } from "babylonjs/Behaviors/behavior";
  36530. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36531. /**
  36532. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  36533. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36534. */
  36535. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  36536. /**
  36537. * Gets the name of the behavior.
  36538. */
  36539. readonly name: string;
  36540. private _zoomStopsAnimation;
  36541. private _idleRotationSpeed;
  36542. private _idleRotationWaitTime;
  36543. private _idleRotationSpinupTime;
  36544. /**
  36545. * Sets the flag that indicates if user zooming should stop animation.
  36546. */
  36547. /**
  36548. * Gets the flag that indicates if user zooming should stop animation.
  36549. */
  36550. zoomStopsAnimation: boolean;
  36551. /**
  36552. * Sets the default speed at which the camera rotates around the model.
  36553. */
  36554. /**
  36555. * Gets the default speed at which the camera rotates around the model.
  36556. */
  36557. idleRotationSpeed: number;
  36558. /**
  36559. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  36560. */
  36561. /**
  36562. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  36563. */
  36564. idleRotationWaitTime: number;
  36565. /**
  36566. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36567. */
  36568. /**
  36569. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36570. */
  36571. idleRotationSpinupTime: number;
  36572. /**
  36573. * Gets a value indicating if the camera is currently rotating because of this behavior
  36574. */
  36575. readonly rotationInProgress: boolean;
  36576. private _onPrePointerObservableObserver;
  36577. private _onAfterCheckInputsObserver;
  36578. private _attachedCamera;
  36579. private _isPointerDown;
  36580. private _lastFrameTime;
  36581. private _lastInteractionTime;
  36582. private _cameraRotationSpeed;
  36583. /**
  36584. * Initializes the behavior.
  36585. */
  36586. init(): void;
  36587. /**
  36588. * Attaches the behavior to its arc rotate camera.
  36589. * @param camera Defines the camera to attach the behavior to
  36590. */
  36591. attach(camera: ArcRotateCamera): void;
  36592. /**
  36593. * Detaches the behavior from its current arc rotate camera.
  36594. */
  36595. detach(): void;
  36596. /**
  36597. * Returns true if user is scrolling.
  36598. * @return true if user is scrolling.
  36599. */
  36600. private _userIsZooming;
  36601. private _lastFrameRadius;
  36602. private _shouldAnimationStopForInteraction;
  36603. /**
  36604. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  36605. */
  36606. private _applyUserInteraction;
  36607. private _userIsMoving;
  36608. }
  36609. }
  36610. declare module "babylonjs/Behaviors/Cameras/index" {
  36611. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  36612. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  36613. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  36614. }
  36615. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  36616. import { Mesh } from "babylonjs/Meshes/mesh";
  36617. import { TransformNode } from "babylonjs/Meshes/transformNode";
  36618. import { Behavior } from "babylonjs/Behaviors/behavior";
  36619. /**
  36620. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  36621. */
  36622. export class AttachToBoxBehavior implements Behavior<Mesh> {
  36623. private ui;
  36624. /**
  36625. * The name of the behavior
  36626. */
  36627. name: string;
  36628. /**
  36629. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  36630. */
  36631. distanceAwayFromFace: number;
  36632. /**
  36633. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  36634. */
  36635. distanceAwayFromBottomOfFace: number;
  36636. private _faceVectors;
  36637. private _target;
  36638. private _scene;
  36639. private _onRenderObserver;
  36640. private _tmpMatrix;
  36641. private _tmpVector;
  36642. /**
  36643. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  36644. * @param ui The transform node that should be attched to the mesh
  36645. */
  36646. constructor(ui: TransformNode);
  36647. /**
  36648. * Initializes the behavior
  36649. */
  36650. init(): void;
  36651. private _closestFace;
  36652. private _zeroVector;
  36653. private _lookAtTmpMatrix;
  36654. private _lookAtToRef;
  36655. /**
  36656. * Attaches the AttachToBoxBehavior to the passed in mesh
  36657. * @param target The mesh that the specified node will be attached to
  36658. */
  36659. attach(target: Mesh): void;
  36660. /**
  36661. * Detaches the behavior from the mesh
  36662. */
  36663. detach(): void;
  36664. }
  36665. }
  36666. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  36667. import { Behavior } from "babylonjs/Behaviors/behavior";
  36668. import { Mesh } from "babylonjs/Meshes/mesh";
  36669. /**
  36670. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  36671. */
  36672. export class FadeInOutBehavior implements Behavior<Mesh> {
  36673. /**
  36674. * Time in milliseconds to delay before fading in (Default: 0)
  36675. */
  36676. delay: number;
  36677. /**
  36678. * Time in milliseconds for the mesh to fade in (Default: 300)
  36679. */
  36680. fadeInTime: number;
  36681. private _millisecondsPerFrame;
  36682. private _hovered;
  36683. private _hoverValue;
  36684. private _ownerNode;
  36685. /**
  36686. * Instatiates the FadeInOutBehavior
  36687. */
  36688. constructor();
  36689. /**
  36690. * The name of the behavior
  36691. */
  36692. readonly name: string;
  36693. /**
  36694. * Initializes the behavior
  36695. */
  36696. init(): void;
  36697. /**
  36698. * Attaches the fade behavior on the passed in mesh
  36699. * @param ownerNode The mesh that will be faded in/out once attached
  36700. */
  36701. attach(ownerNode: Mesh): void;
  36702. /**
  36703. * Detaches the behavior from the mesh
  36704. */
  36705. detach(): void;
  36706. /**
  36707. * Triggers the mesh to begin fading in or out
  36708. * @param value if the object should fade in or out (true to fade in)
  36709. */
  36710. fadeIn(value: boolean): void;
  36711. private _update;
  36712. private _setAllVisibility;
  36713. }
  36714. }
  36715. declare module "babylonjs/Misc/pivotTools" {
  36716. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36717. /**
  36718. * Class containing a set of static utilities functions for managing Pivots
  36719. * @hidden
  36720. */
  36721. export class PivotTools {
  36722. private static _PivotCached;
  36723. private static _OldPivotPoint;
  36724. private static _PivotTranslation;
  36725. private static _PivotTmpVector;
  36726. /** @hidden */
  36727. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  36728. /** @hidden */
  36729. static _RestorePivotPoint(mesh: AbstractMesh): void;
  36730. }
  36731. }
  36732. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  36733. import { Scene } from "babylonjs/scene";
  36734. import { Vector4, Plane } from "babylonjs/Maths/math";
  36735. import { Mesh } from "babylonjs/Meshes/mesh";
  36736. import { Nullable } from "babylonjs/types";
  36737. /**
  36738. * Class containing static functions to help procedurally build meshes
  36739. */
  36740. export class PlaneBuilder {
  36741. /**
  36742. * Creates a plane mesh
  36743. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  36744. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  36745. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  36746. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  36747. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  36748. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  36749. * @param name defines the name of the mesh
  36750. * @param options defines the options used to create the mesh
  36751. * @param scene defines the hosting scene
  36752. * @returns the plane mesh
  36753. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  36754. */
  36755. static CreatePlane(name: string, options: {
  36756. size?: number;
  36757. width?: number;
  36758. height?: number;
  36759. sideOrientation?: number;
  36760. frontUVs?: Vector4;
  36761. backUVs?: Vector4;
  36762. updatable?: boolean;
  36763. sourcePlane?: Plane;
  36764. }, scene?: Nullable<Scene>): Mesh;
  36765. }
  36766. }
  36767. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  36768. import { Behavior } from "babylonjs/Behaviors/behavior";
  36769. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36770. import { Observable } from "babylonjs/Misc/observable";
  36771. import { Vector3 } from "babylonjs/Maths/math";
  36772. import { Ray } from "babylonjs/Culling/ray";
  36773. import "babylonjs/Meshes/Builders/planeBuilder";
  36774. /**
  36775. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  36776. */
  36777. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  36778. private static _AnyMouseID;
  36779. /**
  36780. * Abstract mesh the behavior is set on
  36781. */
  36782. attachedNode: AbstractMesh;
  36783. private _dragPlane;
  36784. private _scene;
  36785. private _pointerObserver;
  36786. private _beforeRenderObserver;
  36787. private static _planeScene;
  36788. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  36789. /**
  36790. * 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)
  36791. */
  36792. maxDragAngle: number;
  36793. /**
  36794. * @hidden
  36795. */
  36796. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  36797. /**
  36798. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36799. */
  36800. currentDraggingPointerID: number;
  36801. /**
  36802. * The last position where the pointer hit the drag plane in world space
  36803. */
  36804. lastDragPosition: Vector3;
  36805. /**
  36806. * If the behavior is currently in a dragging state
  36807. */
  36808. dragging: boolean;
  36809. /**
  36810. * 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)
  36811. */
  36812. dragDeltaRatio: number;
  36813. /**
  36814. * If the drag plane orientation should be updated during the dragging (Default: true)
  36815. */
  36816. updateDragPlane: boolean;
  36817. private _debugMode;
  36818. private _moving;
  36819. /**
  36820. * Fires each time the attached mesh is dragged with the pointer
  36821. * * delta between last drag position and current drag position in world space
  36822. * * dragDistance along the drag axis
  36823. * * dragPlaneNormal normal of the current drag plane used during the drag
  36824. * * dragPlanePoint in world space where the drag intersects the drag plane
  36825. */
  36826. onDragObservable: Observable<{
  36827. delta: Vector3;
  36828. dragPlanePoint: Vector3;
  36829. dragPlaneNormal: Vector3;
  36830. dragDistance: number;
  36831. pointerId: number;
  36832. }>;
  36833. /**
  36834. * Fires each time a drag begins (eg. mouse down on mesh)
  36835. */
  36836. onDragStartObservable: Observable<{
  36837. dragPlanePoint: Vector3;
  36838. pointerId: number;
  36839. }>;
  36840. /**
  36841. * Fires each time a drag ends (eg. mouse release after drag)
  36842. */
  36843. onDragEndObservable: Observable<{
  36844. dragPlanePoint: Vector3;
  36845. pointerId: number;
  36846. }>;
  36847. /**
  36848. * If the attached mesh should be moved when dragged
  36849. */
  36850. moveAttached: boolean;
  36851. /**
  36852. * If the drag behavior will react to drag events (Default: true)
  36853. */
  36854. enabled: boolean;
  36855. /**
  36856. * If camera controls should be detached during the drag
  36857. */
  36858. detachCameraControls: boolean;
  36859. /**
  36860. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  36861. */
  36862. useObjectOrienationForDragging: boolean;
  36863. private _options;
  36864. /**
  36865. * Creates a pointer drag behavior that can be attached to a mesh
  36866. * @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)
  36867. */
  36868. constructor(options?: {
  36869. dragAxis?: Vector3;
  36870. dragPlaneNormal?: Vector3;
  36871. });
  36872. /**
  36873. * Predicate to determine if it is valid to move the object to a new position when it is moved
  36874. */
  36875. validateDrag: (targetPosition: Vector3) => boolean;
  36876. /**
  36877. * The name of the behavior
  36878. */
  36879. readonly name: string;
  36880. /**
  36881. * Initializes the behavior
  36882. */
  36883. init(): void;
  36884. private _tmpVector;
  36885. private _alternatePickedPoint;
  36886. private _worldDragAxis;
  36887. private _targetPosition;
  36888. private _attachedElement;
  36889. /**
  36890. * Attaches the drag behavior the passed in mesh
  36891. * @param ownerNode The mesh that will be dragged around once attached
  36892. */
  36893. attach(ownerNode: AbstractMesh): void;
  36894. /**
  36895. * Force relase the drag action by code.
  36896. */
  36897. releaseDrag(): void;
  36898. private _startDragRay;
  36899. private _lastPointerRay;
  36900. /**
  36901. * Simulates the start of a pointer drag event on the behavior
  36902. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  36903. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  36904. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  36905. */
  36906. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  36907. private _startDrag;
  36908. private _dragDelta;
  36909. private _moveDrag;
  36910. private _pickWithRayOnDragPlane;
  36911. private _pointA;
  36912. private _pointB;
  36913. private _pointC;
  36914. private _lineA;
  36915. private _lineB;
  36916. private _localAxis;
  36917. private _lookAt;
  36918. private _updateDragPlanePosition;
  36919. /**
  36920. * Detaches the behavior from the mesh
  36921. */
  36922. detach(): void;
  36923. }
  36924. }
  36925. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  36926. import { Mesh } from "babylonjs/Meshes/mesh";
  36927. import { Behavior } from "babylonjs/Behaviors/behavior";
  36928. /**
  36929. * A behavior that when attached to a mesh will allow the mesh to be scaled
  36930. */
  36931. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  36932. private _dragBehaviorA;
  36933. private _dragBehaviorB;
  36934. private _startDistance;
  36935. private _initialScale;
  36936. private _targetScale;
  36937. private _ownerNode;
  36938. private _sceneRenderObserver;
  36939. /**
  36940. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  36941. */
  36942. constructor();
  36943. /**
  36944. * The name of the behavior
  36945. */
  36946. readonly name: string;
  36947. /**
  36948. * Initializes the behavior
  36949. */
  36950. init(): void;
  36951. private _getCurrentDistance;
  36952. /**
  36953. * Attaches the scale behavior the passed in mesh
  36954. * @param ownerNode The mesh that will be scaled around once attached
  36955. */
  36956. attach(ownerNode: Mesh): void;
  36957. /**
  36958. * Detaches the behavior from the mesh
  36959. */
  36960. detach(): void;
  36961. }
  36962. }
  36963. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  36964. import { Behavior } from "babylonjs/Behaviors/behavior";
  36965. import { Mesh } from "babylonjs/Meshes/mesh";
  36966. import { Observable } from "babylonjs/Misc/observable";
  36967. /**
  36968. * 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
  36969. */
  36970. export class SixDofDragBehavior implements Behavior<Mesh> {
  36971. private static _virtualScene;
  36972. private _ownerNode;
  36973. private _sceneRenderObserver;
  36974. private _scene;
  36975. private _targetPosition;
  36976. private _virtualOriginMesh;
  36977. private _virtualDragMesh;
  36978. private _pointerObserver;
  36979. private _moving;
  36980. private _startingOrientation;
  36981. /**
  36982. * 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)
  36983. */
  36984. private zDragFactor;
  36985. /**
  36986. * If the object should rotate to face the drag origin
  36987. */
  36988. rotateDraggedObject: boolean;
  36989. /**
  36990. * If the behavior is currently in a dragging state
  36991. */
  36992. dragging: boolean;
  36993. /**
  36994. * 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)
  36995. */
  36996. dragDeltaRatio: number;
  36997. /**
  36998. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36999. */
  37000. currentDraggingPointerID: number;
  37001. /**
  37002. * If camera controls should be detached during the drag
  37003. */
  37004. detachCameraControls: boolean;
  37005. /**
  37006. * Fires each time a drag starts
  37007. */
  37008. onDragStartObservable: Observable<{}>;
  37009. /**
  37010. * Fires each time a drag ends (eg. mouse release after drag)
  37011. */
  37012. onDragEndObservable: Observable<{}>;
  37013. /**
  37014. * 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
  37015. */
  37016. constructor();
  37017. /**
  37018. * The name of the behavior
  37019. */
  37020. readonly name: string;
  37021. /**
  37022. * Initializes the behavior
  37023. */
  37024. init(): void;
  37025. /**
  37026. * Attaches the scale behavior the passed in mesh
  37027. * @param ownerNode The mesh that will be scaled around once attached
  37028. */
  37029. attach(ownerNode: Mesh): void;
  37030. /**
  37031. * Detaches the behavior from the mesh
  37032. */
  37033. detach(): void;
  37034. }
  37035. }
  37036. declare module "babylonjs/Behaviors/Meshes/index" {
  37037. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  37038. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  37039. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  37040. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  37041. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  37042. }
  37043. declare module "babylonjs/Behaviors/index" {
  37044. export * from "babylonjs/Behaviors/behavior";
  37045. export * from "babylonjs/Behaviors/Cameras/index";
  37046. export * from "babylonjs/Behaviors/Meshes/index";
  37047. }
  37048. declare module "babylonjs/Bones/boneIKController" {
  37049. import { Bone } from "babylonjs/Bones/bone";
  37050. import { Vector3 } from "babylonjs/Maths/math";
  37051. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37052. import { Nullable } from "babylonjs/types";
  37053. /**
  37054. * Class used to apply inverse kinematics to bones
  37055. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  37056. */
  37057. export class BoneIKController {
  37058. private static _tmpVecs;
  37059. private static _tmpQuat;
  37060. private static _tmpMats;
  37061. /**
  37062. * Gets or sets the target mesh
  37063. */
  37064. targetMesh: AbstractMesh;
  37065. /** Gets or sets the mesh used as pole */
  37066. poleTargetMesh: AbstractMesh;
  37067. /**
  37068. * Gets or sets the bone used as pole
  37069. */
  37070. poleTargetBone: Nullable<Bone>;
  37071. /**
  37072. * Gets or sets the target position
  37073. */
  37074. targetPosition: Vector3;
  37075. /**
  37076. * Gets or sets the pole target position
  37077. */
  37078. poleTargetPosition: Vector3;
  37079. /**
  37080. * Gets or sets the pole target local offset
  37081. */
  37082. poleTargetLocalOffset: Vector3;
  37083. /**
  37084. * Gets or sets the pole angle
  37085. */
  37086. poleAngle: number;
  37087. /**
  37088. * Gets or sets the mesh associated with the controller
  37089. */
  37090. mesh: AbstractMesh;
  37091. /**
  37092. * 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)
  37093. */
  37094. slerpAmount: number;
  37095. private _bone1Quat;
  37096. private _bone1Mat;
  37097. private _bone2Ang;
  37098. private _bone1;
  37099. private _bone2;
  37100. private _bone1Length;
  37101. private _bone2Length;
  37102. private _maxAngle;
  37103. private _maxReach;
  37104. private _rightHandedSystem;
  37105. private _bendAxis;
  37106. private _slerping;
  37107. private _adjustRoll;
  37108. /**
  37109. * Gets or sets maximum allowed angle
  37110. */
  37111. maxAngle: number;
  37112. /**
  37113. * Creates a new BoneIKController
  37114. * @param mesh defines the mesh to control
  37115. * @param bone defines the bone to control
  37116. * @param options defines options to set up the controller
  37117. */
  37118. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  37119. targetMesh?: AbstractMesh;
  37120. poleTargetMesh?: AbstractMesh;
  37121. poleTargetBone?: Bone;
  37122. poleTargetLocalOffset?: Vector3;
  37123. poleAngle?: number;
  37124. bendAxis?: Vector3;
  37125. maxAngle?: number;
  37126. slerpAmount?: number;
  37127. });
  37128. private _setMaxAngle;
  37129. /**
  37130. * Force the controller to update the bones
  37131. */
  37132. update(): void;
  37133. }
  37134. }
  37135. declare module "babylonjs/Bones/boneLookController" {
  37136. import { Vector3, Space } from "babylonjs/Maths/math";
  37137. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37138. import { Bone } from "babylonjs/Bones/bone";
  37139. /**
  37140. * Class used to make a bone look toward a point in space
  37141. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  37142. */
  37143. export class BoneLookController {
  37144. private static _tmpVecs;
  37145. private static _tmpQuat;
  37146. private static _tmpMats;
  37147. /**
  37148. * The target Vector3 that the bone will look at
  37149. */
  37150. target: Vector3;
  37151. /**
  37152. * The mesh that the bone is attached to
  37153. */
  37154. mesh: AbstractMesh;
  37155. /**
  37156. * The bone that will be looking to the target
  37157. */
  37158. bone: Bone;
  37159. /**
  37160. * The up axis of the coordinate system that is used when the bone is rotated
  37161. */
  37162. upAxis: Vector3;
  37163. /**
  37164. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  37165. */
  37166. upAxisSpace: Space;
  37167. /**
  37168. * Used to make an adjustment to the yaw of the bone
  37169. */
  37170. adjustYaw: number;
  37171. /**
  37172. * Used to make an adjustment to the pitch of the bone
  37173. */
  37174. adjustPitch: number;
  37175. /**
  37176. * Used to make an adjustment to the roll of the bone
  37177. */
  37178. adjustRoll: number;
  37179. /**
  37180. * 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)
  37181. */
  37182. slerpAmount: number;
  37183. private _minYaw;
  37184. private _maxYaw;
  37185. private _minPitch;
  37186. private _maxPitch;
  37187. private _minYawSin;
  37188. private _minYawCos;
  37189. private _maxYawSin;
  37190. private _maxYawCos;
  37191. private _midYawConstraint;
  37192. private _minPitchTan;
  37193. private _maxPitchTan;
  37194. private _boneQuat;
  37195. private _slerping;
  37196. private _transformYawPitch;
  37197. private _transformYawPitchInv;
  37198. private _firstFrameSkipped;
  37199. private _yawRange;
  37200. private _fowardAxis;
  37201. /**
  37202. * Gets or sets the minimum yaw angle that the bone can look to
  37203. */
  37204. minYaw: number;
  37205. /**
  37206. * Gets or sets the maximum yaw angle that the bone can look to
  37207. */
  37208. maxYaw: number;
  37209. /**
  37210. * Gets or sets the minimum pitch angle that the bone can look to
  37211. */
  37212. minPitch: number;
  37213. /**
  37214. * Gets or sets the maximum pitch angle that the bone can look to
  37215. */
  37216. maxPitch: number;
  37217. /**
  37218. * Create a BoneLookController
  37219. * @param mesh the mesh that the bone belongs to
  37220. * @param bone the bone that will be looking to the target
  37221. * @param target the target Vector3 to look at
  37222. * @param options optional settings:
  37223. * * maxYaw: the maximum angle the bone will yaw to
  37224. * * minYaw: the minimum angle the bone will yaw to
  37225. * * maxPitch: the maximum angle the bone will pitch to
  37226. * * minPitch: the minimum angle the bone will yaw to
  37227. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  37228. * * upAxis: the up axis of the coordinate system
  37229. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  37230. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  37231. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  37232. * * adjustYaw: used to make an adjustment to the yaw of the bone
  37233. * * adjustPitch: used to make an adjustment to the pitch of the bone
  37234. * * adjustRoll: used to make an adjustment to the roll of the bone
  37235. **/
  37236. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  37237. maxYaw?: number;
  37238. minYaw?: number;
  37239. maxPitch?: number;
  37240. minPitch?: number;
  37241. slerpAmount?: number;
  37242. upAxis?: Vector3;
  37243. upAxisSpace?: Space;
  37244. yawAxis?: Vector3;
  37245. pitchAxis?: Vector3;
  37246. adjustYaw?: number;
  37247. adjustPitch?: number;
  37248. adjustRoll?: number;
  37249. });
  37250. /**
  37251. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  37252. */
  37253. update(): void;
  37254. private _getAngleDiff;
  37255. private _getAngleBetween;
  37256. private _isAngleBetween;
  37257. }
  37258. }
  37259. declare module "babylonjs/Bones/index" {
  37260. export * from "babylonjs/Bones/bone";
  37261. export * from "babylonjs/Bones/boneIKController";
  37262. export * from "babylonjs/Bones/boneLookController";
  37263. export * from "babylonjs/Bones/skeleton";
  37264. }
  37265. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  37266. import { Nullable } from "babylonjs/types";
  37267. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37268. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37269. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  37270. /**
  37271. * Manage the gamepad inputs to control an arc rotate camera.
  37272. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37273. */
  37274. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  37275. /**
  37276. * Defines the camera the input is attached to.
  37277. */
  37278. camera: ArcRotateCamera;
  37279. /**
  37280. * Defines the gamepad the input is gathering event from.
  37281. */
  37282. gamepad: Nullable<Gamepad>;
  37283. /**
  37284. * Defines the gamepad rotation sensiblity.
  37285. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37286. */
  37287. gamepadRotationSensibility: number;
  37288. /**
  37289. * Defines the gamepad move sensiblity.
  37290. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37291. */
  37292. gamepadMoveSensibility: number;
  37293. private _onGamepadConnectedObserver;
  37294. private _onGamepadDisconnectedObserver;
  37295. /**
  37296. * Attach the input controls to a specific dom element to get the input from.
  37297. * @param element Defines the element the controls should be listened from
  37298. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37299. */
  37300. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37301. /**
  37302. * Detach the current controls from the specified dom element.
  37303. * @param element Defines the element to stop listening the inputs from
  37304. */
  37305. detachControl(element: Nullable<HTMLElement>): void;
  37306. /**
  37307. * Update the current camera state depending on the inputs that have been used this frame.
  37308. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37309. */
  37310. checkInputs(): void;
  37311. /**
  37312. * Gets the class name of the current intput.
  37313. * @returns the class name
  37314. */
  37315. getClassName(): string;
  37316. /**
  37317. * Get the friendly name associated with the input class.
  37318. * @returns the input friendly name
  37319. */
  37320. getSimpleName(): string;
  37321. }
  37322. }
  37323. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  37324. import { Nullable } from "babylonjs/types";
  37325. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37326. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37327. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  37328. interface ArcRotateCameraInputsManager {
  37329. /**
  37330. * Add orientation input support to the input manager.
  37331. * @returns the current input manager
  37332. */
  37333. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  37334. }
  37335. }
  37336. /**
  37337. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  37338. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37339. */
  37340. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  37341. /**
  37342. * Defines the camera the input is attached to.
  37343. */
  37344. camera: ArcRotateCamera;
  37345. /**
  37346. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  37347. */
  37348. alphaCorrection: number;
  37349. /**
  37350. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  37351. */
  37352. gammaCorrection: number;
  37353. private _alpha;
  37354. private _gamma;
  37355. private _dirty;
  37356. private _deviceOrientationHandler;
  37357. /**
  37358. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  37359. */
  37360. constructor();
  37361. /**
  37362. * Attach the input controls to a specific dom element to get the input from.
  37363. * @param element Defines the element the controls should be listened from
  37364. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37365. */
  37366. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37367. /** @hidden */
  37368. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  37369. /**
  37370. * Update the current camera state depending on the inputs that have been used this frame.
  37371. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37372. */
  37373. checkInputs(): void;
  37374. /**
  37375. * Detach the current controls from the specified dom element.
  37376. * @param element Defines the element to stop listening the inputs from
  37377. */
  37378. detachControl(element: Nullable<HTMLElement>): void;
  37379. /**
  37380. * Gets the class name of the current intput.
  37381. * @returns the class name
  37382. */
  37383. getClassName(): string;
  37384. /**
  37385. * Get the friendly name associated with the input class.
  37386. * @returns the input friendly name
  37387. */
  37388. getSimpleName(): string;
  37389. }
  37390. }
  37391. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  37392. import { Nullable } from "babylonjs/types";
  37393. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37394. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  37395. /**
  37396. * Listen to mouse events to control the camera.
  37397. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37398. */
  37399. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  37400. /**
  37401. * Defines the camera the input is attached to.
  37402. */
  37403. camera: FlyCamera;
  37404. /**
  37405. * Defines if touch is enabled. (Default is true.)
  37406. */
  37407. touchEnabled: boolean;
  37408. /**
  37409. * Defines the buttons associated with the input to handle camera rotation.
  37410. */
  37411. buttons: number[];
  37412. /**
  37413. * Assign buttons for Yaw control.
  37414. */
  37415. buttonsYaw: number[];
  37416. /**
  37417. * Assign buttons for Pitch control.
  37418. */
  37419. buttonsPitch: number[];
  37420. /**
  37421. * Assign buttons for Roll control.
  37422. */
  37423. buttonsRoll: number[];
  37424. /**
  37425. * Detect if any button is being pressed while mouse is moved.
  37426. * -1 = Mouse locked.
  37427. * 0 = Left button.
  37428. * 1 = Middle Button.
  37429. * 2 = Right Button.
  37430. */
  37431. activeButton: number;
  37432. /**
  37433. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  37434. * Higher values reduce its sensitivity.
  37435. */
  37436. angularSensibility: number;
  37437. private _mousemoveCallback;
  37438. private _observer;
  37439. private _rollObserver;
  37440. private previousPosition;
  37441. private noPreventDefault;
  37442. private element;
  37443. /**
  37444. * Listen to mouse events to control the camera.
  37445. * @param touchEnabled Define if touch is enabled. (Default is true.)
  37446. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37447. */
  37448. constructor(touchEnabled?: boolean);
  37449. /**
  37450. * Attach the mouse control to the HTML DOM element.
  37451. * @param element Defines the element that listens to the input events.
  37452. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  37453. */
  37454. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37455. /**
  37456. * Detach the current controls from the specified dom element.
  37457. * @param element Defines the element to stop listening the inputs from
  37458. */
  37459. detachControl(element: Nullable<HTMLElement>): void;
  37460. /**
  37461. * Gets the class name of the current input.
  37462. * @returns the class name.
  37463. */
  37464. getClassName(): string;
  37465. /**
  37466. * Get the friendly name associated with the input class.
  37467. * @returns the input's friendly name.
  37468. */
  37469. getSimpleName(): string;
  37470. private _pointerInput;
  37471. private _onMouseMove;
  37472. /**
  37473. * Rotate camera by mouse offset.
  37474. */
  37475. private rotateCamera;
  37476. }
  37477. }
  37478. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  37479. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  37480. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  37481. /**
  37482. * Default Inputs manager for the FlyCamera.
  37483. * It groups all the default supported inputs for ease of use.
  37484. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37485. */
  37486. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  37487. /**
  37488. * Instantiates a new FlyCameraInputsManager.
  37489. * @param camera Defines the camera the inputs belong to.
  37490. */
  37491. constructor(camera: FlyCamera);
  37492. /**
  37493. * Add keyboard input support to the input manager.
  37494. * @returns the new FlyCameraKeyboardMoveInput().
  37495. */
  37496. addKeyboard(): FlyCameraInputsManager;
  37497. /**
  37498. * Add mouse input support to the input manager.
  37499. * @param touchEnabled Enable touch screen support.
  37500. * @returns the new FlyCameraMouseInput().
  37501. */
  37502. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  37503. }
  37504. }
  37505. declare module "babylonjs/Cameras/flyCamera" {
  37506. import { Scene } from "babylonjs/scene";
  37507. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  37508. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37509. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  37510. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  37511. /**
  37512. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37513. * such as in a 3D Space Shooter or a Flight Simulator.
  37514. */
  37515. export class FlyCamera extends TargetCamera {
  37516. /**
  37517. * Define the collision ellipsoid of the camera.
  37518. * This is helpful for simulating a camera body, like a player's body.
  37519. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  37520. */
  37521. ellipsoid: Vector3;
  37522. /**
  37523. * Define an offset for the position of the ellipsoid around the camera.
  37524. * This can be helpful if the camera is attached away from the player's body center,
  37525. * such as at its head.
  37526. */
  37527. ellipsoidOffset: Vector3;
  37528. /**
  37529. * Enable or disable collisions of the camera with the rest of the scene objects.
  37530. */
  37531. checkCollisions: boolean;
  37532. /**
  37533. * Enable or disable gravity on the camera.
  37534. */
  37535. applyGravity: boolean;
  37536. /**
  37537. * Define the current direction the camera is moving to.
  37538. */
  37539. cameraDirection: Vector3;
  37540. /**
  37541. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  37542. * This overrides and empties cameraRotation.
  37543. */
  37544. rotationQuaternion: Quaternion;
  37545. /**
  37546. * Track Roll to maintain the wanted Rolling when looking around.
  37547. */
  37548. _trackRoll: number;
  37549. /**
  37550. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  37551. */
  37552. rollCorrect: number;
  37553. /**
  37554. * Mimic a banked turn, Rolling the camera when Yawing.
  37555. * It's recommended to use rollCorrect = 10 for faster banking correction.
  37556. */
  37557. bankedTurn: boolean;
  37558. /**
  37559. * Limit in radians for how much Roll banking will add. (Default: 90°)
  37560. */
  37561. bankedTurnLimit: number;
  37562. /**
  37563. * Value of 0 disables the banked Roll.
  37564. * Value of 1 is equal to the Yaw angle in radians.
  37565. */
  37566. bankedTurnMultiplier: number;
  37567. /**
  37568. * The inputs manager loads all the input sources, such as keyboard and mouse.
  37569. */
  37570. inputs: FlyCameraInputsManager;
  37571. /**
  37572. * Gets the input sensibility for mouse input.
  37573. * Higher values reduce sensitivity.
  37574. */
  37575. /**
  37576. * Sets the input sensibility for a mouse input.
  37577. * Higher values reduce sensitivity.
  37578. */
  37579. angularSensibility: number;
  37580. /**
  37581. * Get the keys for camera movement forward.
  37582. */
  37583. /**
  37584. * Set the keys for camera movement forward.
  37585. */
  37586. keysForward: number[];
  37587. /**
  37588. * Get the keys for camera movement backward.
  37589. */
  37590. keysBackward: number[];
  37591. /**
  37592. * Get the keys for camera movement up.
  37593. */
  37594. /**
  37595. * Set the keys for camera movement up.
  37596. */
  37597. keysUp: number[];
  37598. /**
  37599. * Get the keys for camera movement down.
  37600. */
  37601. /**
  37602. * Set the keys for camera movement down.
  37603. */
  37604. keysDown: number[];
  37605. /**
  37606. * Get the keys for camera movement left.
  37607. */
  37608. /**
  37609. * Set the keys for camera movement left.
  37610. */
  37611. keysLeft: number[];
  37612. /**
  37613. * Set the keys for camera movement right.
  37614. */
  37615. /**
  37616. * Set the keys for camera movement right.
  37617. */
  37618. keysRight: number[];
  37619. /**
  37620. * Event raised when the camera collides with a mesh in the scene.
  37621. */
  37622. onCollide: (collidedMesh: AbstractMesh) => void;
  37623. private _collider;
  37624. private _needMoveForGravity;
  37625. private _oldPosition;
  37626. private _diffPosition;
  37627. private _newPosition;
  37628. /** @hidden */
  37629. _localDirection: Vector3;
  37630. /** @hidden */
  37631. _transformedDirection: Vector3;
  37632. /**
  37633. * Instantiates a FlyCamera.
  37634. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37635. * such as in a 3D Space Shooter or a Flight Simulator.
  37636. * @param name Define the name of the camera in the scene.
  37637. * @param position Define the starting position of the camera in the scene.
  37638. * @param scene Define the scene the camera belongs to.
  37639. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  37640. */
  37641. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  37642. /**
  37643. * Attach a control to the HTML DOM element.
  37644. * @param element Defines the element that listens to the input events.
  37645. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  37646. */
  37647. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37648. /**
  37649. * Detach a control from the HTML DOM element.
  37650. * The camera will stop reacting to that input.
  37651. * @param element Defines the element that listens to the input events.
  37652. */
  37653. detachControl(element: HTMLElement): void;
  37654. private _collisionMask;
  37655. /**
  37656. * Get the mask that the camera ignores in collision events.
  37657. */
  37658. /**
  37659. * Set the mask that the camera ignores in collision events.
  37660. */
  37661. collisionMask: number;
  37662. /** @hidden */
  37663. _collideWithWorld(displacement: Vector3): void;
  37664. /** @hidden */
  37665. private _onCollisionPositionChange;
  37666. /** @hidden */
  37667. _checkInputs(): void;
  37668. /** @hidden */
  37669. _decideIfNeedsToMove(): boolean;
  37670. /** @hidden */
  37671. _updatePosition(): void;
  37672. /**
  37673. * Restore the Roll to its target value at the rate specified.
  37674. * @param rate - Higher means slower restoring.
  37675. * @hidden
  37676. */
  37677. restoreRoll(rate: number): void;
  37678. /**
  37679. * Destroy the camera and release the current resources held by it.
  37680. */
  37681. dispose(): void;
  37682. /**
  37683. * Get the current object class name.
  37684. * @returns the class name.
  37685. */
  37686. getClassName(): string;
  37687. }
  37688. }
  37689. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  37690. import { Nullable } from "babylonjs/types";
  37691. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37692. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  37693. /**
  37694. * Listen to keyboard events to control the camera.
  37695. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37696. */
  37697. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  37698. /**
  37699. * Defines the camera the input is attached to.
  37700. */
  37701. camera: FlyCamera;
  37702. /**
  37703. * The list of keyboard keys used to control the forward move of the camera.
  37704. */
  37705. keysForward: number[];
  37706. /**
  37707. * The list of keyboard keys used to control the backward move of the camera.
  37708. */
  37709. keysBackward: number[];
  37710. /**
  37711. * The list of keyboard keys used to control the forward move of the camera.
  37712. */
  37713. keysUp: number[];
  37714. /**
  37715. * The list of keyboard keys used to control the backward move of the camera.
  37716. */
  37717. keysDown: number[];
  37718. /**
  37719. * The list of keyboard keys used to control the right strafe move of the camera.
  37720. */
  37721. keysRight: number[];
  37722. /**
  37723. * The list of keyboard keys used to control the left strafe move of the camera.
  37724. */
  37725. keysLeft: number[];
  37726. private _keys;
  37727. private _onCanvasBlurObserver;
  37728. private _onKeyboardObserver;
  37729. private _engine;
  37730. private _scene;
  37731. /**
  37732. * Attach the input controls to a specific dom element to get the input from.
  37733. * @param element Defines the element the controls should be listened from
  37734. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37735. */
  37736. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37737. /**
  37738. * Detach the current controls from the specified dom element.
  37739. * @param element Defines the element to stop listening the inputs from
  37740. */
  37741. detachControl(element: Nullable<HTMLElement>): void;
  37742. /**
  37743. * Gets the class name of the current intput.
  37744. * @returns the class name
  37745. */
  37746. getClassName(): string;
  37747. /** @hidden */
  37748. _onLostFocus(e: FocusEvent): void;
  37749. /**
  37750. * Get the friendly name associated with the input class.
  37751. * @returns the input friendly name
  37752. */
  37753. getSimpleName(): string;
  37754. /**
  37755. * Update the current camera state depending on the inputs that have been used this frame.
  37756. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37757. */
  37758. checkInputs(): void;
  37759. }
  37760. }
  37761. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  37762. import { Nullable } from "babylonjs/types";
  37763. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  37764. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37765. /**
  37766. * Manage the mouse wheel inputs to control a follow camera.
  37767. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37768. */
  37769. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  37770. /**
  37771. * Defines the camera the input is attached to.
  37772. */
  37773. camera: FollowCamera;
  37774. /**
  37775. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  37776. */
  37777. axisControlRadius: boolean;
  37778. /**
  37779. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  37780. */
  37781. axisControlHeight: boolean;
  37782. /**
  37783. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  37784. */
  37785. axisControlRotation: boolean;
  37786. /**
  37787. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  37788. * relation to mouseWheel events.
  37789. */
  37790. wheelPrecision: number;
  37791. /**
  37792. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  37793. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  37794. */
  37795. wheelDeltaPercentage: number;
  37796. private _wheel;
  37797. private _observer;
  37798. /**
  37799. * Attach the input controls to a specific dom element to get the input from.
  37800. * @param element Defines the element the controls should be listened from
  37801. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37802. */
  37803. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37804. /**
  37805. * Detach the current controls from the specified dom element.
  37806. * @param element Defines the element to stop listening the inputs from
  37807. */
  37808. detachControl(element: Nullable<HTMLElement>): void;
  37809. /**
  37810. * Gets the class name of the current intput.
  37811. * @returns the class name
  37812. */
  37813. getClassName(): string;
  37814. /**
  37815. * Get the friendly name associated with the input class.
  37816. * @returns the input friendly name
  37817. */
  37818. getSimpleName(): string;
  37819. }
  37820. }
  37821. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  37822. import { Nullable } from "babylonjs/types";
  37823. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  37824. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  37825. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  37826. /**
  37827. * Manage the pointers inputs to control an follow camera.
  37828. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37829. */
  37830. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  37831. /**
  37832. * Defines the camera the input is attached to.
  37833. */
  37834. camera: FollowCamera;
  37835. /**
  37836. * Gets the class name of the current input.
  37837. * @returns the class name
  37838. */
  37839. getClassName(): string;
  37840. /**
  37841. * Defines the pointer angular sensibility along the X axis or how fast is
  37842. * the camera rotating.
  37843. * A negative number will reverse the axis direction.
  37844. */
  37845. angularSensibilityX: number;
  37846. /**
  37847. * Defines the pointer angular sensibility along the Y axis or how fast is
  37848. * the camera rotating.
  37849. * A negative number will reverse the axis direction.
  37850. */
  37851. angularSensibilityY: number;
  37852. /**
  37853. * Defines the pointer pinch precision or how fast is the camera zooming.
  37854. * A negative number will reverse the axis direction.
  37855. */
  37856. pinchPrecision: number;
  37857. /**
  37858. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  37859. * from 0.
  37860. * It defines the percentage of current camera.radius to use as delta when
  37861. * pinch zoom is used.
  37862. */
  37863. pinchDeltaPercentage: number;
  37864. /**
  37865. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  37866. */
  37867. axisXControlRadius: boolean;
  37868. /**
  37869. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  37870. */
  37871. axisXControlHeight: boolean;
  37872. /**
  37873. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  37874. */
  37875. axisXControlRotation: boolean;
  37876. /**
  37877. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  37878. */
  37879. axisYControlRadius: boolean;
  37880. /**
  37881. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  37882. */
  37883. axisYControlHeight: boolean;
  37884. /**
  37885. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  37886. */
  37887. axisYControlRotation: boolean;
  37888. /**
  37889. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  37890. */
  37891. axisPinchControlRadius: boolean;
  37892. /**
  37893. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  37894. */
  37895. axisPinchControlHeight: boolean;
  37896. /**
  37897. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  37898. */
  37899. axisPinchControlRotation: boolean;
  37900. /**
  37901. * Log error messages if basic misconfiguration has occurred.
  37902. */
  37903. warningEnable: boolean;
  37904. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37905. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37906. private _warningCounter;
  37907. private _warning;
  37908. }
  37909. }
  37910. declare module "babylonjs/Cameras/followCameraInputsManager" {
  37911. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  37912. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  37913. /**
  37914. * Default Inputs manager for the FollowCamera.
  37915. * It groups all the default supported inputs for ease of use.
  37916. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37917. */
  37918. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  37919. /**
  37920. * Instantiates a new FollowCameraInputsManager.
  37921. * @param camera Defines the camera the inputs belong to
  37922. */
  37923. constructor(camera: FollowCamera);
  37924. /**
  37925. * Add keyboard input support to the input manager.
  37926. * @returns the current input manager
  37927. */
  37928. addKeyboard(): FollowCameraInputsManager;
  37929. /**
  37930. * Add mouse wheel input support to the input manager.
  37931. * @returns the current input manager
  37932. */
  37933. addMouseWheel(): FollowCameraInputsManager;
  37934. /**
  37935. * Add pointers input support to the input manager.
  37936. * @returns the current input manager
  37937. */
  37938. addPointers(): FollowCameraInputsManager;
  37939. /**
  37940. * Add orientation input support to the input manager.
  37941. * @returns the current input manager
  37942. */
  37943. addVRDeviceOrientation(): FollowCameraInputsManager;
  37944. }
  37945. }
  37946. declare module "babylonjs/Cameras/followCamera" {
  37947. import { Nullable } from "babylonjs/types";
  37948. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  37949. import { Scene } from "babylonjs/scene";
  37950. import { Vector3 } from "babylonjs/Maths/math";
  37951. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37952. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  37953. /**
  37954. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  37955. * an arc rotate version arcFollowCamera are available.
  37956. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37957. */
  37958. export class FollowCamera extends TargetCamera {
  37959. /**
  37960. * Distance the follow camera should follow an object at
  37961. */
  37962. radius: number;
  37963. /**
  37964. * Minimum allowed distance of the camera to the axis of rotation
  37965. * (The camera can not get closer).
  37966. * This can help limiting how the Camera is able to move in the scene.
  37967. */
  37968. lowerRadiusLimit: Nullable<number>;
  37969. /**
  37970. * Maximum allowed distance of the camera to the axis of rotation
  37971. * (The camera can not get further).
  37972. * This can help limiting how the Camera is able to move in the scene.
  37973. */
  37974. upperRadiusLimit: Nullable<number>;
  37975. /**
  37976. * Define a rotation offset between the camera and the object it follows
  37977. */
  37978. rotationOffset: number;
  37979. /**
  37980. * Minimum allowed angle to camera position relative to target object.
  37981. * This can help limiting how the Camera is able to move in the scene.
  37982. */
  37983. lowerRotationOffsetLimit: Nullable<number>;
  37984. /**
  37985. * Maximum allowed angle to camera position relative to target object.
  37986. * This can help limiting how the Camera is able to move in the scene.
  37987. */
  37988. upperRotationOffsetLimit: Nullable<number>;
  37989. /**
  37990. * Define a height offset between the camera and the object it follows.
  37991. * It can help following an object from the top (like a car chaing a plane)
  37992. */
  37993. heightOffset: number;
  37994. /**
  37995. * Minimum allowed height of camera position relative to target object.
  37996. * This can help limiting how the Camera is able to move in the scene.
  37997. */
  37998. lowerHeightOffsetLimit: Nullable<number>;
  37999. /**
  38000. * Maximum allowed height of camera position relative to target object.
  38001. * This can help limiting how the Camera is able to move in the scene.
  38002. */
  38003. upperHeightOffsetLimit: Nullable<number>;
  38004. /**
  38005. * Define how fast the camera can accelerate to follow it s target.
  38006. */
  38007. cameraAcceleration: number;
  38008. /**
  38009. * Define the speed limit of the camera following an object.
  38010. */
  38011. maxCameraSpeed: number;
  38012. /**
  38013. * Define the target of the camera.
  38014. */
  38015. lockedTarget: Nullable<AbstractMesh>;
  38016. /**
  38017. * Defines the input associated with the camera.
  38018. */
  38019. inputs: FollowCameraInputsManager;
  38020. /**
  38021. * Instantiates the follow camera.
  38022. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38023. * @param name Define the name of the camera in the scene
  38024. * @param position Define the position of the camera
  38025. * @param scene Define the scene the camera belong to
  38026. * @param lockedTarget Define the target of the camera
  38027. */
  38028. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  38029. private _follow;
  38030. /**
  38031. * Attached controls to the current camera.
  38032. * @param element Defines the element the controls should be listened from
  38033. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38034. */
  38035. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38036. /**
  38037. * Detach the current controls from the camera.
  38038. * The camera will stop reacting to inputs.
  38039. * @param element Defines the element to stop listening the inputs from
  38040. */
  38041. detachControl(element: HTMLElement): void;
  38042. /** @hidden */
  38043. _checkInputs(): void;
  38044. private _checkLimits;
  38045. /**
  38046. * Gets the camera class name.
  38047. * @returns the class name
  38048. */
  38049. getClassName(): string;
  38050. }
  38051. /**
  38052. * Arc Rotate version of the follow camera.
  38053. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  38054. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38055. */
  38056. export class ArcFollowCamera extends TargetCamera {
  38057. /** The longitudinal angle of the camera */
  38058. alpha: number;
  38059. /** The latitudinal angle of the camera */
  38060. beta: number;
  38061. /** The radius of the camera from its target */
  38062. radius: number;
  38063. /** Define the camera target (the messh it should follow) */
  38064. target: Nullable<AbstractMesh>;
  38065. private _cartesianCoordinates;
  38066. /**
  38067. * Instantiates a new ArcFollowCamera
  38068. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38069. * @param name Define the name of the camera
  38070. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  38071. * @param beta Define the rotation angle of the camera around the elevation axis
  38072. * @param radius Define the radius of the camera from its target point
  38073. * @param target Define the target of the camera
  38074. * @param scene Define the scene the camera belongs to
  38075. */
  38076. constructor(name: string,
  38077. /** The longitudinal angle of the camera */
  38078. alpha: number,
  38079. /** The latitudinal angle of the camera */
  38080. beta: number,
  38081. /** The radius of the camera from its target */
  38082. radius: number,
  38083. /** Define the camera target (the messh it should follow) */
  38084. target: Nullable<AbstractMesh>, scene: Scene);
  38085. private _follow;
  38086. /** @hidden */
  38087. _checkInputs(): void;
  38088. /**
  38089. * Returns the class name of the object.
  38090. * It is mostly used internally for serialization purposes.
  38091. */
  38092. getClassName(): string;
  38093. }
  38094. }
  38095. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  38096. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38097. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38098. import { Nullable } from "babylonjs/types";
  38099. /**
  38100. * Manage the keyboard inputs to control the movement of a follow camera.
  38101. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38102. */
  38103. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  38104. /**
  38105. * Defines the camera the input is attached to.
  38106. */
  38107. camera: FollowCamera;
  38108. /**
  38109. * Defines the list of key codes associated with the up action (increase heightOffset)
  38110. */
  38111. keysHeightOffsetIncr: number[];
  38112. /**
  38113. * Defines the list of key codes associated with the down action (decrease heightOffset)
  38114. */
  38115. keysHeightOffsetDecr: number[];
  38116. /**
  38117. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  38118. */
  38119. keysHeightOffsetModifierAlt: boolean;
  38120. /**
  38121. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  38122. */
  38123. keysHeightOffsetModifierCtrl: boolean;
  38124. /**
  38125. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  38126. */
  38127. keysHeightOffsetModifierShift: boolean;
  38128. /**
  38129. * Defines the list of key codes associated with the left action (increase rotationOffset)
  38130. */
  38131. keysRotationOffsetIncr: number[];
  38132. /**
  38133. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  38134. */
  38135. keysRotationOffsetDecr: number[];
  38136. /**
  38137. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  38138. */
  38139. keysRotationOffsetModifierAlt: boolean;
  38140. /**
  38141. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  38142. */
  38143. keysRotationOffsetModifierCtrl: boolean;
  38144. /**
  38145. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  38146. */
  38147. keysRotationOffsetModifierShift: boolean;
  38148. /**
  38149. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  38150. */
  38151. keysRadiusIncr: number[];
  38152. /**
  38153. * Defines the list of key codes associated with the zoom-out action (increase radius)
  38154. */
  38155. keysRadiusDecr: number[];
  38156. /**
  38157. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  38158. */
  38159. keysRadiusModifierAlt: boolean;
  38160. /**
  38161. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  38162. */
  38163. keysRadiusModifierCtrl: boolean;
  38164. /**
  38165. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  38166. */
  38167. keysRadiusModifierShift: boolean;
  38168. /**
  38169. * Defines the rate of change of heightOffset.
  38170. */
  38171. heightSensibility: number;
  38172. /**
  38173. * Defines the rate of change of rotationOffset.
  38174. */
  38175. rotationSensibility: number;
  38176. /**
  38177. * Defines the rate of change of radius.
  38178. */
  38179. radiusSensibility: number;
  38180. private _keys;
  38181. private _ctrlPressed;
  38182. private _altPressed;
  38183. private _shiftPressed;
  38184. private _onCanvasBlurObserver;
  38185. private _onKeyboardObserver;
  38186. private _engine;
  38187. private _scene;
  38188. /**
  38189. * Attach the input controls to a specific dom element to get the input from.
  38190. * @param element Defines the element the controls should be listened from
  38191. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38192. */
  38193. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38194. /**
  38195. * Detach the current controls from the specified dom element.
  38196. * @param element Defines the element to stop listening the inputs from
  38197. */
  38198. detachControl(element: Nullable<HTMLElement>): void;
  38199. /**
  38200. * Update the current camera state depending on the inputs that have been used this frame.
  38201. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38202. */
  38203. checkInputs(): void;
  38204. /**
  38205. * Gets the class name of the current input.
  38206. * @returns the class name
  38207. */
  38208. getClassName(): string;
  38209. /**
  38210. * Get the friendly name associated with the input class.
  38211. * @returns the input friendly name
  38212. */
  38213. getSimpleName(): string;
  38214. /**
  38215. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38216. * allow modification of the heightOffset value.
  38217. */
  38218. private _modifierHeightOffset;
  38219. /**
  38220. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38221. * allow modification of the rotationOffset value.
  38222. */
  38223. private _modifierRotationOffset;
  38224. /**
  38225. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38226. * allow modification of the radius value.
  38227. */
  38228. private _modifierRadius;
  38229. }
  38230. }
  38231. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  38232. import { Nullable } from "babylonjs/types";
  38233. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38234. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38235. import { Observable } from "babylonjs/Misc/observable";
  38236. module "babylonjs/Cameras/freeCameraInputsManager" {
  38237. interface FreeCameraInputsManager {
  38238. /**
  38239. * @hidden
  38240. */
  38241. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  38242. /**
  38243. * Add orientation input support to the input manager.
  38244. * @returns the current input manager
  38245. */
  38246. addDeviceOrientation(): FreeCameraInputsManager;
  38247. }
  38248. }
  38249. /**
  38250. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  38251. * Screen rotation is taken into account.
  38252. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38253. */
  38254. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  38255. private _camera;
  38256. private _screenOrientationAngle;
  38257. private _constantTranform;
  38258. private _screenQuaternion;
  38259. private _alpha;
  38260. private _beta;
  38261. private _gamma;
  38262. /**
  38263. * @hidden
  38264. */
  38265. _onDeviceOrientationChangedObservable: Observable<void>;
  38266. /**
  38267. * Instantiates a new input
  38268. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38269. */
  38270. constructor();
  38271. /**
  38272. * Define the camera controlled by the input.
  38273. */
  38274. camera: FreeCamera;
  38275. /**
  38276. * Attach the input controls to a specific dom element to get the input from.
  38277. * @param element Defines the element the controls should be listened from
  38278. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38279. */
  38280. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38281. private _orientationChanged;
  38282. private _deviceOrientation;
  38283. /**
  38284. * Detach the current controls from the specified dom element.
  38285. * @param element Defines the element to stop listening the inputs from
  38286. */
  38287. detachControl(element: Nullable<HTMLElement>): void;
  38288. /**
  38289. * Update the current camera state depending on the inputs that have been used this frame.
  38290. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38291. */
  38292. checkInputs(): void;
  38293. /**
  38294. * Gets the class name of the current intput.
  38295. * @returns the class name
  38296. */
  38297. getClassName(): string;
  38298. /**
  38299. * Get the friendly name associated with the input class.
  38300. * @returns the input friendly name
  38301. */
  38302. getSimpleName(): string;
  38303. }
  38304. }
  38305. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  38306. import { Nullable } from "babylonjs/types";
  38307. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38308. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38309. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  38310. /**
  38311. * Manage the gamepad inputs to control a free camera.
  38312. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38313. */
  38314. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  38315. /**
  38316. * Define the camera the input is attached to.
  38317. */
  38318. camera: FreeCamera;
  38319. /**
  38320. * Define the Gamepad controlling the input
  38321. */
  38322. gamepad: Nullable<Gamepad>;
  38323. /**
  38324. * Defines the gamepad rotation sensiblity.
  38325. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38326. */
  38327. gamepadAngularSensibility: number;
  38328. /**
  38329. * Defines the gamepad move sensiblity.
  38330. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38331. */
  38332. gamepadMoveSensibility: number;
  38333. private _onGamepadConnectedObserver;
  38334. private _onGamepadDisconnectedObserver;
  38335. private _cameraTransform;
  38336. private _deltaTransform;
  38337. private _vector3;
  38338. private _vector2;
  38339. /**
  38340. * Attach the input controls to a specific dom element to get the input from.
  38341. * @param element Defines the element the controls should be listened from
  38342. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38343. */
  38344. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38345. /**
  38346. * Detach the current controls from the specified dom element.
  38347. * @param element Defines the element to stop listening the inputs from
  38348. */
  38349. detachControl(element: Nullable<HTMLElement>): void;
  38350. /**
  38351. * Update the current camera state depending on the inputs that have been used this frame.
  38352. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38353. */
  38354. checkInputs(): void;
  38355. /**
  38356. * Gets the class name of the current intput.
  38357. * @returns the class name
  38358. */
  38359. getClassName(): string;
  38360. /**
  38361. * Get the friendly name associated with the input class.
  38362. * @returns the input friendly name
  38363. */
  38364. getSimpleName(): string;
  38365. }
  38366. }
  38367. declare module "babylonjs/Misc/virtualJoystick" {
  38368. import { Nullable } from "babylonjs/types";
  38369. import { Vector3 } from "babylonjs/Maths/math";
  38370. /**
  38371. * Defines the potential axis of a Joystick
  38372. */
  38373. export enum JoystickAxis {
  38374. /** X axis */
  38375. X = 0,
  38376. /** Y axis */
  38377. Y = 1,
  38378. /** Z axis */
  38379. Z = 2
  38380. }
  38381. /**
  38382. * Class used to define virtual joystick (used in touch mode)
  38383. */
  38384. export class VirtualJoystick {
  38385. /**
  38386. * Gets or sets a boolean indicating that left and right values must be inverted
  38387. */
  38388. reverseLeftRight: boolean;
  38389. /**
  38390. * Gets or sets a boolean indicating that up and down values must be inverted
  38391. */
  38392. reverseUpDown: boolean;
  38393. /**
  38394. * Gets the offset value for the position (ie. the change of the position value)
  38395. */
  38396. deltaPosition: Vector3;
  38397. /**
  38398. * Gets a boolean indicating if the virtual joystick was pressed
  38399. */
  38400. pressed: boolean;
  38401. /**
  38402. * Canvas the virtual joystick will render onto, default z-index of this is 5
  38403. */
  38404. static Canvas: Nullable<HTMLCanvasElement>;
  38405. private static _globalJoystickIndex;
  38406. private static vjCanvasContext;
  38407. private static vjCanvasWidth;
  38408. private static vjCanvasHeight;
  38409. private static halfWidth;
  38410. private _action;
  38411. private _axisTargetedByLeftAndRight;
  38412. private _axisTargetedByUpAndDown;
  38413. private _joystickSensibility;
  38414. private _inversedSensibility;
  38415. private _joystickPointerID;
  38416. private _joystickColor;
  38417. private _joystickPointerPos;
  38418. private _joystickPreviousPointerPos;
  38419. private _joystickPointerStartPos;
  38420. private _deltaJoystickVector;
  38421. private _leftJoystick;
  38422. private _touches;
  38423. private _onPointerDownHandlerRef;
  38424. private _onPointerMoveHandlerRef;
  38425. private _onPointerUpHandlerRef;
  38426. private _onResize;
  38427. /**
  38428. * Creates a new virtual joystick
  38429. * @param leftJoystick defines that the joystick is for left hand (false by default)
  38430. */
  38431. constructor(leftJoystick?: boolean);
  38432. /**
  38433. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  38434. * @param newJoystickSensibility defines the new sensibility
  38435. */
  38436. setJoystickSensibility(newJoystickSensibility: number): void;
  38437. private _onPointerDown;
  38438. private _onPointerMove;
  38439. private _onPointerUp;
  38440. /**
  38441. * Change the color of the virtual joystick
  38442. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  38443. */
  38444. setJoystickColor(newColor: string): void;
  38445. /**
  38446. * Defines a callback to call when the joystick is touched
  38447. * @param action defines the callback
  38448. */
  38449. setActionOnTouch(action: () => any): void;
  38450. /**
  38451. * Defines which axis you'd like to control for left & right
  38452. * @param axis defines the axis to use
  38453. */
  38454. setAxisForLeftRight(axis: JoystickAxis): void;
  38455. /**
  38456. * Defines which axis you'd like to control for up & down
  38457. * @param axis defines the axis to use
  38458. */
  38459. setAxisForUpDown(axis: JoystickAxis): void;
  38460. private _drawVirtualJoystick;
  38461. /**
  38462. * Release internal HTML canvas
  38463. */
  38464. releaseCanvas(): void;
  38465. }
  38466. }
  38467. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  38468. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  38469. import { Nullable } from "babylonjs/types";
  38470. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38471. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38472. module "babylonjs/Cameras/freeCameraInputsManager" {
  38473. interface FreeCameraInputsManager {
  38474. /**
  38475. * Add virtual joystick input support to the input manager.
  38476. * @returns the current input manager
  38477. */
  38478. addVirtualJoystick(): FreeCameraInputsManager;
  38479. }
  38480. }
  38481. /**
  38482. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  38483. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38484. */
  38485. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  38486. /**
  38487. * Defines the camera the input is attached to.
  38488. */
  38489. camera: FreeCamera;
  38490. private _leftjoystick;
  38491. private _rightjoystick;
  38492. /**
  38493. * Gets the left stick of the virtual joystick.
  38494. * @returns The virtual Joystick
  38495. */
  38496. getLeftJoystick(): VirtualJoystick;
  38497. /**
  38498. * Gets the right stick of the virtual joystick.
  38499. * @returns The virtual Joystick
  38500. */
  38501. getRightJoystick(): VirtualJoystick;
  38502. /**
  38503. * Update the current camera state depending on the inputs that have been used this frame.
  38504. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38505. */
  38506. checkInputs(): void;
  38507. /**
  38508. * Attach the input controls to a specific dom element to get the input from.
  38509. * @param element Defines the element the controls should be listened from
  38510. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38511. */
  38512. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38513. /**
  38514. * Detach the current controls from the specified dom element.
  38515. * @param element Defines the element to stop listening the inputs from
  38516. */
  38517. detachControl(element: Nullable<HTMLElement>): void;
  38518. /**
  38519. * Gets the class name of the current intput.
  38520. * @returns the class name
  38521. */
  38522. getClassName(): string;
  38523. /**
  38524. * Get the friendly name associated with the input class.
  38525. * @returns the input friendly name
  38526. */
  38527. getSimpleName(): string;
  38528. }
  38529. }
  38530. declare module "babylonjs/Cameras/Inputs/index" {
  38531. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  38532. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  38533. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  38534. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  38535. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  38536. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  38537. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  38538. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  38539. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  38540. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  38541. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  38542. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  38543. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  38544. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  38545. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  38546. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  38547. }
  38548. declare module "babylonjs/Cameras/touchCamera" {
  38549. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38550. import { Scene } from "babylonjs/scene";
  38551. import { Vector3 } from "babylonjs/Maths/math";
  38552. /**
  38553. * This represents a FPS type of camera controlled by touch.
  38554. * This is like a universal camera minus the Gamepad controls.
  38555. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38556. */
  38557. export class TouchCamera extends FreeCamera {
  38558. /**
  38559. * Defines the touch sensibility for rotation.
  38560. * The higher the faster.
  38561. */
  38562. touchAngularSensibility: number;
  38563. /**
  38564. * Defines the touch sensibility for move.
  38565. * The higher the faster.
  38566. */
  38567. touchMoveSensibility: number;
  38568. /**
  38569. * Instantiates a new touch camera.
  38570. * This represents a FPS type of camera controlled by touch.
  38571. * This is like a universal camera minus the Gamepad controls.
  38572. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38573. * @param name Define the name of the camera in the scene
  38574. * @param position Define the start position of the camera in the scene
  38575. * @param scene Define the scene the camera belongs to
  38576. */
  38577. constructor(name: string, position: Vector3, scene: Scene);
  38578. /**
  38579. * Gets the current object class name.
  38580. * @return the class name
  38581. */
  38582. getClassName(): string;
  38583. /** @hidden */
  38584. _setupInputs(): void;
  38585. }
  38586. }
  38587. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  38588. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38589. import { Scene } from "babylonjs/scene";
  38590. import { Vector3, Axis } from "babylonjs/Maths/math";
  38591. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  38592. /**
  38593. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  38594. * being tilted forward or back and left or right.
  38595. */
  38596. export class DeviceOrientationCamera extends FreeCamera {
  38597. private _initialQuaternion;
  38598. private _quaternionCache;
  38599. private _tmpDragQuaternion;
  38600. /**
  38601. * Creates a new device orientation camera
  38602. * @param name The name of the camera
  38603. * @param position The start position camera
  38604. * @param scene The scene the camera belongs to
  38605. */
  38606. constructor(name: string, position: Vector3, scene: Scene);
  38607. /**
  38608. * @hidden
  38609. * Disabled pointer input on first orientation sensor update (Default: true)
  38610. */
  38611. _disablePointerInputWhenUsingDeviceOrientation: boolean;
  38612. private _dragFactor;
  38613. /**
  38614. * Enabled turning on the y axis when the orientation sensor is active
  38615. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  38616. */
  38617. enableHorizontalDragging(dragFactor?: number): void;
  38618. /**
  38619. * Gets the current instance class name ("DeviceOrientationCamera").
  38620. * This helps avoiding instanceof at run time.
  38621. * @returns the class name
  38622. */
  38623. getClassName(): string;
  38624. /**
  38625. * @hidden
  38626. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  38627. */
  38628. _checkInputs(): void;
  38629. /**
  38630. * Reset the camera to its default orientation on the specified axis only.
  38631. * @param axis The axis to reset
  38632. */
  38633. resetToCurrentRotation(axis?: Axis): void;
  38634. }
  38635. }
  38636. declare module "babylonjs/Gamepads/xboxGamepad" {
  38637. import { Observable } from "babylonjs/Misc/observable";
  38638. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  38639. /**
  38640. * Defines supported buttons for XBox360 compatible gamepads
  38641. */
  38642. export enum Xbox360Button {
  38643. /** A */
  38644. A = 0,
  38645. /** B */
  38646. B = 1,
  38647. /** X */
  38648. X = 2,
  38649. /** Y */
  38650. Y = 3,
  38651. /** Start */
  38652. Start = 4,
  38653. /** Back */
  38654. Back = 5,
  38655. /** Left button */
  38656. LB = 6,
  38657. /** Right button */
  38658. RB = 7,
  38659. /** Left stick */
  38660. LeftStick = 8,
  38661. /** Right stick */
  38662. RightStick = 9
  38663. }
  38664. /** Defines values for XBox360 DPad */
  38665. export enum Xbox360Dpad {
  38666. /** Up */
  38667. Up = 0,
  38668. /** Down */
  38669. Down = 1,
  38670. /** Left */
  38671. Left = 2,
  38672. /** Right */
  38673. Right = 3
  38674. }
  38675. /**
  38676. * Defines a XBox360 gamepad
  38677. */
  38678. export class Xbox360Pad extends Gamepad {
  38679. private _leftTrigger;
  38680. private _rightTrigger;
  38681. private _onlefttriggerchanged;
  38682. private _onrighttriggerchanged;
  38683. private _onbuttondown;
  38684. private _onbuttonup;
  38685. private _ondpaddown;
  38686. private _ondpadup;
  38687. /** Observable raised when a button is pressed */
  38688. onButtonDownObservable: Observable<Xbox360Button>;
  38689. /** Observable raised when a button is released */
  38690. onButtonUpObservable: Observable<Xbox360Button>;
  38691. /** Observable raised when a pad is pressed */
  38692. onPadDownObservable: Observable<Xbox360Dpad>;
  38693. /** Observable raised when a pad is released */
  38694. onPadUpObservable: Observable<Xbox360Dpad>;
  38695. private _buttonA;
  38696. private _buttonB;
  38697. private _buttonX;
  38698. private _buttonY;
  38699. private _buttonBack;
  38700. private _buttonStart;
  38701. private _buttonLB;
  38702. private _buttonRB;
  38703. private _buttonLeftStick;
  38704. private _buttonRightStick;
  38705. private _dPadUp;
  38706. private _dPadDown;
  38707. private _dPadLeft;
  38708. private _dPadRight;
  38709. private _isXboxOnePad;
  38710. /**
  38711. * Creates a new XBox360 gamepad object
  38712. * @param id defines the id of this gamepad
  38713. * @param index defines its index
  38714. * @param gamepad defines the internal HTML gamepad object
  38715. * @param xboxOne defines if it is a XBox One gamepad
  38716. */
  38717. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  38718. /**
  38719. * Defines the callback to call when left trigger is pressed
  38720. * @param callback defines the callback to use
  38721. */
  38722. onlefttriggerchanged(callback: (value: number) => void): void;
  38723. /**
  38724. * Defines the callback to call when right trigger is pressed
  38725. * @param callback defines the callback to use
  38726. */
  38727. onrighttriggerchanged(callback: (value: number) => void): void;
  38728. /**
  38729. * Gets the left trigger value
  38730. */
  38731. /**
  38732. * Sets the left trigger value
  38733. */
  38734. leftTrigger: number;
  38735. /**
  38736. * Gets the right trigger value
  38737. */
  38738. /**
  38739. * Sets the right trigger value
  38740. */
  38741. rightTrigger: number;
  38742. /**
  38743. * Defines the callback to call when a button is pressed
  38744. * @param callback defines the callback to use
  38745. */
  38746. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  38747. /**
  38748. * Defines the callback to call when a button is released
  38749. * @param callback defines the callback to use
  38750. */
  38751. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  38752. /**
  38753. * Defines the callback to call when a pad is pressed
  38754. * @param callback defines the callback to use
  38755. */
  38756. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  38757. /**
  38758. * Defines the callback to call when a pad is released
  38759. * @param callback defines the callback to use
  38760. */
  38761. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  38762. private _setButtonValue;
  38763. private _setDPadValue;
  38764. /**
  38765. * Gets the value of the `A` button
  38766. */
  38767. /**
  38768. * Sets the value of the `A` button
  38769. */
  38770. buttonA: number;
  38771. /**
  38772. * Gets the value of the `B` button
  38773. */
  38774. /**
  38775. * Sets the value of the `B` button
  38776. */
  38777. buttonB: number;
  38778. /**
  38779. * Gets the value of the `X` button
  38780. */
  38781. /**
  38782. * Sets the value of the `X` button
  38783. */
  38784. buttonX: number;
  38785. /**
  38786. * Gets the value of the `Y` button
  38787. */
  38788. /**
  38789. * Sets the value of the `Y` button
  38790. */
  38791. buttonY: number;
  38792. /**
  38793. * Gets the value of the `Start` button
  38794. */
  38795. /**
  38796. * Sets the value of the `Start` button
  38797. */
  38798. buttonStart: number;
  38799. /**
  38800. * Gets the value of the `Back` button
  38801. */
  38802. /**
  38803. * Sets the value of the `Back` button
  38804. */
  38805. buttonBack: number;
  38806. /**
  38807. * Gets the value of the `Left` button
  38808. */
  38809. /**
  38810. * Sets the value of the `Left` button
  38811. */
  38812. buttonLB: number;
  38813. /**
  38814. * Gets the value of the `Right` button
  38815. */
  38816. /**
  38817. * Sets the value of the `Right` button
  38818. */
  38819. buttonRB: number;
  38820. /**
  38821. * Gets the value of the Left joystick
  38822. */
  38823. /**
  38824. * Sets the value of the Left joystick
  38825. */
  38826. buttonLeftStick: number;
  38827. /**
  38828. * Gets the value of the Right joystick
  38829. */
  38830. /**
  38831. * Sets the value of the Right joystick
  38832. */
  38833. buttonRightStick: number;
  38834. /**
  38835. * Gets the value of D-pad up
  38836. */
  38837. /**
  38838. * Sets the value of D-pad up
  38839. */
  38840. dPadUp: number;
  38841. /**
  38842. * Gets the value of D-pad down
  38843. */
  38844. /**
  38845. * Sets the value of D-pad down
  38846. */
  38847. dPadDown: number;
  38848. /**
  38849. * Gets the value of D-pad left
  38850. */
  38851. /**
  38852. * Sets the value of D-pad left
  38853. */
  38854. dPadLeft: number;
  38855. /**
  38856. * Gets the value of D-pad right
  38857. */
  38858. /**
  38859. * Sets the value of D-pad right
  38860. */
  38861. dPadRight: number;
  38862. /**
  38863. * Force the gamepad to synchronize with device values
  38864. */
  38865. update(): void;
  38866. /**
  38867. * Disposes the gamepad
  38868. */
  38869. dispose(): void;
  38870. }
  38871. }
  38872. declare module "babylonjs/Gamepads/gamepadManager" {
  38873. import { Observable } from "babylonjs/Misc/observable";
  38874. import { Nullable } from "babylonjs/types";
  38875. import { Scene } from "babylonjs/scene";
  38876. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  38877. /**
  38878. * Manager for handling gamepads
  38879. */
  38880. export class GamepadManager {
  38881. private _scene?;
  38882. private _babylonGamepads;
  38883. private _oneGamepadConnected;
  38884. /** @hidden */
  38885. _isMonitoring: boolean;
  38886. private _gamepadEventSupported;
  38887. private _gamepadSupport;
  38888. /**
  38889. * observable to be triggered when the gamepad controller has been connected
  38890. */
  38891. onGamepadConnectedObservable: Observable<Gamepad>;
  38892. /**
  38893. * observable to be triggered when the gamepad controller has been disconnected
  38894. */
  38895. onGamepadDisconnectedObservable: Observable<Gamepad>;
  38896. private _onGamepadConnectedEvent;
  38897. private _onGamepadDisconnectedEvent;
  38898. /**
  38899. * Initializes the gamepad manager
  38900. * @param _scene BabylonJS scene
  38901. */
  38902. constructor(_scene?: Scene | undefined);
  38903. /**
  38904. * The gamepads in the game pad manager
  38905. */
  38906. readonly gamepads: Gamepad[];
  38907. /**
  38908. * Get the gamepad controllers based on type
  38909. * @param type The type of gamepad controller
  38910. * @returns Nullable gamepad
  38911. */
  38912. getGamepadByType(type?: number): Nullable<Gamepad>;
  38913. /**
  38914. * Disposes the gamepad manager
  38915. */
  38916. dispose(): void;
  38917. private _addNewGamepad;
  38918. private _startMonitoringGamepads;
  38919. private _stopMonitoringGamepads;
  38920. /** @hidden */
  38921. _checkGamepadsStatus(): void;
  38922. private _updateGamepadObjects;
  38923. }
  38924. }
  38925. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  38926. import { Nullable } from "babylonjs/types";
  38927. import { Scene } from "babylonjs/scene";
  38928. import { ISceneComponent } from "babylonjs/sceneComponent";
  38929. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  38930. module "babylonjs/scene" {
  38931. interface Scene {
  38932. /** @hidden */
  38933. _gamepadManager: Nullable<GamepadManager>;
  38934. /**
  38935. * Gets the gamepad manager associated with the scene
  38936. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  38937. */
  38938. gamepadManager: GamepadManager;
  38939. }
  38940. }
  38941. module "babylonjs/Cameras/freeCameraInputsManager" {
  38942. /**
  38943. * Interface representing a free camera inputs manager
  38944. */
  38945. interface FreeCameraInputsManager {
  38946. /**
  38947. * Adds gamepad input support to the FreeCameraInputsManager.
  38948. * @returns the FreeCameraInputsManager
  38949. */
  38950. addGamepad(): FreeCameraInputsManager;
  38951. }
  38952. }
  38953. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  38954. /**
  38955. * Interface representing an arc rotate camera inputs manager
  38956. */
  38957. interface ArcRotateCameraInputsManager {
  38958. /**
  38959. * Adds gamepad input support to the ArcRotateCamera InputManager.
  38960. * @returns the camera inputs manager
  38961. */
  38962. addGamepad(): ArcRotateCameraInputsManager;
  38963. }
  38964. }
  38965. /**
  38966. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  38967. */
  38968. export class GamepadSystemSceneComponent implements ISceneComponent {
  38969. /**
  38970. * The component name helpfull to identify the component in the list of scene components.
  38971. */
  38972. readonly name: string;
  38973. /**
  38974. * The scene the component belongs to.
  38975. */
  38976. scene: Scene;
  38977. /**
  38978. * Creates a new instance of the component for the given scene
  38979. * @param scene Defines the scene to register the component in
  38980. */
  38981. constructor(scene: Scene);
  38982. /**
  38983. * Registers the component in a given scene
  38984. */
  38985. register(): void;
  38986. /**
  38987. * Rebuilds the elements related to this component in case of
  38988. * context lost for instance.
  38989. */
  38990. rebuild(): void;
  38991. /**
  38992. * Disposes the component and the associated ressources
  38993. */
  38994. dispose(): void;
  38995. private _beforeCameraUpdate;
  38996. }
  38997. }
  38998. declare module "babylonjs/Cameras/universalCamera" {
  38999. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  39000. import { Scene } from "babylonjs/scene";
  39001. import { Vector3 } from "babylonjs/Maths/math";
  39002. import "babylonjs/Gamepads/gamepadSceneComponent";
  39003. /**
  39004. * 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,
  39005. * which still works and will still be found in many Playgrounds.
  39006. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39007. */
  39008. export class UniversalCamera extends TouchCamera {
  39009. /**
  39010. * Defines the gamepad rotation sensiblity.
  39011. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  39012. */
  39013. gamepadAngularSensibility: number;
  39014. /**
  39015. * Defines the gamepad move sensiblity.
  39016. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  39017. */
  39018. gamepadMoveSensibility: number;
  39019. /**
  39020. * 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,
  39021. * which still works and will still be found in many Playgrounds.
  39022. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39023. * @param name Define the name of the camera in the scene
  39024. * @param position Define the start position of the camera in the scene
  39025. * @param scene Define the scene the camera belongs to
  39026. */
  39027. constructor(name: string, position: Vector3, scene: Scene);
  39028. /**
  39029. * Gets the current object class name.
  39030. * @return the class name
  39031. */
  39032. getClassName(): string;
  39033. }
  39034. }
  39035. declare module "babylonjs/Cameras/gamepadCamera" {
  39036. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  39037. import { Scene } from "babylonjs/scene";
  39038. import { Vector3 } from "babylonjs/Maths/math";
  39039. /**
  39040. * This represents a FPS type of camera. This is only here for back compat purpose.
  39041. * Please use the UniversalCamera instead as both are identical.
  39042. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39043. */
  39044. export class GamepadCamera extends UniversalCamera {
  39045. /**
  39046. * Instantiates a new Gamepad Camera
  39047. * This represents a FPS type of camera. This is only here for back compat purpose.
  39048. * Please use the UniversalCamera instead as both are identical.
  39049. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39050. * @param name Define the name of the camera in the scene
  39051. * @param position Define the start position of the camera in the scene
  39052. * @param scene Define the scene the camera belongs to
  39053. */
  39054. constructor(name: string, position: Vector3, scene: Scene);
  39055. /**
  39056. * Gets the current object class name.
  39057. * @return the class name
  39058. */
  39059. getClassName(): string;
  39060. }
  39061. }
  39062. declare module "babylonjs/Shaders/pass.fragment" {
  39063. /** @hidden */
  39064. export var passPixelShader: {
  39065. name: string;
  39066. shader: string;
  39067. };
  39068. }
  39069. declare module "babylonjs/Shaders/passCube.fragment" {
  39070. /** @hidden */
  39071. export var passCubePixelShader: {
  39072. name: string;
  39073. shader: string;
  39074. };
  39075. }
  39076. declare module "babylonjs/PostProcesses/passPostProcess" {
  39077. import { Nullable } from "babylonjs/types";
  39078. import { Camera } from "babylonjs/Cameras/camera";
  39079. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  39080. import { Engine } from "babylonjs/Engines/engine";
  39081. import "babylonjs/Shaders/pass.fragment";
  39082. import "babylonjs/Shaders/passCube.fragment";
  39083. /**
  39084. * PassPostProcess which produces an output the same as it's input
  39085. */
  39086. export class PassPostProcess extends PostProcess {
  39087. /**
  39088. * Creates the PassPostProcess
  39089. * @param name The name of the effect.
  39090. * @param options The required width/height ratio to downsize to before computing the render pass.
  39091. * @param camera The camera to apply the render pass to.
  39092. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39093. * @param engine The engine which the post process will be applied. (default: current engine)
  39094. * @param reusable If the post process can be reused on the same frame. (default: false)
  39095. * @param textureType The type of texture to be used when performing the post processing.
  39096. * @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)
  39097. */
  39098. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  39099. }
  39100. /**
  39101. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  39102. */
  39103. export class PassCubePostProcess extends PostProcess {
  39104. private _face;
  39105. /**
  39106. * Gets or sets the cube face to display.
  39107. * * 0 is +X
  39108. * * 1 is -X
  39109. * * 2 is +Y
  39110. * * 3 is -Y
  39111. * * 4 is +Z
  39112. * * 5 is -Z
  39113. */
  39114. face: number;
  39115. /**
  39116. * Creates the PassCubePostProcess
  39117. * @param name The name of the effect.
  39118. * @param options The required width/height ratio to downsize to before computing the render pass.
  39119. * @param camera The camera to apply the render pass to.
  39120. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39121. * @param engine The engine which the post process will be applied. (default: current engine)
  39122. * @param reusable If the post process can be reused on the same frame. (default: false)
  39123. * @param textureType The type of texture to be used when performing the post processing.
  39124. * @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)
  39125. */
  39126. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  39127. }
  39128. }
  39129. declare module "babylonjs/Shaders/anaglyph.fragment" {
  39130. /** @hidden */
  39131. export var anaglyphPixelShader: {
  39132. name: string;
  39133. shader: string;
  39134. };
  39135. }
  39136. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  39137. import { Engine } from "babylonjs/Engines/engine";
  39138. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  39139. import { Camera } from "babylonjs/Cameras/camera";
  39140. import "babylonjs/Shaders/anaglyph.fragment";
  39141. /**
  39142. * Postprocess used to generate anaglyphic rendering
  39143. */
  39144. export class AnaglyphPostProcess extends PostProcess {
  39145. private _passedProcess;
  39146. /**
  39147. * Creates a new AnaglyphPostProcess
  39148. * @param name defines postprocess name
  39149. * @param options defines creation options or target ratio scale
  39150. * @param rigCameras defines cameras using this postprocess
  39151. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  39152. * @param engine defines hosting engine
  39153. * @param reusable defines if the postprocess will be reused multiple times per frame
  39154. */
  39155. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  39156. }
  39157. }
  39158. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  39159. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  39160. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39161. import { Scene } from "babylonjs/scene";
  39162. import { Vector3 } from "babylonjs/Maths/math";
  39163. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  39164. /**
  39165. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  39166. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39167. */
  39168. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  39169. /**
  39170. * Creates a new AnaglyphArcRotateCamera
  39171. * @param name defines camera name
  39172. * @param alpha defines alpha angle (in radians)
  39173. * @param beta defines beta angle (in radians)
  39174. * @param radius defines radius
  39175. * @param target defines camera target
  39176. * @param interaxialDistance defines distance between each color axis
  39177. * @param scene defines the hosting scene
  39178. */
  39179. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  39180. /**
  39181. * Gets camera class name
  39182. * @returns AnaglyphArcRotateCamera
  39183. */
  39184. getClassName(): string;
  39185. }
  39186. }
  39187. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  39188. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39189. import { Scene } from "babylonjs/scene";
  39190. import { Vector3 } from "babylonjs/Maths/math";
  39191. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  39192. /**
  39193. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  39194. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39195. */
  39196. export class AnaglyphFreeCamera extends FreeCamera {
  39197. /**
  39198. * Creates a new AnaglyphFreeCamera
  39199. * @param name defines camera name
  39200. * @param position defines initial position
  39201. * @param interaxialDistance defines distance between each color axis
  39202. * @param scene defines the hosting scene
  39203. */
  39204. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39205. /**
  39206. * Gets camera class name
  39207. * @returns AnaglyphFreeCamera
  39208. */
  39209. getClassName(): string;
  39210. }
  39211. }
  39212. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  39213. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  39214. import { Scene } from "babylonjs/scene";
  39215. import { Vector3 } from "babylonjs/Maths/math";
  39216. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  39217. /**
  39218. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  39219. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39220. */
  39221. export class AnaglyphGamepadCamera extends GamepadCamera {
  39222. /**
  39223. * Creates a new AnaglyphGamepadCamera
  39224. * @param name defines camera name
  39225. * @param position defines initial position
  39226. * @param interaxialDistance defines distance between each color axis
  39227. * @param scene defines the hosting scene
  39228. */
  39229. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39230. /**
  39231. * Gets camera class name
  39232. * @returns AnaglyphGamepadCamera
  39233. */
  39234. getClassName(): string;
  39235. }
  39236. }
  39237. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  39238. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  39239. import { Scene } from "babylonjs/scene";
  39240. import { Vector3 } from "babylonjs/Maths/math";
  39241. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  39242. /**
  39243. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  39244. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39245. */
  39246. export class AnaglyphUniversalCamera extends UniversalCamera {
  39247. /**
  39248. * Creates a new AnaglyphUniversalCamera
  39249. * @param name defines camera name
  39250. * @param position defines initial position
  39251. * @param interaxialDistance defines distance between each color axis
  39252. * @param scene defines the hosting scene
  39253. */
  39254. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39255. /**
  39256. * Gets camera class name
  39257. * @returns AnaglyphUniversalCamera
  39258. */
  39259. getClassName(): string;
  39260. }
  39261. }
  39262. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  39263. /** @hidden */
  39264. export var stereoscopicInterlacePixelShader: {
  39265. name: string;
  39266. shader: string;
  39267. };
  39268. }
  39269. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  39270. import { Camera } from "babylonjs/Cameras/camera";
  39271. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  39272. import { Engine } from "babylonjs/Engines/engine";
  39273. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  39274. /**
  39275. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  39276. */
  39277. export class StereoscopicInterlacePostProcess extends PostProcess {
  39278. private _stepSize;
  39279. private _passedProcess;
  39280. /**
  39281. * Initializes a StereoscopicInterlacePostProcess
  39282. * @param name The name of the effect.
  39283. * @param rigCameras The rig cameras to be appled to the post process
  39284. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  39285. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39286. * @param engine The engine which the post process will be applied. (default: current engine)
  39287. * @param reusable If the post process can be reused on the same frame. (default: false)
  39288. */
  39289. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  39290. }
  39291. }
  39292. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  39293. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  39294. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39295. import { Scene } from "babylonjs/scene";
  39296. import { Vector3 } from "babylonjs/Maths/math";
  39297. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  39298. /**
  39299. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  39300. * @see http://doc.babylonjs.com/features/cameras
  39301. */
  39302. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  39303. /**
  39304. * Creates a new StereoscopicArcRotateCamera
  39305. * @param name defines camera name
  39306. * @param alpha defines alpha angle (in radians)
  39307. * @param beta defines beta angle (in radians)
  39308. * @param radius defines radius
  39309. * @param target defines camera target
  39310. * @param interaxialDistance defines distance between each color axis
  39311. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39312. * @param scene defines the hosting scene
  39313. */
  39314. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39315. /**
  39316. * Gets camera class name
  39317. * @returns StereoscopicArcRotateCamera
  39318. */
  39319. getClassName(): string;
  39320. }
  39321. }
  39322. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  39323. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39324. import { Scene } from "babylonjs/scene";
  39325. import { Vector3 } from "babylonjs/Maths/math";
  39326. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  39327. /**
  39328. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  39329. * @see http://doc.babylonjs.com/features/cameras
  39330. */
  39331. export class StereoscopicFreeCamera extends FreeCamera {
  39332. /**
  39333. * Creates a new StereoscopicFreeCamera
  39334. * @param name defines camera name
  39335. * @param position defines initial position
  39336. * @param interaxialDistance defines distance between each color axis
  39337. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39338. * @param scene defines the hosting scene
  39339. */
  39340. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39341. /**
  39342. * Gets camera class name
  39343. * @returns StereoscopicFreeCamera
  39344. */
  39345. getClassName(): string;
  39346. }
  39347. }
  39348. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  39349. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  39350. import { Scene } from "babylonjs/scene";
  39351. import { Vector3 } from "babylonjs/Maths/math";
  39352. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  39353. /**
  39354. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  39355. * @see http://doc.babylonjs.com/features/cameras
  39356. */
  39357. export class StereoscopicGamepadCamera extends GamepadCamera {
  39358. /**
  39359. * Creates a new StereoscopicGamepadCamera
  39360. * @param name defines camera name
  39361. * @param position defines initial position
  39362. * @param interaxialDistance defines distance between each color axis
  39363. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39364. * @param scene defines the hosting scene
  39365. */
  39366. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39367. /**
  39368. * Gets camera class name
  39369. * @returns StereoscopicGamepadCamera
  39370. */
  39371. getClassName(): string;
  39372. }
  39373. }
  39374. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  39375. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  39376. import { Scene } from "babylonjs/scene";
  39377. import { Vector3 } from "babylonjs/Maths/math";
  39378. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  39379. /**
  39380. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  39381. * @see http://doc.babylonjs.com/features/cameras
  39382. */
  39383. export class StereoscopicUniversalCamera extends UniversalCamera {
  39384. /**
  39385. * Creates a new StereoscopicUniversalCamera
  39386. * @param name defines camera name
  39387. * @param position defines initial position
  39388. * @param interaxialDistance defines distance between each color axis
  39389. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39390. * @param scene defines the hosting scene
  39391. */
  39392. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39393. /**
  39394. * Gets camera class name
  39395. * @returns StereoscopicUniversalCamera
  39396. */
  39397. getClassName(): string;
  39398. }
  39399. }
  39400. declare module "babylonjs/Cameras/Stereoscopic/index" {
  39401. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  39402. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  39403. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  39404. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  39405. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  39406. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  39407. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  39408. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  39409. }
  39410. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  39411. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39412. import { Scene } from "babylonjs/scene";
  39413. import { Vector3 } from "babylonjs/Maths/math";
  39414. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  39415. /**
  39416. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  39417. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  39418. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  39419. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  39420. */
  39421. export class VirtualJoysticksCamera extends FreeCamera {
  39422. /**
  39423. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  39424. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  39425. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  39426. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  39427. * @param name Define the name of the camera in the scene
  39428. * @param position Define the start position of the camera in the scene
  39429. * @param scene Define the scene the camera belongs to
  39430. */
  39431. constructor(name: string, position: Vector3, scene: Scene);
  39432. /**
  39433. * Gets the current object class name.
  39434. * @return the class name
  39435. */
  39436. getClassName(): string;
  39437. }
  39438. }
  39439. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  39440. import { Matrix } from "babylonjs/Maths/math";
  39441. /**
  39442. * This represents all the required metrics to create a VR camera.
  39443. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  39444. */
  39445. export class VRCameraMetrics {
  39446. /**
  39447. * Define the horizontal resolution off the screen.
  39448. */
  39449. hResolution: number;
  39450. /**
  39451. * Define the vertical resolution off the screen.
  39452. */
  39453. vResolution: number;
  39454. /**
  39455. * Define the horizontal screen size.
  39456. */
  39457. hScreenSize: number;
  39458. /**
  39459. * Define the vertical screen size.
  39460. */
  39461. vScreenSize: number;
  39462. /**
  39463. * Define the vertical screen center position.
  39464. */
  39465. vScreenCenter: number;
  39466. /**
  39467. * Define the distance of the eyes to the screen.
  39468. */
  39469. eyeToScreenDistance: number;
  39470. /**
  39471. * Define the distance between both lenses
  39472. */
  39473. lensSeparationDistance: number;
  39474. /**
  39475. * Define the distance between both viewer's eyes.
  39476. */
  39477. interpupillaryDistance: number;
  39478. /**
  39479. * Define the distortion factor of the VR postprocess.
  39480. * Please, touch with care.
  39481. */
  39482. distortionK: number[];
  39483. /**
  39484. * Define the chromatic aberration correction factors for the VR post process.
  39485. */
  39486. chromaAbCorrection: number[];
  39487. /**
  39488. * Define the scale factor of the post process.
  39489. * The smaller the better but the slower.
  39490. */
  39491. postProcessScaleFactor: number;
  39492. /**
  39493. * Define an offset for the lens center.
  39494. */
  39495. lensCenterOffset: number;
  39496. /**
  39497. * Define if the current vr camera should compensate the distortion of the lense or not.
  39498. */
  39499. compensateDistortion: boolean;
  39500. /**
  39501. * Defines if multiview should be enabled when rendering (Default: false)
  39502. */
  39503. multiviewEnabled: boolean;
  39504. /**
  39505. * Gets the rendering aspect ratio based on the provided resolutions.
  39506. */
  39507. readonly aspectRatio: number;
  39508. /**
  39509. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  39510. */
  39511. readonly aspectRatioFov: number;
  39512. /**
  39513. * @hidden
  39514. */
  39515. readonly leftHMatrix: Matrix;
  39516. /**
  39517. * @hidden
  39518. */
  39519. readonly rightHMatrix: Matrix;
  39520. /**
  39521. * @hidden
  39522. */
  39523. readonly leftPreViewMatrix: Matrix;
  39524. /**
  39525. * @hidden
  39526. */
  39527. readonly rightPreViewMatrix: Matrix;
  39528. /**
  39529. * Get the default VRMetrics based on the most generic setup.
  39530. * @returns the default vr metrics
  39531. */
  39532. static GetDefault(): VRCameraMetrics;
  39533. }
  39534. }
  39535. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  39536. /** @hidden */
  39537. export var vrDistortionCorrectionPixelShader: {
  39538. name: string;
  39539. shader: string;
  39540. };
  39541. }
  39542. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  39543. import { Camera } from "babylonjs/Cameras/camera";
  39544. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  39545. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  39546. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  39547. /**
  39548. * VRDistortionCorrectionPostProcess used for mobile VR
  39549. */
  39550. export class VRDistortionCorrectionPostProcess extends PostProcess {
  39551. private _isRightEye;
  39552. private _distortionFactors;
  39553. private _postProcessScaleFactor;
  39554. private _lensCenterOffset;
  39555. private _scaleIn;
  39556. private _scaleFactor;
  39557. private _lensCenter;
  39558. /**
  39559. * Initializes the VRDistortionCorrectionPostProcess
  39560. * @param name The name of the effect.
  39561. * @param camera The camera to apply the render pass to.
  39562. * @param isRightEye If this is for the right eye distortion
  39563. * @param vrMetrics All the required metrics for the VR camera
  39564. */
  39565. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  39566. }
  39567. }
  39568. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  39569. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  39570. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39571. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  39572. import { Scene } from "babylonjs/scene";
  39573. import { Vector3 } from "babylonjs/Maths/math";
  39574. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  39575. import "babylonjs/Cameras/RigModes/vrRigMode";
  39576. /**
  39577. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  39578. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39579. */
  39580. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  39581. /**
  39582. * Creates a new VRDeviceOrientationArcRotateCamera
  39583. * @param name defines camera name
  39584. * @param alpha defines the camera rotation along the logitudinal axis
  39585. * @param beta defines the camera rotation along the latitudinal axis
  39586. * @param radius defines the camera distance from its target
  39587. * @param target defines the camera target
  39588. * @param scene defines the scene the camera belongs to
  39589. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39590. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39591. */
  39592. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39593. /**
  39594. * Gets camera class name
  39595. * @returns VRDeviceOrientationArcRotateCamera
  39596. */
  39597. getClassName(): string;
  39598. }
  39599. }
  39600. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  39601. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  39602. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  39603. import { Scene } from "babylonjs/scene";
  39604. import { Vector3 } from "babylonjs/Maths/math";
  39605. import "babylonjs/Cameras/RigModes/vrRigMode";
  39606. /**
  39607. * Camera used to simulate VR rendering (based on FreeCamera)
  39608. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39609. */
  39610. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  39611. /**
  39612. * Creates a new VRDeviceOrientationFreeCamera
  39613. * @param name defines camera name
  39614. * @param position defines the start position of the camera
  39615. * @param scene defines the scene the camera belongs to
  39616. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39617. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39618. */
  39619. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39620. /**
  39621. * Gets camera class name
  39622. * @returns VRDeviceOrientationFreeCamera
  39623. */
  39624. getClassName(): string;
  39625. }
  39626. }
  39627. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  39628. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  39629. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  39630. import { Scene } from "babylonjs/scene";
  39631. import { Vector3 } from "babylonjs/Maths/math";
  39632. import "babylonjs/Gamepads/gamepadSceneComponent";
  39633. /**
  39634. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  39635. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39636. */
  39637. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  39638. /**
  39639. * Creates a new VRDeviceOrientationGamepadCamera
  39640. * @param name defines camera name
  39641. * @param position defines the start position of the camera
  39642. * @param scene defines the scene the camera belongs to
  39643. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39644. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39645. */
  39646. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39647. /**
  39648. * Gets camera class name
  39649. * @returns VRDeviceOrientationGamepadCamera
  39650. */
  39651. getClassName(): string;
  39652. }
  39653. }
  39654. declare module "babylonjs/Materials/pushMaterial" {
  39655. import { Nullable } from "babylonjs/types";
  39656. import { Scene } from "babylonjs/scene";
  39657. import { Matrix } from "babylonjs/Maths/math";
  39658. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39659. import { Mesh } from "babylonjs/Meshes/mesh";
  39660. import { Material } from "babylonjs/Materials/material";
  39661. import { Effect } from "babylonjs/Materials/effect";
  39662. /**
  39663. * Base class of materials working in push mode in babylon JS
  39664. * @hidden
  39665. */
  39666. export class PushMaterial extends Material {
  39667. protected _activeEffect: Effect;
  39668. protected _normalMatrix: Matrix;
  39669. /**
  39670. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  39671. * This means that the material can keep using a previous shader while a new one is being compiled.
  39672. * This is mostly used when shader parallel compilation is supported (true by default)
  39673. */
  39674. allowShaderHotSwapping: boolean;
  39675. constructor(name: string, scene: Scene);
  39676. getEffect(): Effect;
  39677. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  39678. /**
  39679. * Binds the given world matrix to the active effect
  39680. *
  39681. * @param world the matrix to bind
  39682. */
  39683. bindOnlyWorldMatrix(world: Matrix): void;
  39684. /**
  39685. * Binds the given normal matrix to the active effect
  39686. *
  39687. * @param normalMatrix the matrix to bind
  39688. */
  39689. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  39690. bind(world: Matrix, mesh?: Mesh): void;
  39691. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  39692. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  39693. }
  39694. }
  39695. declare module "babylonjs/Materials/materialFlags" {
  39696. /**
  39697. * This groups all the flags used to control the materials channel.
  39698. */
  39699. export class MaterialFlags {
  39700. private static _DiffuseTextureEnabled;
  39701. /**
  39702. * Are diffuse textures enabled in the application.
  39703. */
  39704. static DiffuseTextureEnabled: boolean;
  39705. private static _AmbientTextureEnabled;
  39706. /**
  39707. * Are ambient textures enabled in the application.
  39708. */
  39709. static AmbientTextureEnabled: boolean;
  39710. private static _OpacityTextureEnabled;
  39711. /**
  39712. * Are opacity textures enabled in the application.
  39713. */
  39714. static OpacityTextureEnabled: boolean;
  39715. private static _ReflectionTextureEnabled;
  39716. /**
  39717. * Are reflection textures enabled in the application.
  39718. */
  39719. static ReflectionTextureEnabled: boolean;
  39720. private static _EmissiveTextureEnabled;
  39721. /**
  39722. * Are emissive textures enabled in the application.
  39723. */
  39724. static EmissiveTextureEnabled: boolean;
  39725. private static _SpecularTextureEnabled;
  39726. /**
  39727. * Are specular textures enabled in the application.
  39728. */
  39729. static SpecularTextureEnabled: boolean;
  39730. private static _BumpTextureEnabled;
  39731. /**
  39732. * Are bump textures enabled in the application.
  39733. */
  39734. static BumpTextureEnabled: boolean;
  39735. private static _LightmapTextureEnabled;
  39736. /**
  39737. * Are lightmap textures enabled in the application.
  39738. */
  39739. static LightmapTextureEnabled: boolean;
  39740. private static _RefractionTextureEnabled;
  39741. /**
  39742. * Are refraction textures enabled in the application.
  39743. */
  39744. static RefractionTextureEnabled: boolean;
  39745. private static _ColorGradingTextureEnabled;
  39746. /**
  39747. * Are color grading textures enabled in the application.
  39748. */
  39749. static ColorGradingTextureEnabled: boolean;
  39750. private static _FresnelEnabled;
  39751. /**
  39752. * Are fresnels enabled in the application.
  39753. */
  39754. static FresnelEnabled: boolean;
  39755. private static _ClearCoatTextureEnabled;
  39756. /**
  39757. * Are clear coat textures enabled in the application.
  39758. */
  39759. static ClearCoatTextureEnabled: boolean;
  39760. private static _ClearCoatBumpTextureEnabled;
  39761. /**
  39762. * Are clear coat bump textures enabled in the application.
  39763. */
  39764. static ClearCoatBumpTextureEnabled: boolean;
  39765. private static _ClearCoatTintTextureEnabled;
  39766. /**
  39767. * Are clear coat tint textures enabled in the application.
  39768. */
  39769. static ClearCoatTintTextureEnabled: boolean;
  39770. private static _SheenTextureEnabled;
  39771. /**
  39772. * Are sheen textures enabled in the application.
  39773. */
  39774. static SheenTextureEnabled: boolean;
  39775. private static _AnisotropicTextureEnabled;
  39776. /**
  39777. * Are anisotropic textures enabled in the application.
  39778. */
  39779. static AnisotropicTextureEnabled: boolean;
  39780. private static _ThicknessTextureEnabled;
  39781. /**
  39782. * Are thickness textures enabled in the application.
  39783. */
  39784. static ThicknessTextureEnabled: boolean;
  39785. }
  39786. }
  39787. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  39788. /** @hidden */
  39789. export var defaultFragmentDeclaration: {
  39790. name: string;
  39791. shader: string;
  39792. };
  39793. }
  39794. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  39795. /** @hidden */
  39796. export var defaultUboDeclaration: {
  39797. name: string;
  39798. shader: string;
  39799. };
  39800. }
  39801. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  39802. /** @hidden */
  39803. export var lightFragmentDeclaration: {
  39804. name: string;
  39805. shader: string;
  39806. };
  39807. }
  39808. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  39809. /** @hidden */
  39810. export var lightUboDeclaration: {
  39811. name: string;
  39812. shader: string;
  39813. };
  39814. }
  39815. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  39816. /** @hidden */
  39817. export var lightsFragmentFunctions: {
  39818. name: string;
  39819. shader: string;
  39820. };
  39821. }
  39822. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  39823. /** @hidden */
  39824. export var shadowsFragmentFunctions: {
  39825. name: string;
  39826. shader: string;
  39827. };
  39828. }
  39829. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  39830. /** @hidden */
  39831. export var fresnelFunction: {
  39832. name: string;
  39833. shader: string;
  39834. };
  39835. }
  39836. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  39837. /** @hidden */
  39838. export var reflectionFunction: {
  39839. name: string;
  39840. shader: string;
  39841. };
  39842. }
  39843. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  39844. /** @hidden */
  39845. export var bumpFragmentFunctions: {
  39846. name: string;
  39847. shader: string;
  39848. };
  39849. }
  39850. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  39851. /** @hidden */
  39852. export var logDepthDeclaration: {
  39853. name: string;
  39854. shader: string;
  39855. };
  39856. }
  39857. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  39858. /** @hidden */
  39859. export var bumpFragment: {
  39860. name: string;
  39861. shader: string;
  39862. };
  39863. }
  39864. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  39865. /** @hidden */
  39866. export var depthPrePass: {
  39867. name: string;
  39868. shader: string;
  39869. };
  39870. }
  39871. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  39872. /** @hidden */
  39873. export var lightFragment: {
  39874. name: string;
  39875. shader: string;
  39876. };
  39877. }
  39878. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  39879. /** @hidden */
  39880. export var logDepthFragment: {
  39881. name: string;
  39882. shader: string;
  39883. };
  39884. }
  39885. declare module "babylonjs/Shaders/default.fragment" {
  39886. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  39887. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  39888. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  39889. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  39890. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  39891. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  39892. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  39893. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  39894. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  39895. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  39896. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  39897. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  39898. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  39899. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  39900. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  39901. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  39902. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  39903. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  39904. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  39905. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  39906. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  39907. /** @hidden */
  39908. export var defaultPixelShader: {
  39909. name: string;
  39910. shader: string;
  39911. };
  39912. }
  39913. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  39914. /** @hidden */
  39915. export var defaultVertexDeclaration: {
  39916. name: string;
  39917. shader: string;
  39918. };
  39919. }
  39920. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  39921. /** @hidden */
  39922. export var bumpVertexDeclaration: {
  39923. name: string;
  39924. shader: string;
  39925. };
  39926. }
  39927. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  39928. /** @hidden */
  39929. export var bumpVertex: {
  39930. name: string;
  39931. shader: string;
  39932. };
  39933. }
  39934. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  39935. /** @hidden */
  39936. export var fogVertex: {
  39937. name: string;
  39938. shader: string;
  39939. };
  39940. }
  39941. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  39942. /** @hidden */
  39943. export var shadowsVertex: {
  39944. name: string;
  39945. shader: string;
  39946. };
  39947. }
  39948. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  39949. /** @hidden */
  39950. export var pointCloudVertex: {
  39951. name: string;
  39952. shader: string;
  39953. };
  39954. }
  39955. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  39956. /** @hidden */
  39957. export var logDepthVertex: {
  39958. name: string;
  39959. shader: string;
  39960. };
  39961. }
  39962. declare module "babylonjs/Shaders/default.vertex" {
  39963. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  39964. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  39965. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  39966. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  39967. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  39968. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  39969. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  39970. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  39971. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  39972. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  39973. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  39974. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  39975. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  39976. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  39977. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  39978. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  39979. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  39980. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  39981. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  39982. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  39983. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  39984. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  39985. /** @hidden */
  39986. export var defaultVertexShader: {
  39987. name: string;
  39988. shader: string;
  39989. };
  39990. }
  39991. declare module "babylonjs/Materials/standardMaterial" {
  39992. import { SmartArray } from "babylonjs/Misc/smartArray";
  39993. import { IAnimatable } from "babylonjs/Misc/tools";
  39994. import { Nullable } from "babylonjs/types";
  39995. import { Scene } from "babylonjs/scene";
  39996. import { Matrix, Color3 } from "babylonjs/Maths/math";
  39997. import { SubMesh } from "babylonjs/Meshes/subMesh";
  39998. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39999. import { Mesh } from "babylonjs/Meshes/mesh";
  40000. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  40001. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  40002. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  40003. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  40004. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  40005. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  40006. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  40007. import "babylonjs/Shaders/default.fragment";
  40008. import "babylonjs/Shaders/default.vertex";
  40009. /** @hidden */
  40010. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  40011. MAINUV1: boolean;
  40012. MAINUV2: boolean;
  40013. DIFFUSE: boolean;
  40014. DIFFUSEDIRECTUV: number;
  40015. AMBIENT: boolean;
  40016. AMBIENTDIRECTUV: number;
  40017. OPACITY: boolean;
  40018. OPACITYDIRECTUV: number;
  40019. OPACITYRGB: boolean;
  40020. REFLECTION: boolean;
  40021. EMISSIVE: boolean;
  40022. EMISSIVEDIRECTUV: number;
  40023. SPECULAR: boolean;
  40024. SPECULARDIRECTUV: number;
  40025. BUMP: boolean;
  40026. BUMPDIRECTUV: number;
  40027. PARALLAX: boolean;
  40028. PARALLAXOCCLUSION: boolean;
  40029. SPECULAROVERALPHA: boolean;
  40030. CLIPPLANE: boolean;
  40031. CLIPPLANE2: boolean;
  40032. CLIPPLANE3: boolean;
  40033. CLIPPLANE4: boolean;
  40034. ALPHATEST: boolean;
  40035. DEPTHPREPASS: boolean;
  40036. ALPHAFROMDIFFUSE: boolean;
  40037. POINTSIZE: boolean;
  40038. FOG: boolean;
  40039. SPECULARTERM: boolean;
  40040. DIFFUSEFRESNEL: boolean;
  40041. OPACITYFRESNEL: boolean;
  40042. REFLECTIONFRESNEL: boolean;
  40043. REFRACTIONFRESNEL: boolean;
  40044. EMISSIVEFRESNEL: boolean;
  40045. FRESNEL: boolean;
  40046. NORMAL: boolean;
  40047. UV1: boolean;
  40048. UV2: boolean;
  40049. VERTEXCOLOR: boolean;
  40050. VERTEXALPHA: boolean;
  40051. NUM_BONE_INFLUENCERS: number;
  40052. BonesPerMesh: number;
  40053. BONETEXTURE: boolean;
  40054. INSTANCES: boolean;
  40055. GLOSSINESS: boolean;
  40056. ROUGHNESS: boolean;
  40057. EMISSIVEASILLUMINATION: boolean;
  40058. LINKEMISSIVEWITHDIFFUSE: boolean;
  40059. REFLECTIONFRESNELFROMSPECULAR: boolean;
  40060. LIGHTMAP: boolean;
  40061. LIGHTMAPDIRECTUV: number;
  40062. OBJECTSPACE_NORMALMAP: boolean;
  40063. USELIGHTMAPASSHADOWMAP: boolean;
  40064. REFLECTIONMAP_3D: boolean;
  40065. REFLECTIONMAP_SPHERICAL: boolean;
  40066. REFLECTIONMAP_PLANAR: boolean;
  40067. REFLECTIONMAP_CUBIC: boolean;
  40068. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  40069. REFLECTIONMAP_PROJECTION: boolean;
  40070. REFLECTIONMAP_SKYBOX: boolean;
  40071. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  40072. REFLECTIONMAP_EXPLICIT: boolean;
  40073. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  40074. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  40075. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  40076. INVERTCUBICMAP: boolean;
  40077. LOGARITHMICDEPTH: boolean;
  40078. REFRACTION: boolean;
  40079. REFRACTIONMAP_3D: boolean;
  40080. REFLECTIONOVERALPHA: boolean;
  40081. TWOSIDEDLIGHTING: boolean;
  40082. SHADOWFLOAT: boolean;
  40083. MORPHTARGETS: boolean;
  40084. MORPHTARGETS_NORMAL: boolean;
  40085. MORPHTARGETS_TANGENT: boolean;
  40086. NUM_MORPH_INFLUENCERS: number;
  40087. NONUNIFORMSCALING: boolean;
  40088. PREMULTIPLYALPHA: boolean;
  40089. IMAGEPROCESSING: boolean;
  40090. VIGNETTE: boolean;
  40091. VIGNETTEBLENDMODEMULTIPLY: boolean;
  40092. VIGNETTEBLENDMODEOPAQUE: boolean;
  40093. TONEMAPPING: boolean;
  40094. TONEMAPPING_ACES: boolean;
  40095. CONTRAST: boolean;
  40096. COLORCURVES: boolean;
  40097. COLORGRADING: boolean;
  40098. COLORGRADING3D: boolean;
  40099. SAMPLER3DGREENDEPTH: boolean;
  40100. SAMPLER3DBGRMAP: boolean;
  40101. IMAGEPROCESSINGPOSTPROCESS: boolean;
  40102. MULTIVIEW: boolean;
  40103. /**
  40104. * If the reflection texture on this material is in linear color space
  40105. * @hidden
  40106. */
  40107. IS_REFLECTION_LINEAR: boolean;
  40108. /**
  40109. * If the refraction texture on this material is in linear color space
  40110. * @hidden
  40111. */
  40112. IS_REFRACTION_LINEAR: boolean;
  40113. EXPOSURE: boolean;
  40114. constructor();
  40115. setReflectionMode(modeToEnable: string): void;
  40116. }
  40117. /**
  40118. * This is the default material used in Babylon. It is the best trade off between quality
  40119. * and performances.
  40120. * @see http://doc.babylonjs.com/babylon101/materials
  40121. */
  40122. export class StandardMaterial extends PushMaterial {
  40123. private _diffuseTexture;
  40124. /**
  40125. * The basic texture of the material as viewed under a light.
  40126. */
  40127. diffuseTexture: Nullable<BaseTexture>;
  40128. private _ambientTexture;
  40129. /**
  40130. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  40131. */
  40132. ambientTexture: Nullable<BaseTexture>;
  40133. private _opacityTexture;
  40134. /**
  40135. * Define the transparency of the material from a texture.
  40136. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  40137. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  40138. */
  40139. opacityTexture: Nullable<BaseTexture>;
  40140. private _reflectionTexture;
  40141. /**
  40142. * Define the texture used to display the reflection.
  40143. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40144. */
  40145. reflectionTexture: Nullable<BaseTexture>;
  40146. private _emissiveTexture;
  40147. /**
  40148. * Define texture of the material as if self lit.
  40149. * This will be mixed in the final result even in the absence of light.
  40150. */
  40151. emissiveTexture: Nullable<BaseTexture>;
  40152. private _specularTexture;
  40153. /**
  40154. * Define how the color and intensity of the highlight given by the light in the material.
  40155. */
  40156. specularTexture: Nullable<BaseTexture>;
  40157. private _bumpTexture;
  40158. /**
  40159. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  40160. * 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.
  40161. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  40162. */
  40163. bumpTexture: Nullable<BaseTexture>;
  40164. private _lightmapTexture;
  40165. /**
  40166. * Complex lighting can be computationally expensive to compute at runtime.
  40167. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  40168. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  40169. */
  40170. lightmapTexture: Nullable<BaseTexture>;
  40171. private _refractionTexture;
  40172. /**
  40173. * Define the texture used to display the refraction.
  40174. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40175. */
  40176. refractionTexture: Nullable<BaseTexture>;
  40177. /**
  40178. * The color of the material lit by the environmental background lighting.
  40179. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  40180. */
  40181. ambientColor: Color3;
  40182. /**
  40183. * The basic color of the material as viewed under a light.
  40184. */
  40185. diffuseColor: Color3;
  40186. /**
  40187. * Define how the color and intensity of the highlight given by the light in the material.
  40188. */
  40189. specularColor: Color3;
  40190. /**
  40191. * Define the color of the material as if self lit.
  40192. * This will be mixed in the final result even in the absence of light.
  40193. */
  40194. emissiveColor: Color3;
  40195. /**
  40196. * Defines how sharp are the highlights in the material.
  40197. * The bigger the value the sharper giving a more glossy feeling to the result.
  40198. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  40199. */
  40200. specularPower: number;
  40201. private _useAlphaFromDiffuseTexture;
  40202. /**
  40203. * Does the transparency come from the diffuse texture alpha channel.
  40204. */
  40205. useAlphaFromDiffuseTexture: boolean;
  40206. private _useEmissiveAsIllumination;
  40207. /**
  40208. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  40209. */
  40210. useEmissiveAsIllumination: boolean;
  40211. private _linkEmissiveWithDiffuse;
  40212. /**
  40213. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  40214. * the emissive level when the final color is close to one.
  40215. */
  40216. linkEmissiveWithDiffuse: boolean;
  40217. private _useSpecularOverAlpha;
  40218. /**
  40219. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  40220. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  40221. */
  40222. useSpecularOverAlpha: boolean;
  40223. private _useReflectionOverAlpha;
  40224. /**
  40225. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  40226. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  40227. */
  40228. useReflectionOverAlpha: boolean;
  40229. private _disableLighting;
  40230. /**
  40231. * Does lights from the scene impacts this material.
  40232. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  40233. */
  40234. disableLighting: boolean;
  40235. private _useObjectSpaceNormalMap;
  40236. /**
  40237. * Allows using an object space normal map (instead of tangent space).
  40238. */
  40239. useObjectSpaceNormalMap: boolean;
  40240. private _useParallax;
  40241. /**
  40242. * Is parallax enabled or not.
  40243. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  40244. */
  40245. useParallax: boolean;
  40246. private _useParallaxOcclusion;
  40247. /**
  40248. * Is parallax occlusion enabled or not.
  40249. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  40250. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  40251. */
  40252. useParallaxOcclusion: boolean;
  40253. /**
  40254. * 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.
  40255. */
  40256. parallaxScaleBias: number;
  40257. private _roughness;
  40258. /**
  40259. * Helps to define how blurry the reflections should appears in the material.
  40260. */
  40261. roughness: number;
  40262. /**
  40263. * In case of refraction, define the value of the indice of refraction.
  40264. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40265. */
  40266. indexOfRefraction: number;
  40267. /**
  40268. * Invert the refraction texture alongside the y axis.
  40269. * It can be useful with procedural textures or probe for instance.
  40270. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40271. */
  40272. invertRefractionY: boolean;
  40273. /**
  40274. * Defines the alpha limits in alpha test mode.
  40275. */
  40276. alphaCutOff: number;
  40277. private _useLightmapAsShadowmap;
  40278. /**
  40279. * In case of light mapping, define whether the map contains light or shadow informations.
  40280. */
  40281. useLightmapAsShadowmap: boolean;
  40282. private _diffuseFresnelParameters;
  40283. /**
  40284. * Define the diffuse fresnel parameters of the material.
  40285. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40286. */
  40287. diffuseFresnelParameters: FresnelParameters;
  40288. private _opacityFresnelParameters;
  40289. /**
  40290. * Define the opacity fresnel parameters of the material.
  40291. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40292. */
  40293. opacityFresnelParameters: FresnelParameters;
  40294. private _reflectionFresnelParameters;
  40295. /**
  40296. * Define the reflection fresnel parameters of the material.
  40297. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40298. */
  40299. reflectionFresnelParameters: FresnelParameters;
  40300. private _refractionFresnelParameters;
  40301. /**
  40302. * Define the refraction fresnel parameters of the material.
  40303. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40304. */
  40305. refractionFresnelParameters: FresnelParameters;
  40306. private _emissiveFresnelParameters;
  40307. /**
  40308. * Define the emissive fresnel parameters of the material.
  40309. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40310. */
  40311. emissiveFresnelParameters: FresnelParameters;
  40312. private _useReflectionFresnelFromSpecular;
  40313. /**
  40314. * If true automatically deducts the fresnels values from the material specularity.
  40315. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40316. */
  40317. useReflectionFresnelFromSpecular: boolean;
  40318. private _useGlossinessFromSpecularMapAlpha;
  40319. /**
  40320. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  40321. */
  40322. useGlossinessFromSpecularMapAlpha: boolean;
  40323. private _maxSimultaneousLights;
  40324. /**
  40325. * Defines the maximum number of lights that can be used in the material
  40326. */
  40327. maxSimultaneousLights: number;
  40328. private _invertNormalMapX;
  40329. /**
  40330. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  40331. */
  40332. invertNormalMapX: boolean;
  40333. private _invertNormalMapY;
  40334. /**
  40335. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  40336. */
  40337. invertNormalMapY: boolean;
  40338. private _twoSidedLighting;
  40339. /**
  40340. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  40341. */
  40342. twoSidedLighting: boolean;
  40343. /**
  40344. * Default configuration related to image processing available in the standard Material.
  40345. */
  40346. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40347. /**
  40348. * Gets the image processing configuration used either in this material.
  40349. */
  40350. /**
  40351. * Sets the Default image processing configuration used either in the this material.
  40352. *
  40353. * If sets to null, the scene one is in use.
  40354. */
  40355. imageProcessingConfiguration: ImageProcessingConfiguration;
  40356. /**
  40357. * Keep track of the image processing observer to allow dispose and replace.
  40358. */
  40359. private _imageProcessingObserver;
  40360. /**
  40361. * Attaches a new image processing configuration to the Standard Material.
  40362. * @param configuration
  40363. */
  40364. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  40365. /**
  40366. * Gets wether the color curves effect is enabled.
  40367. */
  40368. /**
  40369. * Sets wether the color curves effect is enabled.
  40370. */
  40371. cameraColorCurvesEnabled: boolean;
  40372. /**
  40373. * Gets wether the color grading effect is enabled.
  40374. */
  40375. /**
  40376. * Gets wether the color grading effect is enabled.
  40377. */
  40378. cameraColorGradingEnabled: boolean;
  40379. /**
  40380. * Gets wether tonemapping is enabled or not.
  40381. */
  40382. /**
  40383. * Sets wether tonemapping is enabled or not
  40384. */
  40385. cameraToneMappingEnabled: boolean;
  40386. /**
  40387. * The camera exposure used on this material.
  40388. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  40389. * This corresponds to a photographic exposure.
  40390. */
  40391. /**
  40392. * The camera exposure used on this material.
  40393. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  40394. * This corresponds to a photographic exposure.
  40395. */
  40396. cameraExposure: number;
  40397. /**
  40398. * Gets The camera contrast used on this material.
  40399. */
  40400. /**
  40401. * Sets The camera contrast used on this material.
  40402. */
  40403. cameraContrast: number;
  40404. /**
  40405. * Gets the Color Grading 2D Lookup Texture.
  40406. */
  40407. /**
  40408. * Sets the Color Grading 2D Lookup Texture.
  40409. */
  40410. cameraColorGradingTexture: Nullable<BaseTexture>;
  40411. /**
  40412. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  40413. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  40414. * 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;
  40415. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  40416. */
  40417. /**
  40418. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  40419. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  40420. * 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;
  40421. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  40422. */
  40423. cameraColorCurves: Nullable<ColorCurves>;
  40424. /**
  40425. * Custom callback helping to override the default shader used in the material.
  40426. */
  40427. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  40428. protected _renderTargets: SmartArray<RenderTargetTexture>;
  40429. protected _worldViewProjectionMatrix: Matrix;
  40430. protected _globalAmbientColor: Color3;
  40431. protected _useLogarithmicDepth: boolean;
  40432. /**
  40433. * Instantiates a new standard material.
  40434. * This is the default material used in Babylon. It is the best trade off between quality
  40435. * and performances.
  40436. * @see http://doc.babylonjs.com/babylon101/materials
  40437. * @param name Define the name of the material in the scene
  40438. * @param scene Define the scene the material belong to
  40439. */
  40440. constructor(name: string, scene: Scene);
  40441. /**
  40442. * Gets a boolean indicating that current material needs to register RTT
  40443. */
  40444. readonly hasRenderTargetTextures: boolean;
  40445. /**
  40446. * Gets the current class name of the material e.g. "StandardMaterial"
  40447. * Mainly use in serialization.
  40448. * @returns the class name
  40449. */
  40450. getClassName(): string;
  40451. /**
  40452. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  40453. * You can try switching to logarithmic depth.
  40454. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  40455. */
  40456. useLogarithmicDepth: boolean;
  40457. /**
  40458. * Specifies if the material will require alpha blending
  40459. * @returns a boolean specifying if alpha blending is needed
  40460. */
  40461. needAlphaBlending(): boolean;
  40462. /**
  40463. * Specifies if this material should be rendered in alpha test mode
  40464. * @returns a boolean specifying if an alpha test is needed.
  40465. */
  40466. needAlphaTesting(): boolean;
  40467. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  40468. /**
  40469. * Get the texture used for alpha test purpose.
  40470. * @returns the diffuse texture in case of the standard material.
  40471. */
  40472. getAlphaTestTexture(): Nullable<BaseTexture>;
  40473. /**
  40474. * Get if the submesh is ready to be used and all its information available.
  40475. * Child classes can use it to update shaders
  40476. * @param mesh defines the mesh to check
  40477. * @param subMesh defines which submesh to check
  40478. * @param useInstances specifies that instances should be used
  40479. * @returns a boolean indicating that the submesh is ready or not
  40480. */
  40481. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  40482. /**
  40483. * Builds the material UBO layouts.
  40484. * Used internally during the effect preparation.
  40485. */
  40486. buildUniformLayout(): void;
  40487. /**
  40488. * Unbinds the material from the mesh
  40489. */
  40490. unbind(): void;
  40491. /**
  40492. * Binds the submesh to this material by preparing the effect and shader to draw
  40493. * @param world defines the world transformation matrix
  40494. * @param mesh defines the mesh containing the submesh
  40495. * @param subMesh defines the submesh to bind the material to
  40496. */
  40497. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  40498. /**
  40499. * Get the list of animatables in the material.
  40500. * @returns the list of animatables object used in the material
  40501. */
  40502. getAnimatables(): IAnimatable[];
  40503. /**
  40504. * Gets the active textures from the material
  40505. * @returns an array of textures
  40506. */
  40507. getActiveTextures(): BaseTexture[];
  40508. /**
  40509. * Specifies if the material uses a texture
  40510. * @param texture defines the texture to check against the material
  40511. * @returns a boolean specifying if the material uses the texture
  40512. */
  40513. hasTexture(texture: BaseTexture): boolean;
  40514. /**
  40515. * Disposes the material
  40516. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  40517. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  40518. */
  40519. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  40520. /**
  40521. * Makes a duplicate of the material, and gives it a new name
  40522. * @param name defines the new name for the duplicated material
  40523. * @returns the cloned material
  40524. */
  40525. clone(name: string): StandardMaterial;
  40526. /**
  40527. * Serializes this material in a JSON representation
  40528. * @returns the serialized material object
  40529. */
  40530. serialize(): any;
  40531. /**
  40532. * Creates a standard material from parsed material data
  40533. * @param source defines the JSON representation of the material
  40534. * @param scene defines the hosting scene
  40535. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  40536. * @returns a new standard material
  40537. */
  40538. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  40539. /**
  40540. * Are diffuse textures enabled in the application.
  40541. */
  40542. static DiffuseTextureEnabled: boolean;
  40543. /**
  40544. * Are ambient textures enabled in the application.
  40545. */
  40546. static AmbientTextureEnabled: boolean;
  40547. /**
  40548. * Are opacity textures enabled in the application.
  40549. */
  40550. static OpacityTextureEnabled: boolean;
  40551. /**
  40552. * Are reflection textures enabled in the application.
  40553. */
  40554. static ReflectionTextureEnabled: boolean;
  40555. /**
  40556. * Are emissive textures enabled in the application.
  40557. */
  40558. static EmissiveTextureEnabled: boolean;
  40559. /**
  40560. * Are specular textures enabled in the application.
  40561. */
  40562. static SpecularTextureEnabled: boolean;
  40563. /**
  40564. * Are bump textures enabled in the application.
  40565. */
  40566. static BumpTextureEnabled: boolean;
  40567. /**
  40568. * Are lightmap textures enabled in the application.
  40569. */
  40570. static LightmapTextureEnabled: boolean;
  40571. /**
  40572. * Are refraction textures enabled in the application.
  40573. */
  40574. static RefractionTextureEnabled: boolean;
  40575. /**
  40576. * Are color grading textures enabled in the application.
  40577. */
  40578. static ColorGradingTextureEnabled: boolean;
  40579. /**
  40580. * Are fresnels enabled in the application.
  40581. */
  40582. static FresnelEnabled: boolean;
  40583. }
  40584. }
  40585. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  40586. import { Scene } from "babylonjs/scene";
  40587. import { Texture } from "babylonjs/Materials/Textures/texture";
  40588. /**
  40589. * A class extending Texture allowing drawing on a texture
  40590. * @see http://doc.babylonjs.com/how_to/dynamictexture
  40591. */
  40592. export class DynamicTexture extends Texture {
  40593. private _generateMipMaps;
  40594. private _canvas;
  40595. private _context;
  40596. private _engine;
  40597. /**
  40598. * Creates a DynamicTexture
  40599. * @param name defines the name of the texture
  40600. * @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
  40601. * @param scene defines the scene where you want the texture
  40602. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  40603. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  40604. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  40605. */
  40606. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  40607. /**
  40608. * Get the current class name of the texture useful for serialization or dynamic coding.
  40609. * @returns "DynamicTexture"
  40610. */
  40611. getClassName(): string;
  40612. /**
  40613. * Gets the current state of canRescale
  40614. */
  40615. readonly canRescale: boolean;
  40616. private _recreate;
  40617. /**
  40618. * Scales the texture
  40619. * @param ratio the scale factor to apply to both width and height
  40620. */
  40621. scale(ratio: number): void;
  40622. /**
  40623. * Resizes the texture
  40624. * @param width the new width
  40625. * @param height the new height
  40626. */
  40627. scaleTo(width: number, height: number): void;
  40628. /**
  40629. * Gets the context of the canvas used by the texture
  40630. * @returns the canvas context of the dynamic texture
  40631. */
  40632. getContext(): CanvasRenderingContext2D;
  40633. /**
  40634. * Clears the texture
  40635. */
  40636. clear(): void;
  40637. /**
  40638. * Updates the texture
  40639. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  40640. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  40641. */
  40642. update(invertY?: boolean, premulAlpha?: boolean): void;
  40643. /**
  40644. * Draws text onto the texture
  40645. * @param text defines the text to be drawn
  40646. * @param x defines the placement of the text from the left
  40647. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  40648. * @param font defines the font to be used with font-style, font-size, font-name
  40649. * @param color defines the color used for the text
  40650. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  40651. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  40652. * @param update defines whether texture is immediately update (default is true)
  40653. */
  40654. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  40655. /**
  40656. * Clones the texture
  40657. * @returns the clone of the texture.
  40658. */
  40659. clone(): DynamicTexture;
  40660. /**
  40661. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  40662. * @returns a serialized dynamic texture object
  40663. */
  40664. serialize(): any;
  40665. /** @hidden */
  40666. _rebuild(): void;
  40667. }
  40668. }
  40669. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  40670. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  40671. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  40672. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  40673. /** @hidden */
  40674. export var imageProcessingPixelShader: {
  40675. name: string;
  40676. shader: string;
  40677. };
  40678. }
  40679. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  40680. import { Nullable } from "babylonjs/types";
  40681. import { Color4 } from "babylonjs/Maths/math";
  40682. import { Camera } from "babylonjs/Cameras/camera";
  40683. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  40684. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  40685. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  40686. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  40687. import { Engine } from "babylonjs/Engines/engine";
  40688. import "babylonjs/Shaders/imageProcessing.fragment";
  40689. import "babylonjs/Shaders/postprocess.vertex";
  40690. /**
  40691. * ImageProcessingPostProcess
  40692. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  40693. */
  40694. export class ImageProcessingPostProcess extends PostProcess {
  40695. /**
  40696. * Default configuration related to image processing available in the PBR Material.
  40697. */
  40698. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40699. /**
  40700. * Gets the image processing configuration used either in this material.
  40701. */
  40702. /**
  40703. * Sets the Default image processing configuration used either in the this material.
  40704. *
  40705. * If sets to null, the scene one is in use.
  40706. */
  40707. imageProcessingConfiguration: ImageProcessingConfiguration;
  40708. /**
  40709. * Keep track of the image processing observer to allow dispose and replace.
  40710. */
  40711. private _imageProcessingObserver;
  40712. /**
  40713. * Attaches a new image processing configuration to the PBR Material.
  40714. * @param configuration
  40715. */
  40716. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  40717. /**
  40718. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  40719. */
  40720. /**
  40721. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  40722. */
  40723. colorCurves: Nullable<ColorCurves>;
  40724. /**
  40725. * Gets wether the color curves effect is enabled.
  40726. */
  40727. /**
  40728. * Sets wether the color curves effect is enabled.
  40729. */
  40730. colorCurvesEnabled: boolean;
  40731. /**
  40732. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  40733. */
  40734. /**
  40735. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  40736. */
  40737. colorGradingTexture: Nullable<BaseTexture>;
  40738. /**
  40739. * Gets wether the color grading effect is enabled.
  40740. */
  40741. /**
  40742. * Gets wether the color grading effect is enabled.
  40743. */
  40744. colorGradingEnabled: boolean;
  40745. /**
  40746. * Gets exposure used in the effect.
  40747. */
  40748. /**
  40749. * Sets exposure used in the effect.
  40750. */
  40751. exposure: number;
  40752. /**
  40753. * Gets wether tonemapping is enabled or not.
  40754. */
  40755. /**
  40756. * Sets wether tonemapping is enabled or not
  40757. */
  40758. toneMappingEnabled: boolean;
  40759. /**
  40760. * Gets the type of tone mapping effect.
  40761. */
  40762. /**
  40763. * Sets the type of tone mapping effect.
  40764. */
  40765. toneMappingType: number;
  40766. /**
  40767. * Gets contrast used in the effect.
  40768. */
  40769. /**
  40770. * Sets contrast used in the effect.
  40771. */
  40772. contrast: number;
  40773. /**
  40774. * Gets Vignette stretch size.
  40775. */
  40776. /**
  40777. * Sets Vignette stretch size.
  40778. */
  40779. vignetteStretch: number;
  40780. /**
  40781. * Gets Vignette centre X Offset.
  40782. */
  40783. /**
  40784. * Sets Vignette centre X Offset.
  40785. */
  40786. vignetteCentreX: number;
  40787. /**
  40788. * Gets Vignette centre Y Offset.
  40789. */
  40790. /**
  40791. * Sets Vignette centre Y Offset.
  40792. */
  40793. vignetteCentreY: number;
  40794. /**
  40795. * Gets Vignette weight or intensity of the vignette effect.
  40796. */
  40797. /**
  40798. * Sets Vignette weight or intensity of the vignette effect.
  40799. */
  40800. vignetteWeight: number;
  40801. /**
  40802. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  40803. * if vignetteEnabled is set to true.
  40804. */
  40805. /**
  40806. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  40807. * if vignetteEnabled is set to true.
  40808. */
  40809. vignetteColor: Color4;
  40810. /**
  40811. * Gets Camera field of view used by the Vignette effect.
  40812. */
  40813. /**
  40814. * Sets Camera field of view used by the Vignette effect.
  40815. */
  40816. vignetteCameraFov: number;
  40817. /**
  40818. * Gets the vignette blend mode allowing different kind of effect.
  40819. */
  40820. /**
  40821. * Sets the vignette blend mode allowing different kind of effect.
  40822. */
  40823. vignetteBlendMode: number;
  40824. /**
  40825. * Gets wether the vignette effect is enabled.
  40826. */
  40827. /**
  40828. * Sets wether the vignette effect is enabled.
  40829. */
  40830. vignetteEnabled: boolean;
  40831. private _fromLinearSpace;
  40832. /**
  40833. * Gets wether the input of the processing is in Gamma or Linear Space.
  40834. */
  40835. /**
  40836. * Sets wether the input of the processing is in Gamma or Linear Space.
  40837. */
  40838. fromLinearSpace: boolean;
  40839. /**
  40840. * Defines cache preventing GC.
  40841. */
  40842. private _defines;
  40843. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  40844. /**
  40845. * "ImageProcessingPostProcess"
  40846. * @returns "ImageProcessingPostProcess"
  40847. */
  40848. getClassName(): string;
  40849. protected _updateParameters(): void;
  40850. dispose(camera?: Camera): void;
  40851. }
  40852. }
  40853. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  40854. import { Scene } from "babylonjs/scene";
  40855. import { Color3 } from "babylonjs/Maths/math";
  40856. import { Mesh } from "babylonjs/Meshes/mesh";
  40857. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  40858. import { Nullable } from "babylonjs/types";
  40859. /**
  40860. * Class containing static functions to help procedurally build meshes
  40861. */
  40862. export class GroundBuilder {
  40863. /**
  40864. * Creates a ground mesh
  40865. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  40866. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  40867. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40868. * @param name defines the name of the mesh
  40869. * @param options defines the options used to create the mesh
  40870. * @param scene defines the hosting scene
  40871. * @returns the ground mesh
  40872. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  40873. */
  40874. static CreateGround(name: string, options: {
  40875. width?: number;
  40876. height?: number;
  40877. subdivisions?: number;
  40878. subdivisionsX?: number;
  40879. subdivisionsY?: number;
  40880. updatable?: boolean;
  40881. }, scene: any): Mesh;
  40882. /**
  40883. * Creates a tiled ground mesh
  40884. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  40885. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  40886. * * 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
  40887. * * 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
  40888. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40889. * @param name defines the name of the mesh
  40890. * @param options defines the options used to create the mesh
  40891. * @param scene defines the hosting scene
  40892. * @returns the tiled ground mesh
  40893. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  40894. */
  40895. static CreateTiledGround(name: string, options: {
  40896. xmin: number;
  40897. zmin: number;
  40898. xmax: number;
  40899. zmax: number;
  40900. subdivisions?: {
  40901. w: number;
  40902. h: number;
  40903. };
  40904. precision?: {
  40905. w: number;
  40906. h: number;
  40907. };
  40908. updatable?: boolean;
  40909. }, scene?: Nullable<Scene>): Mesh;
  40910. /**
  40911. * Creates a ground mesh from a height map
  40912. * * The parameter `url` sets the URL of the height map image resource.
  40913. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  40914. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  40915. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  40916. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  40917. * * 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.
  40918. * * 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).
  40919. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  40920. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40921. * @param name defines the name of the mesh
  40922. * @param url defines the url to the height map
  40923. * @param options defines the options used to create the mesh
  40924. * @param scene defines the hosting scene
  40925. * @returns the ground mesh
  40926. * @see https://doc.babylonjs.com/babylon101/height_map
  40927. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  40928. */
  40929. static CreateGroundFromHeightMap(name: string, url: string, options: {
  40930. width?: number;
  40931. height?: number;
  40932. subdivisions?: number;
  40933. minHeight?: number;
  40934. maxHeight?: number;
  40935. colorFilter?: Color3;
  40936. alphaFilter?: number;
  40937. updatable?: boolean;
  40938. onReady?: (mesh: GroundMesh) => void;
  40939. }, scene?: Nullable<Scene>): GroundMesh;
  40940. }
  40941. }
  40942. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  40943. import { Vector4 } from "babylonjs/Maths/math";
  40944. import { Mesh } from "babylonjs/Meshes/mesh";
  40945. /**
  40946. * Class containing static functions to help procedurally build meshes
  40947. */
  40948. export class TorusBuilder {
  40949. /**
  40950. * Creates a torus mesh
  40951. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  40952. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  40953. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  40954. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40955. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  40956. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40957. * @param name defines the name of the mesh
  40958. * @param options defines the options used to create the mesh
  40959. * @param scene defines the hosting scene
  40960. * @returns the torus mesh
  40961. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  40962. */
  40963. static CreateTorus(name: string, options: {
  40964. diameter?: number;
  40965. thickness?: number;
  40966. tessellation?: number;
  40967. updatable?: boolean;
  40968. sideOrientation?: number;
  40969. frontUVs?: Vector4;
  40970. backUVs?: Vector4;
  40971. }, scene: any): Mesh;
  40972. }
  40973. }
  40974. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  40975. import { Color4, Vector4 } from "babylonjs/Maths/math";
  40976. import { Mesh } from "babylonjs/Meshes/mesh";
  40977. /**
  40978. * Class containing static functions to help procedurally build meshes
  40979. */
  40980. export class CylinderBuilder {
  40981. /**
  40982. * Creates a cylinder or a cone mesh
  40983. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  40984. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  40985. * * 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.
  40986. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  40987. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  40988. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  40989. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  40990. * * 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).
  40991. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  40992. * * 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).
  40993. * * 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
  40994. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  40995. * * 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
  40996. * * 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.
  40997. * * If `enclose` is false, a ring surface is one element.
  40998. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  40999. * * 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
  41000. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41001. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  41002. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41003. * @param name defines the name of the mesh
  41004. * @param options defines the options used to create the mesh
  41005. * @param scene defines the hosting scene
  41006. * @returns the cylinder mesh
  41007. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  41008. */
  41009. static CreateCylinder(name: string, options: {
  41010. height?: number;
  41011. diameterTop?: number;
  41012. diameterBottom?: number;
  41013. diameter?: number;
  41014. tessellation?: number;
  41015. subdivisions?: number;
  41016. arc?: number;
  41017. faceColors?: Color4[];
  41018. faceUV?: Vector4[];
  41019. updatable?: boolean;
  41020. hasRings?: boolean;
  41021. enclose?: boolean;
  41022. cap?: number;
  41023. sideOrientation?: number;
  41024. frontUVs?: Vector4;
  41025. backUVs?: Vector4;
  41026. }, scene: any): Mesh;
  41027. }
  41028. }
  41029. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  41030. import { Observable } from "babylonjs/Misc/observable";
  41031. import { Nullable } from "babylonjs/types";
  41032. import { Camera } from "babylonjs/Cameras/camera";
  41033. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  41034. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  41035. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  41036. import { Scene } from "babylonjs/scene";
  41037. import { Vector3, Color3 } from "babylonjs/Maths/math";
  41038. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  41039. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41040. import { Mesh } from "babylonjs/Meshes/mesh";
  41041. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  41042. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41043. import "babylonjs/Meshes/Builders/groundBuilder";
  41044. import "babylonjs/Meshes/Builders/torusBuilder";
  41045. import "babylonjs/Meshes/Builders/cylinderBuilder";
  41046. import "babylonjs/Gamepads/gamepadSceneComponent";
  41047. import "babylonjs/Animations/animatable";
  41048. /**
  41049. * Options to modify the vr teleportation behavior.
  41050. */
  41051. export interface VRTeleportationOptions {
  41052. /**
  41053. * The name of the mesh which should be used as the teleportation floor. (default: null)
  41054. */
  41055. floorMeshName?: string;
  41056. /**
  41057. * A list of meshes to be used as the teleportation floor. (default: empty)
  41058. */
  41059. floorMeshes?: Mesh[];
  41060. }
  41061. /**
  41062. * Options to modify the vr experience helper's behavior.
  41063. */
  41064. export interface VRExperienceHelperOptions extends WebVROptions {
  41065. /**
  41066. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  41067. */
  41068. createDeviceOrientationCamera?: boolean;
  41069. /**
  41070. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  41071. */
  41072. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  41073. /**
  41074. * Uses the main button on the controller to toggle the laser casted. (default: true)
  41075. */
  41076. laserToggle?: boolean;
  41077. /**
  41078. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  41079. */
  41080. floorMeshes?: Mesh[];
  41081. /**
  41082. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  41083. */
  41084. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  41085. }
  41086. /**
  41087. * Event containing information after VR has been entered
  41088. */
  41089. export class OnAfterEnteringVRObservableEvent {
  41090. /**
  41091. * If entering vr was successful
  41092. */
  41093. success: boolean;
  41094. }
  41095. /**
  41096. * Helps to quickly add VR support to an existing scene.
  41097. * See http://doc.babylonjs.com/how_to/webvr_helper
  41098. */
  41099. export class VRExperienceHelper {
  41100. /** Options to modify the vr experience helper's behavior. */
  41101. webVROptions: VRExperienceHelperOptions;
  41102. private _scene;
  41103. private _position;
  41104. private _btnVR;
  41105. private _btnVRDisplayed;
  41106. private _webVRsupported;
  41107. private _webVRready;
  41108. private _webVRrequesting;
  41109. private _webVRpresenting;
  41110. private _hasEnteredVR;
  41111. private _fullscreenVRpresenting;
  41112. private _canvas;
  41113. private _webVRCamera;
  41114. private _vrDeviceOrientationCamera;
  41115. private _deviceOrientationCamera;
  41116. private _existingCamera;
  41117. private _onKeyDown;
  41118. private _onVrDisplayPresentChange;
  41119. private _onVRDisplayChanged;
  41120. private _onVRRequestPresentStart;
  41121. private _onVRRequestPresentComplete;
  41122. /**
  41123. * Observable raised right before entering VR.
  41124. */
  41125. onEnteringVRObservable: Observable<VRExperienceHelper>;
  41126. /**
  41127. * Observable raised when entering VR has completed.
  41128. */
  41129. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  41130. /**
  41131. * Observable raised when exiting VR.
  41132. */
  41133. onExitingVRObservable: Observable<VRExperienceHelper>;
  41134. /**
  41135. * Observable raised when controller mesh is loaded.
  41136. */
  41137. onControllerMeshLoadedObservable: Observable<WebVRController>;
  41138. /** Return this.onEnteringVRObservable
  41139. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  41140. */
  41141. readonly onEnteringVR: Observable<VRExperienceHelper>;
  41142. /** Return this.onExitingVRObservable
  41143. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  41144. */
  41145. readonly onExitingVR: Observable<VRExperienceHelper>;
  41146. /** Return this.onControllerMeshLoadedObservable
  41147. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  41148. */
  41149. readonly onControllerMeshLoaded: Observable<WebVRController>;
  41150. private _rayLength;
  41151. private _useCustomVRButton;
  41152. private _teleportationRequested;
  41153. private _teleportActive;
  41154. private _floorMeshName;
  41155. private _floorMeshesCollection;
  41156. private _rotationAllowed;
  41157. private _teleportBackwardsVector;
  41158. private _teleportationTarget;
  41159. private _isDefaultTeleportationTarget;
  41160. private _postProcessMove;
  41161. private _teleportationFillColor;
  41162. private _teleportationBorderColor;
  41163. private _rotationAngle;
  41164. private _haloCenter;
  41165. private _cameraGazer;
  41166. private _padSensibilityUp;
  41167. private _padSensibilityDown;
  41168. private _leftController;
  41169. private _rightController;
  41170. /**
  41171. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  41172. */
  41173. onNewMeshSelected: Observable<AbstractMesh>;
  41174. /**
  41175. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  41176. */
  41177. onNewMeshPicked: Observable<PickingInfo>;
  41178. private _circleEase;
  41179. /**
  41180. * Observable raised before camera teleportation
  41181. */
  41182. onBeforeCameraTeleport: Observable<Vector3>;
  41183. /**
  41184. * Observable raised after camera teleportation
  41185. */
  41186. onAfterCameraTeleport: Observable<Vector3>;
  41187. /**
  41188. * Observable raised when current selected mesh gets unselected
  41189. */
  41190. onSelectedMeshUnselected: Observable<AbstractMesh>;
  41191. private _raySelectionPredicate;
  41192. /**
  41193. * To be optionaly changed by user to define custom ray selection
  41194. */
  41195. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  41196. /**
  41197. * To be optionaly changed by user to define custom selection logic (after ray selection)
  41198. */
  41199. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  41200. /**
  41201. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  41202. */
  41203. teleportationEnabled: boolean;
  41204. private _defaultHeight;
  41205. private _teleportationInitialized;
  41206. private _interactionsEnabled;
  41207. private _interactionsRequested;
  41208. private _displayGaze;
  41209. private _displayLaserPointer;
  41210. /**
  41211. * The mesh used to display where the user is going to teleport.
  41212. */
  41213. /**
  41214. * Sets the mesh to be used to display where the user is going to teleport.
  41215. */
  41216. teleportationTarget: Mesh;
  41217. /**
  41218. * 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
  41219. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  41220. * See http://doc.babylonjs.com/resources/baking_transformations
  41221. */
  41222. gazeTrackerMesh: Mesh;
  41223. /**
  41224. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  41225. */
  41226. updateGazeTrackerScale: boolean;
  41227. /**
  41228. * If the gaze trackers color should be updated when selecting meshes
  41229. */
  41230. updateGazeTrackerColor: boolean;
  41231. /**
  41232. * The gaze tracking mesh corresponding to the left controller
  41233. */
  41234. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  41235. /**
  41236. * The gaze tracking mesh corresponding to the right controller
  41237. */
  41238. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  41239. /**
  41240. * If the ray of the gaze should be displayed.
  41241. */
  41242. /**
  41243. * Sets if the ray of the gaze should be displayed.
  41244. */
  41245. displayGaze: boolean;
  41246. /**
  41247. * If the ray of the LaserPointer should be displayed.
  41248. */
  41249. /**
  41250. * Sets if the ray of the LaserPointer should be displayed.
  41251. */
  41252. displayLaserPointer: boolean;
  41253. /**
  41254. * The deviceOrientationCamera used as the camera when not in VR.
  41255. */
  41256. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  41257. /**
  41258. * Based on the current WebVR support, returns the current VR camera used.
  41259. */
  41260. readonly currentVRCamera: Nullable<Camera>;
  41261. /**
  41262. * The webVRCamera which is used when in VR.
  41263. */
  41264. readonly webVRCamera: WebVRFreeCamera;
  41265. /**
  41266. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  41267. */
  41268. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  41269. private readonly _teleportationRequestInitiated;
  41270. /**
  41271. * Defines wether or not Pointer lock should be requested when switching to
  41272. * full screen.
  41273. */
  41274. requestPointerLockOnFullScreen: boolean;
  41275. /**
  41276. * Instantiates a VRExperienceHelper.
  41277. * Helps to quickly add VR support to an existing scene.
  41278. * @param scene The scene the VRExperienceHelper belongs to.
  41279. * @param webVROptions Options to modify the vr experience helper's behavior.
  41280. */
  41281. constructor(scene: Scene,
  41282. /** Options to modify the vr experience helper's behavior. */
  41283. webVROptions?: VRExperienceHelperOptions);
  41284. private _onDefaultMeshLoaded;
  41285. private _onResize;
  41286. private _onFullscreenChange;
  41287. /**
  41288. * Gets a value indicating if we are currently in VR mode.
  41289. */
  41290. readonly isInVRMode: boolean;
  41291. private onVrDisplayPresentChange;
  41292. private onVRDisplayChanged;
  41293. private moveButtonToBottomRight;
  41294. private displayVRButton;
  41295. private updateButtonVisibility;
  41296. private _cachedAngularSensibility;
  41297. /**
  41298. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  41299. * Otherwise, will use the fullscreen API.
  41300. */
  41301. enterVR(): void;
  41302. /**
  41303. * Attempt to exit VR, or fullscreen.
  41304. */
  41305. exitVR(): void;
  41306. /**
  41307. * The position of the vr experience helper.
  41308. */
  41309. /**
  41310. * Sets the position of the vr experience helper.
  41311. */
  41312. position: Vector3;
  41313. /**
  41314. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  41315. */
  41316. enableInteractions(): void;
  41317. private readonly _noControllerIsActive;
  41318. private beforeRender;
  41319. private _isTeleportationFloor;
  41320. /**
  41321. * Adds a floor mesh to be used for teleportation.
  41322. * @param floorMesh the mesh to be used for teleportation.
  41323. */
  41324. addFloorMesh(floorMesh: Mesh): void;
  41325. /**
  41326. * Removes a floor mesh from being used for teleportation.
  41327. * @param floorMesh the mesh to be removed.
  41328. */
  41329. removeFloorMesh(floorMesh: Mesh): void;
  41330. /**
  41331. * Enables interactions and teleportation using the VR controllers and gaze.
  41332. * @param vrTeleportationOptions options to modify teleportation behavior.
  41333. */
  41334. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  41335. private _onNewGamepadConnected;
  41336. private _tryEnableInteractionOnController;
  41337. private _onNewGamepadDisconnected;
  41338. private _enableInteractionOnController;
  41339. private _checkTeleportWithRay;
  41340. private _checkRotate;
  41341. private _checkTeleportBackwards;
  41342. private _enableTeleportationOnController;
  41343. private _createTeleportationCircles;
  41344. private _displayTeleportationTarget;
  41345. private _hideTeleportationTarget;
  41346. private _rotateCamera;
  41347. private _moveTeleportationSelectorTo;
  41348. private _workingVector;
  41349. private _workingQuaternion;
  41350. private _workingMatrix;
  41351. /**
  41352. * Teleports the users feet to the desired location
  41353. * @param location The location where the user's feet should be placed
  41354. */
  41355. teleportCamera(location: Vector3): void;
  41356. private _convertNormalToDirectionOfRay;
  41357. private _castRayAndSelectObject;
  41358. private _notifySelectedMeshUnselected;
  41359. /**
  41360. * Sets the color of the laser ray from the vr controllers.
  41361. * @param color new color for the ray.
  41362. */
  41363. changeLaserColor(color: Color3): void;
  41364. /**
  41365. * Sets the color of the ray from the vr headsets gaze.
  41366. * @param color new color for the ray.
  41367. */
  41368. changeGazeColor(color: Color3): void;
  41369. /**
  41370. * Exits VR and disposes of the vr experience helper
  41371. */
  41372. dispose(): void;
  41373. /**
  41374. * Gets the name of the VRExperienceHelper class
  41375. * @returns "VRExperienceHelper"
  41376. */
  41377. getClassName(): string;
  41378. }
  41379. }
  41380. declare module "babylonjs/Cameras/VR/index" {
  41381. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  41382. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  41383. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  41384. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  41385. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  41386. export * from "babylonjs/Cameras/VR/webVRCamera";
  41387. }
  41388. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  41389. import { Observable } from "babylonjs/Misc/observable";
  41390. import { Nullable } from "babylonjs/types";
  41391. import { IDisposable, Scene } from "babylonjs/scene";
  41392. import { Vector3 } from "babylonjs/Maths/math";
  41393. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  41394. import { Ray } from "babylonjs/Culling/ray";
  41395. /**
  41396. * Manages an XRSession
  41397. * @see https://doc.babylonjs.com/how_to/webxr
  41398. */
  41399. export class WebXRSessionManager implements IDisposable {
  41400. private scene;
  41401. /**
  41402. * Fires every time a new xrFrame arrives which can be used to update the camera
  41403. */
  41404. onXRFrameObservable: Observable<any>;
  41405. /**
  41406. * Fires when the xr session is ended either by the device or manually done
  41407. */
  41408. onXRSessionEnded: Observable<any>;
  41409. /** @hidden */
  41410. _xrSession: XRSession;
  41411. /** @hidden */
  41412. _frameOfReference: XRFrameOfReference;
  41413. /** @hidden */
  41414. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  41415. /** @hidden */
  41416. _currentXRFrame: Nullable<XRFrame>;
  41417. private _xrNavigator;
  41418. private _xrDevice;
  41419. private _tmpMatrix;
  41420. /**
  41421. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  41422. * @param scene The scene which the session should be created for
  41423. */
  41424. constructor(scene: Scene);
  41425. /**
  41426. * Initializes the manager
  41427. * After initialization enterXR can be called to start an XR session
  41428. * @returns Promise which resolves after it is initialized
  41429. */
  41430. initializeAsync(): Promise<void>;
  41431. /**
  41432. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  41433. * @param sessionCreationOptions xr options to create the session with
  41434. * @param frameOfReferenceType option to configure how the xr pose is expressed
  41435. * @returns Promise which resolves after it enters XR
  41436. */
  41437. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  41438. /**
  41439. * Stops the xrSession and restores the renderloop
  41440. * @returns Promise which resolves after it exits XR
  41441. */
  41442. exitXRAsync(): Promise<void>;
  41443. /**
  41444. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  41445. * @param ray ray to cast into the environment
  41446. * @returns Promise which resolves with a collision point in the environment if it exists
  41447. */
  41448. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  41449. /**
  41450. * Checks if a session would be supported for the creation options specified
  41451. * @param options creation options to check if they are supported
  41452. * @returns true if supported
  41453. */
  41454. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  41455. /**
  41456. * @hidden
  41457. * Converts the render layer of xrSession to a render target
  41458. * @param session session to create render target for
  41459. * @param scene scene the new render target should be created for
  41460. */
  41461. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  41462. /**
  41463. * Disposes of the session manager
  41464. */
  41465. dispose(): void;
  41466. }
  41467. }
  41468. declare module "babylonjs/Cameras/XR/webXRCamera" {
  41469. import { Scene } from "babylonjs/scene";
  41470. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41471. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  41472. /**
  41473. * WebXR Camera which holds the views for the xrSession
  41474. * @see https://doc.babylonjs.com/how_to/webxr
  41475. */
  41476. export class WebXRCamera extends FreeCamera {
  41477. private static _TmpMatrix;
  41478. /**
  41479. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  41480. * @param name the name of the camera
  41481. * @param scene the scene to add the camera to
  41482. */
  41483. constructor(name: string, scene: Scene);
  41484. private _updateNumberOfRigCameras;
  41485. /** @hidden */
  41486. _updateForDualEyeDebugging(pupilDistance?: number): void;
  41487. /**
  41488. * Updates the cameras position from the current pose information of the XR session
  41489. * @param xrSessionManager the session containing pose information
  41490. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  41491. */
  41492. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  41493. }
  41494. }
  41495. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  41496. import { Nullable } from "babylonjs/types";
  41497. import { Observable } from "babylonjs/Misc/observable";
  41498. import { IDisposable, Scene } from "babylonjs/scene";
  41499. import { Quaternion, Vector3 } from "babylonjs/Maths/math";
  41500. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41501. import { Ray } from "babylonjs/Culling/ray";
  41502. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  41503. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  41504. /**
  41505. * States of the webXR experience
  41506. */
  41507. export enum WebXRState {
  41508. /**
  41509. * Transitioning to being in XR mode
  41510. */
  41511. ENTERING_XR = 0,
  41512. /**
  41513. * Transitioning to non XR mode
  41514. */
  41515. EXITING_XR = 1,
  41516. /**
  41517. * In XR mode and presenting
  41518. */
  41519. IN_XR = 2,
  41520. /**
  41521. * Not entered XR mode
  41522. */
  41523. NOT_IN_XR = 3
  41524. }
  41525. /**
  41526. * Helper class used to enable XR
  41527. * @see https://doc.babylonjs.com/how_to/webxr
  41528. */
  41529. export class WebXRExperienceHelper implements IDisposable {
  41530. private scene;
  41531. /**
  41532. * 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
  41533. */
  41534. container: AbstractMesh;
  41535. /**
  41536. * Camera used to render xr content
  41537. */
  41538. camera: WebXRCamera;
  41539. /**
  41540. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  41541. */
  41542. state: WebXRState;
  41543. private _setState;
  41544. private static _TmpVector;
  41545. /**
  41546. * Fires when the state of the experience helper has changed
  41547. */
  41548. onStateChangedObservable: Observable<WebXRState>;
  41549. /** @hidden */
  41550. _sessionManager: WebXRSessionManager;
  41551. private _nonVRCamera;
  41552. private _originalSceneAutoClear;
  41553. private _supported;
  41554. /**
  41555. * Creates the experience helper
  41556. * @param scene the scene to attach the experience helper to
  41557. * @returns a promise for the experience helper
  41558. */
  41559. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  41560. /**
  41561. * Creates a WebXRExperienceHelper
  41562. * @param scene The scene the helper should be created in
  41563. */
  41564. private constructor();
  41565. /**
  41566. * Exits XR mode and returns the scene to its original state
  41567. * @returns promise that resolves after xr mode has exited
  41568. */
  41569. exitXRAsync(): Promise<void>;
  41570. /**
  41571. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  41572. * @param sessionCreationOptions options for the XR session
  41573. * @param frameOfReference frame of reference of the XR session
  41574. * @returns promise that resolves after xr mode has entered
  41575. */
  41576. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  41577. /**
  41578. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  41579. * @param ray ray to cast into the environment
  41580. * @returns Promise which resolves with a collision point in the environment if it exists
  41581. */
  41582. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  41583. /**
  41584. * Updates the global position of the camera by moving the camera's container
  41585. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  41586. * @param position The desired global position of the camera
  41587. */
  41588. setPositionOfCameraUsingContainer(position: Vector3): void;
  41589. /**
  41590. * Rotates the xr camera by rotating the camera's container around the camera's position
  41591. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  41592. * @param rotation the desired quaternion rotation to apply to the camera
  41593. */
  41594. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  41595. /**
  41596. * Checks if the creation options are supported by the xr session
  41597. * @param options creation options
  41598. * @returns true if supported
  41599. */
  41600. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  41601. /**
  41602. * Disposes of the experience helper
  41603. */
  41604. dispose(): void;
  41605. }
  41606. }
  41607. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  41608. import { Nullable } from "babylonjs/types";
  41609. import { Observable } from "babylonjs/Misc/observable";
  41610. import { IDisposable, Scene } from "babylonjs/scene";
  41611. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  41612. /**
  41613. * Button which can be used to enter a different mode of XR
  41614. */
  41615. export class WebXREnterExitUIButton {
  41616. /** button element */
  41617. element: HTMLElement;
  41618. /** XR initialization options for the button */
  41619. initializationOptions: XRSessionCreationOptions;
  41620. /**
  41621. * Creates a WebXREnterExitUIButton
  41622. * @param element button element
  41623. * @param initializationOptions XR initialization options for the button
  41624. */
  41625. constructor(
  41626. /** button element */
  41627. element: HTMLElement,
  41628. /** XR initialization options for the button */
  41629. initializationOptions: XRSessionCreationOptions);
  41630. /**
  41631. * Overwritable function which can be used to update the button's visuals when the state changes
  41632. * @param activeButton the current active button in the UI
  41633. */
  41634. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  41635. }
  41636. /**
  41637. * Options to create the webXR UI
  41638. */
  41639. export class WebXREnterExitUIOptions {
  41640. /**
  41641. * Context to enter xr with
  41642. */
  41643. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  41644. /**
  41645. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  41646. */
  41647. customButtons?: Array<WebXREnterExitUIButton>;
  41648. }
  41649. /**
  41650. * UI to allow the user to enter/exit XR mode
  41651. */
  41652. export class WebXREnterExitUI implements IDisposable {
  41653. private scene;
  41654. private _overlay;
  41655. private _buttons;
  41656. private _activeButton;
  41657. /**
  41658. * Fired every time the active button is changed.
  41659. *
  41660. * When xr is entered via a button that launches xr that button will be the callback parameter
  41661. *
  41662. * When exiting xr the callback parameter will be null)
  41663. */
  41664. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  41665. /**
  41666. * Creates UI to allow the user to enter/exit XR mode
  41667. * @param scene the scene to add the ui to
  41668. * @param helper the xr experience helper to enter/exit xr with
  41669. * @param options options to configure the UI
  41670. * @returns the created ui
  41671. */
  41672. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  41673. private constructor();
  41674. private _updateButtons;
  41675. /**
  41676. * Disposes of the object
  41677. */
  41678. dispose(): void;
  41679. }
  41680. }
  41681. declare module "babylonjs/Cameras/XR/webXRInput" {
  41682. import { IDisposable, Scene } from "babylonjs/scene";
  41683. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41684. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  41685. /**
  41686. * Represents an XR input
  41687. */
  41688. export class WebXRController {
  41689. /**
  41690. * 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
  41691. */
  41692. grip?: AbstractMesh;
  41693. /**
  41694. * Pointer which can be used to select objects or attach a visible laser to
  41695. */
  41696. pointer: AbstractMesh;
  41697. /**
  41698. * Creates the controller
  41699. * @see https://doc.babylonjs.com/how_to/webxr
  41700. * @param scene the scene which the controller should be associated to
  41701. */
  41702. constructor(scene: Scene);
  41703. /**
  41704. * Disposes of the object
  41705. */
  41706. dispose(): void;
  41707. }
  41708. /**
  41709. * XR input used to track XR inputs such as controllers/rays
  41710. */
  41711. export class WebXRInput implements IDisposable {
  41712. private helper;
  41713. /**
  41714. * XR controllers being tracked
  41715. */
  41716. controllers: Array<WebXRController>;
  41717. private _tmpMatrix;
  41718. private _frameObserver;
  41719. /**
  41720. * Initializes the WebXRInput
  41721. * @param helper experience helper which the input should be created for
  41722. */
  41723. constructor(helper: WebXRExperienceHelper);
  41724. /**
  41725. * Disposes of the object
  41726. */
  41727. dispose(): void;
  41728. }
  41729. }
  41730. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  41731. import { Nullable } from "babylonjs/types";
  41732. import { IDisposable } from "babylonjs/scene";
  41733. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  41734. /**
  41735. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  41736. */
  41737. export class WebXRManagedOutputCanvas implements IDisposable {
  41738. private _canvas;
  41739. /**
  41740. * xrpresent context of the canvas which can be used to display/mirror xr content
  41741. */
  41742. canvasContext: Nullable<WebGLRenderingContext>;
  41743. /**
  41744. * Initializes the canvas to be added/removed upon entering/exiting xr
  41745. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  41746. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  41747. */
  41748. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  41749. /**
  41750. * Disposes of the object
  41751. */
  41752. dispose(): void;
  41753. private _setManagedOutputCanvas;
  41754. private _addCanvas;
  41755. private _removeCanvas;
  41756. }
  41757. }
  41758. declare module "babylonjs/Cameras/XR/index" {
  41759. export * from "babylonjs/Cameras/XR/webXRCamera";
  41760. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  41761. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  41762. export * from "babylonjs/Cameras/XR/webXRInput";
  41763. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  41764. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  41765. }
  41766. declare module "babylonjs/Cameras/RigModes/index" {
  41767. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  41768. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  41769. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  41770. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  41771. }
  41772. declare module "babylonjs/Cameras/index" {
  41773. export * from "babylonjs/Cameras/Inputs/index";
  41774. export * from "babylonjs/Cameras/cameraInputsManager";
  41775. export * from "babylonjs/Cameras/camera";
  41776. export * from "babylonjs/Cameras/targetCamera";
  41777. export * from "babylonjs/Cameras/freeCamera";
  41778. export * from "babylonjs/Cameras/freeCameraInputsManager";
  41779. export * from "babylonjs/Cameras/touchCamera";
  41780. export * from "babylonjs/Cameras/arcRotateCamera";
  41781. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  41782. export * from "babylonjs/Cameras/deviceOrientationCamera";
  41783. export * from "babylonjs/Cameras/flyCamera";
  41784. export * from "babylonjs/Cameras/flyCameraInputsManager";
  41785. export * from "babylonjs/Cameras/followCamera";
  41786. export * from "babylonjs/Cameras/gamepadCamera";
  41787. export * from "babylonjs/Cameras/Stereoscopic/index";
  41788. export * from "babylonjs/Cameras/universalCamera";
  41789. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  41790. export * from "babylonjs/Cameras/VR/index";
  41791. export * from "babylonjs/Cameras/XR/index";
  41792. export * from "babylonjs/Cameras/RigModes/index";
  41793. }
  41794. declare module "babylonjs/Collisions/index" {
  41795. export * from "babylonjs/Collisions/collider";
  41796. export * from "babylonjs/Collisions/collisionCoordinator";
  41797. export * from "babylonjs/Collisions/pickingInfo";
  41798. export * from "babylonjs/Collisions/intersectionInfo";
  41799. export * from "babylonjs/Collisions/meshCollisionData";
  41800. }
  41801. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  41802. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  41803. import { Vector3, Plane } from "babylonjs/Maths/math";
  41804. import { Ray } from "babylonjs/Culling/ray";
  41805. /**
  41806. * Contains an array of blocks representing the octree
  41807. */
  41808. export interface IOctreeContainer<T> {
  41809. /**
  41810. * Blocks within the octree
  41811. */
  41812. blocks: Array<OctreeBlock<T>>;
  41813. }
  41814. /**
  41815. * Class used to store a cell in an octree
  41816. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41817. */
  41818. export class OctreeBlock<T> {
  41819. /**
  41820. * Gets the content of the current block
  41821. */
  41822. entries: T[];
  41823. /**
  41824. * Gets the list of block children
  41825. */
  41826. blocks: Array<OctreeBlock<T>>;
  41827. private _depth;
  41828. private _maxDepth;
  41829. private _capacity;
  41830. private _minPoint;
  41831. private _maxPoint;
  41832. private _boundingVectors;
  41833. private _creationFunc;
  41834. /**
  41835. * Creates a new block
  41836. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  41837. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  41838. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  41839. * @param depth defines the current depth of this block in the octree
  41840. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  41841. * @param creationFunc defines a callback to call when an element is added to the block
  41842. */
  41843. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  41844. /**
  41845. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  41846. */
  41847. readonly capacity: number;
  41848. /**
  41849. * Gets the minimum vector (in world space) of the block's bounding box
  41850. */
  41851. readonly minPoint: Vector3;
  41852. /**
  41853. * Gets the maximum vector (in world space) of the block's bounding box
  41854. */
  41855. readonly maxPoint: Vector3;
  41856. /**
  41857. * Add a new element to this block
  41858. * @param entry defines the element to add
  41859. */
  41860. addEntry(entry: T): void;
  41861. /**
  41862. * Remove an element from this block
  41863. * @param entry defines the element to remove
  41864. */
  41865. removeEntry(entry: T): void;
  41866. /**
  41867. * Add an array of elements to this block
  41868. * @param entries defines the array of elements to add
  41869. */
  41870. addEntries(entries: T[]): void;
  41871. /**
  41872. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  41873. * @param frustumPlanes defines the frustum planes to test
  41874. * @param selection defines the array to store current content if selection is positive
  41875. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41876. */
  41877. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  41878. /**
  41879. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  41880. * @param sphereCenter defines the bounding sphere center
  41881. * @param sphereRadius defines the bounding sphere radius
  41882. * @param selection defines the array to store current content if selection is positive
  41883. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41884. */
  41885. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  41886. /**
  41887. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  41888. * @param ray defines the ray to test with
  41889. * @param selection defines the array to store current content if selection is positive
  41890. */
  41891. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  41892. /**
  41893. * Subdivide the content into child blocks (this block will then be empty)
  41894. */
  41895. createInnerBlocks(): void;
  41896. /**
  41897. * @hidden
  41898. */
  41899. 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;
  41900. }
  41901. }
  41902. declare module "babylonjs/Culling/Octrees/octree" {
  41903. import { SmartArray } from "babylonjs/Misc/smartArray";
  41904. import { Vector3, Plane } from "babylonjs/Maths/math";
  41905. import { SubMesh } from "babylonjs/Meshes/subMesh";
  41906. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41907. import { Ray } from "babylonjs/Culling/ray";
  41908. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  41909. /**
  41910. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  41911. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41912. */
  41913. export class Octree<T> {
  41914. /** 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.) */
  41915. maxDepth: number;
  41916. /**
  41917. * Blocks within the octree containing objects
  41918. */
  41919. blocks: Array<OctreeBlock<T>>;
  41920. /**
  41921. * Content stored in the octree
  41922. */
  41923. dynamicContent: T[];
  41924. private _maxBlockCapacity;
  41925. private _selectionContent;
  41926. private _creationFunc;
  41927. /**
  41928. * Creates a octree
  41929. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41930. * @param creationFunc function to be used to instatiate the octree
  41931. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  41932. * @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.)
  41933. */
  41934. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  41935. /** 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.) */
  41936. maxDepth?: number);
  41937. /**
  41938. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  41939. * @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);
  41940. * @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);
  41941. * @param entries meshes to be added to the octree blocks
  41942. */
  41943. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  41944. /**
  41945. * Adds a mesh to the octree
  41946. * @param entry Mesh to add to the octree
  41947. */
  41948. addMesh(entry: T): void;
  41949. /**
  41950. * Remove an element from the octree
  41951. * @param entry defines the element to remove
  41952. */
  41953. removeMesh(entry: T): void;
  41954. /**
  41955. * Selects an array of meshes within the frustum
  41956. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  41957. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  41958. * @returns array of meshes within the frustum
  41959. */
  41960. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  41961. /**
  41962. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  41963. * @param sphereCenter defines the bounding sphere center
  41964. * @param sphereRadius defines the bounding sphere radius
  41965. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41966. * @returns an array of objects that intersect the sphere
  41967. */
  41968. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  41969. /**
  41970. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  41971. * @param ray defines the ray to test with
  41972. * @returns array of intersected objects
  41973. */
  41974. intersectsRay(ray: Ray): SmartArray<T>;
  41975. /**
  41976. * Adds a mesh into the octree block if it intersects the block
  41977. */
  41978. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  41979. /**
  41980. * Adds a submesh into the octree block if it intersects the block
  41981. */
  41982. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  41983. }
  41984. }
  41985. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  41986. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  41987. import { Scene } from "babylonjs/scene";
  41988. import { SubMesh } from "babylonjs/Meshes/subMesh";
  41989. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41990. import { Ray } from "babylonjs/Culling/ray";
  41991. import { Octree } from "babylonjs/Culling/Octrees/octree";
  41992. import { Collider } from "babylonjs/Collisions/collider";
  41993. module "babylonjs/scene" {
  41994. interface Scene {
  41995. /**
  41996. * @hidden
  41997. * Backing Filed
  41998. */
  41999. _selectionOctree: Octree<AbstractMesh>;
  42000. /**
  42001. * Gets the octree used to boost mesh selection (picking)
  42002. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42003. */
  42004. selectionOctree: Octree<AbstractMesh>;
  42005. /**
  42006. * Creates or updates the octree used to boost selection (picking)
  42007. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42008. * @param maxCapacity defines the maximum capacity per leaf
  42009. * @param maxDepth defines the maximum depth of the octree
  42010. * @returns an octree of AbstractMesh
  42011. */
  42012. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  42013. }
  42014. }
  42015. module "babylonjs/Meshes/abstractMesh" {
  42016. interface AbstractMesh {
  42017. /**
  42018. * @hidden
  42019. * Backing Field
  42020. */
  42021. _submeshesOctree: Octree<SubMesh>;
  42022. /**
  42023. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  42024. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  42025. * @param maxCapacity defines the maximum size of each block (64 by default)
  42026. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  42027. * @returns the new octree
  42028. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  42029. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42030. */
  42031. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  42032. }
  42033. }
  42034. /**
  42035. * Defines the octree scene component responsible to manage any octrees
  42036. * in a given scene.
  42037. */
  42038. export class OctreeSceneComponent {
  42039. /**
  42040. * The component name help to identify the component in the list of scene components.
  42041. */
  42042. readonly name: string;
  42043. /**
  42044. * The scene the component belongs to.
  42045. */
  42046. scene: Scene;
  42047. /**
  42048. * Indicates if the meshes have been checked to make sure they are isEnabled()
  42049. */
  42050. readonly checksIsEnabled: boolean;
  42051. /**
  42052. * Creates a new instance of the component for the given scene
  42053. * @param scene Defines the scene to register the component in
  42054. */
  42055. constructor(scene: Scene);
  42056. /**
  42057. * Registers the component in a given scene
  42058. */
  42059. register(): void;
  42060. /**
  42061. * Return the list of active meshes
  42062. * @returns the list of active meshes
  42063. */
  42064. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  42065. /**
  42066. * Return the list of active sub meshes
  42067. * @param mesh The mesh to get the candidates sub meshes from
  42068. * @returns the list of active sub meshes
  42069. */
  42070. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  42071. private _tempRay;
  42072. /**
  42073. * Return the list of sub meshes intersecting with a given local ray
  42074. * @param mesh defines the mesh to find the submesh for
  42075. * @param localRay defines the ray in local space
  42076. * @returns the list of intersecting sub meshes
  42077. */
  42078. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  42079. /**
  42080. * Return the list of sub meshes colliding with a collider
  42081. * @param mesh defines the mesh to find the submesh for
  42082. * @param collider defines the collider to evaluate the collision against
  42083. * @returns the list of colliding sub meshes
  42084. */
  42085. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  42086. /**
  42087. * Rebuilds the elements related to this component in case of
  42088. * context lost for instance.
  42089. */
  42090. rebuild(): void;
  42091. /**
  42092. * Disposes the component and the associated ressources.
  42093. */
  42094. dispose(): void;
  42095. }
  42096. }
  42097. declare module "babylonjs/Culling/Octrees/index" {
  42098. export * from "babylonjs/Culling/Octrees/octree";
  42099. export * from "babylonjs/Culling/Octrees/octreeBlock";
  42100. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  42101. }
  42102. declare module "babylonjs/Culling/index" {
  42103. export * from "babylonjs/Culling/boundingBox";
  42104. export * from "babylonjs/Culling/boundingInfo";
  42105. export * from "babylonjs/Culling/boundingSphere";
  42106. export * from "babylonjs/Culling/Octrees/index";
  42107. export * from "babylonjs/Culling/ray";
  42108. }
  42109. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  42110. import { IDisposable, Scene } from "babylonjs/scene";
  42111. import { Nullable } from "babylonjs/types";
  42112. import { Observable } from "babylonjs/Misc/observable";
  42113. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42114. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  42115. /**
  42116. * Renders a layer on top of an existing scene
  42117. */
  42118. export class UtilityLayerRenderer implements IDisposable {
  42119. /** the original scene that will be rendered on top of */
  42120. originalScene: Scene;
  42121. private _pointerCaptures;
  42122. private _lastPointerEvents;
  42123. private static _DefaultUtilityLayer;
  42124. private static _DefaultKeepDepthUtilityLayer;
  42125. private _sharedGizmoLight;
  42126. /**
  42127. * @hidden
  42128. * Light which used by gizmos to get light shading
  42129. */
  42130. _getSharedGizmoLight(): HemisphericLight;
  42131. /**
  42132. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  42133. */
  42134. pickUtilitySceneFirst: boolean;
  42135. /**
  42136. * 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)
  42137. */
  42138. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  42139. /**
  42140. * 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)
  42141. */
  42142. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  42143. /**
  42144. * The scene that is rendered on top of the original scene
  42145. */
  42146. utilityLayerScene: Scene;
  42147. /**
  42148. * If the utility layer should automatically be rendered on top of existing scene
  42149. */
  42150. shouldRender: boolean;
  42151. /**
  42152. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  42153. */
  42154. onlyCheckPointerDownEvents: boolean;
  42155. /**
  42156. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  42157. */
  42158. processAllEvents: boolean;
  42159. /**
  42160. * Observable raised when the pointer move from the utility layer scene to the main scene
  42161. */
  42162. onPointerOutObservable: Observable<number>;
  42163. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  42164. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  42165. private _afterRenderObserver;
  42166. private _sceneDisposeObserver;
  42167. private _originalPointerObserver;
  42168. /**
  42169. * Instantiates a UtilityLayerRenderer
  42170. * @param originalScene the original scene that will be rendered on top of
  42171. * @param handleEvents boolean indicating if the utility layer should handle events
  42172. */
  42173. constructor(
  42174. /** the original scene that will be rendered on top of */
  42175. originalScene: Scene, handleEvents?: boolean);
  42176. private _notifyObservers;
  42177. /**
  42178. * Renders the utility layers scene on top of the original scene
  42179. */
  42180. render(): void;
  42181. /**
  42182. * Disposes of the renderer
  42183. */
  42184. dispose(): void;
  42185. private _updateCamera;
  42186. }
  42187. }
  42188. declare module "babylonjs/Gizmos/gizmo" {
  42189. import { Nullable } from "babylonjs/types";
  42190. import { IDisposable } from "babylonjs/scene";
  42191. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42192. import { Mesh } from "babylonjs/Meshes/mesh";
  42193. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42194. /**
  42195. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  42196. */
  42197. export class Gizmo implements IDisposable {
  42198. /** The utility layer the gizmo will be added to */
  42199. gizmoLayer: UtilityLayerRenderer;
  42200. /**
  42201. * The root mesh of the gizmo
  42202. */
  42203. _rootMesh: Mesh;
  42204. private _attachedMesh;
  42205. /**
  42206. * Ratio for the scale of the gizmo (Default: 1)
  42207. */
  42208. scaleRatio: number;
  42209. /**
  42210. * If a custom mesh has been set (Default: false)
  42211. */
  42212. protected _customMeshSet: boolean;
  42213. /**
  42214. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  42215. * * When set, interactions will be enabled
  42216. */
  42217. attachedMesh: Nullable<AbstractMesh>;
  42218. /**
  42219. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  42220. * @param mesh The mesh to replace the default mesh of the gizmo
  42221. */
  42222. setCustomMesh(mesh: Mesh): void;
  42223. /**
  42224. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  42225. */
  42226. updateGizmoRotationToMatchAttachedMesh: boolean;
  42227. /**
  42228. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  42229. */
  42230. updateGizmoPositionToMatchAttachedMesh: boolean;
  42231. /**
  42232. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  42233. */
  42234. protected _updateScale: boolean;
  42235. protected _interactionsEnabled: boolean;
  42236. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42237. private _beforeRenderObserver;
  42238. private _tempVector;
  42239. /**
  42240. * Creates a gizmo
  42241. * @param gizmoLayer The utility layer the gizmo will be added to
  42242. */
  42243. constructor(
  42244. /** The utility layer the gizmo will be added to */
  42245. gizmoLayer?: UtilityLayerRenderer);
  42246. /**
  42247. * Updates the gizmo to match the attached mesh's position/rotation
  42248. */
  42249. protected _update(): void;
  42250. /**
  42251. * Disposes of the gizmo
  42252. */
  42253. dispose(): void;
  42254. }
  42255. }
  42256. declare module "babylonjs/Gizmos/axisDragGizmo" {
  42257. import { Observable } from "babylonjs/Misc/observable";
  42258. import { Nullable } from "babylonjs/types";
  42259. import { Vector3, Color3 } from "babylonjs/Maths/math";
  42260. import { TransformNode } from "babylonjs/Meshes/transformNode";
  42261. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42262. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  42263. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  42264. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42265. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  42266. import { Scene } from "babylonjs/scene";
  42267. /**
  42268. * Single axis drag gizmo
  42269. */
  42270. export class AxisDragGizmo extends Gizmo {
  42271. /**
  42272. * Drag behavior responsible for the gizmos dragging interactions
  42273. */
  42274. dragBehavior: PointerDragBehavior;
  42275. private _pointerObserver;
  42276. /**
  42277. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42278. */
  42279. snapDistance: number;
  42280. /**
  42281. * Event that fires each time the gizmo snaps to a new location.
  42282. * * snapDistance is the the change in distance
  42283. */
  42284. onSnapObservable: Observable<{
  42285. snapDistance: number;
  42286. }>;
  42287. /** @hidden */
  42288. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  42289. /** @hidden */
  42290. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  42291. /**
  42292. * Creates an AxisDragGizmo
  42293. * @param gizmoLayer The utility layer the gizmo will be added to
  42294. * @param dragAxis The axis which the gizmo will be able to drag on
  42295. * @param color The color of the gizmo
  42296. */
  42297. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  42298. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42299. /**
  42300. * Disposes of the gizmo
  42301. */
  42302. dispose(): void;
  42303. }
  42304. }
  42305. declare module "babylonjs/Debug/axesViewer" {
  42306. import { Vector3 } from "babylonjs/Maths/math";
  42307. import { Nullable } from "babylonjs/types";
  42308. import { Scene } from "babylonjs/scene";
  42309. import { TransformNode } from "babylonjs/Meshes/transformNode";
  42310. /**
  42311. * The Axes viewer will show 3 axes in a specific point in space
  42312. */
  42313. export class AxesViewer {
  42314. private _xAxis;
  42315. private _yAxis;
  42316. private _zAxis;
  42317. private _scaleLinesFactor;
  42318. private _instanced;
  42319. /**
  42320. * Gets the hosting scene
  42321. */
  42322. scene: Scene;
  42323. /**
  42324. * Gets or sets a number used to scale line length
  42325. */
  42326. scaleLines: number;
  42327. /** Gets the node hierarchy used to render x-axis */
  42328. readonly xAxis: TransformNode;
  42329. /** Gets the node hierarchy used to render y-axis */
  42330. readonly yAxis: TransformNode;
  42331. /** Gets the node hierarchy used to render z-axis */
  42332. readonly zAxis: TransformNode;
  42333. /**
  42334. * Creates a new AxesViewer
  42335. * @param scene defines the hosting scene
  42336. * @param scaleLines defines a number used to scale line length (1 by default)
  42337. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  42338. * @param xAxis defines the node hierarchy used to render the x-axis
  42339. * @param yAxis defines the node hierarchy used to render the y-axis
  42340. * @param zAxis defines the node hierarchy used to render the z-axis
  42341. */
  42342. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  42343. /**
  42344. * Force the viewer to update
  42345. * @param position defines the position of the viewer
  42346. * @param xaxis defines the x axis of the viewer
  42347. * @param yaxis defines the y axis of the viewer
  42348. * @param zaxis defines the z axis of the viewer
  42349. */
  42350. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  42351. /**
  42352. * Creates an instance of this axes viewer.
  42353. * @returns a new axes viewer with instanced meshes
  42354. */
  42355. createInstance(): AxesViewer;
  42356. /** Releases resources */
  42357. dispose(): void;
  42358. private static _SetRenderingGroupId;
  42359. }
  42360. }
  42361. declare module "babylonjs/Debug/boneAxesViewer" {
  42362. import { Nullable } from "babylonjs/types";
  42363. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  42364. import { Vector3 } from "babylonjs/Maths/math";
  42365. import { Mesh } from "babylonjs/Meshes/mesh";
  42366. import { Bone } from "babylonjs/Bones/bone";
  42367. import { Scene } from "babylonjs/scene";
  42368. /**
  42369. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  42370. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  42371. */
  42372. export class BoneAxesViewer extends AxesViewer {
  42373. /**
  42374. * Gets or sets the target mesh where to display the axes viewer
  42375. */
  42376. mesh: Nullable<Mesh>;
  42377. /**
  42378. * Gets or sets the target bone where to display the axes viewer
  42379. */
  42380. bone: Nullable<Bone>;
  42381. /** Gets current position */
  42382. pos: Vector3;
  42383. /** Gets direction of X axis */
  42384. xaxis: Vector3;
  42385. /** Gets direction of Y axis */
  42386. yaxis: Vector3;
  42387. /** Gets direction of Z axis */
  42388. zaxis: Vector3;
  42389. /**
  42390. * Creates a new BoneAxesViewer
  42391. * @param scene defines the hosting scene
  42392. * @param bone defines the target bone
  42393. * @param mesh defines the target mesh
  42394. * @param scaleLines defines a scaling factor for line length (1 by default)
  42395. */
  42396. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  42397. /**
  42398. * Force the viewer to update
  42399. */
  42400. update(): void;
  42401. /** Releases resources */
  42402. dispose(): void;
  42403. }
  42404. }
  42405. declare module "babylonjs/Debug/debugLayer" {
  42406. import { Observable } from "babylonjs/Misc/observable";
  42407. import { Scene } from "babylonjs/scene";
  42408. /**
  42409. * Interface used to define scene explorer extensibility option
  42410. */
  42411. export interface IExplorerExtensibilityOption {
  42412. /**
  42413. * Define the option label
  42414. */
  42415. label: string;
  42416. /**
  42417. * Defines the action to execute on click
  42418. */
  42419. action: (entity: any) => void;
  42420. }
  42421. /**
  42422. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  42423. */
  42424. export interface IExplorerExtensibilityGroup {
  42425. /**
  42426. * Defines a predicate to test if a given type mut be extended
  42427. */
  42428. predicate: (entity: any) => boolean;
  42429. /**
  42430. * Gets the list of options added to a type
  42431. */
  42432. entries: IExplorerExtensibilityOption[];
  42433. }
  42434. /**
  42435. * Interface used to define the options to use to create the Inspector
  42436. */
  42437. export interface IInspectorOptions {
  42438. /**
  42439. * Display in overlay mode (default: false)
  42440. */
  42441. overlay?: boolean;
  42442. /**
  42443. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  42444. */
  42445. globalRoot?: HTMLElement;
  42446. /**
  42447. * Display the Scene explorer
  42448. */
  42449. showExplorer?: boolean;
  42450. /**
  42451. * Display the property inspector
  42452. */
  42453. showInspector?: boolean;
  42454. /**
  42455. * Display in embed mode (both panes on the right)
  42456. */
  42457. embedMode?: boolean;
  42458. /**
  42459. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  42460. */
  42461. handleResize?: boolean;
  42462. /**
  42463. * Allow the panes to popup (default: true)
  42464. */
  42465. enablePopup?: boolean;
  42466. /**
  42467. * Allow the panes to be closed by users (default: true)
  42468. */
  42469. enableClose?: boolean;
  42470. /**
  42471. * Optional list of extensibility entries
  42472. */
  42473. explorerExtensibility?: IExplorerExtensibilityGroup[];
  42474. /**
  42475. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  42476. */
  42477. inspectorURL?: string;
  42478. }
  42479. module "babylonjs/scene" {
  42480. interface Scene {
  42481. /**
  42482. * @hidden
  42483. * Backing field
  42484. */
  42485. _debugLayer: DebugLayer;
  42486. /**
  42487. * Gets the debug layer (aka Inspector) associated with the scene
  42488. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42489. */
  42490. debugLayer: DebugLayer;
  42491. }
  42492. }
  42493. /**
  42494. * The debug layer (aka Inspector) is the go to tool in order to better understand
  42495. * what is happening in your scene
  42496. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42497. */
  42498. export class DebugLayer {
  42499. /**
  42500. * Define the url to get the inspector script from.
  42501. * By default it uses the babylonjs CDN.
  42502. * @ignoreNaming
  42503. */
  42504. static InspectorURL: string;
  42505. private _scene;
  42506. private BJSINSPECTOR;
  42507. /**
  42508. * Observable triggered when a property is changed through the inspector.
  42509. */
  42510. onPropertyChangedObservable: Observable<{
  42511. object: any;
  42512. property: string;
  42513. value: any;
  42514. initialValue: any;
  42515. }>;
  42516. /**
  42517. * Instantiates a new debug layer.
  42518. * The debug layer (aka Inspector) is the go to tool in order to better understand
  42519. * what is happening in your scene
  42520. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42521. * @param scene Defines the scene to inspect
  42522. */
  42523. constructor(scene: Scene);
  42524. /** Creates the inspector window. */
  42525. private _createInspector;
  42526. /**
  42527. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  42528. * @param entity defines the entity to select
  42529. * @param lineContainerTitle defines the specific block to highlight
  42530. */
  42531. select(entity: any, lineContainerTitle?: string): void;
  42532. /** Get the inspector from bundle or global */
  42533. private _getGlobalInspector;
  42534. /**
  42535. * Get if the inspector is visible or not.
  42536. * @returns true if visible otherwise, false
  42537. */
  42538. isVisible(): boolean;
  42539. /**
  42540. * Hide the inspector and close its window.
  42541. */
  42542. hide(): void;
  42543. /**
  42544. * Launch the debugLayer.
  42545. * @param config Define the configuration of the inspector
  42546. * @return a promise fulfilled when the debug layer is visible
  42547. */
  42548. show(config?: IInspectorOptions): Promise<DebugLayer>;
  42549. }
  42550. }
  42551. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  42552. import { Nullable } from "babylonjs/types";
  42553. import { Scene } from "babylonjs/scene";
  42554. import { Vector4, Color4 } from "babylonjs/Maths/math";
  42555. import { Mesh } from "babylonjs/Meshes/mesh";
  42556. /**
  42557. * Class containing static functions to help procedurally build meshes
  42558. */
  42559. export class BoxBuilder {
  42560. /**
  42561. * Creates a box mesh
  42562. * * The parameter `size` sets the size (float) of each box side (default 1)
  42563. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  42564. * * 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)
  42565. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  42566. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42567. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42568. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42569. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  42570. * @param name defines the name of the mesh
  42571. * @param options defines the options used to create the mesh
  42572. * @param scene defines the hosting scene
  42573. * @returns the box mesh
  42574. */
  42575. static CreateBox(name: string, options: {
  42576. size?: number;
  42577. width?: number;
  42578. height?: number;
  42579. depth?: number;
  42580. faceUV?: Vector4[];
  42581. faceColors?: Color4[];
  42582. sideOrientation?: number;
  42583. frontUVs?: Vector4;
  42584. backUVs?: Vector4;
  42585. wrap?: boolean;
  42586. topBaseAt?: number;
  42587. bottomBaseAt?: number;
  42588. updatable?: boolean;
  42589. }, scene?: Nullable<Scene>): Mesh;
  42590. }
  42591. }
  42592. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  42593. import { Vector4 } from "babylonjs/Maths/math";
  42594. import { Mesh } from "babylonjs/Meshes/mesh";
  42595. /**
  42596. * Class containing static functions to help procedurally build meshes
  42597. */
  42598. export class SphereBuilder {
  42599. /**
  42600. * Creates a sphere mesh
  42601. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  42602. * * 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`)
  42603. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  42604. * * 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
  42605. * * 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)
  42606. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42607. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42608. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42609. * @param name defines the name of the mesh
  42610. * @param options defines the options used to create the mesh
  42611. * @param scene defines the hosting scene
  42612. * @returns the sphere mesh
  42613. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  42614. */
  42615. static CreateSphere(name: string, options: {
  42616. segments?: number;
  42617. diameter?: number;
  42618. diameterX?: number;
  42619. diameterY?: number;
  42620. diameterZ?: number;
  42621. arc?: number;
  42622. slice?: number;
  42623. sideOrientation?: number;
  42624. frontUVs?: Vector4;
  42625. backUVs?: Vector4;
  42626. updatable?: boolean;
  42627. }, scene: any): Mesh;
  42628. }
  42629. }
  42630. declare module "babylonjs/Debug/physicsViewer" {
  42631. import { Nullable } from "babylonjs/types";
  42632. import { Scene } from "babylonjs/scene";
  42633. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42634. import { Mesh } from "babylonjs/Meshes/mesh";
  42635. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  42636. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  42637. /**
  42638. * Used to show the physics impostor around the specific mesh
  42639. */
  42640. export class PhysicsViewer {
  42641. /** @hidden */
  42642. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  42643. /** @hidden */
  42644. protected _meshes: Array<Nullable<AbstractMesh>>;
  42645. /** @hidden */
  42646. protected _scene: Nullable<Scene>;
  42647. /** @hidden */
  42648. protected _numMeshes: number;
  42649. /** @hidden */
  42650. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  42651. private _renderFunction;
  42652. private _utilityLayer;
  42653. private _debugBoxMesh;
  42654. private _debugSphereMesh;
  42655. private _debugCylinderMesh;
  42656. private _debugMaterial;
  42657. private _debugMeshMeshes;
  42658. /**
  42659. * Creates a new PhysicsViewer
  42660. * @param scene defines the hosting scene
  42661. */
  42662. constructor(scene: Scene);
  42663. /** @hidden */
  42664. protected _updateDebugMeshes(): void;
  42665. /**
  42666. * Renders a specified physic impostor
  42667. * @param impostor defines the impostor to render
  42668. * @param targetMesh defines the mesh represented by the impostor
  42669. * @returns the new debug mesh used to render the impostor
  42670. */
  42671. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  42672. /**
  42673. * Hides a specified physic impostor
  42674. * @param impostor defines the impostor to hide
  42675. */
  42676. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  42677. private _getDebugMaterial;
  42678. private _getDebugBoxMesh;
  42679. private _getDebugSphereMesh;
  42680. private _getDebugCylinderMesh;
  42681. private _getDebugMeshMesh;
  42682. private _getDebugMesh;
  42683. /** Releases all resources */
  42684. dispose(): void;
  42685. }
  42686. }
  42687. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  42688. import { Vector3, Color4 } from "babylonjs/Maths/math";
  42689. import { Nullable } from "babylonjs/types";
  42690. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  42691. import { Scene } from "babylonjs/scene";
  42692. /**
  42693. * Class containing static functions to help procedurally build meshes
  42694. */
  42695. export class LinesBuilder {
  42696. /**
  42697. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  42698. * * 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
  42699. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  42700. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  42701. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  42702. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  42703. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  42704. * * 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
  42705. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  42706. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42707. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  42708. * @param name defines the name of the new line system
  42709. * @param options defines the options used to create the line system
  42710. * @param scene defines the hosting scene
  42711. * @returns a new line system mesh
  42712. */
  42713. static CreateLineSystem(name: string, options: {
  42714. lines: Vector3[][];
  42715. updatable?: boolean;
  42716. instance?: Nullable<LinesMesh>;
  42717. colors?: Nullable<Color4[][]>;
  42718. useVertexAlpha?: boolean;
  42719. }, scene: Nullable<Scene>): LinesMesh;
  42720. /**
  42721. * Creates a line mesh
  42722. * 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
  42723. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  42724. * * The parameter `points` is an array successive Vector3
  42725. * * 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
  42726. * * The optional parameter `colors` is an array of successive Color4, one per line point
  42727. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  42728. * * When updating an instance, remember that only point positions can change, not the number of points
  42729. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42730. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  42731. * @param name defines the name of the new line system
  42732. * @param options defines the options used to create the line system
  42733. * @param scene defines the hosting scene
  42734. * @returns a new line mesh
  42735. */
  42736. static CreateLines(name: string, options: {
  42737. points: Vector3[];
  42738. updatable?: boolean;
  42739. instance?: Nullable<LinesMesh>;
  42740. colors?: Color4[];
  42741. useVertexAlpha?: boolean;
  42742. }, scene?: Nullable<Scene>): LinesMesh;
  42743. /**
  42744. * Creates a dashed line mesh
  42745. * * 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
  42746. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  42747. * * The parameter `points` is an array successive Vector3
  42748. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  42749. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  42750. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  42751. * * 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
  42752. * * When updating an instance, remember that only point positions can change, not the number of points
  42753. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42754. * @param name defines the name of the mesh
  42755. * @param options defines the options used to create the mesh
  42756. * @param scene defines the hosting scene
  42757. * @returns the dashed line mesh
  42758. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  42759. */
  42760. static CreateDashedLines(name: string, options: {
  42761. points: Vector3[];
  42762. dashSize?: number;
  42763. gapSize?: number;
  42764. dashNb?: number;
  42765. updatable?: boolean;
  42766. instance?: LinesMesh;
  42767. }, scene?: Nullable<Scene>): LinesMesh;
  42768. }
  42769. }
  42770. declare module "babylonjs/Debug/rayHelper" {
  42771. import { Nullable } from "babylonjs/types";
  42772. import { Ray } from "babylonjs/Culling/ray";
  42773. import { Vector3, Color3 } from "babylonjs/Maths/math";
  42774. import { Scene } from "babylonjs/scene";
  42775. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42776. import "babylonjs/Meshes/Builders/linesBuilder";
  42777. /**
  42778. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  42779. * in order to better appreciate the issue one might have.
  42780. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  42781. */
  42782. export class RayHelper {
  42783. /**
  42784. * Defines the ray we are currently tryin to visualize.
  42785. */
  42786. ray: Nullable<Ray>;
  42787. private _renderPoints;
  42788. private _renderLine;
  42789. private _renderFunction;
  42790. private _scene;
  42791. private _updateToMeshFunction;
  42792. private _attachedToMesh;
  42793. private _meshSpaceDirection;
  42794. private _meshSpaceOrigin;
  42795. /**
  42796. * Helper function to create a colored helper in a scene in one line.
  42797. * @param ray Defines the ray we are currently tryin to visualize
  42798. * @param scene Defines the scene the ray is used in
  42799. * @param color Defines the color we want to see the ray in
  42800. * @returns The newly created ray helper.
  42801. */
  42802. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  42803. /**
  42804. * Instantiate a new ray helper.
  42805. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  42806. * in order to better appreciate the issue one might have.
  42807. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  42808. * @param ray Defines the ray we are currently tryin to visualize
  42809. */
  42810. constructor(ray: Ray);
  42811. /**
  42812. * Shows the ray we are willing to debug.
  42813. * @param scene Defines the scene the ray needs to be rendered in
  42814. * @param color Defines the color the ray needs to be rendered in
  42815. */
  42816. show(scene: Scene, color?: Color3): void;
  42817. /**
  42818. * Hides the ray we are debugging.
  42819. */
  42820. hide(): void;
  42821. private _render;
  42822. /**
  42823. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  42824. * @param mesh Defines the mesh we want the helper attached to
  42825. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  42826. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  42827. * @param length Defines the length of the ray
  42828. */
  42829. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  42830. /**
  42831. * Detach the ray helper from the mesh it has previously been attached to.
  42832. */
  42833. detachFromMesh(): void;
  42834. private _updateToMesh;
  42835. /**
  42836. * Dispose the helper and release its associated resources.
  42837. */
  42838. dispose(): void;
  42839. }
  42840. }
  42841. declare module "babylonjs/Debug/skeletonViewer" {
  42842. import { Color3 } from "babylonjs/Maths/math";
  42843. import { Scene } from "babylonjs/scene";
  42844. import { Nullable } from "babylonjs/types";
  42845. import { Skeleton } from "babylonjs/Bones/skeleton";
  42846. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42847. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  42848. /**
  42849. * Class used to render a debug view of a given skeleton
  42850. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  42851. */
  42852. export class SkeletonViewer {
  42853. /** defines the skeleton to render */
  42854. skeleton: Skeleton;
  42855. /** defines the mesh attached to the skeleton */
  42856. mesh: AbstractMesh;
  42857. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  42858. autoUpdateBonesMatrices: boolean;
  42859. /** defines the rendering group id to use with the viewer */
  42860. renderingGroupId: number;
  42861. /** Gets or sets the color used to render the skeleton */
  42862. color: Color3;
  42863. private _scene;
  42864. private _debugLines;
  42865. private _debugMesh;
  42866. private _isEnabled;
  42867. private _renderFunction;
  42868. private _utilityLayer;
  42869. /**
  42870. * Returns the mesh used to render the bones
  42871. */
  42872. readonly debugMesh: Nullable<LinesMesh>;
  42873. /**
  42874. * Creates a new SkeletonViewer
  42875. * @param skeleton defines the skeleton to render
  42876. * @param mesh defines the mesh attached to the skeleton
  42877. * @param scene defines the hosting scene
  42878. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  42879. * @param renderingGroupId defines the rendering group id to use with the viewer
  42880. */
  42881. constructor(
  42882. /** defines the skeleton to render */
  42883. skeleton: Skeleton,
  42884. /** defines the mesh attached to the skeleton */
  42885. mesh: AbstractMesh, scene: Scene,
  42886. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  42887. autoUpdateBonesMatrices?: boolean,
  42888. /** defines the rendering group id to use with the viewer */
  42889. renderingGroupId?: number);
  42890. /** Gets or sets a boolean indicating if the viewer is enabled */
  42891. isEnabled: boolean;
  42892. private _getBonePosition;
  42893. private _getLinesForBonesWithLength;
  42894. private _getLinesForBonesNoLength;
  42895. /** Update the viewer to sync with current skeleton state */
  42896. update(): void;
  42897. /** Release associated resources */
  42898. dispose(): void;
  42899. }
  42900. }
  42901. declare module "babylonjs/Debug/index" {
  42902. export * from "babylonjs/Debug/axesViewer";
  42903. export * from "babylonjs/Debug/boneAxesViewer";
  42904. export * from "babylonjs/Debug/debugLayer";
  42905. export * from "babylonjs/Debug/physicsViewer";
  42906. export * from "babylonjs/Debug/rayHelper";
  42907. export * from "babylonjs/Debug/skeletonViewer";
  42908. }
  42909. declare module "babylonjs/Engines/nullEngine" {
  42910. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  42911. import { Scene } from "babylonjs/scene";
  42912. import { Matrix, Color3, Color4, Viewport } from "babylonjs/Maths/math";
  42913. import { Engine } from "babylonjs/Engines/engine";
  42914. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  42915. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  42916. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  42917. import { Effect } from "babylonjs/Materials/effect";
  42918. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  42919. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  42920. /**
  42921. * Options to create the null engine
  42922. */
  42923. export class NullEngineOptions {
  42924. /**
  42925. * Render width (Default: 512)
  42926. */
  42927. renderWidth: number;
  42928. /**
  42929. * Render height (Default: 256)
  42930. */
  42931. renderHeight: number;
  42932. /**
  42933. * Texture size (Default: 512)
  42934. */
  42935. textureSize: number;
  42936. /**
  42937. * If delta time between frames should be constant
  42938. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42939. */
  42940. deterministicLockstep: boolean;
  42941. /**
  42942. * Maximum about of steps between frames (Default: 4)
  42943. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42944. */
  42945. lockstepMaxSteps: number;
  42946. }
  42947. /**
  42948. * The null engine class provides support for headless version of babylon.js.
  42949. * This can be used in server side scenario or for testing purposes
  42950. */
  42951. export class NullEngine extends Engine {
  42952. private _options;
  42953. /**
  42954. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42955. */
  42956. isDeterministicLockStep(): boolean;
  42957. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  42958. getLockstepMaxSteps(): number;
  42959. /**
  42960. * Sets hardware scaling, used to save performance if needed
  42961. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  42962. */
  42963. getHardwareScalingLevel(): number;
  42964. constructor(options?: NullEngineOptions);
  42965. createVertexBuffer(vertices: FloatArray): DataBuffer;
  42966. createIndexBuffer(indices: IndicesArray): DataBuffer;
  42967. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  42968. getRenderWidth(useScreen?: boolean): number;
  42969. getRenderHeight(useScreen?: boolean): number;
  42970. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  42971. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  42972. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  42973. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  42974. bindSamplers(effect: Effect): void;
  42975. enableEffect(effect: Effect): void;
  42976. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  42977. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  42978. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  42979. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  42980. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  42981. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  42982. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  42983. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  42984. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  42985. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  42986. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  42987. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  42988. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  42989. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  42990. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  42991. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  42992. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  42993. setFloat(uniform: WebGLUniformLocation, value: number): void;
  42994. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  42995. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  42996. setBool(uniform: WebGLUniformLocation, bool: number): void;
  42997. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  42998. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  42999. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  43000. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  43001. bindBuffers(vertexBuffers: {
  43002. [key: string]: VertexBuffer;
  43003. }, indexBuffer: DataBuffer, effect: Effect): void;
  43004. wipeCaches(bruteForce?: boolean): void;
  43005. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  43006. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  43007. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  43008. /** @hidden */
  43009. _createTexture(): WebGLTexture;
  43010. /** @hidden */
  43011. _releaseTexture(texture: InternalTexture): void;
  43012. 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;
  43013. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  43014. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  43015. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  43016. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  43017. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  43018. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  43019. areAllEffectsReady(): boolean;
  43020. /**
  43021. * @hidden
  43022. * Get the current error code of the webGL context
  43023. * @returns the error code
  43024. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  43025. */
  43026. getError(): number;
  43027. /** @hidden */
  43028. _getUnpackAlignement(): number;
  43029. /** @hidden */
  43030. _unpackFlipY(value: boolean): void;
  43031. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  43032. /**
  43033. * Updates a dynamic vertex buffer.
  43034. * @param vertexBuffer the vertex buffer to update
  43035. * @param data the data used to update the vertex buffer
  43036. * @param byteOffset the byte offset of the data (optional)
  43037. * @param byteLength the byte length of the data (optional)
  43038. */
  43039. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  43040. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  43041. /** @hidden */
  43042. _bindTexture(channel: number, texture: InternalTexture): void;
  43043. /** @hidden */
  43044. _releaseBuffer(buffer: DataBuffer): boolean;
  43045. releaseEffects(): void;
  43046. displayLoadingUI(): void;
  43047. hideLoadingUI(): void;
  43048. /** @hidden */
  43049. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43050. /** @hidden */
  43051. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43052. /** @hidden */
  43053. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43054. /** @hidden */
  43055. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  43056. }
  43057. }
  43058. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  43059. import { Nullable, int } from "babylonjs/types";
  43060. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  43061. /** @hidden */
  43062. export class _OcclusionDataStorage {
  43063. /** @hidden */
  43064. occlusionInternalRetryCounter: number;
  43065. /** @hidden */
  43066. isOcclusionQueryInProgress: boolean;
  43067. /** @hidden */
  43068. isOccluded: boolean;
  43069. /** @hidden */
  43070. occlusionRetryCount: number;
  43071. /** @hidden */
  43072. occlusionType: number;
  43073. /** @hidden */
  43074. occlusionQueryAlgorithmType: number;
  43075. }
  43076. module "babylonjs/Engines/engine" {
  43077. interface Engine {
  43078. /**
  43079. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  43080. * @return the new query
  43081. */
  43082. createQuery(): WebGLQuery;
  43083. /**
  43084. * Delete and release a webGL query
  43085. * @param query defines the query to delete
  43086. * @return the current engine
  43087. */
  43088. deleteQuery(query: WebGLQuery): Engine;
  43089. /**
  43090. * Check if a given query has resolved and got its value
  43091. * @param query defines the query to check
  43092. * @returns true if the query got its value
  43093. */
  43094. isQueryResultAvailable(query: WebGLQuery): boolean;
  43095. /**
  43096. * Gets the value of a given query
  43097. * @param query defines the query to check
  43098. * @returns the value of the query
  43099. */
  43100. getQueryResult(query: WebGLQuery): number;
  43101. /**
  43102. * Initiates an occlusion query
  43103. * @param algorithmType defines the algorithm to use
  43104. * @param query defines the query to use
  43105. * @returns the current engine
  43106. * @see http://doc.babylonjs.com/features/occlusionquery
  43107. */
  43108. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  43109. /**
  43110. * Ends an occlusion query
  43111. * @see http://doc.babylonjs.com/features/occlusionquery
  43112. * @param algorithmType defines the algorithm to use
  43113. * @returns the current engine
  43114. */
  43115. endOcclusionQuery(algorithmType: number): Engine;
  43116. /**
  43117. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  43118. * Please note that only one query can be issued at a time
  43119. * @returns a time token used to track the time span
  43120. */
  43121. startTimeQuery(): Nullable<_TimeToken>;
  43122. /**
  43123. * Ends a time query
  43124. * @param token defines the token used to measure the time span
  43125. * @returns the time spent (in ns)
  43126. */
  43127. endTimeQuery(token: _TimeToken): int;
  43128. /** @hidden */
  43129. _currentNonTimestampToken: Nullable<_TimeToken>;
  43130. /** @hidden */
  43131. _createTimeQuery(): WebGLQuery;
  43132. /** @hidden */
  43133. _deleteTimeQuery(query: WebGLQuery): void;
  43134. /** @hidden */
  43135. _getGlAlgorithmType(algorithmType: number): number;
  43136. /** @hidden */
  43137. _getTimeQueryResult(query: WebGLQuery): any;
  43138. /** @hidden */
  43139. _getTimeQueryAvailability(query: WebGLQuery): any;
  43140. }
  43141. }
  43142. module "babylonjs/Meshes/abstractMesh" {
  43143. interface AbstractMesh {
  43144. /**
  43145. * Backing filed
  43146. * @hidden
  43147. */
  43148. __occlusionDataStorage: _OcclusionDataStorage;
  43149. /**
  43150. * Access property
  43151. * @hidden
  43152. */
  43153. _occlusionDataStorage: _OcclusionDataStorage;
  43154. /**
  43155. * 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.
  43156. * The default value is -1 which means don't break the query and wait till the result
  43157. * @see http://doc.babylonjs.com/features/occlusionquery
  43158. */
  43159. occlusionRetryCount: number;
  43160. /**
  43161. * 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:
  43162. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  43163. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  43164. * * 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.
  43165. * @see http://doc.babylonjs.com/features/occlusionquery
  43166. */
  43167. occlusionType: number;
  43168. /**
  43169. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  43170. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  43171. * * 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.
  43172. * @see http://doc.babylonjs.com/features/occlusionquery
  43173. */
  43174. occlusionQueryAlgorithmType: number;
  43175. /**
  43176. * 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
  43177. * @see http://doc.babylonjs.com/features/occlusionquery
  43178. */
  43179. isOccluded: boolean;
  43180. /**
  43181. * Flag to check the progress status of the query
  43182. * @see http://doc.babylonjs.com/features/occlusionquery
  43183. */
  43184. isOcclusionQueryInProgress: boolean;
  43185. }
  43186. }
  43187. }
  43188. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  43189. import { Nullable } from "babylonjs/types";
  43190. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  43191. /** @hidden */
  43192. export var _forceTransformFeedbackToBundle: boolean;
  43193. module "babylonjs/Engines/engine" {
  43194. interface Engine {
  43195. /**
  43196. * Creates a webGL transform feedback object
  43197. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  43198. * @returns the webGL transform feedback object
  43199. */
  43200. createTransformFeedback(): WebGLTransformFeedback;
  43201. /**
  43202. * Delete a webGL transform feedback object
  43203. * @param value defines the webGL transform feedback object to delete
  43204. */
  43205. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  43206. /**
  43207. * Bind a webGL transform feedback object to the webgl context
  43208. * @param value defines the webGL transform feedback object to bind
  43209. */
  43210. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  43211. /**
  43212. * Begins a transform feedback operation
  43213. * @param usePoints defines if points or triangles must be used
  43214. */
  43215. beginTransformFeedback(usePoints: boolean): void;
  43216. /**
  43217. * Ends a transform feedback operation
  43218. */
  43219. endTransformFeedback(): void;
  43220. /**
  43221. * Specify the varyings to use with transform feedback
  43222. * @param program defines the associated webGL program
  43223. * @param value defines the list of strings representing the varying names
  43224. */
  43225. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  43226. /**
  43227. * Bind a webGL buffer for a transform feedback operation
  43228. * @param value defines the webGL buffer to bind
  43229. */
  43230. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  43231. }
  43232. }
  43233. }
  43234. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  43235. import { Scene } from "babylonjs/scene";
  43236. import { Engine } from "babylonjs/Engines/engine";
  43237. import { Texture } from "babylonjs/Materials/Textures/texture";
  43238. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  43239. import "babylonjs/Engines/Extensions/engine.multiRender";
  43240. /**
  43241. * Creation options of the multi render target texture.
  43242. */
  43243. export interface IMultiRenderTargetOptions {
  43244. /**
  43245. * Define if the texture needs to create mip maps after render.
  43246. */
  43247. generateMipMaps?: boolean;
  43248. /**
  43249. * Define the types of all the draw buffers we want to create
  43250. */
  43251. types?: number[];
  43252. /**
  43253. * Define the sampling modes of all the draw buffers we want to create
  43254. */
  43255. samplingModes?: number[];
  43256. /**
  43257. * Define if a depth buffer is required
  43258. */
  43259. generateDepthBuffer?: boolean;
  43260. /**
  43261. * Define if a stencil buffer is required
  43262. */
  43263. generateStencilBuffer?: boolean;
  43264. /**
  43265. * Define if a depth texture is required instead of a depth buffer
  43266. */
  43267. generateDepthTexture?: boolean;
  43268. /**
  43269. * Define the number of desired draw buffers
  43270. */
  43271. textureCount?: number;
  43272. /**
  43273. * Define if aspect ratio should be adapted to the texture or stay the scene one
  43274. */
  43275. doNotChangeAspectRatio?: boolean;
  43276. /**
  43277. * Define the default type of the buffers we are creating
  43278. */
  43279. defaultType?: number;
  43280. }
  43281. /**
  43282. * A multi render target, like a render target provides the ability to render to a texture.
  43283. * Unlike the render target, it can render to several draw buffers in one draw.
  43284. * This is specially interesting in deferred rendering or for any effects requiring more than
  43285. * just one color from a single pass.
  43286. */
  43287. export class MultiRenderTarget extends RenderTargetTexture {
  43288. private _internalTextures;
  43289. private _textures;
  43290. private _multiRenderTargetOptions;
  43291. /**
  43292. * Get if draw buffers are currently supported by the used hardware and browser.
  43293. */
  43294. readonly isSupported: boolean;
  43295. /**
  43296. * Get the list of textures generated by the multi render target.
  43297. */
  43298. readonly textures: Texture[];
  43299. /**
  43300. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  43301. */
  43302. readonly depthTexture: Texture;
  43303. /**
  43304. * Set the wrapping mode on U of all the textures we are rendering to.
  43305. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  43306. */
  43307. wrapU: number;
  43308. /**
  43309. * Set the wrapping mode on V of all the textures we are rendering to.
  43310. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  43311. */
  43312. wrapV: number;
  43313. /**
  43314. * Instantiate a new multi render target texture.
  43315. * A multi render target, like a render target provides the ability to render to a texture.
  43316. * Unlike the render target, it can render to several draw buffers in one draw.
  43317. * This is specially interesting in deferred rendering or for any effects requiring more than
  43318. * just one color from a single pass.
  43319. * @param name Define the name of the texture
  43320. * @param size Define the size of the buffers to render to
  43321. * @param count Define the number of target we are rendering into
  43322. * @param scene Define the scene the texture belongs to
  43323. * @param options Define the options used to create the multi render target
  43324. */
  43325. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  43326. /** @hidden */
  43327. _rebuild(): void;
  43328. private _createInternalTextures;
  43329. private _createTextures;
  43330. /**
  43331. * Define the number of samples used if MSAA is enabled.
  43332. */
  43333. samples: number;
  43334. /**
  43335. * Resize all the textures in the multi render target.
  43336. * Be carrefull as it will recreate all the data in the new texture.
  43337. * @param size Define the new size
  43338. */
  43339. resize(size: any): void;
  43340. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  43341. /**
  43342. * Dispose the render targets and their associated resources
  43343. */
  43344. dispose(): void;
  43345. /**
  43346. * Release all the underlying texture used as draw buffers.
  43347. */
  43348. releaseInternalTextures(): void;
  43349. }
  43350. }
  43351. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  43352. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  43353. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  43354. import { Nullable } from "babylonjs/types";
  43355. module "babylonjs/Engines/engine" {
  43356. interface Engine {
  43357. /**
  43358. * Unbind a list of render target textures from the webGL context
  43359. * This is used only when drawBuffer extension or webGL2 are active
  43360. * @param textures defines the render target textures to unbind
  43361. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  43362. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  43363. */
  43364. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  43365. /**
  43366. * Create a multi render target texture
  43367. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  43368. * @param size defines the size of the texture
  43369. * @param options defines the creation options
  43370. * @returns the cube texture as an InternalTexture
  43371. */
  43372. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  43373. /**
  43374. * Update the sample count for a given multiple render target texture
  43375. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  43376. * @param textures defines the textures to update
  43377. * @param samples defines the sample count to set
  43378. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  43379. */
  43380. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  43381. }
  43382. }
  43383. }
  43384. declare module "babylonjs/Engines/Extensions/index" {
  43385. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  43386. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  43387. export * from "babylonjs/Engines/Extensions/engine.multiview";
  43388. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  43389. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  43390. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  43391. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  43392. export * from "babylonjs/Engines/Extensions/engine.webVR";
  43393. }
  43394. declare module "babylonjs/Engines/index" {
  43395. export * from "babylonjs/Engines/constants";
  43396. export * from "babylonjs/Engines/engine";
  43397. export * from "babylonjs/Engines/engineStore";
  43398. export * from "babylonjs/Engines/nullEngine";
  43399. export * from "babylonjs/Engines/Extensions/index";
  43400. export * from "babylonjs/Engines/IPipelineContext";
  43401. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  43402. }
  43403. declare module "babylonjs/Events/clipboardEvents" {
  43404. /**
  43405. * Gather the list of clipboard event types as constants.
  43406. */
  43407. export class ClipboardEventTypes {
  43408. /**
  43409. * The clipboard event is fired when a copy command is active (pressed).
  43410. */
  43411. static readonly COPY: number;
  43412. /**
  43413. * The clipboard event is fired when a cut command is active (pressed).
  43414. */
  43415. static readonly CUT: number;
  43416. /**
  43417. * The clipboard event is fired when a paste command is active (pressed).
  43418. */
  43419. static readonly PASTE: number;
  43420. }
  43421. /**
  43422. * This class is used to store clipboard related info for the onClipboardObservable event.
  43423. */
  43424. export class ClipboardInfo {
  43425. /**
  43426. * Defines the type of event (BABYLON.ClipboardEventTypes)
  43427. */
  43428. type: number;
  43429. /**
  43430. * Defines the related dom event
  43431. */
  43432. event: ClipboardEvent;
  43433. /**
  43434. *Creates an instance of ClipboardInfo.
  43435. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  43436. * @param event Defines the related dom event
  43437. */
  43438. constructor(
  43439. /**
  43440. * Defines the type of event (BABYLON.ClipboardEventTypes)
  43441. */
  43442. type: number,
  43443. /**
  43444. * Defines the related dom event
  43445. */
  43446. event: ClipboardEvent);
  43447. /**
  43448. * Get the clipboard event's type from the keycode.
  43449. * @param keyCode Defines the keyCode for the current keyboard event.
  43450. * @return {number}
  43451. */
  43452. static GetTypeFromCharacter(keyCode: number): number;
  43453. }
  43454. }
  43455. declare module "babylonjs/Events/index" {
  43456. export * from "babylonjs/Events/keyboardEvents";
  43457. export * from "babylonjs/Events/pointerEvents";
  43458. export * from "babylonjs/Events/clipboardEvents";
  43459. }
  43460. declare module "babylonjs/Loading/sceneLoader" {
  43461. import { Observable } from "babylonjs/Misc/observable";
  43462. import { Nullable } from "babylonjs/types";
  43463. import { Scene } from "babylonjs/scene";
  43464. import { Engine } from "babylonjs/Engines/engine";
  43465. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43466. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  43467. import { AssetContainer } from "babylonjs/assetContainer";
  43468. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  43469. import { Skeleton } from "babylonjs/Bones/skeleton";
  43470. /**
  43471. * Class used to represent data loading progression
  43472. */
  43473. export class SceneLoaderProgressEvent {
  43474. /** defines if data length to load can be evaluated */
  43475. readonly lengthComputable: boolean;
  43476. /** defines the loaded data length */
  43477. readonly loaded: number;
  43478. /** defines the data length to load */
  43479. readonly total: number;
  43480. /**
  43481. * Create a new progress event
  43482. * @param lengthComputable defines if data length to load can be evaluated
  43483. * @param loaded defines the loaded data length
  43484. * @param total defines the data length to load
  43485. */
  43486. constructor(
  43487. /** defines if data length to load can be evaluated */
  43488. lengthComputable: boolean,
  43489. /** defines the loaded data length */
  43490. loaded: number,
  43491. /** defines the data length to load */
  43492. total: number);
  43493. /**
  43494. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  43495. * @param event defines the source event
  43496. * @returns a new SceneLoaderProgressEvent
  43497. */
  43498. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  43499. }
  43500. /**
  43501. * Interface used by SceneLoader plugins to define supported file extensions
  43502. */
  43503. export interface ISceneLoaderPluginExtensions {
  43504. /**
  43505. * Defines the list of supported extensions
  43506. */
  43507. [extension: string]: {
  43508. isBinary: boolean;
  43509. };
  43510. }
  43511. /**
  43512. * Interface used by SceneLoader plugin factory
  43513. */
  43514. export interface ISceneLoaderPluginFactory {
  43515. /**
  43516. * Defines the name of the factory
  43517. */
  43518. name: string;
  43519. /**
  43520. * Function called to create a new plugin
  43521. * @return the new plugin
  43522. */
  43523. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  43524. /**
  43525. * Boolean indicating if the plugin can direct load specific data
  43526. */
  43527. canDirectLoad?: (data: string) => boolean;
  43528. }
  43529. /**
  43530. * Interface used to define a SceneLoader plugin
  43531. */
  43532. export interface ISceneLoaderPlugin {
  43533. /**
  43534. * The friendly name of this plugin.
  43535. */
  43536. name: string;
  43537. /**
  43538. * The file extensions supported by this plugin.
  43539. */
  43540. extensions: string | ISceneLoaderPluginExtensions;
  43541. /**
  43542. * Import meshes into a scene.
  43543. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43544. * @param scene The scene to import into
  43545. * @param data The data to import
  43546. * @param rootUrl The root url for scene and resources
  43547. * @param meshes The meshes array to import into
  43548. * @param particleSystems The particle systems array to import into
  43549. * @param skeletons The skeletons array to import into
  43550. * @param onError The callback when import fails
  43551. * @returns True if successful or false otherwise
  43552. */
  43553. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  43554. /**
  43555. * Load into a scene.
  43556. * @param scene The scene to load into
  43557. * @param data The data to import
  43558. * @param rootUrl The root url for scene and resources
  43559. * @param onError The callback when import fails
  43560. * @returns true if successful or false otherwise
  43561. */
  43562. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  43563. /**
  43564. * The callback that returns true if the data can be directly loaded.
  43565. */
  43566. canDirectLoad?: (data: string) => boolean;
  43567. /**
  43568. * The callback that allows custom handling of the root url based on the response url.
  43569. */
  43570. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  43571. /**
  43572. * Load into an asset container.
  43573. * @param scene The scene to load into
  43574. * @param data The data to import
  43575. * @param rootUrl The root url for scene and resources
  43576. * @param onError The callback when import fails
  43577. * @returns The loaded asset container
  43578. */
  43579. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  43580. }
  43581. /**
  43582. * Interface used to define an async SceneLoader plugin
  43583. */
  43584. export interface ISceneLoaderPluginAsync {
  43585. /**
  43586. * The friendly name of this plugin.
  43587. */
  43588. name: string;
  43589. /**
  43590. * The file extensions supported by this plugin.
  43591. */
  43592. extensions: string | ISceneLoaderPluginExtensions;
  43593. /**
  43594. * Import meshes into a scene.
  43595. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43596. * @param scene The scene to import into
  43597. * @param data The data to import
  43598. * @param rootUrl The root url for scene and resources
  43599. * @param onProgress The callback when the load progresses
  43600. * @param fileName Defines the name of the file to load
  43601. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  43602. */
  43603. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  43604. meshes: AbstractMesh[];
  43605. particleSystems: IParticleSystem[];
  43606. skeletons: Skeleton[];
  43607. animationGroups: AnimationGroup[];
  43608. }>;
  43609. /**
  43610. * Load into a scene.
  43611. * @param scene The scene to load into
  43612. * @param data The data to import
  43613. * @param rootUrl The root url for scene and resources
  43614. * @param onProgress The callback when the load progresses
  43615. * @param fileName Defines the name of the file to load
  43616. * @returns Nothing
  43617. */
  43618. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  43619. /**
  43620. * The callback that returns true if the data can be directly loaded.
  43621. */
  43622. canDirectLoad?: (data: string) => boolean;
  43623. /**
  43624. * The callback that allows custom handling of the root url based on the response url.
  43625. */
  43626. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  43627. /**
  43628. * Load into an asset container.
  43629. * @param scene The scene to load into
  43630. * @param data The data to import
  43631. * @param rootUrl The root url for scene and resources
  43632. * @param onProgress The callback when the load progresses
  43633. * @param fileName Defines the name of the file to load
  43634. * @returns The loaded asset container
  43635. */
  43636. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  43637. }
  43638. /**
  43639. * Class used to load scene from various file formats using registered plugins
  43640. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  43641. */
  43642. export class SceneLoader {
  43643. /**
  43644. * No logging while loading
  43645. */
  43646. static readonly NO_LOGGING: number;
  43647. /**
  43648. * Minimal logging while loading
  43649. */
  43650. static readonly MINIMAL_LOGGING: number;
  43651. /**
  43652. * Summary logging while loading
  43653. */
  43654. static readonly SUMMARY_LOGGING: number;
  43655. /**
  43656. * Detailled logging while loading
  43657. */
  43658. static readonly DETAILED_LOGGING: number;
  43659. /**
  43660. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  43661. */
  43662. static ForceFullSceneLoadingForIncremental: boolean;
  43663. /**
  43664. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  43665. */
  43666. static ShowLoadingScreen: boolean;
  43667. /**
  43668. * Defines the current logging level (while loading the scene)
  43669. * @ignorenaming
  43670. */
  43671. static loggingLevel: number;
  43672. /**
  43673. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  43674. */
  43675. static CleanBoneMatrixWeights: boolean;
  43676. /**
  43677. * Event raised when a plugin is used to load a scene
  43678. */
  43679. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  43680. private static _registeredPlugins;
  43681. private static _getDefaultPlugin;
  43682. private static _getPluginForExtension;
  43683. private static _getPluginForDirectLoad;
  43684. private static _getPluginForFilename;
  43685. private static _getDirectLoad;
  43686. private static _loadData;
  43687. private static _getFileInfo;
  43688. /**
  43689. * Gets a plugin that can load the given extension
  43690. * @param extension defines the extension to load
  43691. * @returns a plugin or null if none works
  43692. */
  43693. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  43694. /**
  43695. * Gets a boolean indicating that the given extension can be loaded
  43696. * @param extension defines the extension to load
  43697. * @returns true if the extension is supported
  43698. */
  43699. static IsPluginForExtensionAvailable(extension: string): boolean;
  43700. /**
  43701. * Adds a new plugin to the list of registered plugins
  43702. * @param plugin defines the plugin to add
  43703. */
  43704. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  43705. /**
  43706. * Import meshes into a scene
  43707. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43708. * @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)
  43709. * @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)
  43710. * @param scene the instance of BABYLON.Scene to append to
  43711. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  43712. * @param onProgress a callback with a progress event for each file being loaded
  43713. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43714. * @param pluginExtension the extension used to determine the plugin
  43715. * @returns The loaded plugin
  43716. */
  43717. 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>;
  43718. /**
  43719. * Import meshes into a scene
  43720. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43721. * @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)
  43722. * @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)
  43723. * @param scene the instance of BABYLON.Scene to append to
  43724. * @param onProgress a callback with a progress event for each file being loaded
  43725. * @param pluginExtension the extension used to determine the plugin
  43726. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  43727. */
  43728. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  43729. meshes: AbstractMesh[];
  43730. particleSystems: IParticleSystem[];
  43731. skeletons: Skeleton[];
  43732. animationGroups: AnimationGroup[];
  43733. }>;
  43734. /**
  43735. * Load a scene
  43736. * @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)
  43737. * @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)
  43738. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43739. * @param onSuccess a callback with the scene when import succeeds
  43740. * @param onProgress a callback with a progress event for each file being loaded
  43741. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43742. * @param pluginExtension the extension used to determine the plugin
  43743. * @returns The loaded plugin
  43744. */
  43745. 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>;
  43746. /**
  43747. * Load a scene
  43748. * @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)
  43749. * @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)
  43750. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43751. * @param onProgress a callback with a progress event for each file being loaded
  43752. * @param pluginExtension the extension used to determine the plugin
  43753. * @returns The loaded scene
  43754. */
  43755. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43756. /**
  43757. * Append a scene
  43758. * @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)
  43759. * @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)
  43760. * @param scene is the instance of BABYLON.Scene to append to
  43761. * @param onSuccess a callback with the scene when import succeeds
  43762. * @param onProgress a callback with a progress event for each file being loaded
  43763. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43764. * @param pluginExtension the extension used to determine the plugin
  43765. * @returns The loaded plugin
  43766. */
  43767. 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>;
  43768. /**
  43769. * Append a scene
  43770. * @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)
  43771. * @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)
  43772. * @param scene is the instance of BABYLON.Scene to append to
  43773. * @param onProgress a callback with a progress event for each file being loaded
  43774. * @param pluginExtension the extension used to determine the plugin
  43775. * @returns The given scene
  43776. */
  43777. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43778. /**
  43779. * Load a scene into an asset container
  43780. * @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)
  43781. * @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)
  43782. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43783. * @param onSuccess a callback with the scene when import succeeds
  43784. * @param onProgress a callback with a progress event for each file being loaded
  43785. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43786. * @param pluginExtension the extension used to determine the plugin
  43787. * @returns The loaded plugin
  43788. */
  43789. 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>;
  43790. /**
  43791. * Load a scene into an asset container
  43792. * @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)
  43793. * @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)
  43794. * @param scene is the instance of Scene to append to
  43795. * @param onProgress a callback with a progress event for each file being loaded
  43796. * @param pluginExtension the extension used to determine the plugin
  43797. * @returns The loaded asset container
  43798. */
  43799. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  43800. }
  43801. }
  43802. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  43803. import { Scene } from "babylonjs/scene";
  43804. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43805. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43806. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43807. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43808. /**
  43809. * Google Daydream controller
  43810. */
  43811. export class DaydreamController extends WebVRController {
  43812. /**
  43813. * Base Url for the controller model.
  43814. */
  43815. static MODEL_BASE_URL: string;
  43816. /**
  43817. * File name for the controller model.
  43818. */
  43819. static MODEL_FILENAME: string;
  43820. /**
  43821. * Gamepad Id prefix used to identify Daydream Controller.
  43822. */
  43823. static readonly GAMEPAD_ID_PREFIX: string;
  43824. /**
  43825. * Creates a new DaydreamController from a gamepad
  43826. * @param vrGamepad the gamepad that the controller should be created from
  43827. */
  43828. constructor(vrGamepad: any);
  43829. /**
  43830. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43831. * @param scene scene in which to add meshes
  43832. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43833. */
  43834. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43835. /**
  43836. * Called once for each button that changed state since the last frame
  43837. * @param buttonIdx Which button index changed
  43838. * @param state New state of the button
  43839. * @param changes Which properties on the state changed since last frame
  43840. */
  43841. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43842. }
  43843. }
  43844. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  43845. import { Scene } from "babylonjs/scene";
  43846. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43847. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43848. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43849. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43850. /**
  43851. * Gear VR Controller
  43852. */
  43853. export class GearVRController extends WebVRController {
  43854. /**
  43855. * Base Url for the controller model.
  43856. */
  43857. static MODEL_BASE_URL: string;
  43858. /**
  43859. * File name for the controller model.
  43860. */
  43861. static MODEL_FILENAME: string;
  43862. /**
  43863. * Gamepad Id prefix used to identify this controller.
  43864. */
  43865. static readonly GAMEPAD_ID_PREFIX: string;
  43866. private readonly _buttonIndexToObservableNameMap;
  43867. /**
  43868. * Creates a new GearVRController from a gamepad
  43869. * @param vrGamepad the gamepad that the controller should be created from
  43870. */
  43871. constructor(vrGamepad: any);
  43872. /**
  43873. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43874. * @param scene scene in which to add meshes
  43875. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43876. */
  43877. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43878. /**
  43879. * Called once for each button that changed state since the last frame
  43880. * @param buttonIdx Which button index changed
  43881. * @param state New state of the button
  43882. * @param changes Which properties on the state changed since last frame
  43883. */
  43884. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43885. }
  43886. }
  43887. declare module "babylonjs/Gamepads/Controllers/genericController" {
  43888. import { Scene } from "babylonjs/scene";
  43889. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43890. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43891. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43892. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43893. /**
  43894. * Generic Controller
  43895. */
  43896. export class GenericController extends WebVRController {
  43897. /**
  43898. * Base Url for the controller model.
  43899. */
  43900. static readonly MODEL_BASE_URL: string;
  43901. /**
  43902. * File name for the controller model.
  43903. */
  43904. static readonly MODEL_FILENAME: string;
  43905. /**
  43906. * Creates a new GenericController from a gamepad
  43907. * @param vrGamepad the gamepad that the controller should be created from
  43908. */
  43909. constructor(vrGamepad: any);
  43910. /**
  43911. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43912. * @param scene scene in which to add meshes
  43913. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43914. */
  43915. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43916. /**
  43917. * Called once for each button that changed state since the last frame
  43918. * @param buttonIdx Which button index changed
  43919. * @param state New state of the button
  43920. * @param changes Which properties on the state changed since last frame
  43921. */
  43922. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43923. }
  43924. }
  43925. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  43926. import { Observable } from "babylonjs/Misc/observable";
  43927. import { Scene } from "babylonjs/scene";
  43928. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43929. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43930. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43931. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43932. /**
  43933. * Oculus Touch Controller
  43934. */
  43935. export class OculusTouchController extends WebVRController {
  43936. /**
  43937. * Base Url for the controller model.
  43938. */
  43939. static MODEL_BASE_URL: string;
  43940. /**
  43941. * File name for the left controller model.
  43942. */
  43943. static MODEL_LEFT_FILENAME: string;
  43944. /**
  43945. * File name for the right controller model.
  43946. */
  43947. static MODEL_RIGHT_FILENAME: string;
  43948. /**
  43949. * Fired when the secondary trigger on this controller is modified
  43950. */
  43951. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  43952. /**
  43953. * Fired when the thumb rest on this controller is modified
  43954. */
  43955. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  43956. /**
  43957. * Creates a new OculusTouchController from a gamepad
  43958. * @param vrGamepad the gamepad that the controller should be created from
  43959. */
  43960. constructor(vrGamepad: any);
  43961. /**
  43962. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43963. * @param scene scene in which to add meshes
  43964. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43965. */
  43966. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43967. /**
  43968. * Fired when the A button on this controller is modified
  43969. */
  43970. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43971. /**
  43972. * Fired when the B button on this controller is modified
  43973. */
  43974. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43975. /**
  43976. * Fired when the X button on this controller is modified
  43977. */
  43978. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43979. /**
  43980. * Fired when the Y button on this controller is modified
  43981. */
  43982. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43983. /**
  43984. * Called once for each button that changed state since the last frame
  43985. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  43986. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  43987. * 2) secondary trigger (same)
  43988. * 3) A (right) X (left), touch, pressed = value
  43989. * 4) B / Y
  43990. * 5) thumb rest
  43991. * @param buttonIdx Which button index changed
  43992. * @param state New state of the button
  43993. * @param changes Which properties on the state changed since last frame
  43994. */
  43995. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43996. }
  43997. }
  43998. declare module "babylonjs/Gamepads/Controllers/viveController" {
  43999. import { Scene } from "babylonjs/scene";
  44000. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44001. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44002. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44003. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44004. import { Observable } from "babylonjs/Misc/observable";
  44005. /**
  44006. * Vive Controller
  44007. */
  44008. export class ViveController extends WebVRController {
  44009. /**
  44010. * Base Url for the controller model.
  44011. */
  44012. static MODEL_BASE_URL: string;
  44013. /**
  44014. * File name for the controller model.
  44015. */
  44016. static MODEL_FILENAME: string;
  44017. /**
  44018. * Creates a new ViveController from a gamepad
  44019. * @param vrGamepad the gamepad that the controller should be created from
  44020. */
  44021. constructor(vrGamepad: any);
  44022. /**
  44023. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44024. * @param scene scene in which to add meshes
  44025. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44026. */
  44027. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44028. /**
  44029. * Fired when the left button on this controller is modified
  44030. */
  44031. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44032. /**
  44033. * Fired when the right button on this controller is modified
  44034. */
  44035. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44036. /**
  44037. * Fired when the menu button on this controller is modified
  44038. */
  44039. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44040. /**
  44041. * Called once for each button that changed state since the last frame
  44042. * Vive mapping:
  44043. * 0: touchpad
  44044. * 1: trigger
  44045. * 2: left AND right buttons
  44046. * 3: menu button
  44047. * @param buttonIdx Which button index changed
  44048. * @param state New state of the button
  44049. * @param changes Which properties on the state changed since last frame
  44050. */
  44051. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44052. }
  44053. }
  44054. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  44055. import { Observable } from "babylonjs/Misc/observable";
  44056. import { Scene } from "babylonjs/scene";
  44057. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44058. import { Ray } from "babylonjs/Culling/ray";
  44059. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44060. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44061. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44062. /**
  44063. * Defines the WindowsMotionController object that the state of the windows motion controller
  44064. */
  44065. export class WindowsMotionController extends WebVRController {
  44066. /**
  44067. * The base url used to load the left and right controller models
  44068. */
  44069. static MODEL_BASE_URL: string;
  44070. /**
  44071. * The name of the left controller model file
  44072. */
  44073. static MODEL_LEFT_FILENAME: string;
  44074. /**
  44075. * The name of the right controller model file
  44076. */
  44077. static MODEL_RIGHT_FILENAME: string;
  44078. /**
  44079. * The controller name prefix for this controller type
  44080. */
  44081. static readonly GAMEPAD_ID_PREFIX: string;
  44082. /**
  44083. * The controller id pattern for this controller type
  44084. */
  44085. private static readonly GAMEPAD_ID_PATTERN;
  44086. private _loadedMeshInfo;
  44087. private readonly _mapping;
  44088. /**
  44089. * Fired when the trackpad on this controller is clicked
  44090. */
  44091. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  44092. /**
  44093. * Fired when the trackpad on this controller is modified
  44094. */
  44095. onTrackpadValuesChangedObservable: Observable<StickValues>;
  44096. /**
  44097. * The current x and y values of this controller's trackpad
  44098. */
  44099. trackpad: StickValues;
  44100. /**
  44101. * Creates a new WindowsMotionController from a gamepad
  44102. * @param vrGamepad the gamepad that the controller should be created from
  44103. */
  44104. constructor(vrGamepad: any);
  44105. /**
  44106. * Fired when the trigger on this controller is modified
  44107. */
  44108. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44109. /**
  44110. * Fired when the menu button on this controller is modified
  44111. */
  44112. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44113. /**
  44114. * Fired when the grip button on this controller is modified
  44115. */
  44116. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44117. /**
  44118. * Fired when the thumbstick button on this controller is modified
  44119. */
  44120. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44121. /**
  44122. * Fired when the touchpad button on this controller is modified
  44123. */
  44124. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44125. /**
  44126. * Fired when the touchpad values on this controller are modified
  44127. */
  44128. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  44129. private _updateTrackpad;
  44130. /**
  44131. * Called once per frame by the engine.
  44132. */
  44133. update(): void;
  44134. /**
  44135. * Called once for each button that changed state since the last frame
  44136. * @param buttonIdx Which button index changed
  44137. * @param state New state of the button
  44138. * @param changes Which properties on the state changed since last frame
  44139. */
  44140. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44141. /**
  44142. * Moves the buttons on the controller mesh based on their current state
  44143. * @param buttonName the name of the button to move
  44144. * @param buttonValue the value of the button which determines the buttons new position
  44145. */
  44146. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  44147. /**
  44148. * Moves the axis on the controller mesh based on its current state
  44149. * @param axis the index of the axis
  44150. * @param axisValue the value of the axis which determines the meshes new position
  44151. * @hidden
  44152. */
  44153. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  44154. /**
  44155. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44156. * @param scene scene in which to add meshes
  44157. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44158. */
  44159. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  44160. /**
  44161. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  44162. * can be transformed by button presses and axes values, based on this._mapping.
  44163. *
  44164. * @param scene scene in which the meshes exist
  44165. * @param meshes list of meshes that make up the controller model to process
  44166. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  44167. */
  44168. private processModel;
  44169. private createMeshInfo;
  44170. /**
  44171. * Gets the ray of the controller in the direction the controller is pointing
  44172. * @param length the length the resulting ray should be
  44173. * @returns a ray in the direction the controller is pointing
  44174. */
  44175. getForwardRay(length?: number): Ray;
  44176. /**
  44177. * Disposes of the controller
  44178. */
  44179. dispose(): void;
  44180. }
  44181. }
  44182. declare module "babylonjs/Gamepads/Controllers/index" {
  44183. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  44184. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  44185. export * from "babylonjs/Gamepads/Controllers/genericController";
  44186. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  44187. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44188. export * from "babylonjs/Gamepads/Controllers/viveController";
  44189. export * from "babylonjs/Gamepads/Controllers/webVRController";
  44190. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  44191. }
  44192. declare module "babylonjs/Gamepads/index" {
  44193. export * from "babylonjs/Gamepads/Controllers/index";
  44194. export * from "babylonjs/Gamepads/gamepad";
  44195. export * from "babylonjs/Gamepads/gamepadManager";
  44196. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  44197. export * from "babylonjs/Gamepads/xboxGamepad";
  44198. }
  44199. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  44200. import { Observable } from "babylonjs/Misc/observable";
  44201. import { Nullable } from "babylonjs/types";
  44202. import { Vector3, Color3 } from "babylonjs/Maths/math";
  44203. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44204. import { Mesh } from "babylonjs/Meshes/mesh";
  44205. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44206. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44207. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44208. /**
  44209. * Single axis scale gizmo
  44210. */
  44211. export class AxisScaleGizmo extends Gizmo {
  44212. private _coloredMaterial;
  44213. /**
  44214. * Drag behavior responsible for the gizmos dragging interactions
  44215. */
  44216. dragBehavior: PointerDragBehavior;
  44217. private _pointerObserver;
  44218. /**
  44219. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44220. */
  44221. snapDistance: number;
  44222. /**
  44223. * Event that fires each time the gizmo snaps to a new location.
  44224. * * snapDistance is the the change in distance
  44225. */
  44226. onSnapObservable: Observable<{
  44227. snapDistance: number;
  44228. }>;
  44229. /**
  44230. * If the scaling operation should be done on all axis (default: false)
  44231. */
  44232. uniformScaling: boolean;
  44233. /**
  44234. * Creates an AxisScaleGizmo
  44235. * @param gizmoLayer The utility layer the gizmo will be added to
  44236. * @param dragAxis The axis which the gizmo will be able to scale on
  44237. * @param color The color of the gizmo
  44238. */
  44239. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  44240. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44241. /**
  44242. * Disposes of the gizmo
  44243. */
  44244. dispose(): void;
  44245. /**
  44246. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  44247. * @param mesh The mesh to replace the default mesh of the gizmo
  44248. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  44249. */
  44250. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  44251. }
  44252. }
  44253. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  44254. import { Observable } from "babylonjs/Misc/observable";
  44255. import { Nullable } from "babylonjs/types";
  44256. import { Vector3, Color3 } from "babylonjs/Maths/math";
  44257. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44258. import { Mesh } from "babylonjs/Meshes/mesh";
  44259. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44260. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44261. import "babylonjs/Meshes/Builders/boxBuilder";
  44262. /**
  44263. * Bounding box gizmo
  44264. */
  44265. export class BoundingBoxGizmo extends Gizmo {
  44266. private _lineBoundingBox;
  44267. private _rotateSpheresParent;
  44268. private _scaleBoxesParent;
  44269. private _boundingDimensions;
  44270. private _renderObserver;
  44271. private _pointerObserver;
  44272. private _scaleDragSpeed;
  44273. private _tmpQuaternion;
  44274. private _tmpVector;
  44275. private _tmpRotationMatrix;
  44276. /**
  44277. * 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)
  44278. */
  44279. ignoreChildren: boolean;
  44280. /**
  44281. * 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)
  44282. */
  44283. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  44284. /**
  44285. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  44286. */
  44287. rotationSphereSize: number;
  44288. /**
  44289. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  44290. */
  44291. scaleBoxSize: number;
  44292. /**
  44293. * 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)
  44294. */
  44295. fixedDragMeshScreenSize: boolean;
  44296. /**
  44297. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  44298. */
  44299. fixedDragMeshScreenSizeDistanceFactor: number;
  44300. /**
  44301. * Fired when a rotation sphere or scale box is dragged
  44302. */
  44303. onDragStartObservable: Observable<{}>;
  44304. /**
  44305. * Fired when a scale box is dragged
  44306. */
  44307. onScaleBoxDragObservable: Observable<{}>;
  44308. /**
  44309. * Fired when a scale box drag is ended
  44310. */
  44311. onScaleBoxDragEndObservable: Observable<{}>;
  44312. /**
  44313. * Fired when a rotation sphere is dragged
  44314. */
  44315. onRotationSphereDragObservable: Observable<{}>;
  44316. /**
  44317. * Fired when a rotation sphere drag is ended
  44318. */
  44319. onRotationSphereDragEndObservable: Observable<{}>;
  44320. /**
  44321. * 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)
  44322. */
  44323. scalePivot: Nullable<Vector3>;
  44324. /**
  44325. * Mesh used as a pivot to rotate the attached mesh
  44326. */
  44327. private _anchorMesh;
  44328. private _existingMeshScale;
  44329. private _dragMesh;
  44330. private pointerDragBehavior;
  44331. private coloredMaterial;
  44332. private hoverColoredMaterial;
  44333. /**
  44334. * Sets the color of the bounding box gizmo
  44335. * @param color the color to set
  44336. */
  44337. setColor(color: Color3): void;
  44338. /**
  44339. * Creates an BoundingBoxGizmo
  44340. * @param gizmoLayer The utility layer the gizmo will be added to
  44341. * @param color The color of the gizmo
  44342. */
  44343. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  44344. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44345. private _selectNode;
  44346. /**
  44347. * Updates the bounding box information for the Gizmo
  44348. */
  44349. updateBoundingBox(): void;
  44350. private _updateRotationSpheres;
  44351. private _updateScaleBoxes;
  44352. /**
  44353. * Enables rotation on the specified axis and disables rotation on the others
  44354. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  44355. */
  44356. setEnabledRotationAxis(axis: string): void;
  44357. /**
  44358. * Enables/disables scaling
  44359. * @param enable if scaling should be enabled
  44360. */
  44361. setEnabledScaling(enable: boolean): void;
  44362. private _updateDummy;
  44363. /**
  44364. * Enables a pointer drag behavior on the bounding box of the gizmo
  44365. */
  44366. enableDragBehavior(): void;
  44367. /**
  44368. * Disposes of the gizmo
  44369. */
  44370. dispose(): void;
  44371. /**
  44372. * 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)
  44373. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  44374. * @returns the bounding box mesh with the passed in mesh as a child
  44375. */
  44376. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  44377. /**
  44378. * CustomMeshes are not supported by this gizmo
  44379. * @param mesh The mesh to replace the default mesh of the gizmo
  44380. */
  44381. setCustomMesh(mesh: Mesh): void;
  44382. }
  44383. }
  44384. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  44385. import { Observable } from "babylonjs/Misc/observable";
  44386. import { Nullable } from "babylonjs/types";
  44387. import { Vector3, Color3 } from "babylonjs/Maths/math";
  44388. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44389. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44390. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44391. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44392. import "babylonjs/Meshes/Builders/linesBuilder";
  44393. /**
  44394. * Single plane rotation gizmo
  44395. */
  44396. export class PlaneRotationGizmo extends Gizmo {
  44397. /**
  44398. * Drag behavior responsible for the gizmos dragging interactions
  44399. */
  44400. dragBehavior: PointerDragBehavior;
  44401. private _pointerObserver;
  44402. /**
  44403. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  44404. */
  44405. snapDistance: number;
  44406. /**
  44407. * Event that fires each time the gizmo snaps to a new location.
  44408. * * snapDistance is the the change in distance
  44409. */
  44410. onSnapObservable: Observable<{
  44411. snapDistance: number;
  44412. }>;
  44413. /**
  44414. * Creates a PlaneRotationGizmo
  44415. * @param gizmoLayer The utility layer the gizmo will be added to
  44416. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  44417. * @param color The color of the gizmo
  44418. * @param tessellation Amount of tessellation to be used when creating rotation circles
  44419. */
  44420. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  44421. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44422. /**
  44423. * Disposes of the gizmo
  44424. */
  44425. dispose(): void;
  44426. }
  44427. }
  44428. declare module "babylonjs/Gizmos/rotationGizmo" {
  44429. import { Observable } from "babylonjs/Misc/observable";
  44430. import { Nullable } from "babylonjs/types";
  44431. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44432. import { Mesh } from "babylonjs/Meshes/mesh";
  44433. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44434. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  44435. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44436. /**
  44437. * Gizmo that enables rotating a mesh along 3 axis
  44438. */
  44439. export class RotationGizmo extends Gizmo {
  44440. /**
  44441. * Internal gizmo used for interactions on the x axis
  44442. */
  44443. xGizmo: PlaneRotationGizmo;
  44444. /**
  44445. * Internal gizmo used for interactions on the y axis
  44446. */
  44447. yGizmo: PlaneRotationGizmo;
  44448. /**
  44449. * Internal gizmo used for interactions on the z axis
  44450. */
  44451. zGizmo: PlaneRotationGizmo;
  44452. /** Fires an event when any of it's sub gizmos are dragged */
  44453. onDragStartObservable: Observable<{}>;
  44454. /** Fires an event when any of it's sub gizmos are released from dragging */
  44455. onDragEndObservable: Observable<{}>;
  44456. attachedMesh: Nullable<AbstractMesh>;
  44457. /**
  44458. * Creates a RotationGizmo
  44459. * @param gizmoLayer The utility layer the gizmo will be added to
  44460. * @param tessellation Amount of tessellation to be used when creating rotation circles
  44461. */
  44462. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  44463. updateGizmoRotationToMatchAttachedMesh: boolean;
  44464. /**
  44465. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44466. */
  44467. snapDistance: number;
  44468. /**
  44469. * Ratio for the scale of the gizmo (Default: 1)
  44470. */
  44471. scaleRatio: number;
  44472. /**
  44473. * Disposes of the gizmo
  44474. */
  44475. dispose(): void;
  44476. /**
  44477. * CustomMeshes are not supported by this gizmo
  44478. * @param mesh The mesh to replace the default mesh of the gizmo
  44479. */
  44480. setCustomMesh(mesh: Mesh): void;
  44481. }
  44482. }
  44483. declare module "babylonjs/Gizmos/positionGizmo" {
  44484. import { Observable } from "babylonjs/Misc/observable";
  44485. import { Nullable } from "babylonjs/types";
  44486. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44487. import { Mesh } from "babylonjs/Meshes/mesh";
  44488. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44489. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  44490. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44491. /**
  44492. * Gizmo that enables dragging a mesh along 3 axis
  44493. */
  44494. export class PositionGizmo extends Gizmo {
  44495. /**
  44496. * Internal gizmo used for interactions on the x axis
  44497. */
  44498. xGizmo: AxisDragGizmo;
  44499. /**
  44500. * Internal gizmo used for interactions on the y axis
  44501. */
  44502. yGizmo: AxisDragGizmo;
  44503. /**
  44504. * Internal gizmo used for interactions on the z axis
  44505. */
  44506. zGizmo: AxisDragGizmo;
  44507. /** Fires an event when any of it's sub gizmos are dragged */
  44508. onDragStartObservable: Observable<{}>;
  44509. /** Fires an event when any of it's sub gizmos are released from dragging */
  44510. onDragEndObservable: Observable<{}>;
  44511. attachedMesh: Nullable<AbstractMesh>;
  44512. /**
  44513. * Creates a PositionGizmo
  44514. * @param gizmoLayer The utility layer the gizmo will be added to
  44515. */
  44516. constructor(gizmoLayer?: UtilityLayerRenderer);
  44517. updateGizmoRotationToMatchAttachedMesh: boolean;
  44518. /**
  44519. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44520. */
  44521. snapDistance: number;
  44522. /**
  44523. * Ratio for the scale of the gizmo (Default: 1)
  44524. */
  44525. scaleRatio: number;
  44526. /**
  44527. * Disposes of the gizmo
  44528. */
  44529. dispose(): void;
  44530. /**
  44531. * CustomMeshes are not supported by this gizmo
  44532. * @param mesh The mesh to replace the default mesh of the gizmo
  44533. */
  44534. setCustomMesh(mesh: Mesh): void;
  44535. }
  44536. }
  44537. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  44538. import { Scene } from "babylonjs/scene";
  44539. import { Color4, Vector4 } from "babylonjs/Maths/math";
  44540. import { Mesh } from "babylonjs/Meshes/mesh";
  44541. import { Nullable } from "babylonjs/types";
  44542. /**
  44543. * Class containing static functions to help procedurally build meshes
  44544. */
  44545. export class PolyhedronBuilder {
  44546. /**
  44547. * Creates a polyhedron mesh
  44548. * * 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
  44549. * * The parameter `size` (positive float, default 1) sets the polygon size
  44550. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  44551. * * 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`
  44552. * * 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
  44553. * * 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)`)
  44554. * * 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
  44555. * * 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
  44556. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44557. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44558. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44559. * @param name defines the name of the mesh
  44560. * @param options defines the options used to create the mesh
  44561. * @param scene defines the hosting scene
  44562. * @returns the polyhedron mesh
  44563. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  44564. */
  44565. static CreatePolyhedron(name: string, options: {
  44566. type?: number;
  44567. size?: number;
  44568. sizeX?: number;
  44569. sizeY?: number;
  44570. sizeZ?: number;
  44571. custom?: any;
  44572. faceUV?: Vector4[];
  44573. faceColors?: Color4[];
  44574. flat?: boolean;
  44575. updatable?: boolean;
  44576. sideOrientation?: number;
  44577. frontUVs?: Vector4;
  44578. backUVs?: Vector4;
  44579. }, scene?: Nullable<Scene>): Mesh;
  44580. }
  44581. }
  44582. declare module "babylonjs/Gizmos/scaleGizmo" {
  44583. import { Observable } from "babylonjs/Misc/observable";
  44584. import { Nullable } from "babylonjs/types";
  44585. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44586. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44587. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  44588. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44589. /**
  44590. * Gizmo that enables scaling a mesh along 3 axis
  44591. */
  44592. export class ScaleGizmo extends Gizmo {
  44593. /**
  44594. * Internal gizmo used for interactions on the x axis
  44595. */
  44596. xGizmo: AxisScaleGizmo;
  44597. /**
  44598. * Internal gizmo used for interactions on the y axis
  44599. */
  44600. yGizmo: AxisScaleGizmo;
  44601. /**
  44602. * Internal gizmo used for interactions on the z axis
  44603. */
  44604. zGizmo: AxisScaleGizmo;
  44605. /**
  44606. * Internal gizmo used to scale all axis equally
  44607. */
  44608. uniformScaleGizmo: AxisScaleGizmo;
  44609. /** Fires an event when any of it's sub gizmos are dragged */
  44610. onDragStartObservable: Observable<{}>;
  44611. /** Fires an event when any of it's sub gizmos are released from dragging */
  44612. onDragEndObservable: Observable<{}>;
  44613. attachedMesh: Nullable<AbstractMesh>;
  44614. /**
  44615. * Creates a ScaleGizmo
  44616. * @param gizmoLayer The utility layer the gizmo will be added to
  44617. */
  44618. constructor(gizmoLayer?: UtilityLayerRenderer);
  44619. updateGizmoRotationToMatchAttachedMesh: boolean;
  44620. /**
  44621. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44622. */
  44623. snapDistance: number;
  44624. /**
  44625. * Ratio for the scale of the gizmo (Default: 1)
  44626. */
  44627. scaleRatio: number;
  44628. /**
  44629. * Disposes of the gizmo
  44630. */
  44631. dispose(): void;
  44632. }
  44633. }
  44634. declare module "babylonjs/Gizmos/gizmoManager" {
  44635. import { Observable } from "babylonjs/Misc/observable";
  44636. import { Nullable } from "babylonjs/types";
  44637. import { Scene, IDisposable } from "babylonjs/scene";
  44638. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44639. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  44640. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  44641. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  44642. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  44643. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  44644. /**
  44645. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  44646. */
  44647. export class GizmoManager implements IDisposable {
  44648. private scene;
  44649. /**
  44650. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  44651. */
  44652. gizmos: {
  44653. positionGizmo: Nullable<PositionGizmo>;
  44654. rotationGizmo: Nullable<RotationGizmo>;
  44655. scaleGizmo: Nullable<ScaleGizmo>;
  44656. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  44657. };
  44658. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  44659. clearGizmoOnEmptyPointerEvent: boolean;
  44660. /** Fires an event when the manager is attached to a mesh */
  44661. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  44662. private _gizmosEnabled;
  44663. private _pointerObserver;
  44664. private _attachedMesh;
  44665. private _boundingBoxColor;
  44666. private _defaultUtilityLayer;
  44667. private _defaultKeepDepthUtilityLayer;
  44668. /**
  44669. * When bounding box gizmo is enabled, this can be used to track drag/end events
  44670. */
  44671. boundingBoxDragBehavior: SixDofDragBehavior;
  44672. /**
  44673. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  44674. */
  44675. attachableMeshes: Nullable<Array<AbstractMesh>>;
  44676. /**
  44677. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  44678. */
  44679. usePointerToAttachGizmos: boolean;
  44680. /**
  44681. * Instatiates a gizmo manager
  44682. * @param scene the scene to overlay the gizmos on top of
  44683. */
  44684. constructor(scene: Scene);
  44685. /**
  44686. * Attaches a set of gizmos to the specified mesh
  44687. * @param mesh The mesh the gizmo's should be attached to
  44688. */
  44689. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  44690. /**
  44691. * If the position gizmo is enabled
  44692. */
  44693. positionGizmoEnabled: boolean;
  44694. /**
  44695. * If the rotation gizmo is enabled
  44696. */
  44697. rotationGizmoEnabled: boolean;
  44698. /**
  44699. * If the scale gizmo is enabled
  44700. */
  44701. scaleGizmoEnabled: boolean;
  44702. /**
  44703. * If the boundingBox gizmo is enabled
  44704. */
  44705. boundingBoxGizmoEnabled: boolean;
  44706. /**
  44707. * Disposes of the gizmo manager
  44708. */
  44709. dispose(): void;
  44710. }
  44711. }
  44712. declare module "babylonjs/Lights/directionalLight" {
  44713. import { Camera } from "babylonjs/Cameras/camera";
  44714. import { Scene } from "babylonjs/scene";
  44715. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  44716. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44717. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  44718. import { Effect } from "babylonjs/Materials/effect";
  44719. /**
  44720. * A directional light is defined by a direction (what a surprise!).
  44721. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  44722. * 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.
  44723. * Documentation: https://doc.babylonjs.com/babylon101/lights
  44724. */
  44725. export class DirectionalLight extends ShadowLight {
  44726. private _shadowFrustumSize;
  44727. /**
  44728. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  44729. */
  44730. /**
  44731. * Specifies a fix frustum size for the shadow generation.
  44732. */
  44733. shadowFrustumSize: number;
  44734. private _shadowOrthoScale;
  44735. /**
  44736. * Gets the shadow projection scale against the optimal computed one.
  44737. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  44738. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  44739. */
  44740. /**
  44741. * Sets the shadow projection scale against the optimal computed one.
  44742. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  44743. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  44744. */
  44745. shadowOrthoScale: number;
  44746. /**
  44747. * Automatically compute the projection matrix to best fit (including all the casters)
  44748. * on each frame.
  44749. */
  44750. autoUpdateExtends: boolean;
  44751. private _orthoLeft;
  44752. private _orthoRight;
  44753. private _orthoTop;
  44754. private _orthoBottom;
  44755. /**
  44756. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  44757. * The directional light is emitted from everywhere in the given direction.
  44758. * It can cast shadows.
  44759. * Documentation : https://doc.babylonjs.com/babylon101/lights
  44760. * @param name The friendly name of the light
  44761. * @param direction The direction of the light
  44762. * @param scene The scene the light belongs to
  44763. */
  44764. constructor(name: string, direction: Vector3, scene: Scene);
  44765. /**
  44766. * Returns the string "DirectionalLight".
  44767. * @return The class name
  44768. */
  44769. getClassName(): string;
  44770. /**
  44771. * Returns the integer 1.
  44772. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  44773. */
  44774. getTypeID(): number;
  44775. /**
  44776. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  44777. * Returns the DirectionalLight Shadow projection matrix.
  44778. */
  44779. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44780. /**
  44781. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  44782. * Returns the DirectionalLight Shadow projection matrix.
  44783. */
  44784. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  44785. /**
  44786. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  44787. * Returns the DirectionalLight Shadow projection matrix.
  44788. */
  44789. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44790. protected _buildUniformLayout(): void;
  44791. /**
  44792. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  44793. * @param effect The effect to update
  44794. * @param lightIndex The index of the light in the effect to update
  44795. * @returns The directional light
  44796. */
  44797. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  44798. /**
  44799. * Gets the minZ used for shadow according to both the scene and the light.
  44800. *
  44801. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  44802. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  44803. * @param activeCamera The camera we are returning the min for
  44804. * @returns the depth min z
  44805. */
  44806. getDepthMinZ(activeCamera: Camera): number;
  44807. /**
  44808. * Gets the maxZ used for shadow according to both the scene and the light.
  44809. *
  44810. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  44811. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  44812. * @param activeCamera The camera we are returning the max for
  44813. * @returns the depth max z
  44814. */
  44815. getDepthMaxZ(activeCamera: Camera): number;
  44816. /**
  44817. * Prepares the list of defines specific to the light type.
  44818. * @param defines the list of defines
  44819. * @param lightIndex defines the index of the light for the effect
  44820. */
  44821. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  44822. }
  44823. }
  44824. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  44825. import { Mesh } from "babylonjs/Meshes/mesh";
  44826. /**
  44827. * Class containing static functions to help procedurally build meshes
  44828. */
  44829. export class HemisphereBuilder {
  44830. /**
  44831. * Creates a hemisphere mesh
  44832. * @param name defines the name of the mesh
  44833. * @param options defines the options used to create the mesh
  44834. * @param scene defines the hosting scene
  44835. * @returns the hemisphere mesh
  44836. */
  44837. static CreateHemisphere(name: string, options: {
  44838. segments?: number;
  44839. diameter?: number;
  44840. sideOrientation?: number;
  44841. }, scene: any): Mesh;
  44842. }
  44843. }
  44844. declare module "babylonjs/Lights/spotLight" {
  44845. import { Nullable } from "babylonjs/types";
  44846. import { Scene } from "babylonjs/scene";
  44847. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  44848. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44849. import { Effect } from "babylonjs/Materials/effect";
  44850. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44851. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  44852. /**
  44853. * A spot light is defined by a position, a direction, an angle, and an exponent.
  44854. * These values define a cone of light starting from the position, emitting toward the direction.
  44855. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  44856. * and the exponent defines the speed of the decay of the light with distance (reach).
  44857. * Documentation: https://doc.babylonjs.com/babylon101/lights
  44858. */
  44859. export class SpotLight extends ShadowLight {
  44860. private _angle;
  44861. private _innerAngle;
  44862. private _cosHalfAngle;
  44863. private _lightAngleScale;
  44864. private _lightAngleOffset;
  44865. /**
  44866. * Gets the cone angle of the spot light in Radians.
  44867. */
  44868. /**
  44869. * Sets the cone angle of the spot light in Radians.
  44870. */
  44871. angle: number;
  44872. /**
  44873. * Only used in gltf falloff mode, this defines the angle where
  44874. * the directional falloff will start before cutting at angle which could be seen
  44875. * as outer angle.
  44876. */
  44877. /**
  44878. * Only used in gltf falloff mode, this defines the angle where
  44879. * the directional falloff will start before cutting at angle which could be seen
  44880. * as outer angle.
  44881. */
  44882. innerAngle: number;
  44883. private _shadowAngleScale;
  44884. /**
  44885. * Allows scaling the angle of the light for shadow generation only.
  44886. */
  44887. /**
  44888. * Allows scaling the angle of the light for shadow generation only.
  44889. */
  44890. shadowAngleScale: number;
  44891. /**
  44892. * The light decay speed with the distance from the emission spot.
  44893. */
  44894. exponent: number;
  44895. private _projectionTextureMatrix;
  44896. /**
  44897. * Allows reading the projecton texture
  44898. */
  44899. readonly projectionTextureMatrix: Matrix;
  44900. protected _projectionTextureLightNear: number;
  44901. /**
  44902. * Gets the near clip of the Spotlight for texture projection.
  44903. */
  44904. /**
  44905. * Sets the near clip of the Spotlight for texture projection.
  44906. */
  44907. projectionTextureLightNear: number;
  44908. protected _projectionTextureLightFar: number;
  44909. /**
  44910. * Gets the far clip of the Spotlight for texture projection.
  44911. */
  44912. /**
  44913. * Sets the far clip of the Spotlight for texture projection.
  44914. */
  44915. projectionTextureLightFar: number;
  44916. protected _projectionTextureUpDirection: Vector3;
  44917. /**
  44918. * Gets the Up vector of the Spotlight for texture projection.
  44919. */
  44920. /**
  44921. * Sets the Up vector of the Spotlight for texture projection.
  44922. */
  44923. projectionTextureUpDirection: Vector3;
  44924. private _projectionTexture;
  44925. /**
  44926. * Gets the projection texture of the light.
  44927. */
  44928. /**
  44929. * Sets the projection texture of the light.
  44930. */
  44931. projectionTexture: Nullable<BaseTexture>;
  44932. private _projectionTextureViewLightDirty;
  44933. private _projectionTextureProjectionLightDirty;
  44934. private _projectionTextureDirty;
  44935. private _projectionTextureViewTargetVector;
  44936. private _projectionTextureViewLightMatrix;
  44937. private _projectionTextureProjectionLightMatrix;
  44938. private _projectionTextureScalingMatrix;
  44939. /**
  44940. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  44941. * It can cast shadows.
  44942. * Documentation : https://doc.babylonjs.com/babylon101/lights
  44943. * @param name The light friendly name
  44944. * @param position The position of the spot light in the scene
  44945. * @param direction The direction of the light in the scene
  44946. * @param angle The cone angle of the light in Radians
  44947. * @param exponent The light decay speed with the distance from the emission spot
  44948. * @param scene The scene the lights belongs to
  44949. */
  44950. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  44951. /**
  44952. * Returns the string "SpotLight".
  44953. * @returns the class name
  44954. */
  44955. getClassName(): string;
  44956. /**
  44957. * Returns the integer 2.
  44958. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  44959. */
  44960. getTypeID(): number;
  44961. /**
  44962. * Overrides the direction setter to recompute the projection texture view light Matrix.
  44963. */
  44964. protected _setDirection(value: Vector3): void;
  44965. /**
  44966. * Overrides the position setter to recompute the projection texture view light Matrix.
  44967. */
  44968. protected _setPosition(value: Vector3): void;
  44969. /**
  44970. * 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.
  44971. * Returns the SpotLight.
  44972. */
  44973. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44974. protected _computeProjectionTextureViewLightMatrix(): void;
  44975. protected _computeProjectionTextureProjectionLightMatrix(): void;
  44976. /**
  44977. * Main function for light texture projection matrix computing.
  44978. */
  44979. protected _computeProjectionTextureMatrix(): void;
  44980. protected _buildUniformLayout(): void;
  44981. private _computeAngleValues;
  44982. /**
  44983. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  44984. * @param effect The effect to update
  44985. * @param lightIndex The index of the light in the effect to update
  44986. * @returns The spot light
  44987. */
  44988. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  44989. /**
  44990. * Disposes the light and the associated resources.
  44991. */
  44992. dispose(): void;
  44993. /**
  44994. * Prepares the list of defines specific to the light type.
  44995. * @param defines the list of defines
  44996. * @param lightIndex defines the index of the light for the effect
  44997. */
  44998. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  44999. }
  45000. }
  45001. declare module "babylonjs/Gizmos/lightGizmo" {
  45002. import { Nullable } from "babylonjs/types";
  45003. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45004. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45005. import { Light } from "babylonjs/Lights/light";
  45006. /**
  45007. * Gizmo that enables viewing a light
  45008. */
  45009. export class LightGizmo extends Gizmo {
  45010. private _lightMesh;
  45011. private _material;
  45012. private cachedPosition;
  45013. private cachedForward;
  45014. /**
  45015. * Creates a LightGizmo
  45016. * @param gizmoLayer The utility layer the gizmo will be added to
  45017. */
  45018. constructor(gizmoLayer?: UtilityLayerRenderer);
  45019. private _light;
  45020. /**
  45021. * The light that the gizmo is attached to
  45022. */
  45023. light: Nullable<Light>;
  45024. /**
  45025. * @hidden
  45026. * Updates the gizmo to match the attached mesh's position/rotation
  45027. */
  45028. protected _update(): void;
  45029. private static _Scale;
  45030. /**
  45031. * Creates the lines for a light mesh
  45032. */
  45033. private static _createLightLines;
  45034. /**
  45035. * Disposes of the light gizmo
  45036. */
  45037. dispose(): void;
  45038. private static _CreateHemisphericLightMesh;
  45039. private static _CreatePointLightMesh;
  45040. private static _CreateSpotLightMesh;
  45041. private static _CreateDirectionalLightMesh;
  45042. }
  45043. }
  45044. declare module "babylonjs/Gizmos/index" {
  45045. export * from "babylonjs/Gizmos/axisDragGizmo";
  45046. export * from "babylonjs/Gizmos/axisScaleGizmo";
  45047. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  45048. export * from "babylonjs/Gizmos/gizmo";
  45049. export * from "babylonjs/Gizmos/gizmoManager";
  45050. export * from "babylonjs/Gizmos/planeRotationGizmo";
  45051. export * from "babylonjs/Gizmos/positionGizmo";
  45052. export * from "babylonjs/Gizmos/rotationGizmo";
  45053. export * from "babylonjs/Gizmos/scaleGizmo";
  45054. export * from "babylonjs/Gizmos/lightGizmo";
  45055. }
  45056. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  45057. /** @hidden */
  45058. export var backgroundFragmentDeclaration: {
  45059. name: string;
  45060. shader: string;
  45061. };
  45062. }
  45063. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  45064. /** @hidden */
  45065. export var backgroundUboDeclaration: {
  45066. name: string;
  45067. shader: string;
  45068. };
  45069. }
  45070. declare module "babylonjs/Shaders/background.fragment" {
  45071. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  45072. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  45073. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  45074. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  45075. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  45076. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  45077. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  45078. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  45079. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  45080. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  45081. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  45082. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  45083. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  45084. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  45085. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  45086. /** @hidden */
  45087. export var backgroundPixelShader: {
  45088. name: string;
  45089. shader: string;
  45090. };
  45091. }
  45092. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  45093. /** @hidden */
  45094. export var backgroundVertexDeclaration: {
  45095. name: string;
  45096. shader: string;
  45097. };
  45098. }
  45099. declare module "babylonjs/Shaders/background.vertex" {
  45100. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  45101. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  45102. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  45103. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  45104. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  45105. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  45106. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  45107. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  45108. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  45109. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  45110. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  45111. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  45112. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  45113. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  45114. /** @hidden */
  45115. export var backgroundVertexShader: {
  45116. name: string;
  45117. shader: string;
  45118. };
  45119. }
  45120. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  45121. import { Nullable, int, float } from "babylonjs/types";
  45122. import { Scene } from "babylonjs/scene";
  45123. import { Matrix, Vector3, Color3 } from "babylonjs/Maths/math";
  45124. import { SubMesh } from "babylonjs/Meshes/subMesh";
  45125. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45126. import { Mesh } from "babylonjs/Meshes/mesh";
  45127. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  45128. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  45129. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  45130. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45131. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  45132. import "babylonjs/Shaders/background.fragment";
  45133. import "babylonjs/Shaders/background.vertex";
  45134. /**
  45135. * Background material used to create an efficient environement around your scene.
  45136. */
  45137. export class BackgroundMaterial extends PushMaterial {
  45138. /**
  45139. * Standard reflectance value at parallel view angle.
  45140. */
  45141. static StandardReflectance0: number;
  45142. /**
  45143. * Standard reflectance value at grazing angle.
  45144. */
  45145. static StandardReflectance90: number;
  45146. protected _primaryColor: Color3;
  45147. /**
  45148. * Key light Color (multiply against the environement texture)
  45149. */
  45150. primaryColor: Color3;
  45151. protected __perceptualColor: Nullable<Color3>;
  45152. /**
  45153. * Experimental Internal Use Only.
  45154. *
  45155. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  45156. * This acts as a helper to set the primary color to a more "human friendly" value.
  45157. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  45158. * output color as close as possible from the chosen value.
  45159. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  45160. * part of lighting setup.)
  45161. */
  45162. _perceptualColor: Nullable<Color3>;
  45163. protected _primaryColorShadowLevel: float;
  45164. /**
  45165. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  45166. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  45167. */
  45168. primaryColorShadowLevel: float;
  45169. protected _primaryColorHighlightLevel: float;
  45170. /**
  45171. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  45172. * The primary color is used at the level chosen to define what the white area would look.
  45173. */
  45174. primaryColorHighlightLevel: float;
  45175. protected _reflectionTexture: Nullable<BaseTexture>;
  45176. /**
  45177. * Reflection Texture used in the material.
  45178. * Should be author in a specific way for the best result (refer to the documentation).
  45179. */
  45180. reflectionTexture: Nullable<BaseTexture>;
  45181. protected _reflectionBlur: float;
  45182. /**
  45183. * Reflection Texture level of blur.
  45184. *
  45185. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  45186. * texture twice.
  45187. */
  45188. reflectionBlur: float;
  45189. protected _diffuseTexture: Nullable<BaseTexture>;
  45190. /**
  45191. * Diffuse Texture used in the material.
  45192. * Should be author in a specific way for the best result (refer to the documentation).
  45193. */
  45194. diffuseTexture: Nullable<BaseTexture>;
  45195. protected _shadowLights: Nullable<IShadowLight[]>;
  45196. /**
  45197. * Specify the list of lights casting shadow on the material.
  45198. * All scene shadow lights will be included if null.
  45199. */
  45200. shadowLights: Nullable<IShadowLight[]>;
  45201. protected _shadowLevel: float;
  45202. /**
  45203. * Helps adjusting the shadow to a softer level if required.
  45204. * 0 means black shadows and 1 means no shadows.
  45205. */
  45206. shadowLevel: float;
  45207. protected _sceneCenter: Vector3;
  45208. /**
  45209. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  45210. * It is usually zero but might be interesting to modify according to your setup.
  45211. */
  45212. sceneCenter: Vector3;
  45213. protected _opacityFresnel: boolean;
  45214. /**
  45215. * This helps specifying that the material is falling off to the sky box at grazing angle.
  45216. * This helps ensuring a nice transition when the camera goes under the ground.
  45217. */
  45218. opacityFresnel: boolean;
  45219. protected _reflectionFresnel: boolean;
  45220. /**
  45221. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  45222. * This helps adding a mirror texture on the ground.
  45223. */
  45224. reflectionFresnel: boolean;
  45225. protected _reflectionFalloffDistance: number;
  45226. /**
  45227. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  45228. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  45229. */
  45230. reflectionFalloffDistance: number;
  45231. protected _reflectionAmount: number;
  45232. /**
  45233. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  45234. */
  45235. reflectionAmount: number;
  45236. protected _reflectionReflectance0: number;
  45237. /**
  45238. * This specifies the weight of the reflection at grazing angle.
  45239. */
  45240. reflectionReflectance0: number;
  45241. protected _reflectionReflectance90: number;
  45242. /**
  45243. * This specifies the weight of the reflection at a perpendicular point of view.
  45244. */
  45245. reflectionReflectance90: number;
  45246. /**
  45247. * Sets the reflection reflectance fresnel values according to the default standard
  45248. * empirically know to work well :-)
  45249. */
  45250. reflectionStandardFresnelWeight: number;
  45251. protected _useRGBColor: boolean;
  45252. /**
  45253. * Helps to directly use the maps channels instead of their level.
  45254. */
  45255. useRGBColor: boolean;
  45256. protected _enableNoise: boolean;
  45257. /**
  45258. * This helps reducing the banding effect that could occur on the background.
  45259. */
  45260. enableNoise: boolean;
  45261. /**
  45262. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  45263. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  45264. * Recommended to be keep at 1.0 except for special cases.
  45265. */
  45266. fovMultiplier: number;
  45267. private _fovMultiplier;
  45268. /**
  45269. * Enable the FOV adjustment feature controlled by fovMultiplier.
  45270. */
  45271. useEquirectangularFOV: boolean;
  45272. private _maxSimultaneousLights;
  45273. /**
  45274. * Number of Simultaneous lights allowed on the material.
  45275. */
  45276. maxSimultaneousLights: int;
  45277. /**
  45278. * Default configuration related to image processing available in the Background Material.
  45279. */
  45280. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  45281. /**
  45282. * Keep track of the image processing observer to allow dispose and replace.
  45283. */
  45284. private _imageProcessingObserver;
  45285. /**
  45286. * Attaches a new image processing configuration to the PBR Material.
  45287. * @param configuration (if null the scene configuration will be use)
  45288. */
  45289. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  45290. /**
  45291. * Gets the image processing configuration used either in this material.
  45292. */
  45293. /**
  45294. * Sets the Default image processing configuration used either in the this material.
  45295. *
  45296. * If sets to null, the scene one is in use.
  45297. */
  45298. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  45299. /**
  45300. * Gets wether the color curves effect is enabled.
  45301. */
  45302. /**
  45303. * Sets wether the color curves effect is enabled.
  45304. */
  45305. cameraColorCurvesEnabled: boolean;
  45306. /**
  45307. * Gets wether the color grading effect is enabled.
  45308. */
  45309. /**
  45310. * Gets wether the color grading effect is enabled.
  45311. */
  45312. cameraColorGradingEnabled: boolean;
  45313. /**
  45314. * Gets wether tonemapping is enabled or not.
  45315. */
  45316. /**
  45317. * Sets wether tonemapping is enabled or not
  45318. */
  45319. cameraToneMappingEnabled: boolean;
  45320. /**
  45321. * The camera exposure used on this material.
  45322. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45323. * This corresponds to a photographic exposure.
  45324. */
  45325. /**
  45326. * The camera exposure used on this material.
  45327. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45328. * This corresponds to a photographic exposure.
  45329. */
  45330. cameraExposure: float;
  45331. /**
  45332. * Gets The camera contrast used on this material.
  45333. */
  45334. /**
  45335. * Sets The camera contrast used on this material.
  45336. */
  45337. cameraContrast: float;
  45338. /**
  45339. * Gets the Color Grading 2D Lookup Texture.
  45340. */
  45341. /**
  45342. * Sets the Color Grading 2D Lookup Texture.
  45343. */
  45344. cameraColorGradingTexture: Nullable<BaseTexture>;
  45345. /**
  45346. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45347. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45348. * 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;
  45349. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45350. */
  45351. /**
  45352. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45353. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45354. * 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;
  45355. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45356. */
  45357. cameraColorCurves: Nullable<ColorCurves>;
  45358. /**
  45359. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  45360. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  45361. */
  45362. switchToBGR: boolean;
  45363. private _renderTargets;
  45364. private _reflectionControls;
  45365. private _white;
  45366. private _primaryShadowColor;
  45367. private _primaryHighlightColor;
  45368. /**
  45369. * Instantiates a Background Material in the given scene
  45370. * @param name The friendly name of the material
  45371. * @param scene The scene to add the material to
  45372. */
  45373. constructor(name: string, scene: Scene);
  45374. /**
  45375. * Gets a boolean indicating that current material needs to register RTT
  45376. */
  45377. readonly hasRenderTargetTextures: boolean;
  45378. /**
  45379. * The entire material has been created in order to prevent overdraw.
  45380. * @returns false
  45381. */
  45382. needAlphaTesting(): boolean;
  45383. /**
  45384. * The entire material has been created in order to prevent overdraw.
  45385. * @returns true if blending is enable
  45386. */
  45387. needAlphaBlending(): boolean;
  45388. /**
  45389. * Checks wether the material is ready to be rendered for a given mesh.
  45390. * @param mesh The mesh to render
  45391. * @param subMesh The submesh to check against
  45392. * @param useInstances Specify wether or not the material is used with instances
  45393. * @returns true if all the dependencies are ready (Textures, Effects...)
  45394. */
  45395. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  45396. /**
  45397. * Compute the primary color according to the chosen perceptual color.
  45398. */
  45399. private _computePrimaryColorFromPerceptualColor;
  45400. /**
  45401. * Compute the highlights and shadow colors according to their chosen levels.
  45402. */
  45403. private _computePrimaryColors;
  45404. /**
  45405. * Build the uniform buffer used in the material.
  45406. */
  45407. buildUniformLayout(): void;
  45408. /**
  45409. * Unbind the material.
  45410. */
  45411. unbind(): void;
  45412. /**
  45413. * Bind only the world matrix to the material.
  45414. * @param world The world matrix to bind.
  45415. */
  45416. bindOnlyWorldMatrix(world: Matrix): void;
  45417. /**
  45418. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  45419. * @param world The world matrix to bind.
  45420. * @param subMesh The submesh to bind for.
  45421. */
  45422. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  45423. /**
  45424. * Dispose the material.
  45425. * @param forceDisposeEffect Force disposal of the associated effect.
  45426. * @param forceDisposeTextures Force disposal of the associated textures.
  45427. */
  45428. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  45429. /**
  45430. * Clones the material.
  45431. * @param name The cloned name.
  45432. * @returns The cloned material.
  45433. */
  45434. clone(name: string): BackgroundMaterial;
  45435. /**
  45436. * Serializes the current material to its JSON representation.
  45437. * @returns The JSON representation.
  45438. */
  45439. serialize(): any;
  45440. /**
  45441. * Gets the class name of the material
  45442. * @returns "BackgroundMaterial"
  45443. */
  45444. getClassName(): string;
  45445. /**
  45446. * Parse a JSON input to create back a background material.
  45447. * @param source The JSON data to parse
  45448. * @param scene The scene to create the parsed material in
  45449. * @param rootUrl The root url of the assets the material depends upon
  45450. * @returns the instantiated BackgroundMaterial.
  45451. */
  45452. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  45453. }
  45454. }
  45455. declare module "babylonjs/Helpers/environmentHelper" {
  45456. import { Observable } from "babylonjs/Misc/observable";
  45457. import { Nullable } from "babylonjs/types";
  45458. import { Scene } from "babylonjs/scene";
  45459. import { Vector3, Color3 } from "babylonjs/Maths/math";
  45460. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45461. import { Mesh } from "babylonjs/Meshes/mesh";
  45462. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45463. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  45464. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  45465. import "babylonjs/Meshes/Builders/planeBuilder";
  45466. import "babylonjs/Meshes/Builders/boxBuilder";
  45467. /**
  45468. * Represents the different options available during the creation of
  45469. * a Environment helper.
  45470. *
  45471. * This can control the default ground, skybox and image processing setup of your scene.
  45472. */
  45473. export interface IEnvironmentHelperOptions {
  45474. /**
  45475. * Specifies wether or not to create a ground.
  45476. * True by default.
  45477. */
  45478. createGround: boolean;
  45479. /**
  45480. * Specifies the ground size.
  45481. * 15 by default.
  45482. */
  45483. groundSize: number;
  45484. /**
  45485. * The texture used on the ground for the main color.
  45486. * Comes from the BabylonJS CDN by default.
  45487. *
  45488. * Remarks: Can be either a texture or a url.
  45489. */
  45490. groundTexture: string | BaseTexture;
  45491. /**
  45492. * The color mixed in the ground texture by default.
  45493. * BabylonJS clearColor by default.
  45494. */
  45495. groundColor: Color3;
  45496. /**
  45497. * Specifies the ground opacity.
  45498. * 1 by default.
  45499. */
  45500. groundOpacity: number;
  45501. /**
  45502. * Enables the ground to receive shadows.
  45503. * True by default.
  45504. */
  45505. enableGroundShadow: boolean;
  45506. /**
  45507. * Helps preventing the shadow to be fully black on the ground.
  45508. * 0.5 by default.
  45509. */
  45510. groundShadowLevel: number;
  45511. /**
  45512. * Creates a mirror texture attach to the ground.
  45513. * false by default.
  45514. */
  45515. enableGroundMirror: boolean;
  45516. /**
  45517. * Specifies the ground mirror size ratio.
  45518. * 0.3 by default as the default kernel is 64.
  45519. */
  45520. groundMirrorSizeRatio: number;
  45521. /**
  45522. * Specifies the ground mirror blur kernel size.
  45523. * 64 by default.
  45524. */
  45525. groundMirrorBlurKernel: number;
  45526. /**
  45527. * Specifies the ground mirror visibility amount.
  45528. * 1 by default
  45529. */
  45530. groundMirrorAmount: number;
  45531. /**
  45532. * Specifies the ground mirror reflectance weight.
  45533. * This uses the standard weight of the background material to setup the fresnel effect
  45534. * of the mirror.
  45535. * 1 by default.
  45536. */
  45537. groundMirrorFresnelWeight: number;
  45538. /**
  45539. * Specifies the ground mirror Falloff distance.
  45540. * This can helps reducing the size of the reflection.
  45541. * 0 by Default.
  45542. */
  45543. groundMirrorFallOffDistance: number;
  45544. /**
  45545. * Specifies the ground mirror texture type.
  45546. * Unsigned Int by Default.
  45547. */
  45548. groundMirrorTextureType: number;
  45549. /**
  45550. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  45551. * the shown objects.
  45552. */
  45553. groundYBias: number;
  45554. /**
  45555. * Specifies wether or not to create a skybox.
  45556. * True by default.
  45557. */
  45558. createSkybox: boolean;
  45559. /**
  45560. * Specifies the skybox size.
  45561. * 20 by default.
  45562. */
  45563. skyboxSize: number;
  45564. /**
  45565. * The texture used on the skybox for the main color.
  45566. * Comes from the BabylonJS CDN by default.
  45567. *
  45568. * Remarks: Can be either a texture or a url.
  45569. */
  45570. skyboxTexture: string | BaseTexture;
  45571. /**
  45572. * The color mixed in the skybox texture by default.
  45573. * BabylonJS clearColor by default.
  45574. */
  45575. skyboxColor: Color3;
  45576. /**
  45577. * The background rotation around the Y axis of the scene.
  45578. * This helps aligning the key lights of your scene with the background.
  45579. * 0 by default.
  45580. */
  45581. backgroundYRotation: number;
  45582. /**
  45583. * Compute automatically the size of the elements to best fit with the scene.
  45584. */
  45585. sizeAuto: boolean;
  45586. /**
  45587. * Default position of the rootMesh if autoSize is not true.
  45588. */
  45589. rootPosition: Vector3;
  45590. /**
  45591. * Sets up the image processing in the scene.
  45592. * true by default.
  45593. */
  45594. setupImageProcessing: boolean;
  45595. /**
  45596. * The texture used as your environment texture in the scene.
  45597. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  45598. *
  45599. * Remarks: Can be either a texture or a url.
  45600. */
  45601. environmentTexture: string | BaseTexture;
  45602. /**
  45603. * The value of the exposure to apply to the scene.
  45604. * 0.6 by default if setupImageProcessing is true.
  45605. */
  45606. cameraExposure: number;
  45607. /**
  45608. * The value of the contrast to apply to the scene.
  45609. * 1.6 by default if setupImageProcessing is true.
  45610. */
  45611. cameraContrast: number;
  45612. /**
  45613. * Specifies wether or not tonemapping should be enabled in the scene.
  45614. * true by default if setupImageProcessing is true.
  45615. */
  45616. toneMappingEnabled: boolean;
  45617. }
  45618. /**
  45619. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  45620. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  45621. * It also helps with the default setup of your imageProcessing configuration.
  45622. */
  45623. export class EnvironmentHelper {
  45624. /**
  45625. * Default ground texture URL.
  45626. */
  45627. private static _groundTextureCDNUrl;
  45628. /**
  45629. * Default skybox texture URL.
  45630. */
  45631. private static _skyboxTextureCDNUrl;
  45632. /**
  45633. * Default environment texture URL.
  45634. */
  45635. private static _environmentTextureCDNUrl;
  45636. /**
  45637. * Creates the default options for the helper.
  45638. */
  45639. private static _getDefaultOptions;
  45640. private _rootMesh;
  45641. /**
  45642. * Gets the root mesh created by the helper.
  45643. */
  45644. readonly rootMesh: Mesh;
  45645. private _skybox;
  45646. /**
  45647. * Gets the skybox created by the helper.
  45648. */
  45649. readonly skybox: Nullable<Mesh>;
  45650. private _skyboxTexture;
  45651. /**
  45652. * Gets the skybox texture created by the helper.
  45653. */
  45654. readonly skyboxTexture: Nullable<BaseTexture>;
  45655. private _skyboxMaterial;
  45656. /**
  45657. * Gets the skybox material created by the helper.
  45658. */
  45659. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  45660. private _ground;
  45661. /**
  45662. * Gets the ground mesh created by the helper.
  45663. */
  45664. readonly ground: Nullable<Mesh>;
  45665. private _groundTexture;
  45666. /**
  45667. * Gets the ground texture created by the helper.
  45668. */
  45669. readonly groundTexture: Nullable<BaseTexture>;
  45670. private _groundMirror;
  45671. /**
  45672. * Gets the ground mirror created by the helper.
  45673. */
  45674. readonly groundMirror: Nullable<MirrorTexture>;
  45675. /**
  45676. * Gets the ground mirror render list to helps pushing the meshes
  45677. * you wish in the ground reflection.
  45678. */
  45679. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  45680. private _groundMaterial;
  45681. /**
  45682. * Gets the ground material created by the helper.
  45683. */
  45684. readonly groundMaterial: Nullable<BackgroundMaterial>;
  45685. /**
  45686. * Stores the creation options.
  45687. */
  45688. private readonly _scene;
  45689. private _options;
  45690. /**
  45691. * This observable will be notified with any error during the creation of the environment,
  45692. * mainly texture creation errors.
  45693. */
  45694. onErrorObservable: Observable<{
  45695. message?: string;
  45696. exception?: any;
  45697. }>;
  45698. /**
  45699. * constructor
  45700. * @param options Defines the options we want to customize the helper
  45701. * @param scene The scene to add the material to
  45702. */
  45703. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  45704. /**
  45705. * Updates the background according to the new options
  45706. * @param options
  45707. */
  45708. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  45709. /**
  45710. * Sets the primary color of all the available elements.
  45711. * @param color the main color to affect to the ground and the background
  45712. */
  45713. setMainColor(color: Color3): void;
  45714. /**
  45715. * Setup the image processing according to the specified options.
  45716. */
  45717. private _setupImageProcessing;
  45718. /**
  45719. * Setup the environment texture according to the specified options.
  45720. */
  45721. private _setupEnvironmentTexture;
  45722. /**
  45723. * Setup the background according to the specified options.
  45724. */
  45725. private _setupBackground;
  45726. /**
  45727. * Get the scene sizes according to the setup.
  45728. */
  45729. private _getSceneSize;
  45730. /**
  45731. * Setup the ground according to the specified options.
  45732. */
  45733. private _setupGround;
  45734. /**
  45735. * Setup the ground material according to the specified options.
  45736. */
  45737. private _setupGroundMaterial;
  45738. /**
  45739. * Setup the ground diffuse texture according to the specified options.
  45740. */
  45741. private _setupGroundDiffuseTexture;
  45742. /**
  45743. * Setup the ground mirror texture according to the specified options.
  45744. */
  45745. private _setupGroundMirrorTexture;
  45746. /**
  45747. * Setup the ground to receive the mirror texture.
  45748. */
  45749. private _setupMirrorInGroundMaterial;
  45750. /**
  45751. * Setup the skybox according to the specified options.
  45752. */
  45753. private _setupSkybox;
  45754. /**
  45755. * Setup the skybox material according to the specified options.
  45756. */
  45757. private _setupSkyboxMaterial;
  45758. /**
  45759. * Setup the skybox reflection texture according to the specified options.
  45760. */
  45761. private _setupSkyboxReflectionTexture;
  45762. private _errorHandler;
  45763. /**
  45764. * Dispose all the elements created by the Helper.
  45765. */
  45766. dispose(): void;
  45767. }
  45768. }
  45769. declare module "babylonjs/Helpers/photoDome" {
  45770. import { Observable } from "babylonjs/Misc/observable";
  45771. import { Nullable } from "babylonjs/types";
  45772. import { Scene } from "babylonjs/scene";
  45773. import { TransformNode } from "babylonjs/Meshes/transformNode";
  45774. import { Mesh } from "babylonjs/Meshes/mesh";
  45775. import { Texture } from "babylonjs/Materials/Textures/texture";
  45776. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  45777. import "babylonjs/Meshes/Builders/sphereBuilder";
  45778. /**
  45779. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  45780. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  45781. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  45782. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  45783. */
  45784. export class PhotoDome extends TransformNode {
  45785. private _useDirectMapping;
  45786. /**
  45787. * The texture being displayed on the sphere
  45788. */
  45789. protected _photoTexture: Texture;
  45790. /**
  45791. * Gets or sets the texture being displayed on the sphere
  45792. */
  45793. photoTexture: Texture;
  45794. /**
  45795. * Observable raised when an error occured while loading the 360 image
  45796. */
  45797. onLoadErrorObservable: Observable<string>;
  45798. /**
  45799. * The skybox material
  45800. */
  45801. protected _material: BackgroundMaterial;
  45802. /**
  45803. * The surface used for the skybox
  45804. */
  45805. protected _mesh: Mesh;
  45806. /**
  45807. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  45808. * Also see the options.resolution property.
  45809. */
  45810. fovMultiplier: number;
  45811. /**
  45812. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  45813. * @param name Element's name, child elements will append suffixes for their own names.
  45814. * @param urlsOfPhoto defines the url of the photo to display
  45815. * @param options defines an object containing optional or exposed sub element properties
  45816. * @param onError defines a callback called when an error occured while loading the texture
  45817. */
  45818. constructor(name: string, urlOfPhoto: string, options: {
  45819. resolution?: number;
  45820. size?: number;
  45821. useDirectMapping?: boolean;
  45822. faceForward?: boolean;
  45823. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  45824. /**
  45825. * Releases resources associated with this node.
  45826. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  45827. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  45828. */
  45829. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  45830. }
  45831. }
  45832. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  45833. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  45834. /** @hidden */
  45835. export var rgbdDecodePixelShader: {
  45836. name: string;
  45837. shader: string;
  45838. };
  45839. }
  45840. declare module "babylonjs/Misc/brdfTextureTools" {
  45841. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45842. import { Scene } from "babylonjs/scene";
  45843. import "babylonjs/Shaders/rgbdDecode.fragment";
  45844. /**
  45845. * Class used to host texture specific utilities
  45846. */
  45847. export class BRDFTextureTools {
  45848. /**
  45849. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  45850. * @param texture the texture to expand.
  45851. */
  45852. private static _ExpandDefaultBRDFTexture;
  45853. /**
  45854. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  45855. * @param scene defines the hosting scene
  45856. * @returns the environment BRDF texture
  45857. */
  45858. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  45859. private static _environmentBRDFBase64Texture;
  45860. }
  45861. }
  45862. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  45863. import { Nullable } from "babylonjs/types";
  45864. import { IAnimatable } from "babylonjs/Misc/tools";
  45865. import { Color3 } from "babylonjs/Maths/math";
  45866. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45867. import { EffectFallbacks } from "babylonjs/Materials/effect";
  45868. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  45869. import { Engine } from "babylonjs/Engines/engine";
  45870. import { Scene } from "babylonjs/scene";
  45871. /**
  45872. * @hidden
  45873. */
  45874. export interface IMaterialClearCoatDefines {
  45875. CLEARCOAT: boolean;
  45876. CLEARCOAT_DEFAULTIOR: boolean;
  45877. CLEARCOAT_TEXTURE: boolean;
  45878. CLEARCOAT_TEXTUREDIRECTUV: number;
  45879. CLEARCOAT_BUMP: boolean;
  45880. CLEARCOAT_BUMPDIRECTUV: number;
  45881. CLEARCOAT_TINT: boolean;
  45882. CLEARCOAT_TINT_TEXTURE: boolean;
  45883. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  45884. /** @hidden */
  45885. _areTexturesDirty: boolean;
  45886. }
  45887. /**
  45888. * Define the code related to the clear coat parameters of the pbr material.
  45889. */
  45890. export class PBRClearCoatConfiguration {
  45891. /**
  45892. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  45893. * The default fits with a polyurethane material.
  45894. */
  45895. private static readonly _DefaultIndiceOfRefraction;
  45896. private _isEnabled;
  45897. /**
  45898. * Defines if the clear coat is enabled in the material.
  45899. */
  45900. isEnabled: boolean;
  45901. /**
  45902. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  45903. */
  45904. intensity: number;
  45905. /**
  45906. * Defines the clear coat layer roughness.
  45907. */
  45908. roughness: number;
  45909. private _indiceOfRefraction;
  45910. /**
  45911. * Defines the indice of refraction of the clear coat.
  45912. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  45913. * The default fits with a polyurethane material.
  45914. * Changing the default value is more performance intensive.
  45915. */
  45916. indiceOfRefraction: number;
  45917. private _texture;
  45918. /**
  45919. * Stores the clear coat values in a texture.
  45920. */
  45921. texture: Nullable<BaseTexture>;
  45922. private _bumpTexture;
  45923. /**
  45924. * Define the clear coat specific bump texture.
  45925. */
  45926. bumpTexture: Nullable<BaseTexture>;
  45927. private _isTintEnabled;
  45928. /**
  45929. * Defines if the clear coat tint is enabled in the material.
  45930. */
  45931. isTintEnabled: boolean;
  45932. /**
  45933. * Defines the clear coat tint of the material.
  45934. * This is only use if tint is enabled
  45935. */
  45936. tintColor: Color3;
  45937. /**
  45938. * Defines the distance at which the tint color should be found in the
  45939. * clear coat media.
  45940. * This is only use if tint is enabled
  45941. */
  45942. tintColorAtDistance: number;
  45943. /**
  45944. * Defines the clear coat layer thickness.
  45945. * This is only use if tint is enabled
  45946. */
  45947. tintThickness: number;
  45948. private _tintTexture;
  45949. /**
  45950. * Stores the clear tint values in a texture.
  45951. * rgb is tint
  45952. * a is a thickness factor
  45953. */
  45954. tintTexture: Nullable<BaseTexture>;
  45955. /** @hidden */
  45956. private _internalMarkAllSubMeshesAsTexturesDirty;
  45957. /** @hidden */
  45958. _markAllSubMeshesAsTexturesDirty(): void;
  45959. /**
  45960. * Instantiate a new istance of clear coat configuration.
  45961. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  45962. */
  45963. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  45964. /**
  45965. * Gets wehter the submesh is ready to be used or not.
  45966. * @param defines the list of "defines" to update.
  45967. * @param scene defines the scene the material belongs to.
  45968. * @param engine defines the engine the material belongs to.
  45969. * @param disableBumpMap defines wether the material disables bump or not.
  45970. * @returns - boolean indicating that the submesh is ready or not.
  45971. */
  45972. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  45973. /**
  45974. * Checks to see if a texture is used in the material.
  45975. * @param defines the list of "defines" to update.
  45976. * @param scene defines the scene to the material belongs to.
  45977. */
  45978. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  45979. /**
  45980. * Binds the material data.
  45981. * @param uniformBuffer defines the Uniform buffer to fill in.
  45982. * @param scene defines the scene the material belongs to.
  45983. * @param engine defines the engine the material belongs to.
  45984. * @param disableBumpMap defines wether the material disables bump or not.
  45985. * @param isFrozen defines wether the material is frozen or not.
  45986. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  45987. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  45988. */
  45989. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  45990. /**
  45991. * Checks to see if a texture is used in the material.
  45992. * @param texture - Base texture to use.
  45993. * @returns - Boolean specifying if a texture is used in the material.
  45994. */
  45995. hasTexture(texture: BaseTexture): boolean;
  45996. /**
  45997. * Returns an array of the actively used textures.
  45998. * @param activeTextures Array of BaseTextures
  45999. */
  46000. getActiveTextures(activeTextures: BaseTexture[]): void;
  46001. /**
  46002. * Returns the animatable textures.
  46003. * @param animatables Array of animatable textures.
  46004. */
  46005. getAnimatables(animatables: IAnimatable[]): void;
  46006. /**
  46007. * Disposes the resources of the material.
  46008. * @param forceDisposeTextures - Forces the disposal of all textures.
  46009. */
  46010. dispose(forceDisposeTextures?: boolean): void;
  46011. /**
  46012. * Get the current class name of the texture useful for serialization or dynamic coding.
  46013. * @returns "PBRClearCoatConfiguration"
  46014. */
  46015. getClassName(): string;
  46016. /**
  46017. * Add fallbacks to the effect fallbacks list.
  46018. * @param defines defines the Base texture to use.
  46019. * @param fallbacks defines the current fallback list.
  46020. * @param currentRank defines the current fallback rank.
  46021. * @returns the new fallback rank.
  46022. */
  46023. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46024. /**
  46025. * Add the required uniforms to the current list.
  46026. * @param uniforms defines the current uniform list.
  46027. */
  46028. static AddUniforms(uniforms: string[]): void;
  46029. /**
  46030. * Add the required samplers to the current list.
  46031. * @param samplers defines the current sampler list.
  46032. */
  46033. static AddSamplers(samplers: string[]): void;
  46034. /**
  46035. * Add the required uniforms to the current buffer.
  46036. * @param uniformBuffer defines the current uniform buffer.
  46037. */
  46038. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46039. /**
  46040. * Makes a duplicate of the current configuration into another one.
  46041. * @param clearCoatConfiguration define the config where to copy the info
  46042. */
  46043. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  46044. /**
  46045. * Serializes this clear coat configuration.
  46046. * @returns - An object with the serialized config.
  46047. */
  46048. serialize(): any;
  46049. /**
  46050. * Parses a Clear Coat Configuration from a serialized object.
  46051. * @param source - Serialized object.
  46052. */
  46053. parse(source: any): void;
  46054. }
  46055. }
  46056. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  46057. import { EffectFallbacks } from "babylonjs/Materials/effect";
  46058. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  46059. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46060. import { Vector2 } from "babylonjs/Maths/math";
  46061. import { Scene } from "babylonjs/scene";
  46062. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46063. import { IAnimatable } from "babylonjs/Misc/tools";
  46064. import { Nullable } from "babylonjs/types";
  46065. /**
  46066. * @hidden
  46067. */
  46068. export interface IMaterialAnisotropicDefines {
  46069. ANISOTROPIC: boolean;
  46070. ANISOTROPIC_TEXTURE: boolean;
  46071. ANISOTROPIC_TEXTUREDIRECTUV: number;
  46072. MAINUV1: boolean;
  46073. _areTexturesDirty: boolean;
  46074. _needUVs: boolean;
  46075. }
  46076. /**
  46077. * Define the code related to the anisotropic parameters of the pbr material.
  46078. */
  46079. export class PBRAnisotropicConfiguration {
  46080. private _isEnabled;
  46081. /**
  46082. * Defines if the anisotropy is enabled in the material.
  46083. */
  46084. isEnabled: boolean;
  46085. /**
  46086. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  46087. */
  46088. intensity: number;
  46089. /**
  46090. * Defines if the effect is along the tangents, bitangents or in between.
  46091. * By default, the effect is "strectching" the highlights along the tangents.
  46092. */
  46093. direction: Vector2;
  46094. private _texture;
  46095. /**
  46096. * Stores the anisotropy values in a texture.
  46097. * rg is direction (like normal from -1 to 1)
  46098. * b is a intensity
  46099. */
  46100. texture: Nullable<BaseTexture>;
  46101. /** @hidden */
  46102. private _internalMarkAllSubMeshesAsTexturesDirty;
  46103. /** @hidden */
  46104. _markAllSubMeshesAsTexturesDirty(): void;
  46105. /**
  46106. * Instantiate a new istance of anisotropy configuration.
  46107. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46108. */
  46109. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46110. /**
  46111. * Specifies that the submesh is ready to be used.
  46112. * @param defines the list of "defines" to update.
  46113. * @param scene defines the scene the material belongs to.
  46114. * @returns - boolean indicating that the submesh is ready or not.
  46115. */
  46116. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  46117. /**
  46118. * Checks to see if a texture is used in the material.
  46119. * @param defines the list of "defines" to update.
  46120. * @param mesh the mesh we are preparing the defines for.
  46121. * @param scene defines the scene the material belongs to.
  46122. */
  46123. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  46124. /**
  46125. * Binds the material data.
  46126. * @param uniformBuffer defines the Uniform buffer to fill in.
  46127. * @param scene defines the scene the material belongs to.
  46128. * @param isFrozen defines wether the material is frozen or not.
  46129. */
  46130. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  46131. /**
  46132. * Checks to see if a texture is used in the material.
  46133. * @param texture - Base texture to use.
  46134. * @returns - Boolean specifying if a texture is used in the material.
  46135. */
  46136. hasTexture(texture: BaseTexture): boolean;
  46137. /**
  46138. * Returns an array of the actively used textures.
  46139. * @param activeTextures Array of BaseTextures
  46140. */
  46141. getActiveTextures(activeTextures: BaseTexture[]): void;
  46142. /**
  46143. * Returns the animatable textures.
  46144. * @param animatables Array of animatable textures.
  46145. */
  46146. getAnimatables(animatables: IAnimatable[]): void;
  46147. /**
  46148. * Disposes the resources of the material.
  46149. * @param forceDisposeTextures - Forces the disposal of all textures.
  46150. */
  46151. dispose(forceDisposeTextures?: boolean): void;
  46152. /**
  46153. * Get the current class name of the texture useful for serialization or dynamic coding.
  46154. * @returns "PBRAnisotropicConfiguration"
  46155. */
  46156. getClassName(): string;
  46157. /**
  46158. * Add fallbacks to the effect fallbacks list.
  46159. * @param defines defines the Base texture to use.
  46160. * @param fallbacks defines the current fallback list.
  46161. * @param currentRank defines the current fallback rank.
  46162. * @returns the new fallback rank.
  46163. */
  46164. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46165. /**
  46166. * Add the required uniforms to the current list.
  46167. * @param uniforms defines the current uniform list.
  46168. */
  46169. static AddUniforms(uniforms: string[]): void;
  46170. /**
  46171. * Add the required uniforms to the current buffer.
  46172. * @param uniformBuffer defines the current uniform buffer.
  46173. */
  46174. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46175. /**
  46176. * Add the required samplers to the current list.
  46177. * @param samplers defines the current sampler list.
  46178. */
  46179. static AddSamplers(samplers: string[]): void;
  46180. /**
  46181. * Makes a duplicate of the current configuration into another one.
  46182. * @param anisotropicConfiguration define the config where to copy the info
  46183. */
  46184. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  46185. /**
  46186. * Serializes this anisotropy configuration.
  46187. * @returns - An object with the serialized config.
  46188. */
  46189. serialize(): any;
  46190. /**
  46191. * Parses a anisotropy Configuration from a serialized object.
  46192. * @param source - Serialized object.
  46193. */
  46194. parse(source: any): void;
  46195. }
  46196. }
  46197. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  46198. /**
  46199. * @hidden
  46200. */
  46201. export interface IMaterialBRDFDefines {
  46202. BRDF_V_HEIGHT_CORRELATED: boolean;
  46203. MS_BRDF_ENERGY_CONSERVATION: boolean;
  46204. SPHERICAL_HARMONICS: boolean;
  46205. /** @hidden */
  46206. _areMiscDirty: boolean;
  46207. }
  46208. /**
  46209. * Define the code related to the BRDF parameters of the pbr material.
  46210. */
  46211. export class PBRBRDFConfiguration {
  46212. /**
  46213. * Default value used for the energy conservation.
  46214. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  46215. */
  46216. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  46217. /**
  46218. * Default value used for the Smith Visibility Height Correlated mode.
  46219. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  46220. */
  46221. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  46222. /**
  46223. * Default value used for the IBL diffuse part.
  46224. * This can help switching back to the polynomials mode globally which is a tiny bit
  46225. * less GPU intensive at the drawback of a lower quality.
  46226. */
  46227. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  46228. private _useEnergyConservation;
  46229. /**
  46230. * Defines if the material uses energy conservation.
  46231. */
  46232. useEnergyConservation: boolean;
  46233. private _useSmithVisibilityHeightCorrelated;
  46234. /**
  46235. * LEGACY Mode set to false
  46236. * Defines if the material uses height smith correlated visibility term.
  46237. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  46238. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  46239. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  46240. * Not relying on height correlated will also disable energy conservation.
  46241. */
  46242. useSmithVisibilityHeightCorrelated: boolean;
  46243. private _useSphericalHarmonics;
  46244. /**
  46245. * LEGACY Mode set to false
  46246. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  46247. * diffuse part of the IBL.
  46248. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  46249. * to the ground truth.
  46250. */
  46251. useSphericalHarmonics: boolean;
  46252. /** @hidden */
  46253. private _internalMarkAllSubMeshesAsMiscDirty;
  46254. /** @hidden */
  46255. _markAllSubMeshesAsMiscDirty(): void;
  46256. /**
  46257. * Instantiate a new istance of clear coat configuration.
  46258. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  46259. */
  46260. constructor(markAllSubMeshesAsMiscDirty: () => void);
  46261. /**
  46262. * Checks to see if a texture is used in the material.
  46263. * @param defines the list of "defines" to update.
  46264. */
  46265. prepareDefines(defines: IMaterialBRDFDefines): void;
  46266. /**
  46267. * Get the current class name of the texture useful for serialization or dynamic coding.
  46268. * @returns "PBRClearCoatConfiguration"
  46269. */
  46270. getClassName(): string;
  46271. /**
  46272. * Makes a duplicate of the current configuration into another one.
  46273. * @param brdfConfiguration define the config where to copy the info
  46274. */
  46275. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  46276. /**
  46277. * Serializes this BRDF configuration.
  46278. * @returns - An object with the serialized config.
  46279. */
  46280. serialize(): any;
  46281. /**
  46282. * Parses a BRDF Configuration from a serialized object.
  46283. * @param source - Serialized object.
  46284. */
  46285. parse(source: any): void;
  46286. }
  46287. }
  46288. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  46289. import { EffectFallbacks } from "babylonjs/Materials/effect";
  46290. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  46291. import { Color3 } from "babylonjs/Maths/math";
  46292. import { Scene } from "babylonjs/scene";
  46293. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46294. import { IAnimatable } from "babylonjs/Misc/tools";
  46295. import { Nullable } from "babylonjs/types";
  46296. /**
  46297. * @hidden
  46298. */
  46299. export interface IMaterialSheenDefines {
  46300. SHEEN: boolean;
  46301. SHEEN_TEXTURE: boolean;
  46302. SHEEN_TEXTUREDIRECTUV: number;
  46303. SHEEN_LINKWITHALBEDO: boolean;
  46304. /** @hidden */
  46305. _areTexturesDirty: boolean;
  46306. }
  46307. /**
  46308. * Define the code related to the Sheen parameters of the pbr material.
  46309. */
  46310. export class PBRSheenConfiguration {
  46311. private _isEnabled;
  46312. /**
  46313. * Defines if the material uses sheen.
  46314. */
  46315. isEnabled: boolean;
  46316. private _linkSheenWithAlbedo;
  46317. /**
  46318. * Defines if the sheen is linked to the sheen color.
  46319. */
  46320. linkSheenWithAlbedo: boolean;
  46321. /**
  46322. * Defines the sheen intensity.
  46323. */
  46324. intensity: number;
  46325. /**
  46326. * Defines the sheen color.
  46327. */
  46328. color: Color3;
  46329. private _texture;
  46330. /**
  46331. * Stores the sheen tint values in a texture.
  46332. * rgb is tint
  46333. * a is a intensity
  46334. */
  46335. texture: Nullable<BaseTexture>;
  46336. /** @hidden */
  46337. private _internalMarkAllSubMeshesAsTexturesDirty;
  46338. /** @hidden */
  46339. _markAllSubMeshesAsTexturesDirty(): void;
  46340. /**
  46341. * Instantiate a new istance of clear coat configuration.
  46342. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46343. */
  46344. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46345. /**
  46346. * Specifies that the submesh is ready to be used.
  46347. * @param defines the list of "defines" to update.
  46348. * @param scene defines the scene the material belongs to.
  46349. * @returns - boolean indicating that the submesh is ready or not.
  46350. */
  46351. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  46352. /**
  46353. * Checks to see if a texture is used in the material.
  46354. * @param defines the list of "defines" to update.
  46355. * @param scene defines the scene the material belongs to.
  46356. */
  46357. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  46358. /**
  46359. * Binds the material data.
  46360. * @param uniformBuffer defines the Uniform buffer to fill in.
  46361. * @param scene defines the scene the material belongs to.
  46362. * @param isFrozen defines wether the material is frozen or not.
  46363. */
  46364. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  46365. /**
  46366. * Checks to see if a texture is used in the material.
  46367. * @param texture - Base texture to use.
  46368. * @returns - Boolean specifying if a texture is used in the material.
  46369. */
  46370. hasTexture(texture: BaseTexture): boolean;
  46371. /**
  46372. * Returns an array of the actively used textures.
  46373. * @param activeTextures Array of BaseTextures
  46374. */
  46375. getActiveTextures(activeTextures: BaseTexture[]): void;
  46376. /**
  46377. * Returns the animatable textures.
  46378. * @param animatables Array of animatable textures.
  46379. */
  46380. getAnimatables(animatables: IAnimatable[]): void;
  46381. /**
  46382. * Disposes the resources of the material.
  46383. * @param forceDisposeTextures - Forces the disposal of all textures.
  46384. */
  46385. dispose(forceDisposeTextures?: boolean): void;
  46386. /**
  46387. * Get the current class name of the texture useful for serialization or dynamic coding.
  46388. * @returns "PBRSheenConfiguration"
  46389. */
  46390. getClassName(): string;
  46391. /**
  46392. * Add fallbacks to the effect fallbacks list.
  46393. * @param defines defines the Base texture to use.
  46394. * @param fallbacks defines the current fallback list.
  46395. * @param currentRank defines the current fallback rank.
  46396. * @returns the new fallback rank.
  46397. */
  46398. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46399. /**
  46400. * Add the required uniforms to the current list.
  46401. * @param uniforms defines the current uniform list.
  46402. */
  46403. static AddUniforms(uniforms: string[]): void;
  46404. /**
  46405. * Add the required uniforms to the current buffer.
  46406. * @param uniformBuffer defines the current uniform buffer.
  46407. */
  46408. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46409. /**
  46410. * Add the required samplers to the current list.
  46411. * @param samplers defines the current sampler list.
  46412. */
  46413. static AddSamplers(samplers: string[]): void;
  46414. /**
  46415. * Makes a duplicate of the current configuration into another one.
  46416. * @param sheenConfiguration define the config where to copy the info
  46417. */
  46418. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  46419. /**
  46420. * Serializes this BRDF configuration.
  46421. * @returns - An object with the serialized config.
  46422. */
  46423. serialize(): any;
  46424. /**
  46425. * Parses a Sheen Configuration from a serialized object.
  46426. * @param source - Serialized object.
  46427. */
  46428. parse(source: any): void;
  46429. }
  46430. }
  46431. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  46432. import { Nullable } from "babylonjs/types";
  46433. import { IAnimatable } from "babylonjs/Misc/tools";
  46434. import { Color3 } from "babylonjs/Maths/math";
  46435. import { SmartArray } from "babylonjs/Misc/smartArray";
  46436. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46437. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  46438. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  46439. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  46440. import { Engine } from "babylonjs/Engines/engine";
  46441. import { Scene } from "babylonjs/scene";
  46442. /**
  46443. * @hidden
  46444. */
  46445. export interface IMaterialSubSurfaceDefines {
  46446. SUBSURFACE: boolean;
  46447. SS_REFRACTION: boolean;
  46448. SS_TRANSLUCENCY: boolean;
  46449. SS_SCATERRING: boolean;
  46450. SS_THICKNESSANDMASK_TEXTURE: boolean;
  46451. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  46452. SS_REFRACTIONMAP_3D: boolean;
  46453. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  46454. SS_LODINREFRACTIONALPHA: boolean;
  46455. SS_GAMMAREFRACTION: boolean;
  46456. SS_RGBDREFRACTION: boolean;
  46457. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  46458. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  46459. /** @hidden */
  46460. _areTexturesDirty: boolean;
  46461. }
  46462. /**
  46463. * Define the code related to the sub surface parameters of the pbr material.
  46464. */
  46465. export class PBRSubSurfaceConfiguration {
  46466. private _isRefractionEnabled;
  46467. /**
  46468. * Defines if the refraction is enabled in the material.
  46469. */
  46470. isRefractionEnabled: boolean;
  46471. private _isTranslucencyEnabled;
  46472. /**
  46473. * Defines if the translucency is enabled in the material.
  46474. */
  46475. isTranslucencyEnabled: boolean;
  46476. private _isScatteringEnabled;
  46477. /**
  46478. * Defines the refraction intensity of the material.
  46479. * The refraction when enabled replaces the Diffuse part of the material.
  46480. * The intensity helps transitionning between diffuse and refraction.
  46481. */
  46482. refractionIntensity: number;
  46483. /**
  46484. * Defines the translucency intensity of the material.
  46485. * When translucency has been enabled, this defines how much of the "translucency"
  46486. * is addded to the diffuse part of the material.
  46487. */
  46488. translucencyIntensity: number;
  46489. /**
  46490. * Defines the scattering intensity of the material.
  46491. * When scattering has been enabled, this defines how much of the "scattered light"
  46492. * is addded to the diffuse part of the material.
  46493. */
  46494. scatteringIntensity: number;
  46495. private _thicknessTexture;
  46496. /**
  46497. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  46498. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  46499. * 0 would mean minimumThickness
  46500. * 1 would mean maximumThickness
  46501. * The other channels might be use as a mask to vary the different effects intensity.
  46502. */
  46503. thicknessTexture: Nullable<BaseTexture>;
  46504. private _refractionTexture;
  46505. /**
  46506. * Defines the texture to use for refraction.
  46507. */
  46508. refractionTexture: Nullable<BaseTexture>;
  46509. private _indexOfRefraction;
  46510. /**
  46511. * Defines the indice of refraction used in the material.
  46512. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  46513. */
  46514. indexOfRefraction: number;
  46515. private _invertRefractionY;
  46516. /**
  46517. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  46518. */
  46519. invertRefractionY: boolean;
  46520. private _linkRefractionWithTransparency;
  46521. /**
  46522. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  46523. * Materials half opaque for instance using refraction could benefit from this control.
  46524. */
  46525. linkRefractionWithTransparency: boolean;
  46526. /**
  46527. * Defines the minimum thickness stored in the thickness map.
  46528. * If no thickness map is defined, this value will be used to simulate thickness.
  46529. */
  46530. minimumThickness: number;
  46531. /**
  46532. * Defines the maximum thickness stored in the thickness map.
  46533. */
  46534. maximumThickness: number;
  46535. /**
  46536. * Defines the volume tint of the material.
  46537. * This is used for both translucency and scattering.
  46538. */
  46539. tintColor: Color3;
  46540. /**
  46541. * Defines the distance at which the tint color should be found in the media.
  46542. * This is used for refraction only.
  46543. */
  46544. tintColorAtDistance: number;
  46545. /**
  46546. * Defines how far each channel transmit through the media.
  46547. * It is defined as a color to simplify it selection.
  46548. */
  46549. diffusionDistance: Color3;
  46550. private _useMaskFromThicknessTexture;
  46551. /**
  46552. * Stores the intensity of the different subsurface effects in the thickness texture.
  46553. * * the green channel is the translucency intensity.
  46554. * * the blue channel is the scattering intensity.
  46555. * * the alpha channel is the refraction intensity.
  46556. */
  46557. useMaskFromThicknessTexture: boolean;
  46558. /** @hidden */
  46559. private _internalMarkAllSubMeshesAsTexturesDirty;
  46560. /** @hidden */
  46561. _markAllSubMeshesAsTexturesDirty(): void;
  46562. /**
  46563. * Instantiate a new istance of sub surface configuration.
  46564. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46565. */
  46566. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46567. /**
  46568. * Gets wehter the submesh is ready to be used or not.
  46569. * @param defines the list of "defines" to update.
  46570. * @param scene defines the scene the material belongs to.
  46571. * @returns - boolean indicating that the submesh is ready or not.
  46572. */
  46573. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  46574. /**
  46575. * Checks to see if a texture is used in the material.
  46576. * @param defines the list of "defines" to update.
  46577. * @param scene defines the scene to the material belongs to.
  46578. */
  46579. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  46580. /**
  46581. * Binds the material data.
  46582. * @param uniformBuffer defines the Uniform buffer to fill in.
  46583. * @param scene defines the scene the material belongs to.
  46584. * @param engine defines the engine the material belongs to.
  46585. * @param isFrozen defines wether the material is frozen or not.
  46586. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  46587. */
  46588. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  46589. /**
  46590. * Unbinds the material from the mesh.
  46591. * @param activeEffect defines the effect that should be unbound from.
  46592. * @returns true if unbound, otherwise false
  46593. */
  46594. unbind(activeEffect: Effect): boolean;
  46595. /**
  46596. * Returns the texture used for refraction or null if none is used.
  46597. * @param scene defines the scene the material belongs to.
  46598. * @returns - Refraction texture if present. If no refraction texture and refraction
  46599. * is linked with transparency, returns environment texture. Otherwise, returns null.
  46600. */
  46601. private _getRefractionTexture;
  46602. /**
  46603. * Returns true if alpha blending should be disabled.
  46604. */
  46605. readonly disableAlphaBlending: boolean;
  46606. /**
  46607. * Fills the list of render target textures.
  46608. * @param renderTargets the list of render targets to update
  46609. */
  46610. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  46611. /**
  46612. * Checks to see if a texture is used in the material.
  46613. * @param texture - Base texture to use.
  46614. * @returns - Boolean specifying if a texture is used in the material.
  46615. */
  46616. hasTexture(texture: BaseTexture): boolean;
  46617. /**
  46618. * Gets a boolean indicating that current material needs to register RTT
  46619. * @returns true if this uses a render target otherwise false.
  46620. */
  46621. hasRenderTargetTextures(): boolean;
  46622. /**
  46623. * Returns an array of the actively used textures.
  46624. * @param activeTextures Array of BaseTextures
  46625. */
  46626. getActiveTextures(activeTextures: BaseTexture[]): void;
  46627. /**
  46628. * Returns the animatable textures.
  46629. * @param animatables Array of animatable textures.
  46630. */
  46631. getAnimatables(animatables: IAnimatable[]): void;
  46632. /**
  46633. * Disposes the resources of the material.
  46634. * @param forceDisposeTextures - Forces the disposal of all textures.
  46635. */
  46636. dispose(forceDisposeTextures?: boolean): void;
  46637. /**
  46638. * Get the current class name of the texture useful for serialization or dynamic coding.
  46639. * @returns "PBRSubSurfaceConfiguration"
  46640. */
  46641. getClassName(): string;
  46642. /**
  46643. * Add fallbacks to the effect fallbacks list.
  46644. * @param defines defines the Base texture to use.
  46645. * @param fallbacks defines the current fallback list.
  46646. * @param currentRank defines the current fallback rank.
  46647. * @returns the new fallback rank.
  46648. */
  46649. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46650. /**
  46651. * Add the required uniforms to the current list.
  46652. * @param uniforms defines the current uniform list.
  46653. */
  46654. static AddUniforms(uniforms: string[]): void;
  46655. /**
  46656. * Add the required samplers to the current list.
  46657. * @param samplers defines the current sampler list.
  46658. */
  46659. static AddSamplers(samplers: string[]): void;
  46660. /**
  46661. * Add the required uniforms to the current buffer.
  46662. * @param uniformBuffer defines the current uniform buffer.
  46663. */
  46664. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46665. /**
  46666. * Makes a duplicate of the current configuration into another one.
  46667. * @param configuration define the config where to copy the info
  46668. */
  46669. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  46670. /**
  46671. * Serializes this Sub Surface configuration.
  46672. * @returns - An object with the serialized config.
  46673. */
  46674. serialize(): any;
  46675. /**
  46676. * Parses a Sub Surface Configuration from a serialized object.
  46677. * @param source - Serialized object.
  46678. */
  46679. parse(source: any): void;
  46680. }
  46681. }
  46682. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  46683. /** @hidden */
  46684. export var pbrFragmentDeclaration: {
  46685. name: string;
  46686. shader: string;
  46687. };
  46688. }
  46689. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  46690. /** @hidden */
  46691. export var pbrUboDeclaration: {
  46692. name: string;
  46693. shader: string;
  46694. };
  46695. }
  46696. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  46697. /** @hidden */
  46698. export var pbrFragmentExtraDeclaration: {
  46699. name: string;
  46700. shader: string;
  46701. };
  46702. }
  46703. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  46704. /** @hidden */
  46705. export var pbrFragmentSamplersDeclaration: {
  46706. name: string;
  46707. shader: string;
  46708. };
  46709. }
  46710. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  46711. /** @hidden */
  46712. export var pbrHelperFunctions: {
  46713. name: string;
  46714. shader: string;
  46715. };
  46716. }
  46717. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  46718. /** @hidden */
  46719. export var harmonicsFunctions: {
  46720. name: string;
  46721. shader: string;
  46722. };
  46723. }
  46724. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  46725. /** @hidden */
  46726. export var pbrDirectLightingSetupFunctions: {
  46727. name: string;
  46728. shader: string;
  46729. };
  46730. }
  46731. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  46732. /** @hidden */
  46733. export var pbrDirectLightingFalloffFunctions: {
  46734. name: string;
  46735. shader: string;
  46736. };
  46737. }
  46738. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  46739. /** @hidden */
  46740. export var pbrBRDFFunctions: {
  46741. name: string;
  46742. shader: string;
  46743. };
  46744. }
  46745. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  46746. /** @hidden */
  46747. export var pbrDirectLightingFunctions: {
  46748. name: string;
  46749. shader: string;
  46750. };
  46751. }
  46752. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  46753. /** @hidden */
  46754. export var pbrIBLFunctions: {
  46755. name: string;
  46756. shader: string;
  46757. };
  46758. }
  46759. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  46760. /** @hidden */
  46761. export var pbrDebug: {
  46762. name: string;
  46763. shader: string;
  46764. };
  46765. }
  46766. declare module "babylonjs/Shaders/pbr.fragment" {
  46767. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  46768. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  46769. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  46770. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  46771. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  46772. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  46773. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  46774. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  46775. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  46776. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  46777. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46778. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  46779. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  46780. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  46781. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  46782. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  46783. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  46784. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  46785. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  46786. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  46787. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  46788. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  46789. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  46790. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  46791. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  46792. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  46793. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  46794. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  46795. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  46796. /** @hidden */
  46797. export var pbrPixelShader: {
  46798. name: string;
  46799. shader: string;
  46800. };
  46801. }
  46802. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  46803. /** @hidden */
  46804. export var pbrVertexDeclaration: {
  46805. name: string;
  46806. shader: string;
  46807. };
  46808. }
  46809. declare module "babylonjs/Shaders/pbr.vertex" {
  46810. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  46811. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  46812. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46813. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  46814. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  46815. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  46816. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  46817. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  46818. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  46819. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  46820. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  46821. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  46822. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  46823. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  46824. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  46825. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  46826. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  46827. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  46828. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  46829. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  46830. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  46831. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  46832. /** @hidden */
  46833. export var pbrVertexShader: {
  46834. name: string;
  46835. shader: string;
  46836. };
  46837. }
  46838. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  46839. import { IAnimatable } from "babylonjs/Misc/tools";
  46840. import { Nullable } from "babylonjs/types";
  46841. import { Scene } from "babylonjs/scene";
  46842. import { Matrix, Color3 } from "babylonjs/Maths/math";
  46843. import { SubMesh } from "babylonjs/Meshes/subMesh";
  46844. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46845. import { Mesh } from "babylonjs/Meshes/mesh";
  46846. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  46847. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  46848. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  46849. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  46850. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  46851. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  46852. import { Material } from "babylonjs/Materials/material";
  46853. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  46854. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  46855. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46856. import "babylonjs/Shaders/pbr.fragment";
  46857. import "babylonjs/Shaders/pbr.vertex";
  46858. /**
  46859. * Manages the defines for the PBR Material.
  46860. * @hidden
  46861. */
  46862. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  46863. PBR: boolean;
  46864. MAINUV1: boolean;
  46865. MAINUV2: boolean;
  46866. UV1: boolean;
  46867. UV2: boolean;
  46868. ALBEDO: boolean;
  46869. ALBEDODIRECTUV: number;
  46870. VERTEXCOLOR: boolean;
  46871. AMBIENT: boolean;
  46872. AMBIENTDIRECTUV: number;
  46873. AMBIENTINGRAYSCALE: boolean;
  46874. OPACITY: boolean;
  46875. VERTEXALPHA: boolean;
  46876. OPACITYDIRECTUV: number;
  46877. OPACITYRGB: boolean;
  46878. ALPHATEST: boolean;
  46879. DEPTHPREPASS: boolean;
  46880. ALPHABLEND: boolean;
  46881. ALPHAFROMALBEDO: boolean;
  46882. ALPHATESTVALUE: string;
  46883. SPECULAROVERALPHA: boolean;
  46884. RADIANCEOVERALPHA: boolean;
  46885. ALPHAFRESNEL: boolean;
  46886. LINEARALPHAFRESNEL: boolean;
  46887. PREMULTIPLYALPHA: boolean;
  46888. EMISSIVE: boolean;
  46889. EMISSIVEDIRECTUV: number;
  46890. REFLECTIVITY: boolean;
  46891. REFLECTIVITYDIRECTUV: number;
  46892. SPECULARTERM: boolean;
  46893. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  46894. MICROSURFACEAUTOMATIC: boolean;
  46895. LODBASEDMICROSFURACE: boolean;
  46896. MICROSURFACEMAP: boolean;
  46897. MICROSURFACEMAPDIRECTUV: number;
  46898. METALLICWORKFLOW: boolean;
  46899. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  46900. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  46901. METALLNESSSTOREINMETALMAPBLUE: boolean;
  46902. AOSTOREINMETALMAPRED: boolean;
  46903. ENVIRONMENTBRDF: boolean;
  46904. ENVIRONMENTBRDF_RGBD: boolean;
  46905. NORMAL: boolean;
  46906. TANGENT: boolean;
  46907. BUMP: boolean;
  46908. BUMPDIRECTUV: number;
  46909. OBJECTSPACE_NORMALMAP: boolean;
  46910. PARALLAX: boolean;
  46911. PARALLAXOCCLUSION: boolean;
  46912. NORMALXYSCALE: boolean;
  46913. LIGHTMAP: boolean;
  46914. LIGHTMAPDIRECTUV: number;
  46915. USELIGHTMAPASSHADOWMAP: boolean;
  46916. GAMMALIGHTMAP: boolean;
  46917. REFLECTION: boolean;
  46918. REFLECTIONMAP_3D: boolean;
  46919. REFLECTIONMAP_SPHERICAL: boolean;
  46920. REFLECTIONMAP_PLANAR: boolean;
  46921. REFLECTIONMAP_CUBIC: boolean;
  46922. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  46923. REFLECTIONMAP_PROJECTION: boolean;
  46924. REFLECTIONMAP_SKYBOX: boolean;
  46925. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  46926. REFLECTIONMAP_EXPLICIT: boolean;
  46927. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  46928. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  46929. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  46930. INVERTCUBICMAP: boolean;
  46931. USESPHERICALFROMREFLECTIONMAP: boolean;
  46932. SPHERICAL_HARMONICS: boolean;
  46933. USESPHERICALINVERTEX: boolean;
  46934. REFLECTIONMAP_OPPOSITEZ: boolean;
  46935. LODINREFLECTIONALPHA: boolean;
  46936. GAMMAREFLECTION: boolean;
  46937. RGBDREFLECTION: boolean;
  46938. RADIANCEOCCLUSION: boolean;
  46939. HORIZONOCCLUSION: boolean;
  46940. INSTANCES: boolean;
  46941. NUM_BONE_INFLUENCERS: number;
  46942. BonesPerMesh: number;
  46943. BONETEXTURE: boolean;
  46944. NONUNIFORMSCALING: boolean;
  46945. MORPHTARGETS: boolean;
  46946. MORPHTARGETS_NORMAL: boolean;
  46947. MORPHTARGETS_TANGENT: boolean;
  46948. NUM_MORPH_INFLUENCERS: number;
  46949. IMAGEPROCESSING: boolean;
  46950. VIGNETTE: boolean;
  46951. VIGNETTEBLENDMODEMULTIPLY: boolean;
  46952. VIGNETTEBLENDMODEOPAQUE: boolean;
  46953. TONEMAPPING: boolean;
  46954. TONEMAPPING_ACES: boolean;
  46955. CONTRAST: boolean;
  46956. COLORCURVES: boolean;
  46957. COLORGRADING: boolean;
  46958. COLORGRADING3D: boolean;
  46959. SAMPLER3DGREENDEPTH: boolean;
  46960. SAMPLER3DBGRMAP: boolean;
  46961. IMAGEPROCESSINGPOSTPROCESS: boolean;
  46962. EXPOSURE: boolean;
  46963. MULTIVIEW: boolean;
  46964. USEPHYSICALLIGHTFALLOFF: boolean;
  46965. USEGLTFLIGHTFALLOFF: boolean;
  46966. TWOSIDEDLIGHTING: boolean;
  46967. SHADOWFLOAT: boolean;
  46968. CLIPPLANE: boolean;
  46969. CLIPPLANE2: boolean;
  46970. CLIPPLANE3: boolean;
  46971. CLIPPLANE4: boolean;
  46972. POINTSIZE: boolean;
  46973. FOG: boolean;
  46974. LOGARITHMICDEPTH: boolean;
  46975. FORCENORMALFORWARD: boolean;
  46976. SPECULARAA: boolean;
  46977. CLEARCOAT: boolean;
  46978. CLEARCOAT_DEFAULTIOR: boolean;
  46979. CLEARCOAT_TEXTURE: boolean;
  46980. CLEARCOAT_TEXTUREDIRECTUV: number;
  46981. CLEARCOAT_BUMP: boolean;
  46982. CLEARCOAT_BUMPDIRECTUV: number;
  46983. CLEARCOAT_TINT: boolean;
  46984. CLEARCOAT_TINT_TEXTURE: boolean;
  46985. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  46986. ANISOTROPIC: boolean;
  46987. ANISOTROPIC_TEXTURE: boolean;
  46988. ANISOTROPIC_TEXTUREDIRECTUV: number;
  46989. BRDF_V_HEIGHT_CORRELATED: boolean;
  46990. MS_BRDF_ENERGY_CONSERVATION: boolean;
  46991. SHEEN: boolean;
  46992. SHEEN_TEXTURE: boolean;
  46993. SHEEN_TEXTUREDIRECTUV: number;
  46994. SHEEN_LINKWITHALBEDO: boolean;
  46995. SUBSURFACE: boolean;
  46996. SS_REFRACTION: boolean;
  46997. SS_TRANSLUCENCY: boolean;
  46998. SS_SCATERRING: boolean;
  46999. SS_THICKNESSANDMASK_TEXTURE: boolean;
  47000. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  47001. SS_REFRACTIONMAP_3D: boolean;
  47002. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  47003. SS_LODINREFRACTIONALPHA: boolean;
  47004. SS_GAMMAREFRACTION: boolean;
  47005. SS_RGBDREFRACTION: boolean;
  47006. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  47007. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  47008. UNLIT: boolean;
  47009. DEBUGMODE: number;
  47010. /**
  47011. * Initializes the PBR Material defines.
  47012. */
  47013. constructor();
  47014. /**
  47015. * Resets the PBR Material defines.
  47016. */
  47017. reset(): void;
  47018. }
  47019. /**
  47020. * The Physically based material base class of BJS.
  47021. *
  47022. * This offers the main features of a standard PBR material.
  47023. * For more information, please refer to the documentation :
  47024. * https://doc.babylonjs.com/how_to/physically_based_rendering
  47025. */
  47026. export abstract class PBRBaseMaterial extends PushMaterial {
  47027. /**
  47028. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  47029. */
  47030. static readonly PBRMATERIAL_OPAQUE: number;
  47031. /**
  47032. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  47033. */
  47034. static readonly PBRMATERIAL_ALPHATEST: number;
  47035. /**
  47036. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47037. */
  47038. static readonly PBRMATERIAL_ALPHABLEND: number;
  47039. /**
  47040. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47041. * They are also discarded below the alpha cutoff threshold to improve performances.
  47042. */
  47043. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  47044. /**
  47045. * Defines the default value of how much AO map is occluding the analytical lights
  47046. * (point spot...).
  47047. */
  47048. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  47049. /**
  47050. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  47051. */
  47052. static readonly LIGHTFALLOFF_PHYSICAL: number;
  47053. /**
  47054. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  47055. * to enhance interoperability with other engines.
  47056. */
  47057. static readonly LIGHTFALLOFF_GLTF: number;
  47058. /**
  47059. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  47060. * to enhance interoperability with other materials.
  47061. */
  47062. static readonly LIGHTFALLOFF_STANDARD: number;
  47063. /**
  47064. * Intensity of the direct lights e.g. the four lights available in your scene.
  47065. * This impacts both the direct diffuse and specular highlights.
  47066. */
  47067. protected _directIntensity: number;
  47068. /**
  47069. * Intensity of the emissive part of the material.
  47070. * This helps controlling the emissive effect without modifying the emissive color.
  47071. */
  47072. protected _emissiveIntensity: number;
  47073. /**
  47074. * Intensity of the environment e.g. how much the environment will light the object
  47075. * either through harmonics for rough material or through the refelction for shiny ones.
  47076. */
  47077. protected _environmentIntensity: number;
  47078. /**
  47079. * This is a special control allowing the reduction of the specular highlights coming from the
  47080. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  47081. */
  47082. protected _specularIntensity: number;
  47083. /**
  47084. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  47085. */
  47086. private _lightingInfos;
  47087. /**
  47088. * Debug Control allowing disabling the bump map on this material.
  47089. */
  47090. protected _disableBumpMap: boolean;
  47091. /**
  47092. * AKA Diffuse Texture in standard nomenclature.
  47093. */
  47094. protected _albedoTexture: Nullable<BaseTexture>;
  47095. /**
  47096. * AKA Occlusion Texture in other nomenclature.
  47097. */
  47098. protected _ambientTexture: Nullable<BaseTexture>;
  47099. /**
  47100. * AKA Occlusion Texture Intensity in other nomenclature.
  47101. */
  47102. protected _ambientTextureStrength: number;
  47103. /**
  47104. * Defines how much the AO map is occluding the analytical lights (point spot...).
  47105. * 1 means it completely occludes it
  47106. * 0 mean it has no impact
  47107. */
  47108. protected _ambientTextureImpactOnAnalyticalLights: number;
  47109. /**
  47110. * Stores the alpha values in a texture.
  47111. */
  47112. protected _opacityTexture: Nullable<BaseTexture>;
  47113. /**
  47114. * Stores the reflection values in a texture.
  47115. */
  47116. protected _reflectionTexture: Nullable<BaseTexture>;
  47117. /**
  47118. * Stores the emissive values in a texture.
  47119. */
  47120. protected _emissiveTexture: Nullable<BaseTexture>;
  47121. /**
  47122. * AKA Specular texture in other nomenclature.
  47123. */
  47124. protected _reflectivityTexture: Nullable<BaseTexture>;
  47125. /**
  47126. * Used to switch from specular/glossiness to metallic/roughness workflow.
  47127. */
  47128. protected _metallicTexture: Nullable<BaseTexture>;
  47129. /**
  47130. * Specifies the metallic scalar of the metallic/roughness workflow.
  47131. * Can also be used to scale the metalness values of the metallic texture.
  47132. */
  47133. protected _metallic: Nullable<number>;
  47134. /**
  47135. * Specifies the roughness scalar of the metallic/roughness workflow.
  47136. * Can also be used to scale the roughness values of the metallic texture.
  47137. */
  47138. protected _roughness: Nullable<number>;
  47139. /**
  47140. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  47141. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  47142. */
  47143. protected _microSurfaceTexture: Nullable<BaseTexture>;
  47144. /**
  47145. * Stores surface normal data used to displace a mesh in a texture.
  47146. */
  47147. protected _bumpTexture: Nullable<BaseTexture>;
  47148. /**
  47149. * Stores the pre-calculated light information of a mesh in a texture.
  47150. */
  47151. protected _lightmapTexture: Nullable<BaseTexture>;
  47152. /**
  47153. * The color of a material in ambient lighting.
  47154. */
  47155. protected _ambientColor: Color3;
  47156. /**
  47157. * AKA Diffuse Color in other nomenclature.
  47158. */
  47159. protected _albedoColor: Color3;
  47160. /**
  47161. * AKA Specular Color in other nomenclature.
  47162. */
  47163. protected _reflectivityColor: Color3;
  47164. /**
  47165. * The color applied when light is reflected from a material.
  47166. */
  47167. protected _reflectionColor: Color3;
  47168. /**
  47169. * The color applied when light is emitted from a material.
  47170. */
  47171. protected _emissiveColor: Color3;
  47172. /**
  47173. * AKA Glossiness in other nomenclature.
  47174. */
  47175. protected _microSurface: number;
  47176. /**
  47177. * Specifies that the material will use the light map as a show map.
  47178. */
  47179. protected _useLightmapAsShadowmap: boolean;
  47180. /**
  47181. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  47182. * makes the reflect vector face the model (under horizon).
  47183. */
  47184. protected _useHorizonOcclusion: boolean;
  47185. /**
  47186. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  47187. * too much the area relying on ambient texture to define their ambient occlusion.
  47188. */
  47189. protected _useRadianceOcclusion: boolean;
  47190. /**
  47191. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  47192. */
  47193. protected _useAlphaFromAlbedoTexture: boolean;
  47194. /**
  47195. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  47196. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  47197. */
  47198. protected _useSpecularOverAlpha: boolean;
  47199. /**
  47200. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  47201. */
  47202. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  47203. /**
  47204. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  47205. */
  47206. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  47207. /**
  47208. * Specifies if the metallic texture contains the roughness information in its green channel.
  47209. */
  47210. protected _useRoughnessFromMetallicTextureGreen: boolean;
  47211. /**
  47212. * Specifies if the metallic texture contains the metallness information in its blue channel.
  47213. */
  47214. protected _useMetallnessFromMetallicTextureBlue: boolean;
  47215. /**
  47216. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  47217. */
  47218. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  47219. /**
  47220. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  47221. */
  47222. protected _useAmbientInGrayScale: boolean;
  47223. /**
  47224. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  47225. * The material will try to infer what glossiness each pixel should be.
  47226. */
  47227. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  47228. /**
  47229. * Defines the falloff type used in this material.
  47230. * It by default is Physical.
  47231. */
  47232. protected _lightFalloff: number;
  47233. /**
  47234. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  47235. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  47236. */
  47237. protected _useRadianceOverAlpha: boolean;
  47238. /**
  47239. * Allows using an object space normal map (instead of tangent space).
  47240. */
  47241. protected _useObjectSpaceNormalMap: boolean;
  47242. /**
  47243. * Allows using the bump map in parallax mode.
  47244. */
  47245. protected _useParallax: boolean;
  47246. /**
  47247. * Allows using the bump map in parallax occlusion mode.
  47248. */
  47249. protected _useParallaxOcclusion: boolean;
  47250. /**
  47251. * Controls the scale bias of the parallax mode.
  47252. */
  47253. protected _parallaxScaleBias: number;
  47254. /**
  47255. * If sets to true, disables all the lights affecting the material.
  47256. */
  47257. protected _disableLighting: boolean;
  47258. /**
  47259. * Number of Simultaneous lights allowed on the material.
  47260. */
  47261. protected _maxSimultaneousLights: number;
  47262. /**
  47263. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  47264. */
  47265. protected _invertNormalMapX: boolean;
  47266. /**
  47267. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  47268. */
  47269. protected _invertNormalMapY: boolean;
  47270. /**
  47271. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  47272. */
  47273. protected _twoSidedLighting: boolean;
  47274. /**
  47275. * Defines the alpha limits in alpha test mode.
  47276. */
  47277. protected _alphaCutOff: number;
  47278. /**
  47279. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  47280. */
  47281. protected _forceAlphaTest: boolean;
  47282. /**
  47283. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47284. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  47285. */
  47286. protected _useAlphaFresnel: boolean;
  47287. /**
  47288. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47289. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  47290. */
  47291. protected _useLinearAlphaFresnel: boolean;
  47292. /**
  47293. * The transparency mode of the material.
  47294. */
  47295. protected _transparencyMode: Nullable<number>;
  47296. /**
  47297. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  47298. * from cos thetav and roughness:
  47299. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  47300. */
  47301. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  47302. /**
  47303. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  47304. */
  47305. protected _forceIrradianceInFragment: boolean;
  47306. /**
  47307. * Force normal to face away from face.
  47308. */
  47309. protected _forceNormalForward: boolean;
  47310. /**
  47311. * Enables specular anti aliasing in the PBR shader.
  47312. * It will both interacts on the Geometry for analytical and IBL lighting.
  47313. * It also prefilter the roughness map based on the bump values.
  47314. */
  47315. protected _enableSpecularAntiAliasing: boolean;
  47316. /**
  47317. * Default configuration related to image processing available in the PBR Material.
  47318. */
  47319. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  47320. /**
  47321. * Keep track of the image processing observer to allow dispose and replace.
  47322. */
  47323. private _imageProcessingObserver;
  47324. /**
  47325. * Attaches a new image processing configuration to the PBR Material.
  47326. * @param configuration
  47327. */
  47328. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  47329. /**
  47330. * Stores the available render targets.
  47331. */
  47332. private _renderTargets;
  47333. /**
  47334. * Sets the global ambient color for the material used in lighting calculations.
  47335. */
  47336. private _globalAmbientColor;
  47337. /**
  47338. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  47339. */
  47340. private _useLogarithmicDepth;
  47341. /**
  47342. * If set to true, no lighting calculations will be applied.
  47343. */
  47344. private _unlit;
  47345. private _debugMode;
  47346. /**
  47347. * @hidden
  47348. * This is reserved for the inspector.
  47349. * Defines the material debug mode.
  47350. * It helps seeing only some components of the material while troubleshooting.
  47351. */
  47352. debugMode: number;
  47353. /**
  47354. * @hidden
  47355. * This is reserved for the inspector.
  47356. * Specify from where on screen the debug mode should start.
  47357. * The value goes from -1 (full screen) to 1 (not visible)
  47358. * It helps with side by side comparison against the final render
  47359. * This defaults to -1
  47360. */
  47361. private debugLimit;
  47362. /**
  47363. * @hidden
  47364. * This is reserved for the inspector.
  47365. * As the default viewing range might not be enough (if the ambient is really small for instance)
  47366. * You can use the factor to better multiply the final value.
  47367. */
  47368. private debugFactor;
  47369. /**
  47370. * Defines the clear coat layer parameters for the material.
  47371. */
  47372. readonly clearCoat: PBRClearCoatConfiguration;
  47373. /**
  47374. * Defines the anisotropic parameters for the material.
  47375. */
  47376. readonly anisotropy: PBRAnisotropicConfiguration;
  47377. /**
  47378. * Defines the BRDF parameters for the material.
  47379. */
  47380. readonly brdf: PBRBRDFConfiguration;
  47381. /**
  47382. * Defines the Sheen parameters for the material.
  47383. */
  47384. readonly sheen: PBRSheenConfiguration;
  47385. /**
  47386. * Defines the SubSurface parameters for the material.
  47387. */
  47388. readonly subSurface: PBRSubSurfaceConfiguration;
  47389. /**
  47390. * Custom callback helping to override the default shader used in the material.
  47391. */
  47392. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  47393. /**
  47394. * Instantiates a new PBRMaterial instance.
  47395. *
  47396. * @param name The material name
  47397. * @param scene The scene the material will be use in.
  47398. */
  47399. constructor(name: string, scene: Scene);
  47400. /**
  47401. * Gets a boolean indicating that current material needs to register RTT
  47402. */
  47403. readonly hasRenderTargetTextures: boolean;
  47404. /**
  47405. * Gets the name of the material class.
  47406. */
  47407. getClassName(): string;
  47408. /**
  47409. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  47410. */
  47411. /**
  47412. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  47413. */
  47414. useLogarithmicDepth: boolean;
  47415. /**
  47416. * Gets the current transparency mode.
  47417. */
  47418. /**
  47419. * Sets the transparency mode of the material.
  47420. *
  47421. * | Value | Type | Description |
  47422. * | ----- | ----------------------------------- | ----------- |
  47423. * | 0 | OPAQUE | |
  47424. * | 1 | ALPHATEST | |
  47425. * | 2 | ALPHABLEND | |
  47426. * | 3 | ALPHATESTANDBLEND | |
  47427. *
  47428. */
  47429. transparencyMode: Nullable<number>;
  47430. /**
  47431. * Returns true if alpha blending should be disabled.
  47432. */
  47433. private readonly _disableAlphaBlending;
  47434. /**
  47435. * Specifies whether or not this material should be rendered in alpha blend mode.
  47436. */
  47437. needAlphaBlending(): boolean;
  47438. /**
  47439. * Specifies if the mesh will require alpha blending.
  47440. * @param mesh - BJS mesh.
  47441. */
  47442. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  47443. /**
  47444. * Specifies whether or not this material should be rendered in alpha test mode.
  47445. */
  47446. needAlphaTesting(): boolean;
  47447. /**
  47448. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  47449. */
  47450. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  47451. /**
  47452. * Gets the texture used for the alpha test.
  47453. */
  47454. getAlphaTestTexture(): Nullable<BaseTexture>;
  47455. /**
  47456. * Specifies that the submesh is ready to be used.
  47457. * @param mesh - BJS mesh.
  47458. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  47459. * @param useInstances - Specifies that instances should be used.
  47460. * @returns - boolean indicating that the submesh is ready or not.
  47461. */
  47462. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  47463. /**
  47464. * Specifies if the material uses metallic roughness workflow.
  47465. * @returns boolean specifiying if the material uses metallic roughness workflow.
  47466. */
  47467. isMetallicWorkflow(): boolean;
  47468. private _prepareEffect;
  47469. private _prepareDefines;
  47470. /**
  47471. * Force shader compilation
  47472. */
  47473. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  47474. clipPlane: boolean;
  47475. }>): void;
  47476. /**
  47477. * Initializes the uniform buffer layout for the shader.
  47478. */
  47479. buildUniformLayout(): void;
  47480. /**
  47481. * Unbinds the material from the mesh
  47482. */
  47483. unbind(): void;
  47484. /**
  47485. * Binds the submesh data.
  47486. * @param world - The world matrix.
  47487. * @param mesh - The BJS mesh.
  47488. * @param subMesh - A submesh of the BJS mesh.
  47489. */
  47490. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  47491. /**
  47492. * Returns the animatable textures.
  47493. * @returns - Array of animatable textures.
  47494. */
  47495. getAnimatables(): IAnimatable[];
  47496. /**
  47497. * Returns the texture used for reflections.
  47498. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  47499. */
  47500. private _getReflectionTexture;
  47501. /**
  47502. * Returns an array of the actively used textures.
  47503. * @returns - Array of BaseTextures
  47504. */
  47505. getActiveTextures(): BaseTexture[];
  47506. /**
  47507. * Checks to see if a texture is used in the material.
  47508. * @param texture - Base texture to use.
  47509. * @returns - Boolean specifying if a texture is used in the material.
  47510. */
  47511. hasTexture(texture: BaseTexture): boolean;
  47512. /**
  47513. * Disposes the resources of the material.
  47514. * @param forceDisposeEffect - Forces the disposal of effects.
  47515. * @param forceDisposeTextures - Forces the disposal of all textures.
  47516. */
  47517. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  47518. }
  47519. }
  47520. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  47521. import { Nullable } from "babylonjs/types";
  47522. import { Scene } from "babylonjs/scene";
  47523. import { Color3 } from "babylonjs/Maths/math";
  47524. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  47525. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  47526. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47527. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  47528. /**
  47529. * The Physically based material of BJS.
  47530. *
  47531. * This offers the main features of a standard PBR material.
  47532. * For more information, please refer to the documentation :
  47533. * https://doc.babylonjs.com/how_to/physically_based_rendering
  47534. */
  47535. export class PBRMaterial extends PBRBaseMaterial {
  47536. /**
  47537. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  47538. */
  47539. static readonly PBRMATERIAL_OPAQUE: number;
  47540. /**
  47541. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  47542. */
  47543. static readonly PBRMATERIAL_ALPHATEST: number;
  47544. /**
  47545. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47546. */
  47547. static readonly PBRMATERIAL_ALPHABLEND: number;
  47548. /**
  47549. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47550. * They are also discarded below the alpha cutoff threshold to improve performances.
  47551. */
  47552. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  47553. /**
  47554. * Defines the default value of how much AO map is occluding the analytical lights
  47555. * (point spot...).
  47556. */
  47557. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  47558. /**
  47559. * Intensity of the direct lights e.g. the four lights available in your scene.
  47560. * This impacts both the direct diffuse and specular highlights.
  47561. */
  47562. directIntensity: number;
  47563. /**
  47564. * Intensity of the emissive part of the material.
  47565. * This helps controlling the emissive effect without modifying the emissive color.
  47566. */
  47567. emissiveIntensity: number;
  47568. /**
  47569. * Intensity of the environment e.g. how much the environment will light the object
  47570. * either through harmonics for rough material or through the refelction for shiny ones.
  47571. */
  47572. environmentIntensity: number;
  47573. /**
  47574. * This is a special control allowing the reduction of the specular highlights coming from the
  47575. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  47576. */
  47577. specularIntensity: number;
  47578. /**
  47579. * Debug Control allowing disabling the bump map on this material.
  47580. */
  47581. disableBumpMap: boolean;
  47582. /**
  47583. * AKA Diffuse Texture in standard nomenclature.
  47584. */
  47585. albedoTexture: BaseTexture;
  47586. /**
  47587. * AKA Occlusion Texture in other nomenclature.
  47588. */
  47589. ambientTexture: BaseTexture;
  47590. /**
  47591. * AKA Occlusion Texture Intensity in other nomenclature.
  47592. */
  47593. ambientTextureStrength: number;
  47594. /**
  47595. * Defines how much the AO map is occluding the analytical lights (point spot...).
  47596. * 1 means it completely occludes it
  47597. * 0 mean it has no impact
  47598. */
  47599. ambientTextureImpactOnAnalyticalLights: number;
  47600. /**
  47601. * Stores the alpha values in a texture.
  47602. */
  47603. opacityTexture: BaseTexture;
  47604. /**
  47605. * Stores the reflection values in a texture.
  47606. */
  47607. reflectionTexture: Nullable<BaseTexture>;
  47608. /**
  47609. * Stores the emissive values in a texture.
  47610. */
  47611. emissiveTexture: BaseTexture;
  47612. /**
  47613. * AKA Specular texture in other nomenclature.
  47614. */
  47615. reflectivityTexture: BaseTexture;
  47616. /**
  47617. * Used to switch from specular/glossiness to metallic/roughness workflow.
  47618. */
  47619. metallicTexture: BaseTexture;
  47620. /**
  47621. * Specifies the metallic scalar of the metallic/roughness workflow.
  47622. * Can also be used to scale the metalness values of the metallic texture.
  47623. */
  47624. metallic: Nullable<number>;
  47625. /**
  47626. * Specifies the roughness scalar of the metallic/roughness workflow.
  47627. * Can also be used to scale the roughness values of the metallic texture.
  47628. */
  47629. roughness: Nullable<number>;
  47630. /**
  47631. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  47632. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  47633. */
  47634. microSurfaceTexture: BaseTexture;
  47635. /**
  47636. * Stores surface normal data used to displace a mesh in a texture.
  47637. */
  47638. bumpTexture: BaseTexture;
  47639. /**
  47640. * Stores the pre-calculated light information of a mesh in a texture.
  47641. */
  47642. lightmapTexture: BaseTexture;
  47643. /**
  47644. * Stores the refracted light information in a texture.
  47645. */
  47646. refractionTexture: Nullable<BaseTexture>;
  47647. /**
  47648. * The color of a material in ambient lighting.
  47649. */
  47650. ambientColor: Color3;
  47651. /**
  47652. * AKA Diffuse Color in other nomenclature.
  47653. */
  47654. albedoColor: Color3;
  47655. /**
  47656. * AKA Specular Color in other nomenclature.
  47657. */
  47658. reflectivityColor: Color3;
  47659. /**
  47660. * The color reflected from the material.
  47661. */
  47662. reflectionColor: Color3;
  47663. /**
  47664. * The color emitted from the material.
  47665. */
  47666. emissiveColor: Color3;
  47667. /**
  47668. * AKA Glossiness in other nomenclature.
  47669. */
  47670. microSurface: number;
  47671. /**
  47672. * source material index of refraction (IOR)' / 'destination material IOR.
  47673. */
  47674. indexOfRefraction: number;
  47675. /**
  47676. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  47677. */
  47678. invertRefractionY: boolean;
  47679. /**
  47680. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  47681. * Materials half opaque for instance using refraction could benefit from this control.
  47682. */
  47683. linkRefractionWithTransparency: boolean;
  47684. /**
  47685. * If true, the light map contains occlusion information instead of lighting info.
  47686. */
  47687. useLightmapAsShadowmap: boolean;
  47688. /**
  47689. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  47690. */
  47691. useAlphaFromAlbedoTexture: boolean;
  47692. /**
  47693. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  47694. */
  47695. forceAlphaTest: boolean;
  47696. /**
  47697. * Defines the alpha limits in alpha test mode.
  47698. */
  47699. alphaCutOff: number;
  47700. /**
  47701. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  47702. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  47703. */
  47704. useSpecularOverAlpha: boolean;
  47705. /**
  47706. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  47707. */
  47708. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  47709. /**
  47710. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  47711. */
  47712. useRoughnessFromMetallicTextureAlpha: boolean;
  47713. /**
  47714. * Specifies if the metallic texture contains the roughness information in its green channel.
  47715. */
  47716. useRoughnessFromMetallicTextureGreen: boolean;
  47717. /**
  47718. * Specifies if the metallic texture contains the metallness information in its blue channel.
  47719. */
  47720. useMetallnessFromMetallicTextureBlue: boolean;
  47721. /**
  47722. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  47723. */
  47724. useAmbientOcclusionFromMetallicTextureRed: boolean;
  47725. /**
  47726. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  47727. */
  47728. useAmbientInGrayScale: boolean;
  47729. /**
  47730. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  47731. * The material will try to infer what glossiness each pixel should be.
  47732. */
  47733. useAutoMicroSurfaceFromReflectivityMap: boolean;
  47734. /**
  47735. * BJS is using an harcoded light falloff based on a manually sets up range.
  47736. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  47737. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  47738. */
  47739. /**
  47740. * BJS is using an harcoded light falloff based on a manually sets up range.
  47741. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  47742. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  47743. */
  47744. usePhysicalLightFalloff: boolean;
  47745. /**
  47746. * In order to support the falloff compatibility with gltf, a special mode has been added
  47747. * to reproduce the gltf light falloff.
  47748. */
  47749. /**
  47750. * In order to support the falloff compatibility with gltf, a special mode has been added
  47751. * to reproduce the gltf light falloff.
  47752. */
  47753. useGLTFLightFalloff: boolean;
  47754. /**
  47755. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  47756. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  47757. */
  47758. useRadianceOverAlpha: boolean;
  47759. /**
  47760. * Allows using an object space normal map (instead of tangent space).
  47761. */
  47762. useObjectSpaceNormalMap: boolean;
  47763. /**
  47764. * Allows using the bump map in parallax mode.
  47765. */
  47766. useParallax: boolean;
  47767. /**
  47768. * Allows using the bump map in parallax occlusion mode.
  47769. */
  47770. useParallaxOcclusion: boolean;
  47771. /**
  47772. * Controls the scale bias of the parallax mode.
  47773. */
  47774. parallaxScaleBias: number;
  47775. /**
  47776. * If sets to true, disables all the lights affecting the material.
  47777. */
  47778. disableLighting: boolean;
  47779. /**
  47780. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  47781. */
  47782. forceIrradianceInFragment: boolean;
  47783. /**
  47784. * Number of Simultaneous lights allowed on the material.
  47785. */
  47786. maxSimultaneousLights: number;
  47787. /**
  47788. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  47789. */
  47790. invertNormalMapX: boolean;
  47791. /**
  47792. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  47793. */
  47794. invertNormalMapY: boolean;
  47795. /**
  47796. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  47797. */
  47798. twoSidedLighting: boolean;
  47799. /**
  47800. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47801. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  47802. */
  47803. useAlphaFresnel: boolean;
  47804. /**
  47805. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47806. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  47807. */
  47808. useLinearAlphaFresnel: boolean;
  47809. /**
  47810. * Let user defines the brdf lookup texture used for IBL.
  47811. * A default 8bit version is embedded but you could point at :
  47812. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  47813. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  47814. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  47815. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  47816. */
  47817. environmentBRDFTexture: Nullable<BaseTexture>;
  47818. /**
  47819. * Force normal to face away from face.
  47820. */
  47821. forceNormalForward: boolean;
  47822. /**
  47823. * Enables specular anti aliasing in the PBR shader.
  47824. * It will both interacts on the Geometry for analytical and IBL lighting.
  47825. * It also prefilter the roughness map based on the bump values.
  47826. */
  47827. enableSpecularAntiAliasing: boolean;
  47828. /**
  47829. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  47830. * makes the reflect vector face the model (under horizon).
  47831. */
  47832. useHorizonOcclusion: boolean;
  47833. /**
  47834. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  47835. * too much the area relying on ambient texture to define their ambient occlusion.
  47836. */
  47837. useRadianceOcclusion: boolean;
  47838. /**
  47839. * If set to true, no lighting calculations will be applied.
  47840. */
  47841. unlit: boolean;
  47842. /**
  47843. * Gets the image processing configuration used either in this material.
  47844. */
  47845. /**
  47846. * Sets the Default image processing configuration used either in the this material.
  47847. *
  47848. * If sets to null, the scene one is in use.
  47849. */
  47850. imageProcessingConfiguration: ImageProcessingConfiguration;
  47851. /**
  47852. * Gets wether the color curves effect is enabled.
  47853. */
  47854. /**
  47855. * Sets wether the color curves effect is enabled.
  47856. */
  47857. cameraColorCurvesEnabled: boolean;
  47858. /**
  47859. * Gets wether the color grading effect is enabled.
  47860. */
  47861. /**
  47862. * Gets wether the color grading effect is enabled.
  47863. */
  47864. cameraColorGradingEnabled: boolean;
  47865. /**
  47866. * Gets wether tonemapping is enabled or not.
  47867. */
  47868. /**
  47869. * Sets wether tonemapping is enabled or not
  47870. */
  47871. cameraToneMappingEnabled: boolean;
  47872. /**
  47873. * The camera exposure used on this material.
  47874. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47875. * This corresponds to a photographic exposure.
  47876. */
  47877. /**
  47878. * The camera exposure used on this material.
  47879. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47880. * This corresponds to a photographic exposure.
  47881. */
  47882. cameraExposure: number;
  47883. /**
  47884. * Gets The camera contrast used on this material.
  47885. */
  47886. /**
  47887. * Sets The camera contrast used on this material.
  47888. */
  47889. cameraContrast: number;
  47890. /**
  47891. * Gets the Color Grading 2D Lookup Texture.
  47892. */
  47893. /**
  47894. * Sets the Color Grading 2D Lookup Texture.
  47895. */
  47896. cameraColorGradingTexture: Nullable<BaseTexture>;
  47897. /**
  47898. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47899. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47900. * 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;
  47901. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47902. */
  47903. /**
  47904. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47905. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47906. * 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;
  47907. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47908. */
  47909. cameraColorCurves: Nullable<ColorCurves>;
  47910. /**
  47911. * Instantiates a new PBRMaterial instance.
  47912. *
  47913. * @param name The material name
  47914. * @param scene The scene the material will be use in.
  47915. */
  47916. constructor(name: string, scene: Scene);
  47917. /**
  47918. * Returns the name of this material class.
  47919. */
  47920. getClassName(): string;
  47921. /**
  47922. * Makes a duplicate of the current material.
  47923. * @param name - name to use for the new material.
  47924. */
  47925. clone(name: string): PBRMaterial;
  47926. /**
  47927. * Serializes this PBR Material.
  47928. * @returns - An object with the serialized material.
  47929. */
  47930. serialize(): any;
  47931. /**
  47932. * Parses a PBR Material from a serialized object.
  47933. * @param source - Serialized object.
  47934. * @param scene - BJS scene instance.
  47935. * @param rootUrl - url for the scene object
  47936. * @returns - PBRMaterial
  47937. */
  47938. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  47939. }
  47940. }
  47941. declare module "babylonjs/Misc/dds" {
  47942. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  47943. import { Engine } from "babylonjs/Engines/engine";
  47944. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47945. import { Nullable } from "babylonjs/types";
  47946. import { Scene } from "babylonjs/scene";
  47947. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  47948. /**
  47949. * Direct draw surface info
  47950. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  47951. */
  47952. export interface DDSInfo {
  47953. /**
  47954. * Width of the texture
  47955. */
  47956. width: number;
  47957. /**
  47958. * Width of the texture
  47959. */
  47960. height: number;
  47961. /**
  47962. * Number of Mipmaps for the texture
  47963. * @see https://en.wikipedia.org/wiki/Mipmap
  47964. */
  47965. mipmapCount: number;
  47966. /**
  47967. * If the textures format is a known fourCC format
  47968. * @see https://www.fourcc.org/
  47969. */
  47970. isFourCC: boolean;
  47971. /**
  47972. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  47973. */
  47974. isRGB: boolean;
  47975. /**
  47976. * If the texture is a lumincance format
  47977. */
  47978. isLuminance: boolean;
  47979. /**
  47980. * If this is a cube texture
  47981. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  47982. */
  47983. isCube: boolean;
  47984. /**
  47985. * If the texture is a compressed format eg. FOURCC_DXT1
  47986. */
  47987. isCompressed: boolean;
  47988. /**
  47989. * The dxgiFormat of the texture
  47990. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  47991. */
  47992. dxgiFormat: number;
  47993. /**
  47994. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  47995. */
  47996. textureType: number;
  47997. /**
  47998. * Sphericle polynomial created for the dds texture
  47999. */
  48000. sphericalPolynomial?: SphericalPolynomial;
  48001. }
  48002. /**
  48003. * Class used to provide DDS decompression tools
  48004. */
  48005. export class DDSTools {
  48006. /**
  48007. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  48008. */
  48009. static StoreLODInAlphaChannel: boolean;
  48010. /**
  48011. * Gets DDS information from an array buffer
  48012. * @param arrayBuffer defines the array buffer to read data from
  48013. * @returns the DDS information
  48014. */
  48015. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  48016. private static _FloatView;
  48017. private static _Int32View;
  48018. private static _ToHalfFloat;
  48019. private static _FromHalfFloat;
  48020. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  48021. private static _GetHalfFloatRGBAArrayBuffer;
  48022. private static _GetFloatRGBAArrayBuffer;
  48023. private static _GetFloatAsUIntRGBAArrayBuffer;
  48024. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  48025. private static _GetRGBAArrayBuffer;
  48026. private static _ExtractLongWordOrder;
  48027. private static _GetRGBArrayBuffer;
  48028. private static _GetLuminanceArrayBuffer;
  48029. /**
  48030. * Uploads DDS Levels to a Babylon Texture
  48031. * @hidden
  48032. */
  48033. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  48034. }
  48035. module "babylonjs/Engines/engine" {
  48036. interface Engine {
  48037. /**
  48038. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  48039. * @param rootUrl defines the url where the file to load is located
  48040. * @param scene defines the current scene
  48041. * @param lodScale defines scale to apply to the mip map selection
  48042. * @param lodOffset defines offset to apply to the mip map selection
  48043. * @param onLoad defines an optional callback raised when the texture is loaded
  48044. * @param onError defines an optional callback raised if there is an issue to load the texture
  48045. * @param format defines the format of the data
  48046. * @param forcedExtension defines the extension to use to pick the right loader
  48047. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  48048. * @returns the cube texture as an InternalTexture
  48049. */
  48050. 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;
  48051. }
  48052. }
  48053. }
  48054. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  48055. import { Nullable } from "babylonjs/types";
  48056. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48057. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  48058. /**
  48059. * Implementation of the DDS Texture Loader.
  48060. * @hidden
  48061. */
  48062. export class _DDSTextureLoader implements IInternalTextureLoader {
  48063. /**
  48064. * Defines wether the loader supports cascade loading the different faces.
  48065. */
  48066. readonly supportCascades: boolean;
  48067. /**
  48068. * This returns if the loader support the current file information.
  48069. * @param extension defines the file extension of the file being loaded
  48070. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48071. * @param fallback defines the fallback internal texture if any
  48072. * @param isBase64 defines whether the texture is encoded as a base64
  48073. * @param isBuffer defines whether the texture data are stored as a buffer
  48074. * @returns true if the loader can load the specified file
  48075. */
  48076. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48077. /**
  48078. * Transform the url before loading if required.
  48079. * @param rootUrl the url of the texture
  48080. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48081. * @returns the transformed texture
  48082. */
  48083. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48084. /**
  48085. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48086. * @param rootUrl the url of the texture
  48087. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48088. * @returns the fallback texture
  48089. */
  48090. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48091. /**
  48092. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48093. * @param data contains the texture data
  48094. * @param texture defines the BabylonJS internal texture
  48095. * @param createPolynomials will be true if polynomials have been requested
  48096. * @param onLoad defines the callback to trigger once the texture is ready
  48097. * @param onError defines the callback to trigger in case of error
  48098. */
  48099. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48100. /**
  48101. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48102. * @param data contains the texture data
  48103. * @param texture defines the BabylonJS internal texture
  48104. * @param callback defines the method to call once ready to upload
  48105. */
  48106. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  48107. }
  48108. }
  48109. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  48110. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48111. /** @hidden */
  48112. export var rgbdEncodePixelShader: {
  48113. name: string;
  48114. shader: string;
  48115. };
  48116. }
  48117. declare module "babylonjs/Misc/environmentTextureTools" {
  48118. import { Nullable } from "babylonjs/types";
  48119. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  48120. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48121. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  48122. import "babylonjs/Engines/Extensions/engine.renderTarget";
  48123. import "babylonjs/Shaders/rgbdEncode.fragment";
  48124. import "babylonjs/Shaders/rgbdDecode.fragment";
  48125. /**
  48126. * Raw texture data and descriptor sufficient for WebGL texture upload
  48127. */
  48128. export interface EnvironmentTextureInfo {
  48129. /**
  48130. * Version of the environment map
  48131. */
  48132. version: number;
  48133. /**
  48134. * Width of image
  48135. */
  48136. width: number;
  48137. /**
  48138. * Irradiance information stored in the file.
  48139. */
  48140. irradiance: any;
  48141. /**
  48142. * Specular information stored in the file.
  48143. */
  48144. specular: any;
  48145. }
  48146. /**
  48147. * Sets of helpers addressing the serialization and deserialization of environment texture
  48148. * stored in a BabylonJS env file.
  48149. * Those files are usually stored as .env files.
  48150. */
  48151. export class EnvironmentTextureTools {
  48152. /**
  48153. * Magic number identifying the env file.
  48154. */
  48155. private static _MagicBytes;
  48156. /**
  48157. * Gets the environment info from an env file.
  48158. * @param data The array buffer containing the .env bytes.
  48159. * @returns the environment file info (the json header) if successfully parsed.
  48160. */
  48161. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  48162. /**
  48163. * Creates an environment texture from a loaded cube texture.
  48164. * @param texture defines the cube texture to convert in env file
  48165. * @return a promise containing the environment data if succesfull.
  48166. */
  48167. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  48168. /**
  48169. * Creates a JSON representation of the spherical data.
  48170. * @param texture defines the texture containing the polynomials
  48171. * @return the JSON representation of the spherical info
  48172. */
  48173. private static _CreateEnvTextureIrradiance;
  48174. /**
  48175. * Uploads the texture info contained in the env file to the GPU.
  48176. * @param texture defines the internal texture to upload to
  48177. * @param arrayBuffer defines the buffer cotaining the data to load
  48178. * @param info defines the texture info retrieved through the GetEnvInfo method
  48179. * @returns a promise
  48180. */
  48181. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  48182. /**
  48183. * Uploads the levels of image data to the GPU.
  48184. * @param texture defines the internal texture to upload to
  48185. * @param imageData defines the array buffer views of image data [mipmap][face]
  48186. * @returns a promise
  48187. */
  48188. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  48189. /**
  48190. * Uploads spherical polynomials information to the texture.
  48191. * @param texture defines the texture we are trying to upload the information to
  48192. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  48193. */
  48194. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  48195. /** @hidden */
  48196. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  48197. }
  48198. }
  48199. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  48200. import { Nullable } from "babylonjs/types";
  48201. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48202. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  48203. /**
  48204. * Implementation of the ENV Texture Loader.
  48205. * @hidden
  48206. */
  48207. export class _ENVTextureLoader implements IInternalTextureLoader {
  48208. /**
  48209. * Defines wether the loader supports cascade loading the different faces.
  48210. */
  48211. readonly supportCascades: boolean;
  48212. /**
  48213. * This returns if the loader support the current file information.
  48214. * @param extension defines the file extension of the file being loaded
  48215. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48216. * @param fallback defines the fallback internal texture if any
  48217. * @param isBase64 defines whether the texture is encoded as a base64
  48218. * @param isBuffer defines whether the texture data are stored as a buffer
  48219. * @returns true if the loader can load the specified file
  48220. */
  48221. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48222. /**
  48223. * Transform the url before loading if required.
  48224. * @param rootUrl the url of the texture
  48225. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48226. * @returns the transformed texture
  48227. */
  48228. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48229. /**
  48230. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48231. * @param rootUrl the url of the texture
  48232. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48233. * @returns the fallback texture
  48234. */
  48235. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48236. /**
  48237. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48238. * @param data contains the texture data
  48239. * @param texture defines the BabylonJS internal texture
  48240. * @param createPolynomials will be true if polynomials have been requested
  48241. * @param onLoad defines the callback to trigger once the texture is ready
  48242. * @param onError defines the callback to trigger in case of error
  48243. */
  48244. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48245. /**
  48246. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48247. * @param data contains the texture data
  48248. * @param texture defines the BabylonJS internal texture
  48249. * @param callback defines the method to call once ready to upload
  48250. */
  48251. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  48252. }
  48253. }
  48254. declare module "babylonjs/Misc/khronosTextureContainer" {
  48255. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48256. /**
  48257. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  48258. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  48259. */
  48260. export class KhronosTextureContainer {
  48261. /** contents of the KTX container file */
  48262. arrayBuffer: any;
  48263. private static HEADER_LEN;
  48264. private static COMPRESSED_2D;
  48265. private static COMPRESSED_3D;
  48266. private static TEX_2D;
  48267. private static TEX_3D;
  48268. /**
  48269. * Gets the openGL type
  48270. */
  48271. glType: number;
  48272. /**
  48273. * Gets the openGL type size
  48274. */
  48275. glTypeSize: number;
  48276. /**
  48277. * Gets the openGL format
  48278. */
  48279. glFormat: number;
  48280. /**
  48281. * Gets the openGL internal format
  48282. */
  48283. glInternalFormat: number;
  48284. /**
  48285. * Gets the base internal format
  48286. */
  48287. glBaseInternalFormat: number;
  48288. /**
  48289. * Gets image width in pixel
  48290. */
  48291. pixelWidth: number;
  48292. /**
  48293. * Gets image height in pixel
  48294. */
  48295. pixelHeight: number;
  48296. /**
  48297. * Gets image depth in pixels
  48298. */
  48299. pixelDepth: number;
  48300. /**
  48301. * Gets the number of array elements
  48302. */
  48303. numberOfArrayElements: number;
  48304. /**
  48305. * Gets the number of faces
  48306. */
  48307. numberOfFaces: number;
  48308. /**
  48309. * Gets the number of mipmap levels
  48310. */
  48311. numberOfMipmapLevels: number;
  48312. /**
  48313. * Gets the bytes of key value data
  48314. */
  48315. bytesOfKeyValueData: number;
  48316. /**
  48317. * Gets the load type
  48318. */
  48319. loadType: number;
  48320. /**
  48321. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  48322. */
  48323. isInvalid: boolean;
  48324. /**
  48325. * Creates a new KhronosTextureContainer
  48326. * @param arrayBuffer contents of the KTX container file
  48327. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  48328. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  48329. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  48330. */
  48331. constructor(
  48332. /** contents of the KTX container file */
  48333. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  48334. /**
  48335. * Uploads KTX content to a Babylon Texture.
  48336. * It is assumed that the texture has already been created & is currently bound
  48337. * @hidden
  48338. */
  48339. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  48340. private _upload2DCompressedLevels;
  48341. }
  48342. }
  48343. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  48344. import { Nullable } from "babylonjs/types";
  48345. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48346. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  48347. /**
  48348. * Implementation of the KTX Texture Loader.
  48349. * @hidden
  48350. */
  48351. export class _KTXTextureLoader implements IInternalTextureLoader {
  48352. /**
  48353. * Defines wether the loader supports cascade loading the different faces.
  48354. */
  48355. readonly supportCascades: boolean;
  48356. /**
  48357. * This returns if the loader support the current file information.
  48358. * @param extension defines the file extension of the file being loaded
  48359. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48360. * @param fallback defines the fallback internal texture if any
  48361. * @param isBase64 defines whether the texture is encoded as a base64
  48362. * @param isBuffer defines whether the texture data are stored as a buffer
  48363. * @returns true if the loader can load the specified file
  48364. */
  48365. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48366. /**
  48367. * Transform the url before loading if required.
  48368. * @param rootUrl the url of the texture
  48369. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48370. * @returns the transformed texture
  48371. */
  48372. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48373. /**
  48374. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48375. * @param rootUrl the url of the texture
  48376. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48377. * @returns the fallback texture
  48378. */
  48379. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48380. /**
  48381. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48382. * @param data contains the texture data
  48383. * @param texture defines the BabylonJS internal texture
  48384. * @param createPolynomials will be true if polynomials have been requested
  48385. * @param onLoad defines the callback to trigger once the texture is ready
  48386. * @param onError defines the callback to trigger in case of error
  48387. */
  48388. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48389. /**
  48390. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48391. * @param data contains the texture data
  48392. * @param texture defines the BabylonJS internal texture
  48393. * @param callback defines the method to call once ready to upload
  48394. */
  48395. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  48396. }
  48397. }
  48398. declare module "babylonjs/Helpers/sceneHelpers" {
  48399. import { Nullable } from "babylonjs/types";
  48400. import { Mesh } from "babylonjs/Meshes/mesh";
  48401. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48402. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  48403. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  48404. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  48405. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  48406. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  48407. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  48408. import "babylonjs/Meshes/Builders/boxBuilder";
  48409. /** @hidden */
  48410. export var _forceSceneHelpersToBundle: boolean;
  48411. module "babylonjs/scene" {
  48412. interface Scene {
  48413. /**
  48414. * Creates a default light for the scene.
  48415. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  48416. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  48417. */
  48418. createDefaultLight(replace?: boolean): void;
  48419. /**
  48420. * Creates a default camera for the scene.
  48421. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  48422. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  48423. * @param replace has default false, when true replaces the active camera in the scene
  48424. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  48425. */
  48426. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  48427. /**
  48428. * Creates a default camera and a default light.
  48429. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  48430. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  48431. * @param replace has the default false, when true replaces the active camera/light in the scene
  48432. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  48433. */
  48434. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  48435. /**
  48436. * Creates a new sky box
  48437. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  48438. * @param environmentTexture defines the texture to use as environment texture
  48439. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  48440. * @param scale defines the overall scale of the skybox
  48441. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  48442. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  48443. * @returns a new mesh holding the sky box
  48444. */
  48445. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  48446. /**
  48447. * Creates a new environment
  48448. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  48449. * @param options defines the options you can use to configure the environment
  48450. * @returns the new EnvironmentHelper
  48451. */
  48452. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  48453. /**
  48454. * Creates a new VREXperienceHelper
  48455. * @see http://doc.babylonjs.com/how_to/webvr_helper
  48456. * @param webVROptions defines the options used to create the new VREXperienceHelper
  48457. * @returns a new VREXperienceHelper
  48458. */
  48459. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  48460. /**
  48461. * Creates a new XREXperienceHelper
  48462. * @see http://doc.babylonjs.com/how_to/webxr
  48463. * @returns a promise for a new XREXperienceHelper
  48464. */
  48465. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  48466. }
  48467. }
  48468. }
  48469. declare module "babylonjs/Helpers/videoDome" {
  48470. import { Scene } from "babylonjs/scene";
  48471. import { TransformNode } from "babylonjs/Meshes/transformNode";
  48472. import { Mesh } from "babylonjs/Meshes/mesh";
  48473. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  48474. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  48475. import "babylonjs/Meshes/Builders/sphereBuilder";
  48476. /**
  48477. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  48478. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  48479. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  48480. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  48481. */
  48482. export class VideoDome extends TransformNode {
  48483. /**
  48484. * Define the video source as a Monoscopic panoramic 360 video.
  48485. */
  48486. static readonly MODE_MONOSCOPIC: number;
  48487. /**
  48488. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  48489. */
  48490. static readonly MODE_TOPBOTTOM: number;
  48491. /**
  48492. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  48493. */
  48494. static readonly MODE_SIDEBYSIDE: number;
  48495. private _useDirectMapping;
  48496. /**
  48497. * The video texture being displayed on the sphere
  48498. */
  48499. protected _videoTexture: VideoTexture;
  48500. /**
  48501. * Gets the video texture being displayed on the sphere
  48502. */
  48503. readonly videoTexture: VideoTexture;
  48504. /**
  48505. * The skybox material
  48506. */
  48507. protected _material: BackgroundMaterial;
  48508. /**
  48509. * The surface used for the skybox
  48510. */
  48511. protected _mesh: Mesh;
  48512. /**
  48513. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  48514. * Also see the options.resolution property.
  48515. */
  48516. fovMultiplier: number;
  48517. private _videoMode;
  48518. /**
  48519. * Gets or set the current video mode for the video. It can be:
  48520. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  48521. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  48522. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  48523. */
  48524. videoMode: number;
  48525. /**
  48526. * Oberserver used in Stereoscopic VR Mode.
  48527. */
  48528. private _onBeforeCameraRenderObserver;
  48529. /**
  48530. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  48531. * @param name Element's name, child elements will append suffixes for their own names.
  48532. * @param urlsOrVideo defines the url(s) or the video element to use
  48533. * @param options An object containing optional or exposed sub element properties
  48534. */
  48535. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  48536. resolution?: number;
  48537. clickToPlay?: boolean;
  48538. autoPlay?: boolean;
  48539. loop?: boolean;
  48540. size?: number;
  48541. poster?: string;
  48542. faceForward?: boolean;
  48543. useDirectMapping?: boolean;
  48544. }, scene: Scene);
  48545. private _changeVideoMode;
  48546. /**
  48547. * Releases resources associated with this node.
  48548. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  48549. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  48550. */
  48551. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  48552. }
  48553. }
  48554. declare module "babylonjs/Helpers/index" {
  48555. export * from "babylonjs/Helpers/environmentHelper";
  48556. export * from "babylonjs/Helpers/photoDome";
  48557. export * from "babylonjs/Helpers/sceneHelpers";
  48558. export * from "babylonjs/Helpers/videoDome";
  48559. }
  48560. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  48561. import { PerfCounter } from "babylonjs/Misc/tools";
  48562. import { IDisposable } from "babylonjs/scene";
  48563. import { Engine } from "babylonjs/Engines/engine";
  48564. /**
  48565. * This class can be used to get instrumentation data from a Babylon engine
  48566. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  48567. */
  48568. export class EngineInstrumentation implements IDisposable {
  48569. /**
  48570. * Define the instrumented engine.
  48571. */
  48572. engine: Engine;
  48573. private _captureGPUFrameTime;
  48574. private _gpuFrameTimeToken;
  48575. private _gpuFrameTime;
  48576. private _captureShaderCompilationTime;
  48577. private _shaderCompilationTime;
  48578. private _onBeginFrameObserver;
  48579. private _onEndFrameObserver;
  48580. private _onBeforeShaderCompilationObserver;
  48581. private _onAfterShaderCompilationObserver;
  48582. /**
  48583. * Gets the perf counter used for GPU frame time
  48584. */
  48585. readonly gpuFrameTimeCounter: PerfCounter;
  48586. /**
  48587. * Gets the GPU frame time capture status
  48588. */
  48589. /**
  48590. * Enable or disable the GPU frame time capture
  48591. */
  48592. captureGPUFrameTime: boolean;
  48593. /**
  48594. * Gets the perf counter used for shader compilation time
  48595. */
  48596. readonly shaderCompilationTimeCounter: PerfCounter;
  48597. /**
  48598. * Gets the shader compilation time capture status
  48599. */
  48600. /**
  48601. * Enable or disable the shader compilation time capture
  48602. */
  48603. captureShaderCompilationTime: boolean;
  48604. /**
  48605. * Instantiates a new engine instrumentation.
  48606. * This class can be used to get instrumentation data from a Babylon engine
  48607. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  48608. * @param engine Defines the engine to instrument
  48609. */
  48610. constructor(
  48611. /**
  48612. * Define the instrumented engine.
  48613. */
  48614. engine: Engine);
  48615. /**
  48616. * Dispose and release associated resources.
  48617. */
  48618. dispose(): void;
  48619. }
  48620. }
  48621. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  48622. import { PerfCounter } from "babylonjs/Misc/tools";
  48623. import { Scene, IDisposable } from "babylonjs/scene";
  48624. /**
  48625. * This class can be used to get instrumentation data from a Babylon engine
  48626. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  48627. */
  48628. export class SceneInstrumentation implements IDisposable {
  48629. /**
  48630. * Defines the scene to instrument
  48631. */
  48632. scene: Scene;
  48633. private _captureActiveMeshesEvaluationTime;
  48634. private _activeMeshesEvaluationTime;
  48635. private _captureRenderTargetsRenderTime;
  48636. private _renderTargetsRenderTime;
  48637. private _captureFrameTime;
  48638. private _frameTime;
  48639. private _captureRenderTime;
  48640. private _renderTime;
  48641. private _captureInterFrameTime;
  48642. private _interFrameTime;
  48643. private _captureParticlesRenderTime;
  48644. private _particlesRenderTime;
  48645. private _captureSpritesRenderTime;
  48646. private _spritesRenderTime;
  48647. private _capturePhysicsTime;
  48648. private _physicsTime;
  48649. private _captureAnimationsTime;
  48650. private _animationsTime;
  48651. private _captureCameraRenderTime;
  48652. private _cameraRenderTime;
  48653. private _onBeforeActiveMeshesEvaluationObserver;
  48654. private _onAfterActiveMeshesEvaluationObserver;
  48655. private _onBeforeRenderTargetsRenderObserver;
  48656. private _onAfterRenderTargetsRenderObserver;
  48657. private _onAfterRenderObserver;
  48658. private _onBeforeDrawPhaseObserver;
  48659. private _onAfterDrawPhaseObserver;
  48660. private _onBeforeAnimationsObserver;
  48661. private _onBeforeParticlesRenderingObserver;
  48662. private _onAfterParticlesRenderingObserver;
  48663. private _onBeforeSpritesRenderingObserver;
  48664. private _onAfterSpritesRenderingObserver;
  48665. private _onBeforePhysicsObserver;
  48666. private _onAfterPhysicsObserver;
  48667. private _onAfterAnimationsObserver;
  48668. private _onBeforeCameraRenderObserver;
  48669. private _onAfterCameraRenderObserver;
  48670. /**
  48671. * Gets the perf counter used for active meshes evaluation time
  48672. */
  48673. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  48674. /**
  48675. * Gets the active meshes evaluation time capture status
  48676. */
  48677. /**
  48678. * Enable or disable the active meshes evaluation time capture
  48679. */
  48680. captureActiveMeshesEvaluationTime: boolean;
  48681. /**
  48682. * Gets the perf counter used for render targets render time
  48683. */
  48684. readonly renderTargetsRenderTimeCounter: PerfCounter;
  48685. /**
  48686. * Gets the render targets render time capture status
  48687. */
  48688. /**
  48689. * Enable or disable the render targets render time capture
  48690. */
  48691. captureRenderTargetsRenderTime: boolean;
  48692. /**
  48693. * Gets the perf counter used for particles render time
  48694. */
  48695. readonly particlesRenderTimeCounter: PerfCounter;
  48696. /**
  48697. * Gets the particles render time capture status
  48698. */
  48699. /**
  48700. * Enable or disable the particles render time capture
  48701. */
  48702. captureParticlesRenderTime: boolean;
  48703. /**
  48704. * Gets the perf counter used for sprites render time
  48705. */
  48706. readonly spritesRenderTimeCounter: PerfCounter;
  48707. /**
  48708. * Gets the sprites render time capture status
  48709. */
  48710. /**
  48711. * Enable or disable the sprites render time capture
  48712. */
  48713. captureSpritesRenderTime: boolean;
  48714. /**
  48715. * Gets the perf counter used for physics time
  48716. */
  48717. readonly physicsTimeCounter: PerfCounter;
  48718. /**
  48719. * Gets the physics time capture status
  48720. */
  48721. /**
  48722. * Enable or disable the physics time capture
  48723. */
  48724. capturePhysicsTime: boolean;
  48725. /**
  48726. * Gets the perf counter used for animations time
  48727. */
  48728. readonly animationsTimeCounter: PerfCounter;
  48729. /**
  48730. * Gets the animations time capture status
  48731. */
  48732. /**
  48733. * Enable or disable the animations time capture
  48734. */
  48735. captureAnimationsTime: boolean;
  48736. /**
  48737. * Gets the perf counter used for frame time capture
  48738. */
  48739. readonly frameTimeCounter: PerfCounter;
  48740. /**
  48741. * Gets the frame time capture status
  48742. */
  48743. /**
  48744. * Enable or disable the frame time capture
  48745. */
  48746. captureFrameTime: boolean;
  48747. /**
  48748. * Gets the perf counter used for inter-frames time capture
  48749. */
  48750. readonly interFrameTimeCounter: PerfCounter;
  48751. /**
  48752. * Gets the inter-frames time capture status
  48753. */
  48754. /**
  48755. * Enable or disable the inter-frames time capture
  48756. */
  48757. captureInterFrameTime: boolean;
  48758. /**
  48759. * Gets the perf counter used for render time capture
  48760. */
  48761. readonly renderTimeCounter: PerfCounter;
  48762. /**
  48763. * Gets the render time capture status
  48764. */
  48765. /**
  48766. * Enable or disable the render time capture
  48767. */
  48768. captureRenderTime: boolean;
  48769. /**
  48770. * Gets the perf counter used for camera render time capture
  48771. */
  48772. readonly cameraRenderTimeCounter: PerfCounter;
  48773. /**
  48774. * Gets the camera render time capture status
  48775. */
  48776. /**
  48777. * Enable or disable the camera render time capture
  48778. */
  48779. captureCameraRenderTime: boolean;
  48780. /**
  48781. * Gets the perf counter used for draw calls
  48782. */
  48783. readonly drawCallsCounter: PerfCounter;
  48784. /**
  48785. * Instantiates a new scene instrumentation.
  48786. * This class can be used to get instrumentation data from a Babylon engine
  48787. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  48788. * @param scene Defines the scene to instrument
  48789. */
  48790. constructor(
  48791. /**
  48792. * Defines the scene to instrument
  48793. */
  48794. scene: Scene);
  48795. /**
  48796. * Dispose and release associated resources.
  48797. */
  48798. dispose(): void;
  48799. }
  48800. }
  48801. declare module "babylonjs/Instrumentation/index" {
  48802. export * from "babylonjs/Instrumentation/engineInstrumentation";
  48803. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  48804. export * from "babylonjs/Instrumentation/timeToken";
  48805. }
  48806. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  48807. /** @hidden */
  48808. export var glowMapGenerationPixelShader: {
  48809. name: string;
  48810. shader: string;
  48811. };
  48812. }
  48813. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  48814. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  48815. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  48816. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  48817. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  48818. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  48819. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  48820. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  48821. /** @hidden */
  48822. export var glowMapGenerationVertexShader: {
  48823. name: string;
  48824. shader: string;
  48825. };
  48826. }
  48827. declare module "babylonjs/Layers/effectLayer" {
  48828. import { Observable } from "babylonjs/Misc/observable";
  48829. import { Nullable } from "babylonjs/types";
  48830. import { Camera } from "babylonjs/Cameras/camera";
  48831. import { Scene } from "babylonjs/scene";
  48832. import { Color4, ISize } from "babylonjs/Maths/math";
  48833. import { Engine } from "babylonjs/Engines/engine";
  48834. import { SubMesh } from "babylonjs/Meshes/subMesh";
  48835. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48836. import { Mesh } from "babylonjs/Meshes/mesh";
  48837. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  48838. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48839. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  48840. import { Effect } from "babylonjs/Materials/effect";
  48841. import { Material } from "babylonjs/Materials/material";
  48842. import "babylonjs/Shaders/glowMapGeneration.fragment";
  48843. import "babylonjs/Shaders/glowMapGeneration.vertex";
  48844. /**
  48845. * Effect layer options. This helps customizing the behaviour
  48846. * of the effect layer.
  48847. */
  48848. export interface IEffectLayerOptions {
  48849. /**
  48850. * Multiplication factor apply to the canvas size to compute the render target size
  48851. * used to generated the objects (the smaller the faster).
  48852. */
  48853. mainTextureRatio: number;
  48854. /**
  48855. * Enforces a fixed size texture to ensure effect stability across devices.
  48856. */
  48857. mainTextureFixedSize?: number;
  48858. /**
  48859. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  48860. */
  48861. alphaBlendingMode: number;
  48862. /**
  48863. * The camera attached to the layer.
  48864. */
  48865. camera: Nullable<Camera>;
  48866. /**
  48867. * The rendering group to draw the layer in.
  48868. */
  48869. renderingGroupId: number;
  48870. }
  48871. /**
  48872. * The effect layer Helps adding post process effect blended with the main pass.
  48873. *
  48874. * This can be for instance use to generate glow or higlight effects on the scene.
  48875. *
  48876. * The effect layer class can not be used directly and is intented to inherited from to be
  48877. * customized per effects.
  48878. */
  48879. export abstract class EffectLayer {
  48880. private _vertexBuffers;
  48881. private _indexBuffer;
  48882. private _cachedDefines;
  48883. private _effectLayerMapGenerationEffect;
  48884. private _effectLayerOptions;
  48885. private _mergeEffect;
  48886. protected _scene: Scene;
  48887. protected _engine: Engine;
  48888. protected _maxSize: number;
  48889. protected _mainTextureDesiredSize: ISize;
  48890. protected _mainTexture: RenderTargetTexture;
  48891. protected _shouldRender: boolean;
  48892. protected _postProcesses: PostProcess[];
  48893. protected _textures: BaseTexture[];
  48894. protected _emissiveTextureAndColor: {
  48895. texture: Nullable<BaseTexture>;
  48896. color: Color4;
  48897. };
  48898. /**
  48899. * The name of the layer
  48900. */
  48901. name: string;
  48902. /**
  48903. * The clear color of the texture used to generate the glow map.
  48904. */
  48905. neutralColor: Color4;
  48906. /**
  48907. * Specifies wether the highlight layer is enabled or not.
  48908. */
  48909. isEnabled: boolean;
  48910. /**
  48911. * Gets the camera attached to the layer.
  48912. */
  48913. readonly camera: Nullable<Camera>;
  48914. /**
  48915. * Gets the rendering group id the layer should render in.
  48916. */
  48917. readonly renderingGroupId: number;
  48918. /**
  48919. * An event triggered when the effect layer has been disposed.
  48920. */
  48921. onDisposeObservable: Observable<EffectLayer>;
  48922. /**
  48923. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  48924. */
  48925. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  48926. /**
  48927. * An event triggered when the generated texture is being merged in the scene.
  48928. */
  48929. onBeforeComposeObservable: Observable<EffectLayer>;
  48930. /**
  48931. * An event triggered when the generated texture has been merged in the scene.
  48932. */
  48933. onAfterComposeObservable: Observable<EffectLayer>;
  48934. /**
  48935. * An event triggered when the efffect layer changes its size.
  48936. */
  48937. onSizeChangedObservable: Observable<EffectLayer>;
  48938. /** @hidden */
  48939. static _SceneComponentInitialization: (scene: Scene) => void;
  48940. /**
  48941. * Instantiates a new effect Layer and references it in the scene.
  48942. * @param name The name of the layer
  48943. * @param scene The scene to use the layer in
  48944. */
  48945. constructor(
  48946. /** The Friendly of the effect in the scene */
  48947. name: string, scene: Scene);
  48948. /**
  48949. * Get the effect name of the layer.
  48950. * @return The effect name
  48951. */
  48952. abstract getEffectName(): string;
  48953. /**
  48954. * Checks for the readiness of the element composing the layer.
  48955. * @param subMesh the mesh to check for
  48956. * @param useInstances specify wether or not to use instances to render the mesh
  48957. * @return true if ready otherwise, false
  48958. */
  48959. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  48960. /**
  48961. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  48962. * @returns true if the effect requires stencil during the main canvas render pass.
  48963. */
  48964. abstract needStencil(): boolean;
  48965. /**
  48966. * Create the merge effect. This is the shader use to blit the information back
  48967. * to the main canvas at the end of the scene rendering.
  48968. * @returns The effect containing the shader used to merge the effect on the main canvas
  48969. */
  48970. protected abstract _createMergeEffect(): Effect;
  48971. /**
  48972. * Creates the render target textures and post processes used in the effect layer.
  48973. */
  48974. protected abstract _createTextureAndPostProcesses(): void;
  48975. /**
  48976. * Implementation specific of rendering the generating effect on the main canvas.
  48977. * @param effect The effect used to render through
  48978. */
  48979. protected abstract _internalRender(effect: Effect): void;
  48980. /**
  48981. * Sets the required values for both the emissive texture and and the main color.
  48982. */
  48983. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  48984. /**
  48985. * Free any resources and references associated to a mesh.
  48986. * Internal use
  48987. * @param mesh The mesh to free.
  48988. */
  48989. abstract _disposeMesh(mesh: Mesh): void;
  48990. /**
  48991. * Serializes this layer (Glow or Highlight for example)
  48992. * @returns a serialized layer object
  48993. */
  48994. abstract serialize?(): any;
  48995. /**
  48996. * Initializes the effect layer with the required options.
  48997. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  48998. */
  48999. protected _init(options: Partial<IEffectLayerOptions>): void;
  49000. /**
  49001. * Generates the index buffer of the full screen quad blending to the main canvas.
  49002. */
  49003. private _generateIndexBuffer;
  49004. /**
  49005. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  49006. */
  49007. private _generateVertexBuffer;
  49008. /**
  49009. * Sets the main texture desired size which is the closest power of two
  49010. * of the engine canvas size.
  49011. */
  49012. private _setMainTextureSize;
  49013. /**
  49014. * Creates the main texture for the effect layer.
  49015. */
  49016. protected _createMainTexture(): void;
  49017. /**
  49018. * Adds specific effects defines.
  49019. * @param defines The defines to add specifics to.
  49020. */
  49021. protected _addCustomEffectDefines(defines: string[]): void;
  49022. /**
  49023. * Checks for the readiness of the element composing the layer.
  49024. * @param subMesh the mesh to check for
  49025. * @param useInstances specify wether or not to use instances to render the mesh
  49026. * @param emissiveTexture the associated emissive texture used to generate the glow
  49027. * @return true if ready otherwise, false
  49028. */
  49029. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  49030. /**
  49031. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  49032. */
  49033. render(): void;
  49034. /**
  49035. * Determine if a given mesh will be used in the current effect.
  49036. * @param mesh mesh to test
  49037. * @returns true if the mesh will be used
  49038. */
  49039. hasMesh(mesh: AbstractMesh): boolean;
  49040. /**
  49041. * Returns true if the layer contains information to display, otherwise false.
  49042. * @returns true if the glow layer should be rendered
  49043. */
  49044. shouldRender(): boolean;
  49045. /**
  49046. * Returns true if the mesh should render, otherwise false.
  49047. * @param mesh The mesh to render
  49048. * @returns true if it should render otherwise false
  49049. */
  49050. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  49051. /**
  49052. * Returns true if the mesh can be rendered, otherwise false.
  49053. * @param mesh The mesh to render
  49054. * @param material The material used on the mesh
  49055. * @returns true if it can be rendered otherwise false
  49056. */
  49057. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  49058. /**
  49059. * Returns true if the mesh should render, otherwise false.
  49060. * @param mesh The mesh to render
  49061. * @returns true if it should render otherwise false
  49062. */
  49063. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  49064. /**
  49065. * Renders the submesh passed in parameter to the generation map.
  49066. */
  49067. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  49068. /**
  49069. * Rebuild the required buffers.
  49070. * @hidden Internal use only.
  49071. */
  49072. _rebuild(): void;
  49073. /**
  49074. * Dispose only the render target textures and post process.
  49075. */
  49076. private _disposeTextureAndPostProcesses;
  49077. /**
  49078. * Dispose the highlight layer and free resources.
  49079. */
  49080. dispose(): void;
  49081. /**
  49082. * Gets the class name of the effect layer
  49083. * @returns the string with the class name of the effect layer
  49084. */
  49085. getClassName(): string;
  49086. /**
  49087. * Creates an effect layer from parsed effect layer data
  49088. * @param parsedEffectLayer defines effect layer data
  49089. * @param scene defines the current scene
  49090. * @param rootUrl defines the root URL containing the effect layer information
  49091. * @returns a parsed effect Layer
  49092. */
  49093. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  49094. }
  49095. }
  49096. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  49097. import { Scene } from "babylonjs/scene";
  49098. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  49099. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  49100. import { AbstractScene } from "babylonjs/abstractScene";
  49101. module "babylonjs/abstractScene" {
  49102. interface AbstractScene {
  49103. /**
  49104. * The list of effect layers (highlights/glow) added to the scene
  49105. * @see http://doc.babylonjs.com/how_to/highlight_layer
  49106. * @see http://doc.babylonjs.com/how_to/glow_layer
  49107. */
  49108. effectLayers: Array<EffectLayer>;
  49109. /**
  49110. * Removes the given effect layer from this scene.
  49111. * @param toRemove defines the effect layer to remove
  49112. * @returns the index of the removed effect layer
  49113. */
  49114. removeEffectLayer(toRemove: EffectLayer): number;
  49115. /**
  49116. * Adds the given effect layer to this scene
  49117. * @param newEffectLayer defines the effect layer to add
  49118. */
  49119. addEffectLayer(newEffectLayer: EffectLayer): void;
  49120. }
  49121. }
  49122. /**
  49123. * Defines the layer scene component responsible to manage any effect layers
  49124. * in a given scene.
  49125. */
  49126. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  49127. /**
  49128. * The component name helpfull to identify the component in the list of scene components.
  49129. */
  49130. readonly name: string;
  49131. /**
  49132. * The scene the component belongs to.
  49133. */
  49134. scene: Scene;
  49135. private _engine;
  49136. private _renderEffects;
  49137. private _needStencil;
  49138. private _previousStencilState;
  49139. /**
  49140. * Creates a new instance of the component for the given scene
  49141. * @param scene Defines the scene to register the component in
  49142. */
  49143. constructor(scene: Scene);
  49144. /**
  49145. * Registers the component in a given scene
  49146. */
  49147. register(): void;
  49148. /**
  49149. * Rebuilds the elements related to this component in case of
  49150. * context lost for instance.
  49151. */
  49152. rebuild(): void;
  49153. /**
  49154. * Serializes the component data to the specified json object
  49155. * @param serializationObject The object to serialize to
  49156. */
  49157. serialize(serializationObject: any): void;
  49158. /**
  49159. * Adds all the elements from the container to the scene
  49160. * @param container the container holding the elements
  49161. */
  49162. addFromContainer(container: AbstractScene): void;
  49163. /**
  49164. * Removes all the elements in the container from the scene
  49165. * @param container contains the elements to remove
  49166. * @param dispose if the removed element should be disposed (default: false)
  49167. */
  49168. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49169. /**
  49170. * Disposes the component and the associated ressources.
  49171. */
  49172. dispose(): void;
  49173. private _isReadyForMesh;
  49174. private _renderMainTexture;
  49175. private _setStencil;
  49176. private _setStencilBack;
  49177. private _draw;
  49178. private _drawCamera;
  49179. private _drawRenderingGroup;
  49180. }
  49181. }
  49182. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  49183. /** @hidden */
  49184. export var glowMapMergePixelShader: {
  49185. name: string;
  49186. shader: string;
  49187. };
  49188. }
  49189. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  49190. /** @hidden */
  49191. export var glowMapMergeVertexShader: {
  49192. name: string;
  49193. shader: string;
  49194. };
  49195. }
  49196. declare module "babylonjs/Layers/glowLayer" {
  49197. import { Nullable } from "babylonjs/types";
  49198. import { Camera } from "babylonjs/Cameras/camera";
  49199. import { Scene } from "babylonjs/scene";
  49200. import { Color4 } from "babylonjs/Maths/math";
  49201. import { SubMesh } from "babylonjs/Meshes/subMesh";
  49202. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49203. import { Mesh } from "babylonjs/Meshes/mesh";
  49204. import { Texture } from "babylonjs/Materials/Textures/texture";
  49205. import { Effect } from "babylonjs/Materials/effect";
  49206. import { Material } from "babylonjs/Materials/material";
  49207. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  49208. import "babylonjs/Shaders/glowMapMerge.fragment";
  49209. import "babylonjs/Shaders/glowMapMerge.vertex";
  49210. import "babylonjs/Layers/effectLayerSceneComponent";
  49211. module "babylonjs/abstractScene" {
  49212. interface AbstractScene {
  49213. /**
  49214. * Return a the first highlight layer of the scene with a given name.
  49215. * @param name The name of the highlight layer to look for.
  49216. * @return The highlight layer if found otherwise null.
  49217. */
  49218. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  49219. }
  49220. }
  49221. /**
  49222. * Glow layer options. This helps customizing the behaviour
  49223. * of the glow layer.
  49224. */
  49225. export interface IGlowLayerOptions {
  49226. /**
  49227. * Multiplication factor apply to the canvas size to compute the render target size
  49228. * used to generated the glowing objects (the smaller the faster).
  49229. */
  49230. mainTextureRatio: number;
  49231. /**
  49232. * Enforces a fixed size texture to ensure resize independant blur.
  49233. */
  49234. mainTextureFixedSize?: number;
  49235. /**
  49236. * How big is the kernel of the blur texture.
  49237. */
  49238. blurKernelSize: number;
  49239. /**
  49240. * The camera attached to the layer.
  49241. */
  49242. camera: Nullable<Camera>;
  49243. /**
  49244. * Enable MSAA by chosing the number of samples.
  49245. */
  49246. mainTextureSamples?: number;
  49247. /**
  49248. * The rendering group to draw the layer in.
  49249. */
  49250. renderingGroupId: number;
  49251. }
  49252. /**
  49253. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  49254. *
  49255. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  49256. * glowy meshes to your scene.
  49257. *
  49258. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  49259. */
  49260. export class GlowLayer extends EffectLayer {
  49261. /**
  49262. * Effect Name of the layer.
  49263. */
  49264. static readonly EffectName: string;
  49265. /**
  49266. * The default blur kernel size used for the glow.
  49267. */
  49268. static DefaultBlurKernelSize: number;
  49269. /**
  49270. * The default texture size ratio used for the glow.
  49271. */
  49272. static DefaultTextureRatio: number;
  49273. /**
  49274. * Sets the kernel size of the blur.
  49275. */
  49276. /**
  49277. * Gets the kernel size of the blur.
  49278. */
  49279. blurKernelSize: number;
  49280. /**
  49281. * Sets the glow intensity.
  49282. */
  49283. /**
  49284. * Gets the glow intensity.
  49285. */
  49286. intensity: number;
  49287. private _options;
  49288. private _intensity;
  49289. private _horizontalBlurPostprocess1;
  49290. private _verticalBlurPostprocess1;
  49291. private _horizontalBlurPostprocess2;
  49292. private _verticalBlurPostprocess2;
  49293. private _blurTexture1;
  49294. private _blurTexture2;
  49295. private _postProcesses1;
  49296. private _postProcesses2;
  49297. private _includedOnlyMeshes;
  49298. private _excludedMeshes;
  49299. /**
  49300. * Callback used to let the user override the color selection on a per mesh basis
  49301. */
  49302. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  49303. /**
  49304. * Callback used to let the user override the texture selection on a per mesh basis
  49305. */
  49306. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  49307. /**
  49308. * Instantiates a new glow Layer and references it to the scene.
  49309. * @param name The name of the layer
  49310. * @param scene The scene to use the layer in
  49311. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  49312. */
  49313. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  49314. /**
  49315. * Get the effect name of the layer.
  49316. * @return The effect name
  49317. */
  49318. getEffectName(): string;
  49319. /**
  49320. * Create the merge effect. This is the shader use to blit the information back
  49321. * to the main canvas at the end of the scene rendering.
  49322. */
  49323. protected _createMergeEffect(): Effect;
  49324. /**
  49325. * Creates the render target textures and post processes used in the glow layer.
  49326. */
  49327. protected _createTextureAndPostProcesses(): void;
  49328. /**
  49329. * Checks for the readiness of the element composing the layer.
  49330. * @param subMesh the mesh to check for
  49331. * @param useInstances specify wether or not to use instances to render the mesh
  49332. * @param emissiveTexture the associated emissive texture used to generate the glow
  49333. * @return true if ready otherwise, false
  49334. */
  49335. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  49336. /**
  49337. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  49338. */
  49339. needStencil(): boolean;
  49340. /**
  49341. * Returns true if the mesh can be rendered, otherwise false.
  49342. * @param mesh The mesh to render
  49343. * @param material The material used on the mesh
  49344. * @returns true if it can be rendered otherwise false
  49345. */
  49346. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  49347. /**
  49348. * Implementation specific of rendering the generating effect on the main canvas.
  49349. * @param effect The effect used to render through
  49350. */
  49351. protected _internalRender(effect: Effect): void;
  49352. /**
  49353. * Sets the required values for both the emissive texture and and the main color.
  49354. */
  49355. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  49356. /**
  49357. * Returns true if the mesh should render, otherwise false.
  49358. * @param mesh The mesh to render
  49359. * @returns true if it should render otherwise false
  49360. */
  49361. protected _shouldRenderMesh(mesh: Mesh): boolean;
  49362. /**
  49363. * Adds specific effects defines.
  49364. * @param defines The defines to add specifics to.
  49365. */
  49366. protected _addCustomEffectDefines(defines: string[]): void;
  49367. /**
  49368. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  49369. * @param mesh The mesh to exclude from the glow layer
  49370. */
  49371. addExcludedMesh(mesh: Mesh): void;
  49372. /**
  49373. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  49374. * @param mesh The mesh to remove
  49375. */
  49376. removeExcludedMesh(mesh: Mesh): void;
  49377. /**
  49378. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  49379. * @param mesh The mesh to include in the glow layer
  49380. */
  49381. addIncludedOnlyMesh(mesh: Mesh): void;
  49382. /**
  49383. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  49384. * @param mesh The mesh to remove
  49385. */
  49386. removeIncludedOnlyMesh(mesh: Mesh): void;
  49387. /**
  49388. * Determine if a given mesh will be used in the glow layer
  49389. * @param mesh The mesh to test
  49390. * @returns true if the mesh will be highlighted by the current glow layer
  49391. */
  49392. hasMesh(mesh: AbstractMesh): boolean;
  49393. /**
  49394. * Free any resources and references associated to a mesh.
  49395. * Internal use
  49396. * @param mesh The mesh to free.
  49397. * @hidden
  49398. */
  49399. _disposeMesh(mesh: Mesh): void;
  49400. /**
  49401. * Gets the class name of the effect layer
  49402. * @returns the string with the class name of the effect layer
  49403. */
  49404. getClassName(): string;
  49405. /**
  49406. * Serializes this glow layer
  49407. * @returns a serialized glow layer object
  49408. */
  49409. serialize(): any;
  49410. /**
  49411. * Creates a Glow Layer from parsed glow layer data
  49412. * @param parsedGlowLayer defines glow layer data
  49413. * @param scene defines the current scene
  49414. * @param rootUrl defines the root URL containing the glow layer information
  49415. * @returns a parsed Glow Layer
  49416. */
  49417. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  49418. }
  49419. }
  49420. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  49421. /** @hidden */
  49422. export var glowBlurPostProcessPixelShader: {
  49423. name: string;
  49424. shader: string;
  49425. };
  49426. }
  49427. declare module "babylonjs/Layers/highlightLayer" {
  49428. import { Observable } from "babylonjs/Misc/observable";
  49429. import { Nullable } from "babylonjs/types";
  49430. import { Camera } from "babylonjs/Cameras/camera";
  49431. import { Scene } from "babylonjs/scene";
  49432. import { Color3, Color4 } from "babylonjs/Maths/math";
  49433. import { SubMesh } from "babylonjs/Meshes/subMesh";
  49434. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49435. import { Mesh } from "babylonjs/Meshes/mesh";
  49436. import { Effect } from "babylonjs/Materials/effect";
  49437. import { Material } from "babylonjs/Materials/material";
  49438. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  49439. import "babylonjs/Shaders/glowMapMerge.fragment";
  49440. import "babylonjs/Shaders/glowMapMerge.vertex";
  49441. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  49442. module "babylonjs/abstractScene" {
  49443. interface AbstractScene {
  49444. /**
  49445. * Return a the first highlight layer of the scene with a given name.
  49446. * @param name The name of the highlight layer to look for.
  49447. * @return The highlight layer if found otherwise null.
  49448. */
  49449. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  49450. }
  49451. }
  49452. /**
  49453. * Highlight layer options. This helps customizing the behaviour
  49454. * of the highlight layer.
  49455. */
  49456. export interface IHighlightLayerOptions {
  49457. /**
  49458. * Multiplication factor apply to the canvas size to compute the render target size
  49459. * used to generated the glowing objects (the smaller the faster).
  49460. */
  49461. mainTextureRatio: number;
  49462. /**
  49463. * Enforces a fixed size texture to ensure resize independant blur.
  49464. */
  49465. mainTextureFixedSize?: number;
  49466. /**
  49467. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  49468. * of the picture to blur (the smaller the faster).
  49469. */
  49470. blurTextureSizeRatio: number;
  49471. /**
  49472. * How big in texel of the blur texture is the vertical blur.
  49473. */
  49474. blurVerticalSize: number;
  49475. /**
  49476. * How big in texel of the blur texture is the horizontal blur.
  49477. */
  49478. blurHorizontalSize: number;
  49479. /**
  49480. * Alpha blending mode used to apply the blur. Default is combine.
  49481. */
  49482. alphaBlendingMode: number;
  49483. /**
  49484. * The camera attached to the layer.
  49485. */
  49486. camera: Nullable<Camera>;
  49487. /**
  49488. * Should we display highlight as a solid stroke?
  49489. */
  49490. isStroke?: boolean;
  49491. /**
  49492. * The rendering group to draw the layer in.
  49493. */
  49494. renderingGroupId: number;
  49495. }
  49496. /**
  49497. * The highlight layer Helps adding a glow effect around a mesh.
  49498. *
  49499. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  49500. * glowy meshes to your scene.
  49501. *
  49502. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  49503. */
  49504. export class HighlightLayer extends EffectLayer {
  49505. name: string;
  49506. /**
  49507. * Effect Name of the highlight layer.
  49508. */
  49509. static readonly EffectName: string;
  49510. /**
  49511. * The neutral color used during the preparation of the glow effect.
  49512. * This is black by default as the blend operation is a blend operation.
  49513. */
  49514. static NeutralColor: Color4;
  49515. /**
  49516. * Stencil value used for glowing meshes.
  49517. */
  49518. static GlowingMeshStencilReference: number;
  49519. /**
  49520. * Stencil value used for the other meshes in the scene.
  49521. */
  49522. static NormalMeshStencilReference: number;
  49523. /**
  49524. * Specifies whether or not the inner glow is ACTIVE in the layer.
  49525. */
  49526. innerGlow: boolean;
  49527. /**
  49528. * Specifies whether or not the outer glow is ACTIVE in the layer.
  49529. */
  49530. outerGlow: boolean;
  49531. /**
  49532. * Specifies the horizontal size of the blur.
  49533. */
  49534. /**
  49535. * Gets the horizontal size of the blur.
  49536. */
  49537. blurHorizontalSize: number;
  49538. /**
  49539. * Specifies the vertical size of the blur.
  49540. */
  49541. /**
  49542. * Gets the vertical size of the blur.
  49543. */
  49544. blurVerticalSize: number;
  49545. /**
  49546. * An event triggered when the highlight layer is being blurred.
  49547. */
  49548. onBeforeBlurObservable: Observable<HighlightLayer>;
  49549. /**
  49550. * An event triggered when the highlight layer has been blurred.
  49551. */
  49552. onAfterBlurObservable: Observable<HighlightLayer>;
  49553. private _instanceGlowingMeshStencilReference;
  49554. private _options;
  49555. private _downSamplePostprocess;
  49556. private _horizontalBlurPostprocess;
  49557. private _verticalBlurPostprocess;
  49558. private _blurTexture;
  49559. private _meshes;
  49560. private _excludedMeshes;
  49561. /**
  49562. * Instantiates a new highlight Layer and references it to the scene..
  49563. * @param name The name of the layer
  49564. * @param scene The scene to use the layer in
  49565. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  49566. */
  49567. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  49568. /**
  49569. * Get the effect name of the layer.
  49570. * @return The effect name
  49571. */
  49572. getEffectName(): string;
  49573. /**
  49574. * Create the merge effect. This is the shader use to blit the information back
  49575. * to the main canvas at the end of the scene rendering.
  49576. */
  49577. protected _createMergeEffect(): Effect;
  49578. /**
  49579. * Creates the render target textures and post processes used in the highlight layer.
  49580. */
  49581. protected _createTextureAndPostProcesses(): void;
  49582. /**
  49583. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  49584. */
  49585. needStencil(): boolean;
  49586. /**
  49587. * Checks for the readiness of the element composing the layer.
  49588. * @param subMesh the mesh to check for
  49589. * @param useInstances specify wether or not to use instances to render the mesh
  49590. * @param emissiveTexture the associated emissive texture used to generate the glow
  49591. * @return true if ready otherwise, false
  49592. */
  49593. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  49594. /**
  49595. * Implementation specific of rendering the generating effect on the main canvas.
  49596. * @param effect The effect used to render through
  49597. */
  49598. protected _internalRender(effect: Effect): void;
  49599. /**
  49600. * Returns true if the layer contains information to display, otherwise false.
  49601. */
  49602. shouldRender(): boolean;
  49603. /**
  49604. * Returns true if the mesh should render, otherwise false.
  49605. * @param mesh The mesh to render
  49606. * @returns true if it should render otherwise false
  49607. */
  49608. protected _shouldRenderMesh(mesh: Mesh): boolean;
  49609. /**
  49610. * Sets the required values for both the emissive texture and and the main color.
  49611. */
  49612. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  49613. /**
  49614. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  49615. * @param mesh The mesh to exclude from the highlight layer
  49616. */
  49617. addExcludedMesh(mesh: Mesh): void;
  49618. /**
  49619. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  49620. * @param mesh The mesh to highlight
  49621. */
  49622. removeExcludedMesh(mesh: Mesh): void;
  49623. /**
  49624. * Determine if a given mesh will be highlighted by the current HighlightLayer
  49625. * @param mesh mesh to test
  49626. * @returns true if the mesh will be highlighted by the current HighlightLayer
  49627. */
  49628. hasMesh(mesh: AbstractMesh): boolean;
  49629. /**
  49630. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  49631. * @param mesh The mesh to highlight
  49632. * @param color The color of the highlight
  49633. * @param glowEmissiveOnly Extract the glow from the emissive texture
  49634. */
  49635. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  49636. /**
  49637. * Remove a mesh from the highlight layer in order to make it stop glowing.
  49638. * @param mesh The mesh to highlight
  49639. */
  49640. removeMesh(mesh: Mesh): void;
  49641. /**
  49642. * Force the stencil to the normal expected value for none glowing parts
  49643. */
  49644. private _defaultStencilReference;
  49645. /**
  49646. * Free any resources and references associated to a mesh.
  49647. * Internal use
  49648. * @param mesh The mesh to free.
  49649. * @hidden
  49650. */
  49651. _disposeMesh(mesh: Mesh): void;
  49652. /**
  49653. * Dispose the highlight layer and free resources.
  49654. */
  49655. dispose(): void;
  49656. /**
  49657. * Gets the class name of the effect layer
  49658. * @returns the string with the class name of the effect layer
  49659. */
  49660. getClassName(): string;
  49661. /**
  49662. * Serializes this Highlight layer
  49663. * @returns a serialized Highlight layer object
  49664. */
  49665. serialize(): any;
  49666. /**
  49667. * Creates a Highlight layer from parsed Highlight layer data
  49668. * @param parsedHightlightLayer defines the Highlight layer data
  49669. * @param scene defines the current scene
  49670. * @param rootUrl defines the root URL containing the Highlight layer information
  49671. * @returns a parsed Highlight layer
  49672. */
  49673. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  49674. }
  49675. }
  49676. declare module "babylonjs/Layers/layerSceneComponent" {
  49677. import { Scene } from "babylonjs/scene";
  49678. import { ISceneComponent } from "babylonjs/sceneComponent";
  49679. import { Layer } from "babylonjs/Layers/layer";
  49680. import { AbstractScene } from "babylonjs/abstractScene";
  49681. module "babylonjs/abstractScene" {
  49682. interface AbstractScene {
  49683. /**
  49684. * The list of layers (background and foreground) of the scene
  49685. */
  49686. layers: Array<Layer>;
  49687. }
  49688. }
  49689. /**
  49690. * Defines the layer scene component responsible to manage any layers
  49691. * in a given scene.
  49692. */
  49693. export class LayerSceneComponent implements ISceneComponent {
  49694. /**
  49695. * The component name helpfull to identify the component in the list of scene components.
  49696. */
  49697. readonly name: string;
  49698. /**
  49699. * The scene the component belongs to.
  49700. */
  49701. scene: Scene;
  49702. private _engine;
  49703. /**
  49704. * Creates a new instance of the component for the given scene
  49705. * @param scene Defines the scene to register the component in
  49706. */
  49707. constructor(scene: Scene);
  49708. /**
  49709. * Registers the component in a given scene
  49710. */
  49711. register(): void;
  49712. /**
  49713. * Rebuilds the elements related to this component in case of
  49714. * context lost for instance.
  49715. */
  49716. rebuild(): void;
  49717. /**
  49718. * Disposes the component and the associated ressources.
  49719. */
  49720. dispose(): void;
  49721. private _draw;
  49722. private _drawCameraPredicate;
  49723. private _drawCameraBackground;
  49724. private _drawCameraForeground;
  49725. private _drawRenderTargetPredicate;
  49726. private _drawRenderTargetBackground;
  49727. private _drawRenderTargetForeground;
  49728. /**
  49729. * Adds all the elements from the container to the scene
  49730. * @param container the container holding the elements
  49731. */
  49732. addFromContainer(container: AbstractScene): void;
  49733. /**
  49734. * Removes all the elements in the container from the scene
  49735. * @param container contains the elements to remove
  49736. * @param dispose if the removed element should be disposed (default: false)
  49737. */
  49738. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49739. }
  49740. }
  49741. declare module "babylonjs/Shaders/layer.fragment" {
  49742. /** @hidden */
  49743. export var layerPixelShader: {
  49744. name: string;
  49745. shader: string;
  49746. };
  49747. }
  49748. declare module "babylonjs/Shaders/layer.vertex" {
  49749. /** @hidden */
  49750. export var layerVertexShader: {
  49751. name: string;
  49752. shader: string;
  49753. };
  49754. }
  49755. declare module "babylonjs/Layers/layer" {
  49756. import { Observable } from "babylonjs/Misc/observable";
  49757. import { Nullable } from "babylonjs/types";
  49758. import { Scene } from "babylonjs/scene";
  49759. import { Vector2, Color4 } from "babylonjs/Maths/math";
  49760. import { Texture } from "babylonjs/Materials/Textures/texture";
  49761. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  49762. import "babylonjs/Shaders/layer.fragment";
  49763. import "babylonjs/Shaders/layer.vertex";
  49764. /**
  49765. * This represents a full screen 2d layer.
  49766. * This can be useful to display a picture in the background of your scene for instance.
  49767. * @see https://www.babylonjs-playground.com/#08A2BS#1
  49768. */
  49769. export class Layer {
  49770. /**
  49771. * Define the name of the layer.
  49772. */
  49773. name: string;
  49774. /**
  49775. * Define the texture the layer should display.
  49776. */
  49777. texture: Nullable<Texture>;
  49778. /**
  49779. * Is the layer in background or foreground.
  49780. */
  49781. isBackground: boolean;
  49782. /**
  49783. * Define the color of the layer (instead of texture).
  49784. */
  49785. color: Color4;
  49786. /**
  49787. * Define the scale of the layer in order to zoom in out of the texture.
  49788. */
  49789. scale: Vector2;
  49790. /**
  49791. * Define an offset for the layer in order to shift the texture.
  49792. */
  49793. offset: Vector2;
  49794. /**
  49795. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  49796. */
  49797. alphaBlendingMode: number;
  49798. /**
  49799. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  49800. * Alpha test will not mix with the background color in case of transparency.
  49801. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  49802. */
  49803. alphaTest: boolean;
  49804. /**
  49805. * Define a mask to restrict the layer to only some of the scene cameras.
  49806. */
  49807. layerMask: number;
  49808. /**
  49809. * Define the list of render target the layer is visible into.
  49810. */
  49811. renderTargetTextures: RenderTargetTexture[];
  49812. /**
  49813. * Define if the layer is only used in renderTarget or if it also
  49814. * renders in the main frame buffer of the canvas.
  49815. */
  49816. renderOnlyInRenderTargetTextures: boolean;
  49817. private _scene;
  49818. private _vertexBuffers;
  49819. private _indexBuffer;
  49820. private _effect;
  49821. private _alphaTestEffect;
  49822. /**
  49823. * An event triggered when the layer is disposed.
  49824. */
  49825. onDisposeObservable: Observable<Layer>;
  49826. private _onDisposeObserver;
  49827. /**
  49828. * Back compatibility with callback before the onDisposeObservable existed.
  49829. * The set callback will be triggered when the layer has been disposed.
  49830. */
  49831. onDispose: () => void;
  49832. /**
  49833. * An event triggered before rendering the scene
  49834. */
  49835. onBeforeRenderObservable: Observable<Layer>;
  49836. private _onBeforeRenderObserver;
  49837. /**
  49838. * Back compatibility with callback before the onBeforeRenderObservable existed.
  49839. * The set callback will be triggered just before rendering the layer.
  49840. */
  49841. onBeforeRender: () => void;
  49842. /**
  49843. * An event triggered after rendering the scene
  49844. */
  49845. onAfterRenderObservable: Observable<Layer>;
  49846. private _onAfterRenderObserver;
  49847. /**
  49848. * Back compatibility with callback before the onAfterRenderObservable existed.
  49849. * The set callback will be triggered just after rendering the layer.
  49850. */
  49851. onAfterRender: () => void;
  49852. /**
  49853. * Instantiates a new layer.
  49854. * This represents a full screen 2d layer.
  49855. * This can be useful to display a picture in the background of your scene for instance.
  49856. * @see https://www.babylonjs-playground.com/#08A2BS#1
  49857. * @param name Define the name of the layer in the scene
  49858. * @param imgUrl Define the url of the texture to display in the layer
  49859. * @param scene Define the scene the layer belongs to
  49860. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  49861. * @param color Defines a color for the layer
  49862. */
  49863. constructor(
  49864. /**
  49865. * Define the name of the layer.
  49866. */
  49867. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  49868. private _createIndexBuffer;
  49869. /** @hidden */
  49870. _rebuild(): void;
  49871. /**
  49872. * Renders the layer in the scene.
  49873. */
  49874. render(): void;
  49875. /**
  49876. * Disposes and releases the associated ressources.
  49877. */
  49878. dispose(): void;
  49879. }
  49880. }
  49881. declare module "babylonjs/Layers/index" {
  49882. export * from "babylonjs/Layers/effectLayer";
  49883. export * from "babylonjs/Layers/effectLayerSceneComponent";
  49884. export * from "babylonjs/Layers/glowLayer";
  49885. export * from "babylonjs/Layers/highlightLayer";
  49886. export * from "babylonjs/Layers/layer";
  49887. export * from "babylonjs/Layers/layerSceneComponent";
  49888. }
  49889. declare module "babylonjs/Shaders/lensFlare.fragment" {
  49890. /** @hidden */
  49891. export var lensFlarePixelShader: {
  49892. name: string;
  49893. shader: string;
  49894. };
  49895. }
  49896. declare module "babylonjs/Shaders/lensFlare.vertex" {
  49897. /** @hidden */
  49898. export var lensFlareVertexShader: {
  49899. name: string;
  49900. shader: string;
  49901. };
  49902. }
  49903. declare module "babylonjs/LensFlares/lensFlareSystem" {
  49904. import { Scene } from "babylonjs/scene";
  49905. import { Vector3, Viewport } from "babylonjs/Maths/math";
  49906. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49907. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  49908. import "babylonjs/Shaders/lensFlare.fragment";
  49909. import "babylonjs/Shaders/lensFlare.vertex";
  49910. /**
  49911. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  49912. * It is usually composed of several `lensFlare`.
  49913. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49914. */
  49915. export class LensFlareSystem {
  49916. /**
  49917. * Define the name of the lens flare system
  49918. */
  49919. name: string;
  49920. /**
  49921. * List of lens flares used in this system.
  49922. */
  49923. lensFlares: LensFlare[];
  49924. /**
  49925. * Define a limit from the border the lens flare can be visible.
  49926. */
  49927. borderLimit: number;
  49928. /**
  49929. * Define a viewport border we do not want to see the lens flare in.
  49930. */
  49931. viewportBorder: number;
  49932. /**
  49933. * Define a predicate which could limit the list of meshes able to occlude the effect.
  49934. */
  49935. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  49936. /**
  49937. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  49938. */
  49939. layerMask: number;
  49940. /**
  49941. * Define the id of the lens flare system in the scene.
  49942. * (equal to name by default)
  49943. */
  49944. id: string;
  49945. private _scene;
  49946. private _emitter;
  49947. private _vertexBuffers;
  49948. private _indexBuffer;
  49949. private _effect;
  49950. private _positionX;
  49951. private _positionY;
  49952. private _isEnabled;
  49953. /** @hidden */
  49954. static _SceneComponentInitialization: (scene: Scene) => void;
  49955. /**
  49956. * Instantiates a lens flare system.
  49957. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  49958. * It is usually composed of several `lensFlare`.
  49959. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49960. * @param name Define the name of the lens flare system in the scene
  49961. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  49962. * @param scene Define the scene the lens flare system belongs to
  49963. */
  49964. constructor(
  49965. /**
  49966. * Define the name of the lens flare system
  49967. */
  49968. name: string, emitter: any, scene: Scene);
  49969. /**
  49970. * Define if the lens flare system is enabled.
  49971. */
  49972. isEnabled: boolean;
  49973. /**
  49974. * Get the scene the effects belongs to.
  49975. * @returns the scene holding the lens flare system
  49976. */
  49977. getScene(): Scene;
  49978. /**
  49979. * Get the emitter of the lens flare system.
  49980. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  49981. * @returns the emitter of the lens flare system
  49982. */
  49983. getEmitter(): any;
  49984. /**
  49985. * Set the emitter of the lens flare system.
  49986. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  49987. * @param newEmitter Define the new emitter of the system
  49988. */
  49989. setEmitter(newEmitter: any): void;
  49990. /**
  49991. * Get the lens flare system emitter position.
  49992. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  49993. * @returns the position
  49994. */
  49995. getEmitterPosition(): Vector3;
  49996. /**
  49997. * @hidden
  49998. */
  49999. computeEffectivePosition(globalViewport: Viewport): boolean;
  50000. /** @hidden */
  50001. _isVisible(): boolean;
  50002. /**
  50003. * @hidden
  50004. */
  50005. render(): boolean;
  50006. /**
  50007. * Dispose and release the lens flare with its associated resources.
  50008. */
  50009. dispose(): void;
  50010. /**
  50011. * Parse a lens flare system from a JSON repressentation
  50012. * @param parsedLensFlareSystem Define the JSON to parse
  50013. * @param scene Define the scene the parsed system should be instantiated in
  50014. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  50015. * @returns the parsed system
  50016. */
  50017. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  50018. /**
  50019. * Serialize the current Lens Flare System into a JSON representation.
  50020. * @returns the serialized JSON
  50021. */
  50022. serialize(): any;
  50023. }
  50024. }
  50025. declare module "babylonjs/LensFlares/lensFlare" {
  50026. import { Nullable } from "babylonjs/types";
  50027. import { Color3 } from "babylonjs/Maths/math";
  50028. import { Texture } from "babylonjs/Materials/Textures/texture";
  50029. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  50030. /**
  50031. * This represents one of the lens effect in a `lensFlareSystem`.
  50032. * It controls one of the indiviual texture used in the effect.
  50033. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50034. */
  50035. export class LensFlare {
  50036. /**
  50037. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  50038. */
  50039. size: number;
  50040. /**
  50041. * 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.
  50042. */
  50043. position: number;
  50044. /**
  50045. * Define the lens color.
  50046. */
  50047. color: Color3;
  50048. /**
  50049. * Define the lens texture.
  50050. */
  50051. texture: Nullable<Texture>;
  50052. /**
  50053. * Define the alpha mode to render this particular lens.
  50054. */
  50055. alphaMode: number;
  50056. private _system;
  50057. /**
  50058. * Creates a new Lens Flare.
  50059. * This represents one of the lens effect in a `lensFlareSystem`.
  50060. * It controls one of the indiviual texture used in the effect.
  50061. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50062. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  50063. * @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.
  50064. * @param color Define the lens color
  50065. * @param imgUrl Define the lens texture url
  50066. * @param system Define the `lensFlareSystem` this flare is part of
  50067. * @returns The newly created Lens Flare
  50068. */
  50069. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  50070. /**
  50071. * Instantiates a new Lens Flare.
  50072. * This represents one of the lens effect in a `lensFlareSystem`.
  50073. * It controls one of the indiviual texture used in the effect.
  50074. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50075. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  50076. * @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.
  50077. * @param color Define the lens color
  50078. * @param imgUrl Define the lens texture url
  50079. * @param system Define the `lensFlareSystem` this flare is part of
  50080. */
  50081. constructor(
  50082. /**
  50083. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  50084. */
  50085. size: number,
  50086. /**
  50087. * 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.
  50088. */
  50089. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  50090. /**
  50091. * Dispose and release the lens flare with its associated resources.
  50092. */
  50093. dispose(): void;
  50094. }
  50095. }
  50096. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  50097. import { Nullable } from "babylonjs/types";
  50098. import { Scene } from "babylonjs/scene";
  50099. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  50100. import { AbstractScene } from "babylonjs/abstractScene";
  50101. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  50102. module "babylonjs/abstractScene" {
  50103. interface AbstractScene {
  50104. /**
  50105. * The list of lens flare system added to the scene
  50106. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50107. */
  50108. lensFlareSystems: Array<LensFlareSystem>;
  50109. /**
  50110. * Removes the given lens flare system from this scene.
  50111. * @param toRemove The lens flare system to remove
  50112. * @returns The index of the removed lens flare system
  50113. */
  50114. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  50115. /**
  50116. * Adds the given lens flare system to this scene
  50117. * @param newLensFlareSystem The lens flare system to add
  50118. */
  50119. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  50120. /**
  50121. * Gets a lens flare system using its name
  50122. * @param name defines the name to look for
  50123. * @returns the lens flare system or null if not found
  50124. */
  50125. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  50126. /**
  50127. * Gets a lens flare system using its id
  50128. * @param id defines the id to look for
  50129. * @returns the lens flare system or null if not found
  50130. */
  50131. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  50132. }
  50133. }
  50134. /**
  50135. * Defines the lens flare scene component responsible to manage any lens flares
  50136. * in a given scene.
  50137. */
  50138. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  50139. /**
  50140. * The component name helpfull to identify the component in the list of scene components.
  50141. */
  50142. readonly name: string;
  50143. /**
  50144. * The scene the component belongs to.
  50145. */
  50146. scene: Scene;
  50147. /**
  50148. * Creates a new instance of the component for the given scene
  50149. * @param scene Defines the scene to register the component in
  50150. */
  50151. constructor(scene: Scene);
  50152. /**
  50153. * Registers the component in a given scene
  50154. */
  50155. register(): void;
  50156. /**
  50157. * Rebuilds the elements related to this component in case of
  50158. * context lost for instance.
  50159. */
  50160. rebuild(): void;
  50161. /**
  50162. * Adds all the elements from the container to the scene
  50163. * @param container the container holding the elements
  50164. */
  50165. addFromContainer(container: AbstractScene): void;
  50166. /**
  50167. * Removes all the elements in the container from the scene
  50168. * @param container contains the elements to remove
  50169. * @param dispose if the removed element should be disposed (default: false)
  50170. */
  50171. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  50172. /**
  50173. * Serializes the component data to the specified json object
  50174. * @param serializationObject The object to serialize to
  50175. */
  50176. serialize(serializationObject: any): void;
  50177. /**
  50178. * Disposes the component and the associated ressources.
  50179. */
  50180. dispose(): void;
  50181. private _draw;
  50182. }
  50183. }
  50184. declare module "babylonjs/LensFlares/index" {
  50185. export * from "babylonjs/LensFlares/lensFlare";
  50186. export * from "babylonjs/LensFlares/lensFlareSystem";
  50187. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  50188. }
  50189. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  50190. import { Scene } from "babylonjs/scene";
  50191. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  50192. import { AbstractScene } from "babylonjs/abstractScene";
  50193. /**
  50194. * Defines the shadow generator component responsible to manage any shadow generators
  50195. * in a given scene.
  50196. */
  50197. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  50198. /**
  50199. * The component name helpfull to identify the component in the list of scene components.
  50200. */
  50201. readonly name: string;
  50202. /**
  50203. * The scene the component belongs to.
  50204. */
  50205. scene: Scene;
  50206. /**
  50207. * Creates a new instance of the component for the given scene
  50208. * @param scene Defines the scene to register the component in
  50209. */
  50210. constructor(scene: Scene);
  50211. /**
  50212. * Registers the component in a given scene
  50213. */
  50214. register(): void;
  50215. /**
  50216. * Rebuilds the elements related to this component in case of
  50217. * context lost for instance.
  50218. */
  50219. rebuild(): void;
  50220. /**
  50221. * Serializes the component data to the specified json object
  50222. * @param serializationObject The object to serialize to
  50223. */
  50224. serialize(serializationObject: any): void;
  50225. /**
  50226. * Adds all the elements from the container to the scene
  50227. * @param container the container holding the elements
  50228. */
  50229. addFromContainer(container: AbstractScene): void;
  50230. /**
  50231. * Removes all the elements in the container from the scene
  50232. * @param container contains the elements to remove
  50233. * @param dispose if the removed element should be disposed (default: false)
  50234. */
  50235. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  50236. /**
  50237. * Rebuilds the elements related to this component in case of
  50238. * context lost for instance.
  50239. */
  50240. dispose(): void;
  50241. private _gatherRenderTargets;
  50242. }
  50243. }
  50244. declare module "babylonjs/Lights/Shadows/index" {
  50245. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  50246. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  50247. }
  50248. declare module "babylonjs/Lights/pointLight" {
  50249. import { Scene } from "babylonjs/scene";
  50250. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  50251. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50252. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  50253. import { Effect } from "babylonjs/Materials/effect";
  50254. /**
  50255. * A point light is a light defined by an unique point in world space.
  50256. * The light is emitted in every direction from this point.
  50257. * A good example of a point light is a standard light bulb.
  50258. * Documentation: https://doc.babylonjs.com/babylon101/lights
  50259. */
  50260. export class PointLight extends ShadowLight {
  50261. private _shadowAngle;
  50262. /**
  50263. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50264. * This specifies what angle the shadow will use to be created.
  50265. *
  50266. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  50267. */
  50268. /**
  50269. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50270. * This specifies what angle the shadow will use to be created.
  50271. *
  50272. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  50273. */
  50274. shadowAngle: number;
  50275. /**
  50276. * Gets the direction if it has been set.
  50277. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50278. */
  50279. /**
  50280. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50281. */
  50282. direction: Vector3;
  50283. /**
  50284. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  50285. * A PointLight emits the light in every direction.
  50286. * It can cast shadows.
  50287. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  50288. * ```javascript
  50289. * var pointLight = new PointLight("pl", camera.position, scene);
  50290. * ```
  50291. * Documentation : https://doc.babylonjs.com/babylon101/lights
  50292. * @param name The light friendly name
  50293. * @param position The position of the point light in the scene
  50294. * @param scene The scene the lights belongs to
  50295. */
  50296. constructor(name: string, position: Vector3, scene: Scene);
  50297. /**
  50298. * Returns the string "PointLight"
  50299. * @returns the class name
  50300. */
  50301. getClassName(): string;
  50302. /**
  50303. * Returns the integer 0.
  50304. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  50305. */
  50306. getTypeID(): number;
  50307. /**
  50308. * Specifies wether or not the shadowmap should be a cube texture.
  50309. * @returns true if the shadowmap needs to be a cube texture.
  50310. */
  50311. needCube(): boolean;
  50312. /**
  50313. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  50314. * @param faceIndex The index of the face we are computed the direction to generate shadow
  50315. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  50316. */
  50317. getShadowDirection(faceIndex?: number): Vector3;
  50318. /**
  50319. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  50320. * - fov = PI / 2
  50321. * - aspect ratio : 1.0
  50322. * - z-near and far equal to the active camera minZ and maxZ.
  50323. * Returns the PointLight.
  50324. */
  50325. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  50326. protected _buildUniformLayout(): void;
  50327. /**
  50328. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  50329. * @param effect The effect to update
  50330. * @param lightIndex The index of the light in the effect to update
  50331. * @returns The point light
  50332. */
  50333. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  50334. /**
  50335. * Prepares the list of defines specific to the light type.
  50336. * @param defines the list of defines
  50337. * @param lightIndex defines the index of the light for the effect
  50338. */
  50339. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  50340. }
  50341. }
  50342. declare module "babylonjs/Lights/index" {
  50343. export * from "babylonjs/Lights/light";
  50344. export * from "babylonjs/Lights/shadowLight";
  50345. export * from "babylonjs/Lights/Shadows/index";
  50346. export * from "babylonjs/Lights/directionalLight";
  50347. export * from "babylonjs/Lights/hemisphericLight";
  50348. export * from "babylonjs/Lights/pointLight";
  50349. export * from "babylonjs/Lights/spotLight";
  50350. }
  50351. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  50352. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  50353. /**
  50354. * Header information of HDR texture files.
  50355. */
  50356. export interface HDRInfo {
  50357. /**
  50358. * The height of the texture in pixels.
  50359. */
  50360. height: number;
  50361. /**
  50362. * The width of the texture in pixels.
  50363. */
  50364. width: number;
  50365. /**
  50366. * The index of the beginning of the data in the binary file.
  50367. */
  50368. dataPosition: number;
  50369. }
  50370. /**
  50371. * This groups tools to convert HDR texture to native colors array.
  50372. */
  50373. export class HDRTools {
  50374. private static Ldexp;
  50375. private static Rgbe2float;
  50376. private static readStringLine;
  50377. /**
  50378. * Reads header information from an RGBE texture stored in a native array.
  50379. * More information on this format are available here:
  50380. * https://en.wikipedia.org/wiki/RGBE_image_format
  50381. *
  50382. * @param uint8array The binary file stored in native array.
  50383. * @return The header information.
  50384. */
  50385. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  50386. /**
  50387. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  50388. * This RGBE texture needs to store the information as a panorama.
  50389. *
  50390. * More information on this format are available here:
  50391. * https://en.wikipedia.org/wiki/RGBE_image_format
  50392. *
  50393. * @param buffer The binary file stored in an array buffer.
  50394. * @param size The expected size of the extracted cubemap.
  50395. * @return The Cube Map information.
  50396. */
  50397. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  50398. /**
  50399. * Returns the pixels data extracted from an RGBE texture.
  50400. * This pixels will be stored left to right up to down in the R G B order in one array.
  50401. *
  50402. * More information on this format are available here:
  50403. * https://en.wikipedia.org/wiki/RGBE_image_format
  50404. *
  50405. * @param uint8array The binary file stored in an array buffer.
  50406. * @param hdrInfo The header information of the file.
  50407. * @return The pixels data in RGB right to left up to down order.
  50408. */
  50409. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  50410. private static RGBE_ReadPixels_RLE;
  50411. }
  50412. }
  50413. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  50414. import { Nullable } from "babylonjs/types";
  50415. import { Scene } from "babylonjs/scene";
  50416. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  50417. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50418. import "babylonjs/Engines/Extensions/engine.rawTexture";
  50419. /**
  50420. * This represents a texture coming from an HDR input.
  50421. *
  50422. * The only supported format is currently panorama picture stored in RGBE format.
  50423. * Example of such files can be found on HDRLib: http://hdrlib.com/
  50424. */
  50425. export class HDRCubeTexture extends BaseTexture {
  50426. private static _facesMapping;
  50427. private _generateHarmonics;
  50428. private _noMipmap;
  50429. private _textureMatrix;
  50430. private _size;
  50431. private _onLoad;
  50432. private _onError;
  50433. /**
  50434. * The texture URL.
  50435. */
  50436. url: string;
  50437. /**
  50438. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  50439. */
  50440. coordinatesMode: number;
  50441. protected _isBlocking: boolean;
  50442. /**
  50443. * Sets wether or not the texture is blocking during loading.
  50444. */
  50445. /**
  50446. * Gets wether or not the texture is blocking during loading.
  50447. */
  50448. isBlocking: boolean;
  50449. protected _rotationY: number;
  50450. /**
  50451. * Sets texture matrix rotation angle around Y axis in radians.
  50452. */
  50453. /**
  50454. * Gets texture matrix rotation angle around Y axis radians.
  50455. */
  50456. rotationY: number;
  50457. /**
  50458. * Gets or sets the center of the bounding box associated with the cube texture
  50459. * It must define where the camera used to render the texture was set
  50460. */
  50461. boundingBoxPosition: Vector3;
  50462. private _boundingBoxSize;
  50463. /**
  50464. * Gets or sets the size of the bounding box associated with the cube texture
  50465. * When defined, the cubemap will switch to local mode
  50466. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  50467. * @example https://www.babylonjs-playground.com/#RNASML
  50468. */
  50469. boundingBoxSize: Vector3;
  50470. /**
  50471. * Instantiates an HDRTexture from the following parameters.
  50472. *
  50473. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  50474. * @param scene The scene the texture will be used in
  50475. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  50476. * @param noMipmap Forces to not generate the mipmap if true
  50477. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  50478. * @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)
  50479. * @param reserved Reserved flag for internal use.
  50480. */
  50481. 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>);
  50482. /**
  50483. * Get the current class name of the texture useful for serialization or dynamic coding.
  50484. * @returns "HDRCubeTexture"
  50485. */
  50486. getClassName(): string;
  50487. /**
  50488. * Occurs when the file is raw .hdr file.
  50489. */
  50490. private loadTexture;
  50491. clone(): HDRCubeTexture;
  50492. delayLoad(): void;
  50493. /**
  50494. * Get the texture reflection matrix used to rotate/transform the reflection.
  50495. * @returns the reflection matrix
  50496. */
  50497. getReflectionTextureMatrix(): Matrix;
  50498. /**
  50499. * Set the texture reflection matrix used to rotate/transform the reflection.
  50500. * @param value Define the reflection matrix to set
  50501. */
  50502. setReflectionTextureMatrix(value: Matrix): void;
  50503. /**
  50504. * Parses a JSON representation of an HDR Texture in order to create the texture
  50505. * @param parsedTexture Define the JSON representation
  50506. * @param scene Define the scene the texture should be created in
  50507. * @param rootUrl Define the root url in case we need to load relative dependencies
  50508. * @returns the newly created texture after parsing
  50509. */
  50510. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  50511. serialize(): any;
  50512. }
  50513. }
  50514. declare module "babylonjs/Physics/physicsEngine" {
  50515. import { Nullable } from "babylonjs/types";
  50516. import { Vector3 } from "babylonjs/Maths/math";
  50517. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  50518. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  50519. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  50520. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  50521. /**
  50522. * Class used to control physics engine
  50523. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  50524. */
  50525. export class PhysicsEngine implements IPhysicsEngine {
  50526. private _physicsPlugin;
  50527. /**
  50528. * Global value used to control the smallest number supported by the simulation
  50529. */
  50530. static Epsilon: number;
  50531. private _impostors;
  50532. private _joints;
  50533. /**
  50534. * Gets the gravity vector used by the simulation
  50535. */
  50536. gravity: Vector3;
  50537. /**
  50538. * Factory used to create the default physics plugin.
  50539. * @returns The default physics plugin
  50540. */
  50541. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  50542. /**
  50543. * Creates a new Physics Engine
  50544. * @param gravity defines the gravity vector used by the simulation
  50545. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  50546. */
  50547. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  50548. /**
  50549. * Sets the gravity vector used by the simulation
  50550. * @param gravity defines the gravity vector to use
  50551. */
  50552. setGravity(gravity: Vector3): void;
  50553. /**
  50554. * Set the time step of the physics engine.
  50555. * Default is 1/60.
  50556. * To slow it down, enter 1/600 for example.
  50557. * To speed it up, 1/30
  50558. * @param newTimeStep defines the new timestep to apply to this world.
  50559. */
  50560. setTimeStep(newTimeStep?: number): void;
  50561. /**
  50562. * Get the time step of the physics engine.
  50563. * @returns the current time step
  50564. */
  50565. getTimeStep(): number;
  50566. /**
  50567. * Release all resources
  50568. */
  50569. dispose(): void;
  50570. /**
  50571. * Gets the name of the current physics plugin
  50572. * @returns the name of the plugin
  50573. */
  50574. getPhysicsPluginName(): string;
  50575. /**
  50576. * Adding a new impostor for the impostor tracking.
  50577. * This will be done by the impostor itself.
  50578. * @param impostor the impostor to add
  50579. */
  50580. addImpostor(impostor: PhysicsImpostor): void;
  50581. /**
  50582. * Remove an impostor from the engine.
  50583. * This impostor and its mesh will not longer be updated by the physics engine.
  50584. * @param impostor the impostor to remove
  50585. */
  50586. removeImpostor(impostor: PhysicsImpostor): void;
  50587. /**
  50588. * Add a joint to the physics engine
  50589. * @param mainImpostor defines the main impostor to which the joint is added.
  50590. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  50591. * @param joint defines the joint that will connect both impostors.
  50592. */
  50593. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  50594. /**
  50595. * Removes a joint from the simulation
  50596. * @param mainImpostor defines the impostor used with the joint
  50597. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  50598. * @param joint defines the joint to remove
  50599. */
  50600. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  50601. /**
  50602. * Called by the scene. No need to call it.
  50603. * @param delta defines the timespam between frames
  50604. */
  50605. _step(delta: number): void;
  50606. /**
  50607. * Gets the current plugin used to run the simulation
  50608. * @returns current plugin
  50609. */
  50610. getPhysicsPlugin(): IPhysicsEnginePlugin;
  50611. /**
  50612. * Gets the list of physic impostors
  50613. * @returns an array of PhysicsImpostor
  50614. */
  50615. getImpostors(): Array<PhysicsImpostor>;
  50616. /**
  50617. * Gets the impostor for a physics enabled object
  50618. * @param object defines the object impersonated by the impostor
  50619. * @returns the PhysicsImpostor or null if not found
  50620. */
  50621. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  50622. /**
  50623. * Gets the impostor for a physics body object
  50624. * @param body defines physics body used by the impostor
  50625. * @returns the PhysicsImpostor or null if not found
  50626. */
  50627. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  50628. /**
  50629. * Does a raycast in the physics world
  50630. * @param from when should the ray start?
  50631. * @param to when should the ray end?
  50632. * @returns PhysicsRaycastResult
  50633. */
  50634. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50635. }
  50636. }
  50637. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  50638. import { Nullable } from "babylonjs/types";
  50639. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  50640. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50641. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  50642. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  50643. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  50644. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  50645. /** @hidden */
  50646. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  50647. private _useDeltaForWorldStep;
  50648. world: any;
  50649. name: string;
  50650. private _physicsMaterials;
  50651. private _fixedTimeStep;
  50652. private _cannonRaycastResult;
  50653. private _raycastResult;
  50654. private _removeAfterStep;
  50655. BJSCANNON: any;
  50656. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  50657. setGravity(gravity: Vector3): void;
  50658. setTimeStep(timeStep: number): void;
  50659. getTimeStep(): number;
  50660. executeStep(delta: number): void;
  50661. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50662. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50663. generatePhysicsBody(impostor: PhysicsImpostor): void;
  50664. private _processChildMeshes;
  50665. removePhysicsBody(impostor: PhysicsImpostor): void;
  50666. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  50667. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  50668. private _addMaterial;
  50669. private _checkWithEpsilon;
  50670. private _createShape;
  50671. private _createHeightmap;
  50672. private _minus90X;
  50673. private _plus90X;
  50674. private _tmpPosition;
  50675. private _tmpDeltaPosition;
  50676. private _tmpUnityRotation;
  50677. private _updatePhysicsBodyTransformation;
  50678. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  50679. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  50680. isSupported(): boolean;
  50681. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50682. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50683. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50684. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50685. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  50686. getBodyMass(impostor: PhysicsImpostor): number;
  50687. getBodyFriction(impostor: PhysicsImpostor): number;
  50688. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  50689. getBodyRestitution(impostor: PhysicsImpostor): number;
  50690. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  50691. sleepBody(impostor: PhysicsImpostor): void;
  50692. wakeUpBody(impostor: PhysicsImpostor): void;
  50693. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  50694. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  50695. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  50696. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  50697. getRadius(impostor: PhysicsImpostor): number;
  50698. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  50699. dispose(): void;
  50700. private _extendNamespace;
  50701. /**
  50702. * Does a raycast in the physics world
  50703. * @param from when should the ray start?
  50704. * @param to when should the ray end?
  50705. * @returns PhysicsRaycastResult
  50706. */
  50707. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50708. }
  50709. }
  50710. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  50711. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  50712. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  50713. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  50714. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50715. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  50716. import { Nullable } from "babylonjs/types";
  50717. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  50718. /** @hidden */
  50719. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  50720. world: any;
  50721. name: string;
  50722. BJSOIMO: any;
  50723. private _raycastResult;
  50724. constructor(iterations?: number, oimoInjection?: any);
  50725. setGravity(gravity: Vector3): void;
  50726. setTimeStep(timeStep: number): void;
  50727. getTimeStep(): number;
  50728. private _tmpImpostorsArray;
  50729. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  50730. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50731. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50732. generatePhysicsBody(impostor: PhysicsImpostor): void;
  50733. private _tmpPositionVector;
  50734. removePhysicsBody(impostor: PhysicsImpostor): void;
  50735. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  50736. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  50737. isSupported(): boolean;
  50738. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  50739. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  50740. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50741. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50742. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50743. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50744. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  50745. getBodyMass(impostor: PhysicsImpostor): number;
  50746. getBodyFriction(impostor: PhysicsImpostor): number;
  50747. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  50748. getBodyRestitution(impostor: PhysicsImpostor): number;
  50749. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  50750. sleepBody(impostor: PhysicsImpostor): void;
  50751. wakeUpBody(impostor: PhysicsImpostor): void;
  50752. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  50753. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  50754. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  50755. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  50756. getRadius(impostor: PhysicsImpostor): number;
  50757. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  50758. dispose(): void;
  50759. /**
  50760. * Does a raycast in the physics world
  50761. * @param from when should the ray start?
  50762. * @param to when should the ray end?
  50763. * @returns PhysicsRaycastResult
  50764. */
  50765. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50766. }
  50767. }
  50768. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  50769. import { Nullable } from "babylonjs/types";
  50770. import { Scene } from "babylonjs/scene";
  50771. import { Vector3, Vector2, Color4, Vector4 } from "babylonjs/Maths/math";
  50772. import { Mesh } from "babylonjs/Meshes/mesh";
  50773. /**
  50774. * Class containing static functions to help procedurally build meshes
  50775. */
  50776. export class RibbonBuilder {
  50777. /**
  50778. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  50779. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  50780. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  50781. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  50782. * * 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
  50783. * * 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
  50784. * * 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
  50785. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50786. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50787. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50788. * * 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
  50789. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  50790. * * 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
  50791. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  50792. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50793. * @param name defines the name of the mesh
  50794. * @param options defines the options used to create the mesh
  50795. * @param scene defines the hosting scene
  50796. * @returns the ribbon mesh
  50797. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  50798. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50799. */
  50800. static CreateRibbon(name: string, options: {
  50801. pathArray: Vector3[][];
  50802. closeArray?: boolean;
  50803. closePath?: boolean;
  50804. offset?: number;
  50805. updatable?: boolean;
  50806. sideOrientation?: number;
  50807. frontUVs?: Vector4;
  50808. backUVs?: Vector4;
  50809. instance?: Mesh;
  50810. invertUV?: boolean;
  50811. uvs?: Vector2[];
  50812. colors?: Color4[];
  50813. }, scene?: Nullable<Scene>): Mesh;
  50814. }
  50815. }
  50816. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  50817. import { Nullable } from "babylonjs/types";
  50818. import { Scene } from "babylonjs/scene";
  50819. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  50820. import { Mesh } from "babylonjs/Meshes/mesh";
  50821. /**
  50822. * Class containing static functions to help procedurally build meshes
  50823. */
  50824. export class ShapeBuilder {
  50825. /**
  50826. * 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.
  50827. * * 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.
  50828. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50829. * * 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.
  50830. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  50831. * * 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
  50832. * * 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
  50833. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  50834. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50835. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50836. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  50837. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50838. * @param name defines the name of the mesh
  50839. * @param options defines the options used to create the mesh
  50840. * @param scene defines the hosting scene
  50841. * @returns the extruded shape mesh
  50842. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50843. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50844. */
  50845. static ExtrudeShape(name: string, options: {
  50846. shape: Vector3[];
  50847. path: Vector3[];
  50848. scale?: number;
  50849. rotation?: number;
  50850. cap?: number;
  50851. updatable?: boolean;
  50852. sideOrientation?: number;
  50853. frontUVs?: Vector4;
  50854. backUVs?: Vector4;
  50855. instance?: Mesh;
  50856. invertUV?: boolean;
  50857. }, scene?: Nullable<Scene>): Mesh;
  50858. /**
  50859. * Creates an custom extruded shape mesh.
  50860. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  50861. * * 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.
  50862. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50863. * * 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
  50864. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  50865. * * 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
  50866. * * It must returns a float value that will be the scale value applied to the shape on each path point
  50867. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  50868. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  50869. * * 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
  50870. * * 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
  50871. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  50872. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50873. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50874. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50875. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50876. * @param name defines the name of the mesh
  50877. * @param options defines the options used to create the mesh
  50878. * @param scene defines the hosting scene
  50879. * @returns the custom extruded shape mesh
  50880. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  50881. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50882. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50883. */
  50884. static ExtrudeShapeCustom(name: string, options: {
  50885. shape: Vector3[];
  50886. path: Vector3[];
  50887. scaleFunction?: any;
  50888. rotationFunction?: any;
  50889. ribbonCloseArray?: boolean;
  50890. ribbonClosePath?: boolean;
  50891. cap?: number;
  50892. updatable?: boolean;
  50893. sideOrientation?: number;
  50894. frontUVs?: Vector4;
  50895. backUVs?: Vector4;
  50896. instance?: Mesh;
  50897. invertUV?: boolean;
  50898. }, scene?: Nullable<Scene>): Mesh;
  50899. private static _ExtrudeShapeGeneric;
  50900. }
  50901. }
  50902. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  50903. import { Quaternion, Vector3 } from "babylonjs/Maths/math";
  50904. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  50905. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  50906. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  50907. import { Nullable } from "babylonjs/types";
  50908. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50909. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  50910. /**
  50911. * AmmoJS Physics plugin
  50912. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  50913. * @see https://github.com/kripken/ammo.js/
  50914. */
  50915. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  50916. private _useDeltaForWorldStep;
  50917. /**
  50918. * Reference to the Ammo library
  50919. */
  50920. bjsAMMO: any;
  50921. /**
  50922. * Created ammoJS world which physics bodies are added to
  50923. */
  50924. world: any;
  50925. /**
  50926. * Name of the plugin
  50927. */
  50928. name: string;
  50929. private _timeStep;
  50930. private _fixedTimeStep;
  50931. private _maxSteps;
  50932. private _tmpQuaternion;
  50933. private _tmpAmmoTransform;
  50934. private _tmpAmmoQuaternion;
  50935. private _tmpAmmoConcreteContactResultCallback;
  50936. private _collisionConfiguration;
  50937. private _dispatcher;
  50938. private _overlappingPairCache;
  50939. private _solver;
  50940. private _softBodySolver;
  50941. private _tmpAmmoVectorA;
  50942. private _tmpAmmoVectorB;
  50943. private _tmpAmmoVectorC;
  50944. private _tmpAmmoVectorD;
  50945. private _tmpContactCallbackResult;
  50946. private _tmpAmmoVectorRCA;
  50947. private _tmpAmmoVectorRCB;
  50948. private _raycastResult;
  50949. private static readonly DISABLE_COLLISION_FLAG;
  50950. private static readonly KINEMATIC_FLAG;
  50951. private static readonly DISABLE_DEACTIVATION_FLAG;
  50952. /**
  50953. * Initializes the ammoJS plugin
  50954. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  50955. * @param ammoInjection can be used to inject your own ammo reference
  50956. */
  50957. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  50958. /**
  50959. * Sets the gravity of the physics world (m/(s^2))
  50960. * @param gravity Gravity to set
  50961. */
  50962. setGravity(gravity: Vector3): void;
  50963. /**
  50964. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  50965. * @param timeStep timestep to use in seconds
  50966. */
  50967. setTimeStep(timeStep: number): void;
  50968. /**
  50969. * 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)
  50970. * @param fixedTimeStep fixedTimeStep to use in seconds
  50971. */
  50972. setFixedTimeStep(fixedTimeStep: number): void;
  50973. /**
  50974. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  50975. * @param maxSteps the maximum number of steps by the physics engine per frame
  50976. */
  50977. setMaxSteps(maxSteps: number): void;
  50978. /**
  50979. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  50980. * @returns the current timestep in seconds
  50981. */
  50982. getTimeStep(): number;
  50983. private _isImpostorInContact;
  50984. private _isImpostorPairInContact;
  50985. private _stepSimulation;
  50986. /**
  50987. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  50988. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  50989. * After the step the babylon meshes are set to the position of the physics imposters
  50990. * @param delta amount of time to step forward
  50991. * @param impostors array of imposters to update before/after the step
  50992. */
  50993. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  50994. /**
  50995. * Update babylon mesh to match physics world object
  50996. * @param impostor imposter to match
  50997. */
  50998. private _afterSoftStep;
  50999. /**
  51000. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  51001. * @param impostor imposter to match
  51002. */
  51003. private _ropeStep;
  51004. /**
  51005. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  51006. * @param impostor imposter to match
  51007. */
  51008. private _softbodyOrClothStep;
  51009. private _tmpVector;
  51010. private _tmpMatrix;
  51011. /**
  51012. * Applies an impulse on the imposter
  51013. * @param impostor imposter to apply impulse to
  51014. * @param force amount of force to be applied to the imposter
  51015. * @param contactPoint the location to apply the impulse on the imposter
  51016. */
  51017. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51018. /**
  51019. * Applies a force on the imposter
  51020. * @param impostor imposter to apply force
  51021. * @param force amount of force to be applied to the imposter
  51022. * @param contactPoint the location to apply the force on the imposter
  51023. */
  51024. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51025. /**
  51026. * Creates a physics body using the plugin
  51027. * @param impostor the imposter to create the physics body on
  51028. */
  51029. generatePhysicsBody(impostor: PhysicsImpostor): void;
  51030. /**
  51031. * Removes the physics body from the imposter and disposes of the body's memory
  51032. * @param impostor imposter to remove the physics body from
  51033. */
  51034. removePhysicsBody(impostor: PhysicsImpostor): void;
  51035. /**
  51036. * Generates a joint
  51037. * @param impostorJoint the imposter joint to create the joint with
  51038. */
  51039. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  51040. /**
  51041. * Removes a joint
  51042. * @param impostorJoint the imposter joint to remove the joint from
  51043. */
  51044. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  51045. private _addMeshVerts;
  51046. /**
  51047. * Initialise the soft body vertices to match its object's (mesh) vertices
  51048. * Softbody vertices (nodes) are in world space and to match this
  51049. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  51050. * @param impostor to create the softbody for
  51051. */
  51052. private _softVertexData;
  51053. /**
  51054. * Create an impostor's soft body
  51055. * @param impostor to create the softbody for
  51056. */
  51057. private _createSoftbody;
  51058. /**
  51059. * Create cloth for an impostor
  51060. * @param impostor to create the softbody for
  51061. */
  51062. private _createCloth;
  51063. /**
  51064. * Create rope for an impostor
  51065. * @param impostor to create the softbody for
  51066. */
  51067. private _createRope;
  51068. private _addHullVerts;
  51069. private _createShape;
  51070. /**
  51071. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  51072. * @param impostor imposter containing the physics body and babylon object
  51073. */
  51074. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  51075. /**
  51076. * Sets the babylon object's position/rotation from the physics body's position/rotation
  51077. * @param impostor imposter containing the physics body and babylon object
  51078. * @param newPosition new position
  51079. * @param newRotation new rotation
  51080. */
  51081. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  51082. /**
  51083. * If this plugin is supported
  51084. * @returns true if its supported
  51085. */
  51086. isSupported(): boolean;
  51087. /**
  51088. * Sets the linear velocity of the physics body
  51089. * @param impostor imposter to set the velocity on
  51090. * @param velocity velocity to set
  51091. */
  51092. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51093. /**
  51094. * Sets the angular velocity of the physics body
  51095. * @param impostor imposter to set the velocity on
  51096. * @param velocity velocity to set
  51097. */
  51098. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51099. /**
  51100. * gets the linear velocity
  51101. * @param impostor imposter to get linear velocity from
  51102. * @returns linear velocity
  51103. */
  51104. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51105. /**
  51106. * gets the angular velocity
  51107. * @param impostor imposter to get angular velocity from
  51108. * @returns angular velocity
  51109. */
  51110. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51111. /**
  51112. * Sets the mass of physics body
  51113. * @param impostor imposter to set the mass on
  51114. * @param mass mass to set
  51115. */
  51116. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  51117. /**
  51118. * Gets the mass of the physics body
  51119. * @param impostor imposter to get the mass from
  51120. * @returns mass
  51121. */
  51122. getBodyMass(impostor: PhysicsImpostor): number;
  51123. /**
  51124. * Gets friction of the impostor
  51125. * @param impostor impostor to get friction from
  51126. * @returns friction value
  51127. */
  51128. getBodyFriction(impostor: PhysicsImpostor): number;
  51129. /**
  51130. * Sets friction of the impostor
  51131. * @param impostor impostor to set friction on
  51132. * @param friction friction value
  51133. */
  51134. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  51135. /**
  51136. * Gets restitution of the impostor
  51137. * @param impostor impostor to get restitution from
  51138. * @returns restitution value
  51139. */
  51140. getBodyRestitution(impostor: PhysicsImpostor): number;
  51141. /**
  51142. * Sets resitution of the impostor
  51143. * @param impostor impostor to set resitution on
  51144. * @param restitution resitution value
  51145. */
  51146. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  51147. /**
  51148. * Gets pressure inside the impostor
  51149. * @param impostor impostor to get pressure from
  51150. * @returns pressure value
  51151. */
  51152. getBodyPressure(impostor: PhysicsImpostor): number;
  51153. /**
  51154. * Sets pressure inside a soft body impostor
  51155. * Cloth and rope must remain 0 pressure
  51156. * @param impostor impostor to set pressure on
  51157. * @param pressure pressure value
  51158. */
  51159. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  51160. /**
  51161. * Gets stiffness of the impostor
  51162. * @param impostor impostor to get stiffness from
  51163. * @returns pressure value
  51164. */
  51165. getBodyStiffness(impostor: PhysicsImpostor): number;
  51166. /**
  51167. * Sets stiffness of the impostor
  51168. * @param impostor impostor to set stiffness on
  51169. * @param stiffness stiffness value from 0 to 1
  51170. */
  51171. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  51172. /**
  51173. * Gets velocityIterations of the impostor
  51174. * @param impostor impostor to get velocity iterations from
  51175. * @returns velocityIterations value
  51176. */
  51177. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  51178. /**
  51179. * Sets velocityIterations of the impostor
  51180. * @param impostor impostor to set velocity iterations on
  51181. * @param velocityIterations velocityIterations value
  51182. */
  51183. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  51184. /**
  51185. * Gets positionIterations of the impostor
  51186. * @param impostor impostor to get position iterations from
  51187. * @returns positionIterations value
  51188. */
  51189. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  51190. /**
  51191. * Sets positionIterations of the impostor
  51192. * @param impostor impostor to set position on
  51193. * @param positionIterations positionIterations value
  51194. */
  51195. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  51196. /**
  51197. * Append an anchor to a cloth object
  51198. * @param impostor is the cloth impostor to add anchor to
  51199. * @param otherImpostor is the rigid impostor to anchor to
  51200. * @param width ratio across width from 0 to 1
  51201. * @param height ratio up height from 0 to 1
  51202. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  51203. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  51204. */
  51205. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  51206. /**
  51207. * Append an hook to a rope object
  51208. * @param impostor is the rope impostor to add hook to
  51209. * @param otherImpostor is the rigid impostor to hook to
  51210. * @param length ratio along the rope from 0 to 1
  51211. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  51212. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  51213. */
  51214. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  51215. /**
  51216. * Sleeps the physics body and stops it from being active
  51217. * @param impostor impostor to sleep
  51218. */
  51219. sleepBody(impostor: PhysicsImpostor): void;
  51220. /**
  51221. * Activates the physics body
  51222. * @param impostor impostor to activate
  51223. */
  51224. wakeUpBody(impostor: PhysicsImpostor): void;
  51225. /**
  51226. * Updates the distance parameters of the joint
  51227. * @param joint joint to update
  51228. * @param maxDistance maximum distance of the joint
  51229. * @param minDistance minimum distance of the joint
  51230. */
  51231. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  51232. /**
  51233. * Sets a motor on the joint
  51234. * @param joint joint to set motor on
  51235. * @param speed speed of the motor
  51236. * @param maxForce maximum force of the motor
  51237. * @param motorIndex index of the motor
  51238. */
  51239. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  51240. /**
  51241. * Sets the motors limit
  51242. * @param joint joint to set limit on
  51243. * @param upperLimit upper limit
  51244. * @param lowerLimit lower limit
  51245. */
  51246. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  51247. /**
  51248. * Syncs the position and rotation of a mesh with the impostor
  51249. * @param mesh mesh to sync
  51250. * @param impostor impostor to update the mesh with
  51251. */
  51252. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  51253. /**
  51254. * Gets the radius of the impostor
  51255. * @param impostor impostor to get radius from
  51256. * @returns the radius
  51257. */
  51258. getRadius(impostor: PhysicsImpostor): number;
  51259. /**
  51260. * Gets the box size of the impostor
  51261. * @param impostor impostor to get box size from
  51262. * @param result the resulting box size
  51263. */
  51264. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  51265. /**
  51266. * Disposes of the impostor
  51267. */
  51268. dispose(): void;
  51269. /**
  51270. * Does a raycast in the physics world
  51271. * @param from when should the ray start?
  51272. * @param to when should the ray end?
  51273. * @returns PhysicsRaycastResult
  51274. */
  51275. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  51276. }
  51277. }
  51278. declare module "babylonjs/Probes/reflectionProbe" {
  51279. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  51280. import { Vector3 } from "babylonjs/Maths/math";
  51281. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51282. import { Nullable } from "babylonjs/types";
  51283. import { Scene } from "babylonjs/scene";
  51284. module "babylonjs/abstractScene" {
  51285. interface AbstractScene {
  51286. /**
  51287. * The list of reflection probes added to the scene
  51288. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  51289. */
  51290. reflectionProbes: Array<ReflectionProbe>;
  51291. /**
  51292. * Removes the given reflection probe from this scene.
  51293. * @param toRemove The reflection probe to remove
  51294. * @returns The index of the removed reflection probe
  51295. */
  51296. removeReflectionProbe(toRemove: ReflectionProbe): number;
  51297. /**
  51298. * Adds the given reflection probe to this scene.
  51299. * @param newReflectionProbe The reflection probe to add
  51300. */
  51301. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  51302. }
  51303. }
  51304. /**
  51305. * Class used to generate realtime reflection / refraction cube textures
  51306. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  51307. */
  51308. export class ReflectionProbe {
  51309. /** defines the name of the probe */
  51310. name: string;
  51311. private _scene;
  51312. private _renderTargetTexture;
  51313. private _projectionMatrix;
  51314. private _viewMatrix;
  51315. private _target;
  51316. private _add;
  51317. private _attachedMesh;
  51318. private _invertYAxis;
  51319. /** Gets or sets probe position (center of the cube map) */
  51320. position: Vector3;
  51321. /**
  51322. * Creates a new reflection probe
  51323. * @param name defines the name of the probe
  51324. * @param size defines the texture resolution (for each face)
  51325. * @param scene defines the hosting scene
  51326. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  51327. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  51328. */
  51329. constructor(
  51330. /** defines the name of the probe */
  51331. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  51332. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  51333. samples: number;
  51334. /** Gets or sets the refresh rate to use (on every frame by default) */
  51335. refreshRate: number;
  51336. /**
  51337. * Gets the hosting scene
  51338. * @returns a Scene
  51339. */
  51340. getScene(): Scene;
  51341. /** Gets the internal CubeTexture used to render to */
  51342. readonly cubeTexture: RenderTargetTexture;
  51343. /** Gets the list of meshes to render */
  51344. readonly renderList: Nullable<AbstractMesh[]>;
  51345. /**
  51346. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  51347. * @param mesh defines the mesh to attach to
  51348. */
  51349. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  51350. /**
  51351. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  51352. * @param renderingGroupId The rendering group id corresponding to its index
  51353. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  51354. */
  51355. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  51356. /**
  51357. * Clean all associated resources
  51358. */
  51359. dispose(): void;
  51360. /**
  51361. * Converts the reflection probe information to a readable string for debug purpose.
  51362. * @param fullDetails Supports for multiple levels of logging within scene loading
  51363. * @returns the human readable reflection probe info
  51364. */
  51365. toString(fullDetails?: boolean): string;
  51366. /**
  51367. * Get the class name of the relfection probe.
  51368. * @returns "ReflectionProbe"
  51369. */
  51370. getClassName(): string;
  51371. /**
  51372. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  51373. * @returns The JSON representation of the texture
  51374. */
  51375. serialize(): any;
  51376. /**
  51377. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  51378. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  51379. * @param scene Define the scene the parsed reflection probe should be instantiated in
  51380. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  51381. * @returns The parsed reflection probe if successful
  51382. */
  51383. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  51384. }
  51385. }
  51386. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  51387. /** @hidden */
  51388. export var _BabylonLoaderRegistered: boolean;
  51389. }
  51390. declare module "babylonjs/Loading/Plugins/index" {
  51391. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  51392. }
  51393. declare module "babylonjs/Loading/index" {
  51394. export * from "babylonjs/Loading/loadingScreen";
  51395. export * from "babylonjs/Loading/Plugins/index";
  51396. export * from "babylonjs/Loading/sceneLoader";
  51397. export * from "babylonjs/Loading/sceneLoaderFlags";
  51398. }
  51399. declare module "babylonjs/Materials/Background/index" {
  51400. export * from "babylonjs/Materials/Background/backgroundMaterial";
  51401. }
  51402. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  51403. import { Scene } from "babylonjs/scene";
  51404. import { Color3 } from "babylonjs/Maths/math";
  51405. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  51406. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51407. /**
  51408. * The Physically based simple base material of BJS.
  51409. *
  51410. * This enables better naming and convention enforcements on top of the pbrMaterial.
  51411. * It is used as the base class for both the specGloss and metalRough conventions.
  51412. */
  51413. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  51414. /**
  51415. * Number of Simultaneous lights allowed on the material.
  51416. */
  51417. maxSimultaneousLights: number;
  51418. /**
  51419. * If sets to true, disables all the lights affecting the material.
  51420. */
  51421. disableLighting: boolean;
  51422. /**
  51423. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  51424. */
  51425. environmentTexture: BaseTexture;
  51426. /**
  51427. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  51428. */
  51429. invertNormalMapX: boolean;
  51430. /**
  51431. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  51432. */
  51433. invertNormalMapY: boolean;
  51434. /**
  51435. * Normal map used in the model.
  51436. */
  51437. normalTexture: BaseTexture;
  51438. /**
  51439. * Emissivie color used to self-illuminate the model.
  51440. */
  51441. emissiveColor: Color3;
  51442. /**
  51443. * Emissivie texture used to self-illuminate the model.
  51444. */
  51445. emissiveTexture: BaseTexture;
  51446. /**
  51447. * Occlusion Channel Strenght.
  51448. */
  51449. occlusionStrength: number;
  51450. /**
  51451. * Occlusion Texture of the material (adding extra occlusion effects).
  51452. */
  51453. occlusionTexture: BaseTexture;
  51454. /**
  51455. * Defines the alpha limits in alpha test mode.
  51456. */
  51457. alphaCutOff: number;
  51458. /**
  51459. * Gets the current double sided mode.
  51460. */
  51461. /**
  51462. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  51463. */
  51464. doubleSided: boolean;
  51465. /**
  51466. * Stores the pre-calculated light information of a mesh in a texture.
  51467. */
  51468. lightmapTexture: BaseTexture;
  51469. /**
  51470. * If true, the light map contains occlusion information instead of lighting info.
  51471. */
  51472. useLightmapAsShadowmap: boolean;
  51473. /**
  51474. * Instantiates a new PBRMaterial instance.
  51475. *
  51476. * @param name The material name
  51477. * @param scene The scene the material will be use in.
  51478. */
  51479. constructor(name: string, scene: Scene);
  51480. getClassName(): string;
  51481. }
  51482. }
  51483. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  51484. import { Scene } from "babylonjs/scene";
  51485. import { Color3 } from "babylonjs/Maths/math";
  51486. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51487. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  51488. /**
  51489. * The PBR material of BJS following the metal roughness convention.
  51490. *
  51491. * This fits to the PBR convention in the GLTF definition:
  51492. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  51493. */
  51494. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  51495. /**
  51496. * The base color has two different interpretations depending on the value of metalness.
  51497. * When the material is a metal, the base color is the specific measured reflectance value
  51498. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  51499. * of the material.
  51500. */
  51501. baseColor: Color3;
  51502. /**
  51503. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  51504. * well as opacity information in the alpha channel.
  51505. */
  51506. baseTexture: BaseTexture;
  51507. /**
  51508. * Specifies the metallic scalar value of the material.
  51509. * Can also be used to scale the metalness values of the metallic texture.
  51510. */
  51511. metallic: number;
  51512. /**
  51513. * Specifies the roughness scalar value of the material.
  51514. * Can also be used to scale the roughness values of the metallic texture.
  51515. */
  51516. roughness: number;
  51517. /**
  51518. * Texture containing both the metallic value in the B channel and the
  51519. * roughness value in the G channel to keep better precision.
  51520. */
  51521. metallicRoughnessTexture: BaseTexture;
  51522. /**
  51523. * Instantiates a new PBRMetalRoughnessMaterial instance.
  51524. *
  51525. * @param name The material name
  51526. * @param scene The scene the material will be use in.
  51527. */
  51528. constructor(name: string, scene: Scene);
  51529. /**
  51530. * Return the currrent class name of the material.
  51531. */
  51532. getClassName(): string;
  51533. /**
  51534. * Makes a duplicate of the current material.
  51535. * @param name - name to use for the new material.
  51536. */
  51537. clone(name: string): PBRMetallicRoughnessMaterial;
  51538. /**
  51539. * Serialize the material to a parsable JSON object.
  51540. */
  51541. serialize(): any;
  51542. /**
  51543. * Parses a JSON object correponding to the serialize function.
  51544. */
  51545. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  51546. }
  51547. }
  51548. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  51549. import { Scene } from "babylonjs/scene";
  51550. import { Color3 } from "babylonjs/Maths/math";
  51551. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51552. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  51553. /**
  51554. * The PBR material of BJS following the specular glossiness convention.
  51555. *
  51556. * This fits to the PBR convention in the GLTF definition:
  51557. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  51558. */
  51559. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  51560. /**
  51561. * Specifies the diffuse color of the material.
  51562. */
  51563. diffuseColor: Color3;
  51564. /**
  51565. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  51566. * channel.
  51567. */
  51568. diffuseTexture: BaseTexture;
  51569. /**
  51570. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  51571. */
  51572. specularColor: Color3;
  51573. /**
  51574. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  51575. */
  51576. glossiness: number;
  51577. /**
  51578. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  51579. */
  51580. specularGlossinessTexture: BaseTexture;
  51581. /**
  51582. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  51583. *
  51584. * @param name The material name
  51585. * @param scene The scene the material will be use in.
  51586. */
  51587. constructor(name: string, scene: Scene);
  51588. /**
  51589. * Return the currrent class name of the material.
  51590. */
  51591. getClassName(): string;
  51592. /**
  51593. * Makes a duplicate of the current material.
  51594. * @param name - name to use for the new material.
  51595. */
  51596. clone(name: string): PBRSpecularGlossinessMaterial;
  51597. /**
  51598. * Serialize the material to a parsable JSON object.
  51599. */
  51600. serialize(): any;
  51601. /**
  51602. * Parses a JSON object correponding to the serialize function.
  51603. */
  51604. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  51605. }
  51606. }
  51607. declare module "babylonjs/Materials/PBR/index" {
  51608. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  51609. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  51610. export * from "babylonjs/Materials/PBR/pbrMaterial";
  51611. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  51612. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  51613. }
  51614. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  51615. import { Nullable } from "babylonjs/types";
  51616. import { Scene } from "babylonjs/scene";
  51617. import { Matrix } from "babylonjs/Maths/math";
  51618. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51619. /**
  51620. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  51621. * It can help converting any input color in a desired output one. This can then be used to create effects
  51622. * from sepia, black and white to sixties or futuristic rendering...
  51623. *
  51624. * The only supported format is currently 3dl.
  51625. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  51626. */
  51627. export class ColorGradingTexture extends BaseTexture {
  51628. /**
  51629. * The current texture matrix. (will always be identity in color grading texture)
  51630. */
  51631. private _textureMatrix;
  51632. /**
  51633. * The texture URL.
  51634. */
  51635. url: string;
  51636. /**
  51637. * Empty line regex stored for GC.
  51638. */
  51639. private static _noneEmptyLineRegex;
  51640. private _engine;
  51641. /**
  51642. * Instantiates a ColorGradingTexture from the following parameters.
  51643. *
  51644. * @param url The location of the color gradind data (currently only supporting 3dl)
  51645. * @param scene The scene the texture will be used in
  51646. */
  51647. constructor(url: string, scene: Scene);
  51648. /**
  51649. * Returns the texture matrix used in most of the material.
  51650. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  51651. */
  51652. getTextureMatrix(): Matrix;
  51653. /**
  51654. * Occurs when the file being loaded is a .3dl LUT file.
  51655. */
  51656. private load3dlTexture;
  51657. /**
  51658. * Starts the loading process of the texture.
  51659. */
  51660. private loadTexture;
  51661. /**
  51662. * Clones the color gradind texture.
  51663. */
  51664. clone(): ColorGradingTexture;
  51665. /**
  51666. * Called during delayed load for textures.
  51667. */
  51668. delayLoad(): void;
  51669. /**
  51670. * Parses a color grading texture serialized by Babylon.
  51671. * @param parsedTexture The texture information being parsedTexture
  51672. * @param scene The scene to load the texture in
  51673. * @param rootUrl The root url of the data assets to load
  51674. * @return A color gradind texture
  51675. */
  51676. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  51677. /**
  51678. * Serializes the LUT texture to json format.
  51679. */
  51680. serialize(): any;
  51681. }
  51682. }
  51683. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  51684. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51685. import { Scene } from "babylonjs/scene";
  51686. import { Nullable } from "babylonjs/types";
  51687. import "babylonjs/Engines/Extensions/engine.rawTexture";
  51688. /**
  51689. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  51690. */
  51691. export class EquiRectangularCubeTexture extends BaseTexture {
  51692. /** The six faces of the cube. */
  51693. private static _FacesMapping;
  51694. private _noMipmap;
  51695. private _onLoad;
  51696. private _onError;
  51697. /** The size of the cubemap. */
  51698. private _size;
  51699. /** The buffer of the image. */
  51700. private _buffer;
  51701. /** The width of the input image. */
  51702. private _width;
  51703. /** The height of the input image. */
  51704. private _height;
  51705. /** The URL to the image. */
  51706. url: string;
  51707. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  51708. coordinatesMode: number;
  51709. /**
  51710. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  51711. * @param url The location of the image
  51712. * @param scene The scene the texture will be used in
  51713. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  51714. * @param noMipmap Forces to not generate the mipmap if true
  51715. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  51716. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  51717. * @param onLoad — defines a callback called when texture is loaded
  51718. * @param onError — defines a callback called if there is an error
  51719. */
  51720. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  51721. /**
  51722. * Load the image data, by putting the image on a canvas and extracting its buffer.
  51723. */
  51724. private loadImage;
  51725. /**
  51726. * Convert the image buffer into a cubemap and create a CubeTexture.
  51727. */
  51728. private loadTexture;
  51729. /**
  51730. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  51731. * @param buffer The ArrayBuffer that should be converted.
  51732. * @returns The buffer as Float32Array.
  51733. */
  51734. private getFloat32ArrayFromArrayBuffer;
  51735. /**
  51736. * Get the current class name of the texture useful for serialization or dynamic coding.
  51737. * @returns "EquiRectangularCubeTexture"
  51738. */
  51739. getClassName(): string;
  51740. /**
  51741. * Create a clone of the current EquiRectangularCubeTexture and return it.
  51742. * @returns A clone of the current EquiRectangularCubeTexture.
  51743. */
  51744. clone(): EquiRectangularCubeTexture;
  51745. }
  51746. }
  51747. declare module "babylonjs/Misc/tga" {
  51748. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51749. /**
  51750. * Based on jsTGALoader - Javascript loader for TGA file
  51751. * By Vincent Thibault
  51752. * @see http://blog.robrowser.com/javascript-tga-loader.html
  51753. */
  51754. export class TGATools {
  51755. private static _TYPE_INDEXED;
  51756. private static _TYPE_RGB;
  51757. private static _TYPE_GREY;
  51758. private static _TYPE_RLE_INDEXED;
  51759. private static _TYPE_RLE_RGB;
  51760. private static _TYPE_RLE_GREY;
  51761. private static _ORIGIN_MASK;
  51762. private static _ORIGIN_SHIFT;
  51763. private static _ORIGIN_BL;
  51764. private static _ORIGIN_BR;
  51765. private static _ORIGIN_UL;
  51766. private static _ORIGIN_UR;
  51767. /**
  51768. * Gets the header of a TGA file
  51769. * @param data defines the TGA data
  51770. * @returns the header
  51771. */
  51772. static GetTGAHeader(data: Uint8Array): any;
  51773. /**
  51774. * Uploads TGA content to a Babylon Texture
  51775. * @hidden
  51776. */
  51777. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  51778. /** @hidden */
  51779. 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;
  51780. /** @hidden */
  51781. 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;
  51782. /** @hidden */
  51783. 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;
  51784. /** @hidden */
  51785. 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;
  51786. /** @hidden */
  51787. 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;
  51788. /** @hidden */
  51789. 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;
  51790. }
  51791. }
  51792. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  51793. import { Nullable } from "babylonjs/types";
  51794. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51795. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  51796. /**
  51797. * Implementation of the TGA Texture Loader.
  51798. * @hidden
  51799. */
  51800. export class _TGATextureLoader implements IInternalTextureLoader {
  51801. /**
  51802. * Defines wether the loader supports cascade loading the different faces.
  51803. */
  51804. readonly supportCascades: boolean;
  51805. /**
  51806. * This returns if the loader support the current file information.
  51807. * @param extension defines the file extension of the file being loaded
  51808. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51809. * @param fallback defines the fallback internal texture if any
  51810. * @param isBase64 defines whether the texture is encoded as a base64
  51811. * @param isBuffer defines whether the texture data are stored as a buffer
  51812. * @returns true if the loader can load the specified file
  51813. */
  51814. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  51815. /**
  51816. * Transform the url before loading if required.
  51817. * @param rootUrl the url of the texture
  51818. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51819. * @returns the transformed texture
  51820. */
  51821. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  51822. /**
  51823. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  51824. * @param rootUrl the url of the texture
  51825. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51826. * @returns the fallback texture
  51827. */
  51828. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  51829. /**
  51830. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  51831. * @param data contains the texture data
  51832. * @param texture defines the BabylonJS internal texture
  51833. * @param createPolynomials will be true if polynomials have been requested
  51834. * @param onLoad defines the callback to trigger once the texture is ready
  51835. * @param onError defines the callback to trigger in case of error
  51836. */
  51837. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  51838. /**
  51839. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  51840. * @param data contains the texture data
  51841. * @param texture defines the BabylonJS internal texture
  51842. * @param callback defines the method to call once ready to upload
  51843. */
  51844. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  51845. }
  51846. }
  51847. declare module "babylonjs/Materials/Textures/Loaders/index" {
  51848. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  51849. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  51850. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  51851. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  51852. }
  51853. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  51854. import { Scene } from "babylonjs/scene";
  51855. import { Texture } from "babylonjs/Materials/Textures/texture";
  51856. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  51857. /**
  51858. * 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.
  51859. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  51860. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  51861. */
  51862. export class CustomProceduralTexture extends ProceduralTexture {
  51863. private _animate;
  51864. private _time;
  51865. private _config;
  51866. private _texturePath;
  51867. /**
  51868. * Instantiates a new Custom Procedural Texture.
  51869. * 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.
  51870. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  51871. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  51872. * @param name Define the name of the texture
  51873. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  51874. * @param size Define the size of the texture to create
  51875. * @param scene Define the scene the texture belongs to
  51876. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  51877. * @param generateMipMaps Define if the texture should creates mip maps or not
  51878. */
  51879. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  51880. private _loadJson;
  51881. /**
  51882. * Is the texture ready to be used ? (rendered at least once)
  51883. * @returns true if ready, otherwise, false.
  51884. */
  51885. isReady(): boolean;
  51886. /**
  51887. * Render the texture to its associated render target.
  51888. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  51889. */
  51890. render(useCameraPostProcess?: boolean): void;
  51891. /**
  51892. * Update the list of dependant textures samplers in the shader.
  51893. */
  51894. updateTextures(): void;
  51895. /**
  51896. * Update the uniform values of the procedural texture in the shader.
  51897. */
  51898. updateShaderUniforms(): void;
  51899. /**
  51900. * Define if the texture animates or not.
  51901. */
  51902. animate: boolean;
  51903. }
  51904. }
  51905. declare module "babylonjs/Shaders/noise.fragment" {
  51906. /** @hidden */
  51907. export var noisePixelShader: {
  51908. name: string;
  51909. shader: string;
  51910. };
  51911. }
  51912. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  51913. import { Nullable } from "babylonjs/types";
  51914. import { Scene } from "babylonjs/scene";
  51915. import { Texture } from "babylonjs/Materials/Textures/texture";
  51916. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  51917. import "babylonjs/Shaders/noise.fragment";
  51918. /**
  51919. * Class used to generate noise procedural textures
  51920. */
  51921. export class NoiseProceduralTexture extends ProceduralTexture {
  51922. private _time;
  51923. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  51924. brightness: number;
  51925. /** Defines the number of octaves to process */
  51926. octaves: number;
  51927. /** Defines the level of persistence (0.8 by default) */
  51928. persistence: number;
  51929. /** Gets or sets animation speed factor (default is 1) */
  51930. animationSpeedFactor: number;
  51931. /**
  51932. * Creates a new NoiseProceduralTexture
  51933. * @param name defines the name fo the texture
  51934. * @param size defines the size of the texture (default is 256)
  51935. * @param scene defines the hosting scene
  51936. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  51937. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  51938. */
  51939. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  51940. private _updateShaderUniforms;
  51941. protected _getDefines(): string;
  51942. /** Generate the current state of the procedural texture */
  51943. render(useCameraPostProcess?: boolean): void;
  51944. /**
  51945. * Serializes this noise procedural texture
  51946. * @returns a serialized noise procedural texture object
  51947. */
  51948. serialize(): any;
  51949. /**
  51950. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  51951. * @param parsedTexture defines parsed texture data
  51952. * @param scene defines the current scene
  51953. * @param rootUrl defines the root URL containing noise procedural texture information
  51954. * @returns a parsed NoiseProceduralTexture
  51955. */
  51956. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  51957. }
  51958. }
  51959. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  51960. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  51961. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  51962. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  51963. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  51964. }
  51965. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  51966. import { Nullable } from "babylonjs/types";
  51967. import { Scene } from "babylonjs/scene";
  51968. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  51969. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51970. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  51971. import "babylonjs/Engines/Extensions/engine.rawTexture";
  51972. /**
  51973. * Raw cube texture where the raw buffers are passed in
  51974. */
  51975. export class RawCubeTexture extends CubeTexture {
  51976. /**
  51977. * Creates a cube texture where the raw buffers are passed in.
  51978. * @param scene defines the scene the texture is attached to
  51979. * @param data defines the array of data to use to create each face
  51980. * @param size defines the size of the textures
  51981. * @param format defines the format of the data
  51982. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  51983. * @param generateMipMaps defines if the engine should generate the mip levels
  51984. * @param invertY defines if data must be stored with Y axis inverted
  51985. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  51986. * @param compression defines the compression used (null by default)
  51987. */
  51988. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  51989. /**
  51990. * Updates the raw cube texture.
  51991. * @param data defines the data to store
  51992. * @param format defines the data format
  51993. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  51994. * @param invertY defines if data must be stored with Y axis inverted
  51995. * @param compression defines the compression used (null by default)
  51996. * @param level defines which level of the texture to update
  51997. */
  51998. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  51999. /**
  52000. * Updates a raw cube texture with RGBD encoded data.
  52001. * @param data defines the array of data [mipmap][face] to use to create each face
  52002. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  52003. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  52004. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  52005. * @returns a promsie that resolves when the operation is complete
  52006. */
  52007. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  52008. /**
  52009. * Clones the raw cube texture.
  52010. * @return a new cube texture
  52011. */
  52012. clone(): CubeTexture;
  52013. /** @hidden */
  52014. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  52015. }
  52016. }
  52017. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  52018. import { Scene } from "babylonjs/scene";
  52019. import { Texture } from "babylonjs/Materials/Textures/texture";
  52020. import "babylonjs/Engines/Extensions/engine.rawTexture";
  52021. /**
  52022. * Class used to store 3D textures containing user data
  52023. */
  52024. export class RawTexture3D extends Texture {
  52025. /** Gets or sets the texture format to use */
  52026. format: number;
  52027. private _engine;
  52028. /**
  52029. * Create a new RawTexture3D
  52030. * @param data defines the data of the texture
  52031. * @param width defines the width of the texture
  52032. * @param height defines the height of the texture
  52033. * @param depth defines the depth of the texture
  52034. * @param format defines the texture format to use
  52035. * @param scene defines the hosting scene
  52036. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  52037. * @param invertY defines if texture must be stored with Y axis inverted
  52038. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  52039. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  52040. */
  52041. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  52042. /** Gets or sets the texture format to use */
  52043. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  52044. /**
  52045. * Update the texture with new data
  52046. * @param data defines the data to store in the texture
  52047. */
  52048. update(data: ArrayBufferView): void;
  52049. }
  52050. }
  52051. declare module "babylonjs/Materials/Textures/refractionTexture" {
  52052. import { Scene } from "babylonjs/scene";
  52053. import { Plane } from "babylonjs/Maths/math";
  52054. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  52055. /**
  52056. * Creates a refraction texture used by refraction channel of the standard material.
  52057. * It is like a mirror but to see through a material.
  52058. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  52059. */
  52060. export class RefractionTexture extends RenderTargetTexture {
  52061. /**
  52062. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  52063. * 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.
  52064. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  52065. */
  52066. refractionPlane: Plane;
  52067. /**
  52068. * Define how deep under the surface we should see.
  52069. */
  52070. depth: number;
  52071. /**
  52072. * Creates a refraction texture used by refraction channel of the standard material.
  52073. * It is like a mirror but to see through a material.
  52074. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  52075. * @param name Define the texture name
  52076. * @param size Define the size of the underlying texture
  52077. * @param scene Define the scene the refraction belongs to
  52078. * @param generateMipMaps Define if we need to generate mips level for the refraction
  52079. */
  52080. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  52081. /**
  52082. * Clone the refraction texture.
  52083. * @returns the cloned texture
  52084. */
  52085. clone(): RefractionTexture;
  52086. /**
  52087. * Serialize the texture to a JSON representation you could use in Parse later on
  52088. * @returns the serialized JSON representation
  52089. */
  52090. serialize(): any;
  52091. }
  52092. }
  52093. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  52094. import { Nullable } from "babylonjs/types";
  52095. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52096. import { Matrix } from "babylonjs/Maths/math";
  52097. import { Engine } from "babylonjs/Engines/engine";
  52098. import { Scene } from "babylonjs/scene";
  52099. /**
  52100. * Defines the options related to the creation of an HtmlElementTexture
  52101. */
  52102. export interface IHtmlElementTextureOptions {
  52103. /**
  52104. * Defines wether mip maps should be created or not.
  52105. */
  52106. generateMipMaps?: boolean;
  52107. /**
  52108. * Defines the sampling mode of the texture.
  52109. */
  52110. samplingMode?: number;
  52111. /**
  52112. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  52113. */
  52114. engine: Nullable<Engine>;
  52115. /**
  52116. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  52117. */
  52118. scene: Nullable<Scene>;
  52119. }
  52120. /**
  52121. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  52122. * To be as efficient as possible depending on your constraints nothing aside the first upload
  52123. * is automatically managed.
  52124. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  52125. * in your application.
  52126. *
  52127. * As the update is not automatic, you need to call them manually.
  52128. */
  52129. export class HtmlElementTexture extends BaseTexture {
  52130. /**
  52131. * The texture URL.
  52132. */
  52133. element: HTMLVideoElement | HTMLCanvasElement;
  52134. private static readonly DefaultOptions;
  52135. private _textureMatrix;
  52136. private _engine;
  52137. private _isVideo;
  52138. private _generateMipMaps;
  52139. private _samplingMode;
  52140. /**
  52141. * Instantiates a HtmlElementTexture from the following parameters.
  52142. *
  52143. * @param name Defines the name of the texture
  52144. * @param element Defines the video or canvas the texture is filled with
  52145. * @param options Defines the other none mandatory texture creation options
  52146. */
  52147. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  52148. private _createInternalTexture;
  52149. /**
  52150. * Returns the texture matrix used in most of the material.
  52151. */
  52152. getTextureMatrix(): Matrix;
  52153. /**
  52154. * Updates the content of the texture.
  52155. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  52156. */
  52157. update(invertY?: Nullable<boolean>): void;
  52158. }
  52159. }
  52160. declare module "babylonjs/Materials/Textures/index" {
  52161. export * from "babylonjs/Materials/Textures/baseTexture";
  52162. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  52163. export * from "babylonjs/Materials/Textures/cubeTexture";
  52164. export * from "babylonjs/Materials/Textures/dynamicTexture";
  52165. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  52166. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  52167. export * from "babylonjs/Materials/Textures/internalTexture";
  52168. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  52169. export * from "babylonjs/Materials/Textures/Loaders/index";
  52170. export * from "babylonjs/Materials/Textures/mirrorTexture";
  52171. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  52172. export * from "babylonjs/Materials/Textures/Procedurals/index";
  52173. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  52174. export * from "babylonjs/Materials/Textures/rawTexture";
  52175. export * from "babylonjs/Materials/Textures/rawTexture3D";
  52176. export * from "babylonjs/Materials/Textures/refractionTexture";
  52177. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  52178. export * from "babylonjs/Materials/Textures/texture";
  52179. export * from "babylonjs/Materials/Textures/videoTexture";
  52180. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  52181. }
  52182. declare module "babylonjs/Materials/Node/nodeMaterialBlockTargets" {
  52183. /**
  52184. * Enum used to define the target of a block
  52185. */
  52186. export enum NodeMaterialBlockTargets {
  52187. /** Vertex shader */
  52188. Vertex = 1,
  52189. /** Fragment shader */
  52190. Fragment = 2,
  52191. /** Vertex and Fragment */
  52192. VertexAndFragment = 3
  52193. }
  52194. }
  52195. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes" {
  52196. /**
  52197. * Defines the kind of connection point for node based material
  52198. */
  52199. export enum NodeMaterialBlockConnectionPointTypes {
  52200. /** Float */
  52201. Float = 1,
  52202. /** Int */
  52203. Int = 2,
  52204. /** Vector2 */
  52205. Vector2 = 4,
  52206. /** Vector3 */
  52207. Vector3 = 8,
  52208. /** Vector4 */
  52209. Vector4 = 16,
  52210. /** Color3 */
  52211. Color3 = 32,
  52212. /** Color4 */
  52213. Color4 = 64,
  52214. /** Matrix */
  52215. Matrix = 128,
  52216. /** Texture */
  52217. Texture = 256,
  52218. /** Texture3D */
  52219. Texture3D = 512,
  52220. /** Vector3 or Color3 */
  52221. Vector3OrColor3 = 40,
  52222. /** Vector3 or Vector4 */
  52223. Vector3OrVector4 = 24,
  52224. /** Vector4 or Color4 */
  52225. Vector4OrColor4 = 80,
  52226. /** Color3 or Color4 */
  52227. Color3OrColor4 = 96,
  52228. /** Vector3 or Color3 */
  52229. Vector3OrColor3OrVector4OrColor4 = 120
  52230. }
  52231. }
  52232. declare module "babylonjs/Materials/Node/nodeMaterialWellKnownValues" {
  52233. /**
  52234. * Enum used to define well known values e.g. values automatically provided by the system
  52235. */
  52236. export enum NodeMaterialWellKnownValues {
  52237. /** World */
  52238. World = 1,
  52239. /** View */
  52240. View = 2,
  52241. /** Projection */
  52242. Projection = 3,
  52243. /** ViewProjection */
  52244. ViewProjection = 4,
  52245. /** WorldView */
  52246. WorldView = 5,
  52247. /** WorldViewProjection */
  52248. WorldViewProjection = 6,
  52249. /** Will be filled by the block itself */
  52250. Automatic = 7
  52251. }
  52252. }
  52253. declare module "babylonjs/Materials/Node/NodeMaterialBlockConnectionPointMode" {
  52254. /**
  52255. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  52256. */
  52257. export enum NodeMaterialBlockConnectionPointMode {
  52258. /** Value is an uniform */
  52259. Uniform = 0,
  52260. /** Value is a mesh attribute */
  52261. Attribute = 1,
  52262. /** Value is a varying between vertex and fragment shaders */
  52263. Varying = 2,
  52264. /** Mode is undefined */
  52265. Undefined = 3
  52266. }
  52267. }
  52268. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  52269. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  52270. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  52271. /**
  52272. * Class used to store shared data between 2 NodeMaterialBuildState
  52273. */
  52274. export class NodeMaterialBuildStateSharedData {
  52275. /**
  52276. * Gets the list of emitted varyings
  52277. */
  52278. varyings: string[];
  52279. /**
  52280. * Gets the varying declaration string
  52281. */
  52282. varyingDeclaration: string;
  52283. /**
  52284. * Uniform connection points
  52285. */
  52286. uniformConnectionPoints: NodeMaterialConnectionPoint[];
  52287. /**
  52288. * Bindable blocks (Blocks that need to set data to the effect)
  52289. */
  52290. bindableBlocks: NodeMaterialBlock[];
  52291. /**
  52292. * List of blocks that can provide a compilation fallback
  52293. */
  52294. blocksWithFallbacks: NodeMaterialBlock[];
  52295. /**
  52296. * List of blocks that can provide a define update
  52297. */
  52298. blocksWithDefines: NodeMaterialBlock[];
  52299. /**
  52300. * List of blocks that can provide a repeatable content
  52301. */
  52302. repeatableContentBlocks: NodeMaterialBlock[];
  52303. /**
  52304. * List of blocks that can block the isReady function for the material
  52305. */
  52306. blockingBlocks: NodeMaterialBlock[];
  52307. /**
  52308. * Build Id used to avoid multiple recompilations
  52309. */
  52310. buildId: number;
  52311. /** List of emitted variables */
  52312. variableNames: {
  52313. [key: string]: number;
  52314. };
  52315. /** List of emitted defines */
  52316. defineNames: {
  52317. [key: string]: number;
  52318. };
  52319. /** Should emit comments? */
  52320. emitComments: boolean;
  52321. /** Emit build activity */
  52322. verbose: boolean;
  52323. /**
  52324. * Gets the compilation hints emitted at compilation time
  52325. */
  52326. hints: {
  52327. needWorldViewMatrix: boolean;
  52328. needWorldViewProjectionMatrix: boolean;
  52329. needAlphaBlending: boolean;
  52330. needAlphaTesting: boolean;
  52331. };
  52332. /**
  52333. * List of compilation checks
  52334. */
  52335. checks: {
  52336. emitVertex: boolean;
  52337. emitFragment: boolean;
  52338. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  52339. };
  52340. /** Creates a new shared data */
  52341. constructor();
  52342. /**
  52343. * Emits console errors and exceptions if there is a failing check
  52344. */
  52345. emitErrors(): void;
  52346. }
  52347. }
  52348. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  52349. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  52350. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  52351. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  52352. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  52353. /**
  52354. * Class used to store node based material build state
  52355. */
  52356. export class NodeMaterialBuildState {
  52357. /**
  52358. * Gets the list of emitted attributes
  52359. */
  52360. attributes: string[];
  52361. /**
  52362. * Gets the list of emitted uniforms
  52363. */
  52364. uniforms: string[];
  52365. /**
  52366. * Gets the list of emitted samplers
  52367. */
  52368. samplers: string[];
  52369. /**
  52370. * Gets the list of emitted functions
  52371. */
  52372. functions: {
  52373. [key: string]: string;
  52374. };
  52375. /**
  52376. * Gets the target of the compilation state
  52377. */
  52378. target: NodeMaterialBlockTargets;
  52379. /**
  52380. * Shared data between multiple NodeMaterialBuildState instances
  52381. */
  52382. sharedData: NodeMaterialBuildStateSharedData;
  52383. /** @hidden */
  52384. _vertexState: NodeMaterialBuildState;
  52385. private _attributeDeclaration;
  52386. private _uniformDeclaration;
  52387. private _samplerDeclaration;
  52388. private _varyingTransfer;
  52389. private _repeatableContentAnchorIndex;
  52390. /** @hidden */
  52391. _builtCompilationString: string;
  52392. /**
  52393. * Gets the emitted compilation strings
  52394. */
  52395. compilationString: string;
  52396. /**
  52397. * Finalize the compilation strings
  52398. * @param state defines the current compilation state
  52399. */
  52400. finalize(state: NodeMaterialBuildState): void;
  52401. /** @hidden */
  52402. readonly _repeatableContentAnchor: string;
  52403. /** @hidden */
  52404. _getFreeVariableName(prefix: string): string;
  52405. /** @hidden */
  52406. _getFreeDefineName(prefix: string): string;
  52407. /** @hidden */
  52408. _excludeVariableName(name: string): void;
  52409. /** @hidden */
  52410. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  52411. /** @hidden */
  52412. _emitFunction(name: string, code: string, comments: string): void;
  52413. /** @hidden */
  52414. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  52415. replaceStrings?: {
  52416. search: RegExp;
  52417. replace: string;
  52418. }[];
  52419. }): string;
  52420. /** @hidden */
  52421. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  52422. repeatKey?: string;
  52423. removeAttributes?: boolean;
  52424. removeUniforms?: boolean;
  52425. removeVaryings?: boolean;
  52426. removeIfDef?: boolean;
  52427. replaceStrings?: {
  52428. search: RegExp;
  52429. replace: string;
  52430. }[];
  52431. }): void;
  52432. /** @hidden */
  52433. _emitVaryings(point: NodeMaterialConnectionPoint, define?: string, force?: boolean, fromFragment?: boolean, replacementName?: string): void;
  52434. private _emitDefine;
  52435. /** @hidden */
  52436. _emitUniformOrAttributes(point: NodeMaterialConnectionPoint, define?: string): void;
  52437. }
  52438. }
  52439. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  52440. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  52441. /**
  52442. * Root class for all node material optimizers
  52443. */
  52444. export class NodeMaterialOptimizer {
  52445. /**
  52446. * Function used to optimize a NodeMaterial graph
  52447. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  52448. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  52449. */
  52450. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  52451. }
  52452. }
  52453. declare module "babylonjs/Materials/Node/nodeMaterial" {
  52454. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  52455. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  52456. import { Scene } from "babylonjs/scene";
  52457. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52458. import { Matrix } from "babylonjs/Maths/math";
  52459. import { Mesh } from "babylonjs/Meshes/mesh";
  52460. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52461. import { Observable } from "babylonjs/Misc/observable";
  52462. import { SubMesh } from "babylonjs/Meshes/subMesh";
  52463. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  52464. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  52465. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  52466. import { Nullable } from "babylonjs/types";
  52467. /**
  52468. * Interface used to configure the node material editor
  52469. */
  52470. export interface INodeMaterialEditorOptions {
  52471. /** Define the URl to load node editor script */
  52472. editorURL?: string;
  52473. }
  52474. /** @hidden */
  52475. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  52476. /** BONES */
  52477. NUM_BONE_INFLUENCERS: number;
  52478. BonesPerMesh: number;
  52479. BONETEXTURE: boolean;
  52480. /** MORPH TARGETS */
  52481. MORPHTARGETS: boolean;
  52482. MORPHTARGETS_NORMAL: boolean;
  52483. MORPHTARGETS_TANGENT: boolean;
  52484. NUM_MORPH_INFLUENCERS: number;
  52485. /** IMAGE PROCESSING */
  52486. IMAGEPROCESSING: boolean;
  52487. VIGNETTE: boolean;
  52488. VIGNETTEBLENDMODEMULTIPLY: boolean;
  52489. VIGNETTEBLENDMODEOPAQUE: boolean;
  52490. TONEMAPPING: boolean;
  52491. TONEMAPPING_ACES: boolean;
  52492. CONTRAST: boolean;
  52493. EXPOSURE: boolean;
  52494. COLORCURVES: boolean;
  52495. COLORGRADING: boolean;
  52496. COLORGRADING3D: boolean;
  52497. SAMPLER3DGREENDEPTH: boolean;
  52498. SAMPLER3DBGRMAP: boolean;
  52499. IMAGEPROCESSINGPOSTPROCESS: boolean;
  52500. constructor();
  52501. setValue(name: string, value: boolean): void;
  52502. }
  52503. /**
  52504. * Class used to configure NodeMaterial
  52505. */
  52506. export interface INodeMaterialOptions {
  52507. /**
  52508. * Defines if blocks should emit comments
  52509. */
  52510. emitComments: boolean;
  52511. }
  52512. /**
  52513. * Class used to create a node based material built by assembling shader blocks
  52514. */
  52515. export class NodeMaterial extends PushMaterial {
  52516. private _options;
  52517. private _vertexCompilationState;
  52518. private _fragmentCompilationState;
  52519. private _sharedData;
  52520. private _buildId;
  52521. private _buildWasSuccessful;
  52522. private _cachedWorldViewMatrix;
  52523. private _cachedWorldViewProjectionMatrix;
  52524. private _textureConnectionPoints;
  52525. private _optimizers;
  52526. /** Define the URl to load node editor script */
  52527. static EditorURL: string;
  52528. private BJSNODEMATERIALEDITOR;
  52529. /** Get the inspector from bundle or global */
  52530. private _getGlobalNodeMaterialEditor;
  52531. /**
  52532. * Defines the maximum number of lights that can be used in the material
  52533. */
  52534. maxSimultaneousLights: number;
  52535. /**
  52536. * Observable raised when the material is built
  52537. */
  52538. onBuildObservable: Observable<NodeMaterial>;
  52539. /**
  52540. * Gets or sets the root nodes of the material vertex shader
  52541. */
  52542. _vertexOutputNodes: NodeMaterialBlock[];
  52543. /**
  52544. * Gets or sets the root nodes of the material fragment (pixel) shader
  52545. */
  52546. _fragmentOutputNodes: NodeMaterialBlock[];
  52547. /** Gets or sets options to control the node material overall behavior */
  52548. options: INodeMaterialOptions;
  52549. /**
  52550. * Default configuration related to image processing available in the standard Material.
  52551. */
  52552. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  52553. /**
  52554. * Gets the image processing configuration used either in this material.
  52555. */
  52556. /**
  52557. * Sets the Default image processing configuration used either in the this material.
  52558. *
  52559. * If sets to null, the scene one is in use.
  52560. */
  52561. imageProcessingConfiguration: ImageProcessingConfiguration;
  52562. /**
  52563. * Create a new node based material
  52564. * @param name defines the material name
  52565. * @param scene defines the hosting scene
  52566. * @param options defines creation option
  52567. */
  52568. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  52569. /**
  52570. * Gets the current class name of the material e.g. "NodeMaterial"
  52571. * @returns the class name
  52572. */
  52573. getClassName(): string;
  52574. /**
  52575. * Keep track of the image processing observer to allow dispose and replace.
  52576. */
  52577. private _imageProcessingObserver;
  52578. /**
  52579. * Attaches a new image processing configuration to the Standard Material.
  52580. * @param configuration
  52581. */
  52582. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  52583. /**
  52584. * Adds a new optimizer to the list of optimizers
  52585. * @param optimizer defines the optimizers to add
  52586. * @returns the current material
  52587. */
  52588. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  52589. /**
  52590. * Remove an optimizer from the list of optimizers
  52591. * @param optimizer defines the optimizers to remove
  52592. * @returns the current material
  52593. */
  52594. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  52595. /**
  52596. * Add a new block to the list of output nodes
  52597. * @param node defines the node to add
  52598. * @returns the current material
  52599. */
  52600. addOutputNode(node: NodeMaterialBlock): this;
  52601. /**
  52602. * Remove a block from the list of root nodes
  52603. * @param node defines the node to remove
  52604. * @returns the current material
  52605. */
  52606. removeOutputNode(node: NodeMaterialBlock): this;
  52607. private _addVertexOutputNode;
  52608. private _removeVertexOutputNode;
  52609. private _addFragmentOutputNode;
  52610. private _removeFragmentOutputNode;
  52611. /**
  52612. * Specifies if the material will require alpha blending
  52613. * @returns a boolean specifying if alpha blending is needed
  52614. */
  52615. needAlphaBlending(): boolean;
  52616. /**
  52617. * Specifies if this material should be rendered in alpha test mode
  52618. * @returns a boolean specifying if an alpha test is needed.
  52619. */
  52620. needAlphaTesting(): boolean;
  52621. private _initializeBlock;
  52622. private _resetDualBlocks;
  52623. /**
  52624. * Build the material and generates the inner effect
  52625. * @param verbose defines if the build should log activity
  52626. */
  52627. build(verbose?: boolean): void;
  52628. /**
  52629. * Runs an otpimization phase to try to improve the shader code
  52630. */
  52631. optimize(): void;
  52632. private _prepareDefinesForAttributes;
  52633. /**
  52634. * Get if the submesh is ready to be used and all its information available.
  52635. * Child classes can use it to update shaders
  52636. * @param mesh defines the mesh to check
  52637. * @param subMesh defines which submesh to check
  52638. * @param useInstances specifies that instances should be used
  52639. * @returns a boolean indicating that the submesh is ready or not
  52640. */
  52641. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  52642. /**
  52643. * Binds the world matrix to the material
  52644. * @param world defines the world transformation matrix
  52645. */
  52646. bindOnlyWorldMatrix(world: Matrix): void;
  52647. /**
  52648. * Binds the submesh to this material by preparing the effect and shader to draw
  52649. * @param world defines the world transformation matrix
  52650. * @param mesh defines the mesh containing the submesh
  52651. * @param subMesh defines the submesh to bind the material to
  52652. */
  52653. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  52654. /**
  52655. * Gets the active textures from the material
  52656. * @returns an array of textures
  52657. */
  52658. getActiveTextures(): BaseTexture[];
  52659. /**
  52660. * Specifies if the material uses a texture
  52661. * @param texture defines the texture to check against the material
  52662. * @returns a boolean specifying if the material uses the texture
  52663. */
  52664. hasTexture(texture: BaseTexture): boolean;
  52665. /**
  52666. * Disposes the material
  52667. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  52668. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  52669. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  52670. */
  52671. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  52672. /** Creates the node editor window. */
  52673. private _createNodeEditor;
  52674. /**
  52675. * Launch the node material editor
  52676. * @param config Define the configuration of the editor
  52677. * @return a promise fulfilled when the node editor is visible
  52678. */
  52679. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  52680. }
  52681. }
  52682. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  52683. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  52684. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  52685. import { Nullable } from "babylonjs/types";
  52686. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  52687. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  52688. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  52689. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52690. import { Mesh } from "babylonjs/Meshes/mesh";
  52691. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  52692. /**
  52693. * Defines a block that can be used inside a node based material
  52694. */
  52695. export class NodeMaterialBlock {
  52696. private _buildId;
  52697. private _target;
  52698. private _isFinalMerger;
  52699. /** @hidden */
  52700. _inputs: NodeMaterialConnectionPoint[];
  52701. /** @hidden */
  52702. _outputs: NodeMaterialConnectionPoint[];
  52703. /**
  52704. * Gets or sets the name of the block
  52705. */
  52706. name: string;
  52707. /**
  52708. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  52709. */
  52710. readonly isFinalMerger: boolean;
  52711. /**
  52712. * Gets or sets the build Id
  52713. */
  52714. buildId: number;
  52715. /**
  52716. * Gets or sets the target of the block
  52717. */
  52718. target: NodeMaterialBlockTargets;
  52719. /**
  52720. * Gets the list of input points
  52721. */
  52722. readonly inputs: NodeMaterialConnectionPoint[];
  52723. /** Gets the list of output points */
  52724. readonly outputs: NodeMaterialConnectionPoint[];
  52725. /**
  52726. * Find an input by its name
  52727. * @param name defines the name of the input to look for
  52728. * @returns the input or null if not found
  52729. */
  52730. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  52731. /**
  52732. * Find an output by its name
  52733. * @param name defines the name of the outputto look for
  52734. * @returns the output or null if not found
  52735. */
  52736. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  52737. /**
  52738. * Creates a new NodeMaterialBlock
  52739. * @param name defines the block name
  52740. * @param target defines the target of that block (Vertex by default)
  52741. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  52742. */
  52743. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean);
  52744. /**
  52745. * Initialize the block and prepare the context for build
  52746. * @param state defines the state that will be used for the build
  52747. */
  52748. initialize(state: NodeMaterialBuildState): void;
  52749. /**
  52750. * Bind data to effect. Will only be called for blocks with isBindable === true
  52751. * @param effect defines the effect to bind data to
  52752. * @param nodeMaterial defines the hosting NodeMaterial
  52753. * @param mesh defines the mesh that will be rendered
  52754. */
  52755. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  52756. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  52757. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  52758. protected _writeFloat(value: number): string;
  52759. /**
  52760. * Gets the current class name e.g. "NodeMaterialBlock"
  52761. * @returns the class name
  52762. */
  52763. getClassName(): string;
  52764. /**
  52765. * Register a new input. Must be called inside a block constructor
  52766. * @param name defines the connection point name
  52767. * @param type defines the connection point type
  52768. * @param isOptional defines a boolean indicating that this input can be omitted
  52769. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  52770. * @returns the current block
  52771. */
  52772. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  52773. /**
  52774. * Register a new output. Must be called inside a block constructor
  52775. * @param name defines the connection point name
  52776. * @param type defines the connection point type
  52777. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  52778. * @returns the current block
  52779. */
  52780. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  52781. /**
  52782. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  52783. * @param forOutput defines an optional connection point to check compatibility with
  52784. * @returns the first available input or null
  52785. */
  52786. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  52787. /**
  52788. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  52789. * @param forBlock defines an optional block to check compatibility with
  52790. * @returns the first available input or null
  52791. */
  52792. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  52793. /**
  52794. * Connect current block with another block
  52795. * @param other defines the block to connect with
  52796. * @param options define the various options to help pick the right connections
  52797. * @returns the current block
  52798. */
  52799. connectTo(other: NodeMaterialBlock, options?: {
  52800. input?: string;
  52801. output?: string;
  52802. outputSwizzle?: string;
  52803. }): this | undefined;
  52804. protected _buildBlock(state: NodeMaterialBuildState): void;
  52805. /**
  52806. * Add potential fallbacks if shader compilation fails
  52807. * @param mesh defines the mesh to be rendered
  52808. * @param fallbacks defines the current prioritized list of fallbacks
  52809. */
  52810. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  52811. /**
  52812. * Update defines for shader compilation
  52813. * @param mesh defines the mesh to be rendered
  52814. * @param nodeMaterial defines the node material requesting the update
  52815. * @param defines defines the material defines to update
  52816. * @param useInstances specifies that instances should be used
  52817. */
  52818. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  52819. /**
  52820. * Lets the block try to connect some inputs automatically
  52821. */
  52822. autoConfigure(): void;
  52823. /**
  52824. * Function called when a block is declared as repeatable content generator
  52825. * @param vertexShaderState defines the current compilation state for the vertex shader
  52826. * @param fragmentShaderState defines the current compilation state for the fragment shader
  52827. * @param mesh defines the mesh to be rendered
  52828. * @param defines defines the material defines to update
  52829. */
  52830. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  52831. /**
  52832. * Checks if the block is ready
  52833. * @param mesh defines the mesh to be rendered
  52834. * @param nodeMaterial defines the node material requesting the update
  52835. * @param defines defines the material defines to update
  52836. * @param useInstances specifies that instances should be used
  52837. * @returns true if the block is ready
  52838. */
  52839. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  52840. /**
  52841. * Compile the current node and generate the shader code
  52842. * @param state defines the current compilation state (uniforms, samplers, current string)
  52843. * @returns the current block
  52844. */
  52845. build(state: NodeMaterialBuildState): this | undefined;
  52846. }
  52847. }
  52848. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  52849. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  52850. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  52851. import { Nullable } from "babylonjs/types";
  52852. import { Effect } from "babylonjs/Materials/effect";
  52853. import { NodeMaterialWellKnownValues } from "babylonjs/Materials/Node/nodeMaterialWellKnownValues";
  52854. import { Scene } from "babylonjs/scene";
  52855. import { Matrix } from "babylonjs/Maths/math";
  52856. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  52857. /**
  52858. * Defines a connection point for a block
  52859. */
  52860. export class NodeMaterialConnectionPoint {
  52861. /** @hidden */
  52862. _ownerBlock: NodeMaterialBlock;
  52863. /** @hidden */
  52864. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  52865. private _associatedVariableName;
  52866. private _endpoints;
  52867. private _storedValue;
  52868. private _valueCallback;
  52869. private _mode;
  52870. /** @hidden */
  52871. _wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  52872. /**
  52873. * Gets or sets the connection point type (default is float)
  52874. */
  52875. type: NodeMaterialBlockConnectionPointTypes;
  52876. /**
  52877. * Gets or sets the connection point name
  52878. */
  52879. name: string;
  52880. /**
  52881. * Gets or sets the swizzle to apply to this connection point when reading or writing
  52882. */
  52883. swizzle: string;
  52884. /**
  52885. * Gets or sets a boolean indicating that this connection point can be omitted
  52886. */
  52887. isOptional: boolean;
  52888. /**
  52889. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  52890. */
  52891. define: string;
  52892. /** Gets or sets the target of that connection point */
  52893. target: NodeMaterialBlockTargets;
  52894. /**
  52895. * Gets or sets the value of that point.
  52896. * Please note that this value will be ignored if valueCallback is defined
  52897. */
  52898. value: any;
  52899. /**
  52900. * Gets or sets a callback used to get the value of that point.
  52901. * Please note that setting this value will force the connection point to ignore the value property
  52902. */
  52903. valueCallback: () => any;
  52904. /**
  52905. * Gets or sets the associated variable name in the shader
  52906. */
  52907. associatedVariableName: string;
  52908. /**
  52909. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  52910. * In this case the connection point name must be the name of the uniform to use.
  52911. * Can only be set on inputs
  52912. */
  52913. isUniform: boolean;
  52914. /**
  52915. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  52916. * In this case the connection point name must be the name of the attribute to use
  52917. * Can only be set on inputs
  52918. */
  52919. isAttribute: boolean;
  52920. /**
  52921. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  52922. * Can only be set on exit points
  52923. */
  52924. isVarying: boolean;
  52925. /** Get the other side of the connection (if any) */
  52926. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  52927. /** Get the block that owns this connection point */
  52928. readonly ownerBlock: NodeMaterialBlock;
  52929. /** Get the block connected on the other side of this connection (if any) */
  52930. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  52931. /** Get the block connected on the endpoints of this connection (if any) */
  52932. readonly connectedBlocks: Array<NodeMaterialBlock>;
  52933. /**
  52934. * Creates a new connection point
  52935. * @param name defines the connection point name
  52936. * @param ownerBlock defines the block hosting this connection point
  52937. */
  52938. constructor(name: string, ownerBlock: NodeMaterialBlock);
  52939. /**
  52940. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  52941. * @returns the class name
  52942. */
  52943. getClassName(): string;
  52944. /**
  52945. * Set the source of this connection point to a vertex attribute
  52946. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  52947. * @returns the current connection point
  52948. */
  52949. setAsAttribute(attributeName?: string): NodeMaterialConnectionPoint;
  52950. /**
  52951. * Set the source of this connection point to a well known value
  52952. * @param value define the well known value to use (world, view, etc...) or null to switch to manual value
  52953. * @returns the current connection point
  52954. */
  52955. setAsWellKnownValue(value: Nullable<NodeMaterialWellKnownValues>): NodeMaterialConnectionPoint;
  52956. /**
  52957. * Gets a boolean indicating that the current connection point is a well known value
  52958. */
  52959. readonly isWellKnownValue: boolean;
  52960. /**
  52961. * Gets or sets the current well known value or null if not defined as well know value
  52962. */
  52963. wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  52964. private _getTypeLength;
  52965. /**
  52966. * Connect this point to another connection point
  52967. * @param connectionPoint defines the other connection point
  52968. * @returns the current connection point
  52969. */
  52970. connectTo(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  52971. /**
  52972. * Disconnect this point from one of his endpoint
  52973. * @param endpoint defines the other connection point
  52974. * @returns the current connection point
  52975. */
  52976. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  52977. /**
  52978. * When connection point is an uniform, this function will send its value to the effect
  52979. * @param effect defines the effect to transmit value to
  52980. * @param world defines the world matrix
  52981. * @param worldView defines the worldxview matrix
  52982. * @param worldViewProjection defines the worldxviewxprojection matrix
  52983. */
  52984. transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  52985. /**
  52986. * When connection point is an uniform, this function will send its value to the effect
  52987. * @param effect defines the effect to transmit value to
  52988. * @param scene defines the hosting scene
  52989. */
  52990. transmit(effect: Effect, scene: Scene): void;
  52991. }
  52992. }
  52993. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  52994. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  52995. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  52996. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  52997. /**
  52998. * Block used to output the vertex position
  52999. */
  53000. export class VertexOutputBlock extends NodeMaterialBlock {
  53001. /**
  53002. * Creates a new VertexOutputBlock
  53003. * @param name defines the block name
  53004. */
  53005. constructor(name: string);
  53006. /**
  53007. * Gets the current class name
  53008. * @returns the class name
  53009. */
  53010. getClassName(): string;
  53011. /**
  53012. * Gets the vector input component
  53013. */
  53014. readonly vector: NodeMaterialConnectionPoint;
  53015. protected _buildBlock(state: NodeMaterialBuildState): this;
  53016. }
  53017. }
  53018. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  53019. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53020. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53021. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53022. import { Mesh } from "babylonjs/Meshes/mesh";
  53023. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  53024. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53025. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  53026. /**
  53027. * Block used to add support for vertex skinning (bones)
  53028. */
  53029. export class BonesBlock extends NodeMaterialBlock {
  53030. /**
  53031. * Creates a new BonesBlock
  53032. * @param name defines the block name
  53033. */
  53034. constructor(name: string);
  53035. /**
  53036. * Initialize the block and prepare the context for build
  53037. * @param state defines the state that will be used for the build
  53038. */
  53039. initialize(state: NodeMaterialBuildState): void;
  53040. /**
  53041. * Gets the current class name
  53042. * @returns the class name
  53043. */
  53044. getClassName(): string;
  53045. /**
  53046. * Gets the matrix indices input component
  53047. */
  53048. readonly matricesIndices: NodeMaterialConnectionPoint;
  53049. /**
  53050. * Gets the matrix weights input component
  53051. */
  53052. readonly matricesWeights: NodeMaterialConnectionPoint;
  53053. /**
  53054. * Gets the extra matrix indices input component
  53055. */
  53056. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  53057. /**
  53058. * Gets the extra matrix weights input component
  53059. */
  53060. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  53061. /**
  53062. * Gets the world input component
  53063. */
  53064. readonly world: NodeMaterialConnectionPoint;
  53065. autoConfigure(): void;
  53066. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  53067. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53068. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53069. protected _buildBlock(state: NodeMaterialBuildState): this;
  53070. }
  53071. }
  53072. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  53073. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53074. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53075. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53076. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53077. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  53078. /**
  53079. * Block used to add support for instances
  53080. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  53081. */
  53082. export class InstancesBlock extends NodeMaterialBlock {
  53083. /**
  53084. * Creates a new InstancesBlock
  53085. * @param name defines the block name
  53086. */
  53087. constructor(name: string);
  53088. /**
  53089. * Gets the current class name
  53090. * @returns the class name
  53091. */
  53092. getClassName(): string;
  53093. /**
  53094. * Gets the first world row input component
  53095. */
  53096. readonly world0: NodeMaterialConnectionPoint;
  53097. /**
  53098. * Gets the second world row input component
  53099. */
  53100. readonly world1: NodeMaterialConnectionPoint;
  53101. /**
  53102. * Gets the third world row input component
  53103. */
  53104. readonly world2: NodeMaterialConnectionPoint;
  53105. /**
  53106. * Gets the forth world row input component
  53107. */
  53108. readonly world3: NodeMaterialConnectionPoint;
  53109. /**
  53110. * Gets the world input component
  53111. */
  53112. readonly world: NodeMaterialConnectionPoint;
  53113. /**
  53114. * Gets the output component
  53115. */
  53116. readonly output: NodeMaterialConnectionPoint;
  53117. autoConfigure(): void;
  53118. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  53119. protected _buildBlock(state: NodeMaterialBuildState): this;
  53120. }
  53121. }
  53122. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  53123. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53124. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53125. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53126. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53127. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  53128. import { Effect } from "babylonjs/Materials/effect";
  53129. import { Mesh } from "babylonjs/Meshes/mesh";
  53130. /**
  53131. * Block used to add morph targets support to vertex shader
  53132. */
  53133. export class MorphTargetsBlock extends NodeMaterialBlock {
  53134. private _repeatableContentAnchor;
  53135. private _repeatebleContentGenerated;
  53136. /**
  53137. * Create a new MorphTargetsBlock
  53138. * @param name defines the block name
  53139. */
  53140. constructor(name: string);
  53141. /**
  53142. * Gets the current class name
  53143. * @returns the class name
  53144. */
  53145. getClassName(): string;
  53146. /**
  53147. * Gets the position input component
  53148. */
  53149. readonly position: NodeMaterialConnectionPoint;
  53150. /**
  53151. * Gets the normal input component
  53152. */
  53153. readonly normal: NodeMaterialConnectionPoint;
  53154. /**
  53155. * Gets the tangent input component
  53156. */
  53157. readonly tangent: NodeMaterialConnectionPoint;
  53158. /**
  53159. * Gets the position output component
  53160. */
  53161. readonly positionOutput: NodeMaterialConnectionPoint;
  53162. /**
  53163. * Gets the normal output component
  53164. */
  53165. readonly normalOutput: NodeMaterialConnectionPoint;
  53166. /**
  53167. * Gets the tangent output component
  53168. */
  53169. readonly tangentOutput: NodeMaterialConnectionPoint;
  53170. initialize(state: NodeMaterialBuildState): void;
  53171. autoConfigure(): void;
  53172. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53173. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53174. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  53175. protected _buildBlock(state: NodeMaterialBuildState): this;
  53176. }
  53177. }
  53178. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  53179. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  53180. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  53181. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  53182. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  53183. }
  53184. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  53185. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53186. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53187. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53188. /**
  53189. * Block used to output the final color
  53190. */
  53191. export class FragmentOutputBlock extends NodeMaterialBlock {
  53192. /**
  53193. * Gets or sets a boolean indicating if this block will output an alpha value
  53194. */
  53195. alphaBlendingEnabled: boolean;
  53196. /**
  53197. * Create a new FragmentOutputBlock
  53198. * @param name defines the block name
  53199. */
  53200. constructor(name: string);
  53201. /**
  53202. * Gets the current class name
  53203. * @returns the class name
  53204. */
  53205. getClassName(): string;
  53206. /**
  53207. * Gets the color input component
  53208. */
  53209. readonly color: NodeMaterialConnectionPoint;
  53210. protected _buildBlock(state: NodeMaterialBuildState): this;
  53211. }
  53212. }
  53213. declare module "babylonjs/Materials/Node/Blocks/Fragment/alphaTestBlock" {
  53214. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53215. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53216. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53217. /**
  53218. * Block used to add an alpha test in the fragment shader
  53219. */
  53220. export class AlphaTestBlock extends NodeMaterialBlock {
  53221. /**
  53222. * Gets or sets the alpha value where alpha testing happens
  53223. */
  53224. alphaCutOff: number;
  53225. /**
  53226. * Create a new AlphaTestBlock
  53227. * @param name defines the block name
  53228. */
  53229. constructor(name: string);
  53230. /**
  53231. * Gets the current class name
  53232. * @returns the class name
  53233. */
  53234. getClassName(): string;
  53235. /**
  53236. * Gets the color input component
  53237. */
  53238. readonly color: NodeMaterialConnectionPoint;
  53239. protected _buildBlock(state: NodeMaterialBuildState): this;
  53240. }
  53241. }
  53242. declare module "babylonjs/Materials/Node/Blocks/Fragment/rgbaMergerBlock" {
  53243. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53244. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53245. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53246. /**
  53247. * Block used to create a Color4 out of 4 inputs (one for each component)
  53248. */
  53249. export class RGBAMergerBlock extends NodeMaterialBlock {
  53250. /**
  53251. * Create a new RGBAMergerBlock
  53252. * @param name defines the block name
  53253. */
  53254. constructor(name: string);
  53255. /**
  53256. * Gets the current class name
  53257. * @returns the class name
  53258. */
  53259. getClassName(): string;
  53260. /**
  53261. * Gets the R input component
  53262. */
  53263. readonly r: NodeMaterialConnectionPoint;
  53264. /**
  53265. * Gets the G input component
  53266. */
  53267. readonly g: NodeMaterialConnectionPoint;
  53268. /**
  53269. * Gets the B input component
  53270. */
  53271. readonly b: NodeMaterialConnectionPoint;
  53272. /**
  53273. * Gets the RGB input component
  53274. */
  53275. readonly rgb: NodeMaterialConnectionPoint;
  53276. /**
  53277. * Gets the R input component
  53278. */
  53279. readonly a: NodeMaterialConnectionPoint;
  53280. protected _buildBlock(state: NodeMaterialBuildState): this;
  53281. }
  53282. }
  53283. declare module "babylonjs/Materials/Node/Blocks/Fragment/rgbMergerBlock" {
  53284. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53285. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53286. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53287. /**
  53288. * Block used to create a Color3 out of 3 inputs (one for each component)
  53289. */
  53290. export class RGBMergerBlock extends NodeMaterialBlock {
  53291. /**
  53292. * Create a new RGBMergerBlock
  53293. * @param name defines the block name
  53294. */
  53295. constructor(name: string);
  53296. /**
  53297. * Gets the current class name
  53298. * @returns the class name
  53299. */
  53300. getClassName(): string;
  53301. /**
  53302. * Gets the R component input
  53303. */
  53304. readonly r: NodeMaterialConnectionPoint;
  53305. /**
  53306. * Gets the G component input
  53307. */
  53308. readonly g: NodeMaterialConnectionPoint;
  53309. /**
  53310. * Gets the B component input
  53311. */
  53312. readonly b: NodeMaterialConnectionPoint;
  53313. protected _buildBlock(state: NodeMaterialBuildState): this;
  53314. }
  53315. }
  53316. declare module "babylonjs/Materials/Node/Blocks/Fragment/rgbaSplitterBlock" {
  53317. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53318. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53319. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53320. /**
  53321. * Block used to expand a Color4 or a Vector4 into 4 outputs (one for each component)
  53322. */
  53323. export class RGBASplitterBlock extends NodeMaterialBlock {
  53324. /**
  53325. * Create a new RGBASplitterBlock
  53326. * @param name defines the block name
  53327. */
  53328. constructor(name: string);
  53329. /**
  53330. * Gets the current class name
  53331. * @returns the class name
  53332. */
  53333. getClassName(): string;
  53334. /**
  53335. * Gets the input component
  53336. */
  53337. readonly input: NodeMaterialConnectionPoint;
  53338. protected _buildBlock(state: NodeMaterialBuildState): this;
  53339. }
  53340. }
  53341. declare module "babylonjs/Materials/Node/Blocks/Fragment/rgbSplitterBlock" {
  53342. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53343. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53344. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53345. /**
  53346. * Block used to expand a Color3 or a Vector3 into 3 outputs (one for each component)
  53347. */
  53348. export class RGBSplitterBlock extends NodeMaterialBlock {
  53349. /**
  53350. * Create a new RGBSplitterBlock
  53351. * @param name defines the block name
  53352. */
  53353. constructor(name: string);
  53354. /**
  53355. * Gets the current class name
  53356. * @returns the class name
  53357. */
  53358. getClassName(): string;
  53359. /**
  53360. * Gets the input component
  53361. */
  53362. readonly input: NodeMaterialConnectionPoint;
  53363. protected _buildBlock(state: NodeMaterialBuildState): this;
  53364. }
  53365. }
  53366. declare module "babylonjs/Materials/Node/Blocks/Fragment/textureBlock" {
  53367. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53368. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53369. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53370. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53371. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  53372. /**
  53373. * Block used to read a texture from a sampler
  53374. */
  53375. export class TextureBlock extends NodeMaterialBlock {
  53376. private _defineName;
  53377. /**
  53378. * Gets or sets a boolean indicating that the block can automatically fetch the texture matrix
  53379. */
  53380. autoConnectTextureMatrix: boolean;
  53381. /**
  53382. * Gets or sets a boolean indicating that the block can automatically select the uv channel based on texture
  53383. */
  53384. autoSelectUV: boolean;
  53385. /**
  53386. * Create a new TextureBlock
  53387. * @param name defines the block name
  53388. */
  53389. constructor(name: string);
  53390. /**
  53391. * Gets the current class name
  53392. * @returns the class name
  53393. */
  53394. getClassName(): string;
  53395. /**
  53396. * Gets the uv input component
  53397. */
  53398. readonly uv: NodeMaterialConnectionPoint;
  53399. /**
  53400. * Gets the texture information input component
  53401. */
  53402. readonly textureInfo: NodeMaterialConnectionPoint;
  53403. /**
  53404. * Gets the transformed uv input component
  53405. */
  53406. readonly transformedUV: NodeMaterialConnectionPoint;
  53407. /**
  53408. * Gets the texture input component
  53409. */
  53410. readonly texture: NodeMaterialConnectionPoint;
  53411. /**
  53412. * Gets the texture transform input component
  53413. */
  53414. readonly textureTransform: NodeMaterialConnectionPoint;
  53415. autoConfigure(): void;
  53416. initialize(state: NodeMaterialBuildState): void;
  53417. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53418. isReady(): boolean;
  53419. private _injectVertexCode;
  53420. protected _buildBlock(state: NodeMaterialBuildState): this;
  53421. }
  53422. }
  53423. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  53424. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53425. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53426. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53427. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53428. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  53429. import { Effect } from "babylonjs/Materials/effect";
  53430. import { Mesh } from "babylonjs/Meshes/mesh";
  53431. /**
  53432. * Block used to add image processing support to fragment shader
  53433. */
  53434. export class ImageProcessingBlock extends NodeMaterialBlock {
  53435. /**
  53436. * Create a new ImageProcessingBlock
  53437. * @param name defines the block name
  53438. */
  53439. constructor(name: string);
  53440. /**
  53441. * Gets the current class name
  53442. * @returns the class name
  53443. */
  53444. getClassName(): string;
  53445. /**
  53446. * Gets the color input component
  53447. */
  53448. readonly color: NodeMaterialConnectionPoint;
  53449. /**
  53450. * Initialize the block and prepare the context for build
  53451. * @param state defines the state that will be used for the build
  53452. */
  53453. initialize(state: NodeMaterialBuildState): void;
  53454. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  53455. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53456. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53457. protected _buildBlock(state: NodeMaterialBuildState): this;
  53458. }
  53459. }
  53460. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  53461. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  53462. export * from "babylonjs/Materials/Node/Blocks/Fragment/alphaTestBlock";
  53463. export * from "babylonjs/Materials/Node/Blocks/Fragment/rgbaMergerBlock";
  53464. export * from "babylonjs/Materials/Node/Blocks/Fragment/rgbMergerBlock";
  53465. export * from "babylonjs/Materials/Node/Blocks/Fragment/rgbaSplitterBlock";
  53466. export * from "babylonjs/Materials/Node/Blocks/Fragment/rgbSplitterBlock";
  53467. export * from "babylonjs/Materials/Node/Blocks/Fragment/textureBlock";
  53468. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  53469. }
  53470. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  53471. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53472. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53473. import { Mesh } from "babylonjs/Meshes/mesh";
  53474. import { Effect } from "babylonjs/Materials/effect";
  53475. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53476. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53477. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  53478. /**
  53479. * Block used to add support for scene fog
  53480. */
  53481. export class FogBlock extends NodeMaterialBlock {
  53482. /**
  53483. * Create a new FogBlock
  53484. * @param name defines the block name
  53485. */
  53486. constructor(name: string);
  53487. /**
  53488. * Gets the current class name
  53489. * @returns the class name
  53490. */
  53491. getClassName(): string;
  53492. /**
  53493. * Gets the world position input component
  53494. */
  53495. readonly worldPosition: NodeMaterialConnectionPoint;
  53496. /**
  53497. * Gets the view input component
  53498. */
  53499. readonly view: NodeMaterialConnectionPoint;
  53500. /**
  53501. * Gets the color input component
  53502. */
  53503. readonly color: NodeMaterialConnectionPoint;
  53504. /**
  53505. * Gets the fog color input component
  53506. */
  53507. readonly fogColor: NodeMaterialConnectionPoint;
  53508. /**
  53509. * Gets the for parameter input component
  53510. */
  53511. readonly fogParameters: NodeMaterialConnectionPoint;
  53512. autoConfigure(): void;
  53513. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53514. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53515. protected _buildBlock(state: NodeMaterialBuildState): this;
  53516. }
  53517. }
  53518. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  53519. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  53520. }
  53521. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  53522. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53523. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53524. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53525. /**
  53526. * Block used to multiply 2 vector4
  53527. */
  53528. export class MultiplyBlock extends NodeMaterialBlock {
  53529. /**
  53530. * Creates a new MultiplyBlock
  53531. * @param name defines the block name
  53532. */
  53533. constructor(name: string);
  53534. /**
  53535. * Gets the current class name
  53536. * @returns the class name
  53537. */
  53538. getClassName(): string;
  53539. /**
  53540. * Gets the left operand input component
  53541. */
  53542. readonly left: NodeMaterialConnectionPoint;
  53543. /**
  53544. * Gets the right operand input component
  53545. */
  53546. readonly right: NodeMaterialConnectionPoint;
  53547. protected _buildBlock(state: NodeMaterialBuildState): this;
  53548. }
  53549. }
  53550. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  53551. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53552. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53553. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53554. /**
  53555. * Block used to add 2 vector4
  53556. */
  53557. export class AddBlock extends NodeMaterialBlock {
  53558. /**
  53559. * Creates a new AddBlock
  53560. * @param name defines the block name
  53561. */
  53562. constructor(name: string);
  53563. /**
  53564. * Gets the current class name
  53565. * @returns the class name
  53566. */
  53567. getClassName(): string;
  53568. /**
  53569. * Gets the left operand input component
  53570. */
  53571. readonly left: NodeMaterialConnectionPoint;
  53572. /**
  53573. * Gets the right operand input component
  53574. */
  53575. readonly right: NodeMaterialConnectionPoint;
  53576. protected _buildBlock(state: NodeMaterialBuildState): this;
  53577. }
  53578. }
  53579. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  53580. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53581. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53582. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53583. /**
  53584. * Block used to clamp a float
  53585. */
  53586. export class ClampBlock extends NodeMaterialBlock {
  53587. /** Gets or sets the minimum range */
  53588. minimum: number;
  53589. /** Gets or sets the maximum range */
  53590. maximum: number;
  53591. /**
  53592. * Creates a new ClampBlock
  53593. * @param name defines the block name
  53594. */
  53595. constructor(name: string);
  53596. /**
  53597. * Gets the current class name
  53598. * @returns the class name
  53599. */
  53600. getClassName(): string;
  53601. /**
  53602. * Gets the value input component
  53603. */
  53604. readonly value: NodeMaterialConnectionPoint;
  53605. protected _buildBlock(state: NodeMaterialBuildState): this;
  53606. }
  53607. }
  53608. declare module "babylonjs/Materials/Node/Blocks/vector2TransformBlock" {
  53609. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53610. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53611. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53612. /**
  53613. * Block used to transform a vector2 with a matrix
  53614. */
  53615. export class Vector2TransformBlock extends NodeMaterialBlock {
  53616. /**
  53617. * Defines the value to use to complement Vector2 to transform it to a Vector4
  53618. */
  53619. complementZ: number;
  53620. /**
  53621. * Defines the value to use to complement Vector2 to transform it to a Vector4
  53622. */
  53623. complementW: number;
  53624. /**
  53625. * Creates a new Vector2TransformBlock
  53626. * @param name defines the block name
  53627. */
  53628. constructor(name: string);
  53629. /**
  53630. * Gets the vector input
  53631. */
  53632. readonly vector: NodeMaterialConnectionPoint;
  53633. /**
  53634. * Gets the matrix transform input
  53635. */
  53636. readonly transform: NodeMaterialConnectionPoint;
  53637. /**
  53638. * Gets the current class name
  53639. * @returns the class name
  53640. */
  53641. getClassName(): string;
  53642. protected _buildBlock(state: NodeMaterialBuildState): this;
  53643. }
  53644. }
  53645. declare module "babylonjs/Materials/Node/Blocks/vector3TransformBlock" {
  53646. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53647. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53648. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53649. /**
  53650. * Block used to transform a vector3 with a matrix
  53651. */
  53652. export class Vector3TransformBlock extends NodeMaterialBlock {
  53653. /**
  53654. * Defines the value to use to complement Vector3 to transform it to a Vector4
  53655. */
  53656. complement: number;
  53657. /**
  53658. * Creates a new Vector3TransformBlock
  53659. * @param name defines the block name
  53660. */
  53661. constructor(name: string);
  53662. /**
  53663. * Gets the vector input
  53664. */
  53665. readonly vector: NodeMaterialConnectionPoint;
  53666. /**
  53667. * Gets the matrix transform input
  53668. */
  53669. readonly transform: NodeMaterialConnectionPoint;
  53670. /**
  53671. * Gets the current class name
  53672. * @returns the class name
  53673. */
  53674. getClassName(): string;
  53675. protected _buildBlock(state: NodeMaterialBuildState): this;
  53676. }
  53677. }
  53678. declare module "babylonjs/Materials/Node/Blocks/vector4TransformBlock" {
  53679. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53680. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53681. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53682. /**
  53683. * Block used to transform a vector4 with a matrix
  53684. */
  53685. export class Vector4TransformBlock extends NodeMaterialBlock {
  53686. /**
  53687. * Defines the value to use to complement Vector3 to transform it to a Vector4
  53688. */
  53689. complementW: number;
  53690. /**
  53691. * Creates a new Vector4TransformBlock
  53692. * @param name defines the block name
  53693. */
  53694. constructor(name: string);
  53695. /**
  53696. * Gets the current class name
  53697. * @returns the class name
  53698. */
  53699. getClassName(): string;
  53700. /**
  53701. * Gets the vector input
  53702. */
  53703. readonly vector: NodeMaterialConnectionPoint;
  53704. /**
  53705. * Gets the matrix transform input
  53706. */
  53707. readonly transform: NodeMaterialConnectionPoint;
  53708. protected _buildBlock(state: NodeMaterialBuildState): this;
  53709. }
  53710. }
  53711. declare module "babylonjs/Materials/Node/Blocks/matrixMultiplicationBlock" {
  53712. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53713. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53714. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53715. /**
  53716. * Block used to multiply two matrices
  53717. */
  53718. export class MatrixMultiplicationBlock extends NodeMaterialBlock {
  53719. /**
  53720. * Creates a new MatrixMultiplicationBlock
  53721. * @param name defines the block name
  53722. */
  53723. constructor(name: string);
  53724. /**
  53725. * Gets the left operand
  53726. */
  53727. readonly left: NodeMaterialConnectionPoint;
  53728. /**
  53729. * Gets the right operand
  53730. */
  53731. readonly right: NodeMaterialConnectionPoint;
  53732. /**
  53733. * Gets the current class name
  53734. * @returns the class name
  53735. */
  53736. getClassName(): string;
  53737. protected _buildBlock(state: NodeMaterialBuildState): this;
  53738. }
  53739. }
  53740. declare module "babylonjs/Materials/Node/Blocks/index" {
  53741. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  53742. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  53743. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  53744. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  53745. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  53746. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  53747. export * from "babylonjs/Materials/Node/Blocks/vector2TransformBlock";
  53748. export * from "babylonjs/Materials/Node/Blocks/vector3TransformBlock";
  53749. export * from "babylonjs/Materials/Node/Blocks/vector4TransformBlock";
  53750. export * from "babylonjs/Materials/Node/Blocks/matrixMultiplicationBlock";
  53751. }
  53752. declare module "babylonjs/Materials/Node/Optimizers/index" {
  53753. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  53754. }
  53755. declare module "babylonjs/Materials/Node/index" {
  53756. export * from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  53757. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  53758. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53759. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  53760. export * from "babylonjs/Materials/Node/nodeMaterial";
  53761. export * from "babylonjs/Materials/Node/nodeMaterialWellKnownValues";
  53762. export * from "babylonjs/Materials/Node/Blocks/index";
  53763. export * from "babylonjs/Materials/Node/Optimizers/index";
  53764. }
  53765. declare module "babylonjs/Materials/index" {
  53766. export * from "babylonjs/Materials/Background/index";
  53767. export * from "babylonjs/Materials/colorCurves";
  53768. export * from "babylonjs/Materials/effect";
  53769. export * from "babylonjs/Materials/fresnelParameters";
  53770. export * from "babylonjs/Materials/imageProcessingConfiguration";
  53771. export * from "babylonjs/Materials/material";
  53772. export * from "babylonjs/Materials/materialDefines";
  53773. export * from "babylonjs/Materials/materialHelper";
  53774. export * from "babylonjs/Materials/multiMaterial";
  53775. export * from "babylonjs/Materials/PBR/index";
  53776. export * from "babylonjs/Materials/pushMaterial";
  53777. export * from "babylonjs/Materials/shaderMaterial";
  53778. export * from "babylonjs/Materials/standardMaterial";
  53779. export * from "babylonjs/Materials/Textures/index";
  53780. export * from "babylonjs/Materials/uniformBuffer";
  53781. export * from "babylonjs/Materials/materialFlags";
  53782. export * from "babylonjs/Materials/Node/index";
  53783. }
  53784. declare module "babylonjs/Maths/index" {
  53785. export * from "babylonjs/Maths/math.scalar";
  53786. export * from "babylonjs/Maths/math";
  53787. export * from "babylonjs/Maths/sphericalPolynomial";
  53788. }
  53789. declare module "babylonjs/Misc/workerPool" {
  53790. import { IDisposable } from "babylonjs/scene";
  53791. /**
  53792. * Helper class to push actions to a pool of workers.
  53793. */
  53794. export class WorkerPool implements IDisposable {
  53795. private _workerInfos;
  53796. private _pendingActions;
  53797. /**
  53798. * Constructor
  53799. * @param workers Array of workers to use for actions
  53800. */
  53801. constructor(workers: Array<Worker>);
  53802. /**
  53803. * Terminates all workers and clears any pending actions.
  53804. */
  53805. dispose(): void;
  53806. /**
  53807. * Pushes an action to the worker pool. If all the workers are active, the action will be
  53808. * pended until a worker has completed its action.
  53809. * @param action The action to perform. Call onComplete when the action is complete.
  53810. */
  53811. push(action: (worker: Worker, onComplete: () => void) => void): void;
  53812. private _execute;
  53813. }
  53814. }
  53815. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  53816. import { IDisposable } from "babylonjs/scene";
  53817. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  53818. /**
  53819. * Configuration for Draco compression
  53820. */
  53821. export interface IDracoCompressionConfiguration {
  53822. /**
  53823. * Configuration for the decoder.
  53824. */
  53825. decoder: {
  53826. /**
  53827. * The url to the WebAssembly module.
  53828. */
  53829. wasmUrl?: string;
  53830. /**
  53831. * The url to the WebAssembly binary.
  53832. */
  53833. wasmBinaryUrl?: string;
  53834. /**
  53835. * The url to the fallback JavaScript module.
  53836. */
  53837. fallbackUrl?: string;
  53838. };
  53839. }
  53840. /**
  53841. * Draco compression (https://google.github.io/draco/)
  53842. *
  53843. * This class wraps the Draco module.
  53844. *
  53845. * **Encoder**
  53846. *
  53847. * The encoder is not currently implemented.
  53848. *
  53849. * **Decoder**
  53850. *
  53851. * 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.
  53852. *
  53853. * To update the configuration, use the following code:
  53854. * ```javascript
  53855. * DracoCompression.Configuration = {
  53856. * decoder: {
  53857. * wasmUrl: "<url to the WebAssembly library>",
  53858. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  53859. * fallbackUrl: "<url to the fallback JavaScript library>",
  53860. * }
  53861. * };
  53862. * ```
  53863. *
  53864. * 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.
  53865. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  53866. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  53867. *
  53868. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  53869. * ```javascript
  53870. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  53871. * ```
  53872. *
  53873. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  53874. */
  53875. export class DracoCompression implements IDisposable {
  53876. private _workerPoolPromise?;
  53877. private _decoderModulePromise?;
  53878. /**
  53879. * The configuration. Defaults to the following urls:
  53880. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  53881. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  53882. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  53883. */
  53884. static Configuration: IDracoCompressionConfiguration;
  53885. /**
  53886. * Returns true if the decoder configuration is available.
  53887. */
  53888. static readonly DecoderAvailable: boolean;
  53889. /**
  53890. * Default number of workers to create when creating the draco compression object.
  53891. */
  53892. static DefaultNumWorkers: number;
  53893. private static GetDefaultNumWorkers;
  53894. private static _Default;
  53895. /**
  53896. * Default instance for the draco compression object.
  53897. */
  53898. static readonly Default: DracoCompression;
  53899. /**
  53900. * Constructor
  53901. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  53902. */
  53903. constructor(numWorkers?: number);
  53904. /**
  53905. * Stop all async operations and release resources.
  53906. */
  53907. dispose(): void;
  53908. /**
  53909. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  53910. * @returns a promise that resolves when ready
  53911. */
  53912. whenReadyAsync(): Promise<void>;
  53913. /**
  53914. * Decode Draco compressed mesh data to vertex data.
  53915. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  53916. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  53917. * @returns A promise that resolves with the decoded vertex data
  53918. */
  53919. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  53920. [kind: string]: number;
  53921. }): Promise<VertexData>;
  53922. }
  53923. }
  53924. declare module "babylonjs/Meshes/Compression/index" {
  53925. export * from "babylonjs/Meshes/Compression/dracoCompression";
  53926. }
  53927. declare module "babylonjs/Meshes/csg" {
  53928. import { Nullable } from "babylonjs/types";
  53929. import { Scene } from "babylonjs/scene";
  53930. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  53931. import { Mesh } from "babylonjs/Meshes/mesh";
  53932. import { Material } from "babylonjs/Materials/material";
  53933. /**
  53934. * Class for building Constructive Solid Geometry
  53935. */
  53936. export class CSG {
  53937. private polygons;
  53938. /**
  53939. * The world matrix
  53940. */
  53941. matrix: Matrix;
  53942. /**
  53943. * Stores the position
  53944. */
  53945. position: Vector3;
  53946. /**
  53947. * Stores the rotation
  53948. */
  53949. rotation: Vector3;
  53950. /**
  53951. * Stores the rotation quaternion
  53952. */
  53953. rotationQuaternion: Nullable<Quaternion>;
  53954. /**
  53955. * Stores the scaling vector
  53956. */
  53957. scaling: Vector3;
  53958. /**
  53959. * Convert the Mesh to CSG
  53960. * @param mesh The Mesh to convert to CSG
  53961. * @returns A new CSG from the Mesh
  53962. */
  53963. static FromMesh(mesh: Mesh): CSG;
  53964. /**
  53965. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  53966. * @param polygons Polygons used to construct a CSG solid
  53967. */
  53968. private static FromPolygons;
  53969. /**
  53970. * Clones, or makes a deep copy, of the CSG
  53971. * @returns A new CSG
  53972. */
  53973. clone(): CSG;
  53974. /**
  53975. * Unions this CSG with another CSG
  53976. * @param csg The CSG to union against this CSG
  53977. * @returns The unioned CSG
  53978. */
  53979. union(csg: CSG): CSG;
  53980. /**
  53981. * Unions this CSG with another CSG in place
  53982. * @param csg The CSG to union against this CSG
  53983. */
  53984. unionInPlace(csg: CSG): void;
  53985. /**
  53986. * Subtracts this CSG with another CSG
  53987. * @param csg The CSG to subtract against this CSG
  53988. * @returns A new CSG
  53989. */
  53990. subtract(csg: CSG): CSG;
  53991. /**
  53992. * Subtracts this CSG with another CSG in place
  53993. * @param csg The CSG to subtact against this CSG
  53994. */
  53995. subtractInPlace(csg: CSG): void;
  53996. /**
  53997. * Intersect this CSG with another CSG
  53998. * @param csg The CSG to intersect against this CSG
  53999. * @returns A new CSG
  54000. */
  54001. intersect(csg: CSG): CSG;
  54002. /**
  54003. * Intersects this CSG with another CSG in place
  54004. * @param csg The CSG to intersect against this CSG
  54005. */
  54006. intersectInPlace(csg: CSG): void;
  54007. /**
  54008. * Return a new CSG solid with solid and empty space switched. This solid is
  54009. * not modified.
  54010. * @returns A new CSG solid with solid and empty space switched
  54011. */
  54012. inverse(): CSG;
  54013. /**
  54014. * Inverses the CSG in place
  54015. */
  54016. inverseInPlace(): void;
  54017. /**
  54018. * This is used to keep meshes transformations so they can be restored
  54019. * when we build back a Babylon Mesh
  54020. * NB : All CSG operations are performed in world coordinates
  54021. * @param csg The CSG to copy the transform attributes from
  54022. * @returns This CSG
  54023. */
  54024. copyTransformAttributes(csg: CSG): CSG;
  54025. /**
  54026. * Build Raw mesh from CSG
  54027. * Coordinates here are in world space
  54028. * @param name The name of the mesh geometry
  54029. * @param scene The Scene
  54030. * @param keepSubMeshes Specifies if the submeshes should be kept
  54031. * @returns A new Mesh
  54032. */
  54033. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  54034. /**
  54035. * Build Mesh from CSG taking material and transforms into account
  54036. * @param name The name of the Mesh
  54037. * @param material The material of the Mesh
  54038. * @param scene The Scene
  54039. * @param keepSubMeshes Specifies if submeshes should be kept
  54040. * @returns The new Mesh
  54041. */
  54042. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  54043. }
  54044. }
  54045. declare module "babylonjs/Meshes/trailMesh" {
  54046. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54047. import { Mesh } from "babylonjs/Meshes/mesh";
  54048. import { Scene } from "babylonjs/scene";
  54049. /**
  54050. * Class used to create a trail following a mesh
  54051. */
  54052. export class TrailMesh extends Mesh {
  54053. private _generator;
  54054. private _autoStart;
  54055. private _running;
  54056. private _diameter;
  54057. private _length;
  54058. private _sectionPolygonPointsCount;
  54059. private _sectionVectors;
  54060. private _sectionNormalVectors;
  54061. private _beforeRenderObserver;
  54062. /**
  54063. * @constructor
  54064. * @param name The value used by scene.getMeshByName() to do a lookup.
  54065. * @param generator The mesh to generate a trail.
  54066. * @param scene The scene to add this mesh to.
  54067. * @param diameter Diameter of trailing mesh. Default is 1.
  54068. * @param length Length of trailing mesh. Default is 60.
  54069. * @param autoStart Automatically start trailing mesh. Default true.
  54070. */
  54071. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  54072. /**
  54073. * "TrailMesh"
  54074. * @returns "TrailMesh"
  54075. */
  54076. getClassName(): string;
  54077. private _createMesh;
  54078. /**
  54079. * Start trailing mesh.
  54080. */
  54081. start(): void;
  54082. /**
  54083. * Stop trailing mesh.
  54084. */
  54085. stop(): void;
  54086. /**
  54087. * Update trailing mesh geometry.
  54088. */
  54089. update(): void;
  54090. /**
  54091. * Returns a new TrailMesh object.
  54092. * @param name is a string, the name given to the new mesh
  54093. * @param newGenerator use new generator object for cloned trail mesh
  54094. * @returns a new mesh
  54095. */
  54096. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  54097. /**
  54098. * Serializes this trail mesh
  54099. * @param serializationObject object to write serialization to
  54100. */
  54101. serialize(serializationObject: any): void;
  54102. /**
  54103. * Parses a serialized trail mesh
  54104. * @param parsedMesh the serialized mesh
  54105. * @param scene the scene to create the trail mesh in
  54106. * @returns the created trail mesh
  54107. */
  54108. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  54109. }
  54110. }
  54111. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  54112. import { Nullable } from "babylonjs/types";
  54113. import { Scene } from "babylonjs/scene";
  54114. import { Vector4, Color4 } from "babylonjs/Maths/math";
  54115. import { Mesh } from "babylonjs/Meshes/mesh";
  54116. /**
  54117. * Class containing static functions to help procedurally build meshes
  54118. */
  54119. export class TiledBoxBuilder {
  54120. /**
  54121. * Creates a box mesh
  54122. * 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)
  54123. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  54124. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54125. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  54126. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54127. * @param name defines the name of the mesh
  54128. * @param options defines the options used to create the mesh
  54129. * @param scene defines the hosting scene
  54130. * @returns the box mesh
  54131. */
  54132. static CreateTiledBox(name: string, options: {
  54133. pattern?: number;
  54134. width?: number;
  54135. height?: number;
  54136. depth?: number;
  54137. tileSize?: number;
  54138. tileWidth?: number;
  54139. tileHeight?: number;
  54140. alignHorizontal?: number;
  54141. alignVertical?: number;
  54142. faceUV?: Vector4[];
  54143. faceColors?: Color4[];
  54144. sideOrientation?: number;
  54145. updatable?: boolean;
  54146. }, scene?: Nullable<Scene>): Mesh;
  54147. }
  54148. }
  54149. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  54150. import { Vector4 } from "babylonjs/Maths/math";
  54151. import { Mesh } from "babylonjs/Meshes/mesh";
  54152. /**
  54153. * Class containing static functions to help procedurally build meshes
  54154. */
  54155. export class TorusKnotBuilder {
  54156. /**
  54157. * Creates a torus knot mesh
  54158. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  54159. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  54160. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  54161. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  54162. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54163. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  54164. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  54165. * @param name defines the name of the mesh
  54166. * @param options defines the options used to create the mesh
  54167. * @param scene defines the hosting scene
  54168. * @returns the torus knot mesh
  54169. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  54170. */
  54171. static CreateTorusKnot(name: string, options: {
  54172. radius?: number;
  54173. tube?: number;
  54174. radialSegments?: number;
  54175. tubularSegments?: number;
  54176. p?: number;
  54177. q?: number;
  54178. updatable?: boolean;
  54179. sideOrientation?: number;
  54180. frontUVs?: Vector4;
  54181. backUVs?: Vector4;
  54182. }, scene: any): Mesh;
  54183. }
  54184. }
  54185. declare module "babylonjs/Meshes/polygonMesh" {
  54186. import { Scene } from "babylonjs/scene";
  54187. import { Vector2, Path2 } from "babylonjs/Maths/math";
  54188. import { Mesh } from "babylonjs/Meshes/mesh";
  54189. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  54190. /**
  54191. * Polygon
  54192. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  54193. */
  54194. export class Polygon {
  54195. /**
  54196. * Creates a rectangle
  54197. * @param xmin bottom X coord
  54198. * @param ymin bottom Y coord
  54199. * @param xmax top X coord
  54200. * @param ymax top Y coord
  54201. * @returns points that make the resulting rectation
  54202. */
  54203. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  54204. /**
  54205. * Creates a circle
  54206. * @param radius radius of circle
  54207. * @param cx scale in x
  54208. * @param cy scale in y
  54209. * @param numberOfSides number of sides that make up the circle
  54210. * @returns points that make the resulting circle
  54211. */
  54212. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  54213. /**
  54214. * Creates a polygon from input string
  54215. * @param input Input polygon data
  54216. * @returns the parsed points
  54217. */
  54218. static Parse(input: string): Vector2[];
  54219. /**
  54220. * Starts building a polygon from x and y coordinates
  54221. * @param x x coordinate
  54222. * @param y y coordinate
  54223. * @returns the started path2
  54224. */
  54225. static StartingAt(x: number, y: number): Path2;
  54226. }
  54227. /**
  54228. * Builds a polygon
  54229. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  54230. */
  54231. export class PolygonMeshBuilder {
  54232. private _points;
  54233. private _outlinepoints;
  54234. private _holes;
  54235. private _name;
  54236. private _scene;
  54237. private _epoints;
  54238. private _eholes;
  54239. private _addToepoint;
  54240. /**
  54241. * Babylon reference to the earcut plugin.
  54242. */
  54243. bjsEarcut: any;
  54244. /**
  54245. * Creates a PolygonMeshBuilder
  54246. * @param name name of the builder
  54247. * @param contours Path of the polygon
  54248. * @param scene scene to add to when creating the mesh
  54249. * @param earcutInjection can be used to inject your own earcut reference
  54250. */
  54251. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  54252. /**
  54253. * Adds a whole within the polygon
  54254. * @param hole Array of points defining the hole
  54255. * @returns this
  54256. */
  54257. addHole(hole: Vector2[]): PolygonMeshBuilder;
  54258. /**
  54259. * Creates the polygon
  54260. * @param updatable If the mesh should be updatable
  54261. * @param depth The depth of the mesh created
  54262. * @returns the created mesh
  54263. */
  54264. build(updatable?: boolean, depth?: number): Mesh;
  54265. /**
  54266. * Creates the polygon
  54267. * @param depth The depth of the mesh created
  54268. * @returns the created VertexData
  54269. */
  54270. buildVertexData(depth?: number): VertexData;
  54271. /**
  54272. * Adds a side to the polygon
  54273. * @param positions points that make the polygon
  54274. * @param normals normals of the polygon
  54275. * @param uvs uvs of the polygon
  54276. * @param indices indices of the polygon
  54277. * @param bounds bounds of the polygon
  54278. * @param points points of the polygon
  54279. * @param depth depth of the polygon
  54280. * @param flip flip of the polygon
  54281. */
  54282. private addSide;
  54283. }
  54284. }
  54285. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  54286. import { Scene } from "babylonjs/scene";
  54287. import { Vector3, Color4, Vector4 } from "babylonjs/Maths/math";
  54288. import { Mesh } from "babylonjs/Meshes/mesh";
  54289. import { Nullable } from "babylonjs/types";
  54290. /**
  54291. * Class containing static functions to help procedurally build meshes
  54292. */
  54293. export class PolygonBuilder {
  54294. /**
  54295. * Creates a polygon mesh
  54296. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  54297. * * 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
  54298. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  54299. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54300. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  54301. * * Remember you can only change the shape positions, not their number when updating a polygon
  54302. * @param name defines the name of the mesh
  54303. * @param options defines the options used to create the mesh
  54304. * @param scene defines the hosting scene
  54305. * @param earcutInjection can be used to inject your own earcut reference
  54306. * @returns the polygon mesh
  54307. */
  54308. static CreatePolygon(name: string, options: {
  54309. shape: Vector3[];
  54310. holes?: Vector3[][];
  54311. depth?: number;
  54312. faceUV?: Vector4[];
  54313. faceColors?: Color4[];
  54314. updatable?: boolean;
  54315. sideOrientation?: number;
  54316. frontUVs?: Vector4;
  54317. backUVs?: Vector4;
  54318. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  54319. /**
  54320. * Creates an extruded polygon mesh, with depth in the Y direction.
  54321. * * 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)
  54322. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  54323. * @param name defines the name of the mesh
  54324. * @param options defines the options used to create the mesh
  54325. * @param scene defines the hosting scene
  54326. * @param earcutInjection can be used to inject your own earcut reference
  54327. * @returns the polygon mesh
  54328. */
  54329. static ExtrudePolygon(name: string, options: {
  54330. shape: Vector3[];
  54331. holes?: Vector3[][];
  54332. depth?: number;
  54333. faceUV?: Vector4[];
  54334. faceColors?: Color4[];
  54335. updatable?: boolean;
  54336. sideOrientation?: number;
  54337. frontUVs?: Vector4;
  54338. backUVs?: Vector4;
  54339. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  54340. }
  54341. }
  54342. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  54343. import { Scene } from "babylonjs/scene";
  54344. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  54345. import { Mesh } from "babylonjs/Meshes/mesh";
  54346. import { Nullable } from "babylonjs/types";
  54347. /**
  54348. * Class containing static functions to help procedurally build meshes
  54349. */
  54350. export class LatheBuilder {
  54351. /**
  54352. * Creates lathe mesh.
  54353. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  54354. * * 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
  54355. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  54356. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  54357. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  54358. * * 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
  54359. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  54360. * * 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
  54361. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54362. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  54363. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  54364. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54365. * @param name defines the name of the mesh
  54366. * @param options defines the options used to create the mesh
  54367. * @param scene defines the hosting scene
  54368. * @returns the lathe mesh
  54369. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  54370. */
  54371. static CreateLathe(name: string, options: {
  54372. shape: Vector3[];
  54373. radius?: number;
  54374. tessellation?: number;
  54375. clip?: number;
  54376. arc?: number;
  54377. closed?: boolean;
  54378. updatable?: boolean;
  54379. sideOrientation?: number;
  54380. frontUVs?: Vector4;
  54381. backUVs?: Vector4;
  54382. cap?: number;
  54383. invertUV?: boolean;
  54384. }, scene?: Nullable<Scene>): Mesh;
  54385. }
  54386. }
  54387. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  54388. import { Nullable } from "babylonjs/types";
  54389. import { Scene } from "babylonjs/scene";
  54390. import { Vector4 } from "babylonjs/Maths/math";
  54391. import { Mesh } from "babylonjs/Meshes/mesh";
  54392. /**
  54393. * Class containing static functions to help procedurally build meshes
  54394. */
  54395. export class TiledPlaneBuilder {
  54396. /**
  54397. * Creates a tiled plane mesh
  54398. * * The parameter `pattern` will, depending on value, do nothing or
  54399. * * * flip (reflect about central vertical) alternate tiles across and up
  54400. * * * flip every tile on alternate rows
  54401. * * * rotate (180 degs) alternate tiles across and up
  54402. * * * rotate every tile on alternate rows
  54403. * * * flip and rotate alternate tiles across and up
  54404. * * * flip and rotate every tile on alternate rows
  54405. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  54406. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  54407. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  54408. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  54409. * * 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)
  54410. * * 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)
  54411. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  54412. * @param name defines the name of the mesh
  54413. * @param options defines the options used to create the mesh
  54414. * @param scene defines the hosting scene
  54415. * @returns the box mesh
  54416. */
  54417. static CreateTiledPlane(name: string, options: {
  54418. pattern?: number;
  54419. tileSize?: number;
  54420. tileWidth?: number;
  54421. tileHeight?: number;
  54422. size?: number;
  54423. width?: number;
  54424. height?: number;
  54425. alignHorizontal?: number;
  54426. alignVertical?: number;
  54427. sideOrientation?: number;
  54428. frontUVs?: Vector4;
  54429. backUVs?: Vector4;
  54430. updatable?: boolean;
  54431. }, scene?: Nullable<Scene>): Mesh;
  54432. }
  54433. }
  54434. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  54435. import { Nullable } from "babylonjs/types";
  54436. import { Scene } from "babylonjs/scene";
  54437. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  54438. import { Mesh } from "babylonjs/Meshes/mesh";
  54439. /**
  54440. * Class containing static functions to help procedurally build meshes
  54441. */
  54442. export class TubeBuilder {
  54443. /**
  54444. * Creates a tube mesh.
  54445. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  54446. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  54447. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  54448. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  54449. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  54450. * * 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)
  54451. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  54452. * * 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
  54453. * * 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
  54454. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54455. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  54456. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  54457. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54458. * @param name defines the name of the mesh
  54459. * @param options defines the options used to create the mesh
  54460. * @param scene defines the hosting scene
  54461. * @returns the tube mesh
  54462. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54463. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  54464. */
  54465. static CreateTube(name: string, options: {
  54466. path: Vector3[];
  54467. radius?: number;
  54468. tessellation?: number;
  54469. radiusFunction?: {
  54470. (i: number, distance: number): number;
  54471. };
  54472. cap?: number;
  54473. arc?: number;
  54474. updatable?: boolean;
  54475. sideOrientation?: number;
  54476. frontUVs?: Vector4;
  54477. backUVs?: Vector4;
  54478. instance?: Mesh;
  54479. invertUV?: boolean;
  54480. }, scene?: Nullable<Scene>): Mesh;
  54481. }
  54482. }
  54483. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  54484. import { Scene } from "babylonjs/scene";
  54485. import { Vector4 } from "babylonjs/Maths/math";
  54486. import { Mesh } from "babylonjs/Meshes/mesh";
  54487. import { Nullable } from "babylonjs/types";
  54488. /**
  54489. * Class containing static functions to help procedurally build meshes
  54490. */
  54491. export class IcoSphereBuilder {
  54492. /**
  54493. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  54494. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  54495. * * 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`)
  54496. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  54497. * * 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
  54498. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54499. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  54500. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54501. * @param name defines the name of the mesh
  54502. * @param options defines the options used to create the mesh
  54503. * @param scene defines the hosting scene
  54504. * @returns the icosahedron mesh
  54505. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  54506. */
  54507. static CreateIcoSphere(name: string, options: {
  54508. radius?: number;
  54509. radiusX?: number;
  54510. radiusY?: number;
  54511. radiusZ?: number;
  54512. flat?: boolean;
  54513. subdivisions?: number;
  54514. sideOrientation?: number;
  54515. frontUVs?: Vector4;
  54516. backUVs?: Vector4;
  54517. updatable?: boolean;
  54518. }, scene?: Nullable<Scene>): Mesh;
  54519. }
  54520. }
  54521. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  54522. import { Vector3 } from "babylonjs/Maths/math";
  54523. import { Mesh } from "babylonjs/Meshes/mesh";
  54524. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54525. /**
  54526. * Class containing static functions to help procedurally build meshes
  54527. */
  54528. export class DecalBuilder {
  54529. /**
  54530. * Creates a decal mesh.
  54531. * 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
  54532. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  54533. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  54534. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  54535. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  54536. * @param name defines the name of the mesh
  54537. * @param sourceMesh defines the mesh where the decal must be applied
  54538. * @param options defines the options used to create the mesh
  54539. * @param scene defines the hosting scene
  54540. * @returns the decal mesh
  54541. * @see https://doc.babylonjs.com/how_to/decals
  54542. */
  54543. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  54544. position?: Vector3;
  54545. normal?: Vector3;
  54546. size?: Vector3;
  54547. angle?: number;
  54548. }): Mesh;
  54549. }
  54550. }
  54551. declare module "babylonjs/Meshes/meshBuilder" {
  54552. import { Vector4, Color4, Vector3, Vector2, Plane, Color3 } from "babylonjs/Maths/math";
  54553. import { Nullable } from "babylonjs/types";
  54554. import { Scene } from "babylonjs/scene";
  54555. import { Mesh } from "babylonjs/Meshes/mesh";
  54556. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  54557. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  54558. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54559. /**
  54560. * Class containing static functions to help procedurally build meshes
  54561. */
  54562. export class MeshBuilder {
  54563. /**
  54564. * Creates a box mesh
  54565. * * The parameter `size` sets the size (float) of each box side (default 1)
  54566. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  54567. * * 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)
  54568. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  54569. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54570. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  54571. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54572. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  54573. * @param name defines the name of the mesh
  54574. * @param options defines the options used to create the mesh
  54575. * @param scene defines the hosting scene
  54576. * @returns the box mesh
  54577. */
  54578. static CreateBox(name: string, options: {
  54579. size?: number;
  54580. width?: number;
  54581. height?: number;
  54582. depth?: number;
  54583. faceUV?: Vector4[];
  54584. faceColors?: Color4[];
  54585. sideOrientation?: number;
  54586. frontUVs?: Vector4;
  54587. backUVs?: Vector4;
  54588. updatable?: boolean;
  54589. }, scene?: Nullable<Scene>): Mesh;
  54590. /**
  54591. * Creates a tiled box mesh
  54592. * * faceTiles sets the pattern, tile size and number of tiles for a face
  54593. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54594. * @param name defines the name of the mesh
  54595. * @param options defines the options used to create the mesh
  54596. * @param scene defines the hosting scene
  54597. * @returns the tiled box mesh
  54598. */
  54599. static CreateTiledBox(name: string, options: {
  54600. pattern?: number;
  54601. size?: number;
  54602. width?: number;
  54603. height?: number;
  54604. depth: number;
  54605. tileSize?: number;
  54606. tileWidth?: number;
  54607. tileHeight?: number;
  54608. faceUV?: Vector4[];
  54609. faceColors?: Color4[];
  54610. alignHorizontal?: number;
  54611. alignVertical?: number;
  54612. sideOrientation?: number;
  54613. updatable?: boolean;
  54614. }, scene?: Nullable<Scene>): Mesh;
  54615. /**
  54616. * Creates a sphere mesh
  54617. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  54618. * * 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`)
  54619. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  54620. * * 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
  54621. * * 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)
  54622. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54623. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  54624. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54625. * @param name defines the name of the mesh
  54626. * @param options defines the options used to create the mesh
  54627. * @param scene defines the hosting scene
  54628. * @returns the sphere mesh
  54629. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  54630. */
  54631. static CreateSphere(name: string, options: {
  54632. segments?: number;
  54633. diameter?: number;
  54634. diameterX?: number;
  54635. diameterY?: number;
  54636. diameterZ?: number;
  54637. arc?: number;
  54638. slice?: number;
  54639. sideOrientation?: number;
  54640. frontUVs?: Vector4;
  54641. backUVs?: Vector4;
  54642. updatable?: boolean;
  54643. }, scene?: Nullable<Scene>): Mesh;
  54644. /**
  54645. * Creates a plane polygonal mesh. By default, this is a disc
  54646. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  54647. * * 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
  54648. * * 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
  54649. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54650. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  54651. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54652. * @param name defines the name of the mesh
  54653. * @param options defines the options used to create the mesh
  54654. * @param scene defines the hosting scene
  54655. * @returns the plane polygonal mesh
  54656. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  54657. */
  54658. static CreateDisc(name: string, options: {
  54659. radius?: number;
  54660. tessellation?: number;
  54661. arc?: number;
  54662. updatable?: boolean;
  54663. sideOrientation?: number;
  54664. frontUVs?: Vector4;
  54665. backUVs?: Vector4;
  54666. }, scene?: Nullable<Scene>): Mesh;
  54667. /**
  54668. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  54669. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  54670. * * 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`)
  54671. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  54672. * * 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
  54673. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54674. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  54675. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54676. * @param name defines the name of the mesh
  54677. * @param options defines the options used to create the mesh
  54678. * @param scene defines the hosting scene
  54679. * @returns the icosahedron mesh
  54680. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  54681. */
  54682. static CreateIcoSphere(name: string, options: {
  54683. radius?: number;
  54684. radiusX?: number;
  54685. radiusY?: number;
  54686. radiusZ?: number;
  54687. flat?: boolean;
  54688. subdivisions?: number;
  54689. sideOrientation?: number;
  54690. frontUVs?: Vector4;
  54691. backUVs?: Vector4;
  54692. updatable?: boolean;
  54693. }, scene?: Nullable<Scene>): Mesh;
  54694. /**
  54695. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  54696. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  54697. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  54698. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  54699. * * 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
  54700. * * 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
  54701. * * 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
  54702. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54703. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  54704. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  54705. * * 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
  54706. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  54707. * * 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
  54708. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  54709. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54710. * @param name defines the name of the mesh
  54711. * @param options defines the options used to create the mesh
  54712. * @param scene defines the hosting scene
  54713. * @returns the ribbon mesh
  54714. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  54715. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54716. */
  54717. static CreateRibbon(name: string, options: {
  54718. pathArray: Vector3[][];
  54719. closeArray?: boolean;
  54720. closePath?: boolean;
  54721. offset?: number;
  54722. updatable?: boolean;
  54723. sideOrientation?: number;
  54724. frontUVs?: Vector4;
  54725. backUVs?: Vector4;
  54726. instance?: Mesh;
  54727. invertUV?: boolean;
  54728. uvs?: Vector2[];
  54729. colors?: Color4[];
  54730. }, scene?: Nullable<Scene>): Mesh;
  54731. /**
  54732. * Creates a cylinder or a cone mesh
  54733. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  54734. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  54735. * * 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.
  54736. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  54737. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  54738. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  54739. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  54740. * * 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).
  54741. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  54742. * * 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).
  54743. * * 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
  54744. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  54745. * * 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
  54746. * * 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.
  54747. * * If `enclose` is false, a ring surface is one element.
  54748. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  54749. * * 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
  54750. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54751. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  54752. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  54753. * @param name defines the name of the mesh
  54754. * @param options defines the options used to create the mesh
  54755. * @param scene defines the hosting scene
  54756. * @returns the cylinder mesh
  54757. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  54758. */
  54759. static CreateCylinder(name: string, options: {
  54760. height?: number;
  54761. diameterTop?: number;
  54762. diameterBottom?: number;
  54763. diameter?: number;
  54764. tessellation?: number;
  54765. subdivisions?: number;
  54766. arc?: number;
  54767. faceColors?: Color4[];
  54768. faceUV?: Vector4[];
  54769. updatable?: boolean;
  54770. hasRings?: boolean;
  54771. enclose?: boolean;
  54772. cap?: number;
  54773. sideOrientation?: number;
  54774. frontUVs?: Vector4;
  54775. backUVs?: Vector4;
  54776. }, scene?: Nullable<Scene>): Mesh;
  54777. /**
  54778. * Creates a torus mesh
  54779. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  54780. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  54781. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  54782. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54783. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  54784. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  54785. * @param name defines the name of the mesh
  54786. * @param options defines the options used to create the mesh
  54787. * @param scene defines the hosting scene
  54788. * @returns the torus mesh
  54789. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  54790. */
  54791. static CreateTorus(name: string, options: {
  54792. diameter?: number;
  54793. thickness?: number;
  54794. tessellation?: number;
  54795. updatable?: boolean;
  54796. sideOrientation?: number;
  54797. frontUVs?: Vector4;
  54798. backUVs?: Vector4;
  54799. }, scene?: Nullable<Scene>): Mesh;
  54800. /**
  54801. * Creates a torus knot mesh
  54802. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  54803. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  54804. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  54805. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  54806. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54807. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  54808. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  54809. * @param name defines the name of the mesh
  54810. * @param options defines the options used to create the mesh
  54811. * @param scene defines the hosting scene
  54812. * @returns the torus knot mesh
  54813. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  54814. */
  54815. static CreateTorusKnot(name: string, options: {
  54816. radius?: number;
  54817. tube?: number;
  54818. radialSegments?: number;
  54819. tubularSegments?: number;
  54820. p?: number;
  54821. q?: number;
  54822. updatable?: boolean;
  54823. sideOrientation?: number;
  54824. frontUVs?: Vector4;
  54825. backUVs?: Vector4;
  54826. }, scene?: Nullable<Scene>): Mesh;
  54827. /**
  54828. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  54829. * * 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
  54830. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  54831. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  54832. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  54833. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  54834. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  54835. * * 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
  54836. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  54837. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54838. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  54839. * @param name defines the name of the new line system
  54840. * @param options defines the options used to create the line system
  54841. * @param scene defines the hosting scene
  54842. * @returns a new line system mesh
  54843. */
  54844. static CreateLineSystem(name: string, options: {
  54845. lines: Vector3[][];
  54846. updatable?: boolean;
  54847. instance?: Nullable<LinesMesh>;
  54848. colors?: Nullable<Color4[][]>;
  54849. useVertexAlpha?: boolean;
  54850. }, scene: Nullable<Scene>): LinesMesh;
  54851. /**
  54852. * Creates a line mesh
  54853. * 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
  54854. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  54855. * * The parameter `points` is an array successive Vector3
  54856. * * 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
  54857. * * The optional parameter `colors` is an array of successive Color4, one per line point
  54858. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  54859. * * When updating an instance, remember that only point positions can change, not the number of points
  54860. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54861. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  54862. * @param name defines the name of the new line system
  54863. * @param options defines the options used to create the line system
  54864. * @param scene defines the hosting scene
  54865. * @returns a new line mesh
  54866. */
  54867. static CreateLines(name: string, options: {
  54868. points: Vector3[];
  54869. updatable?: boolean;
  54870. instance?: Nullable<LinesMesh>;
  54871. colors?: Color4[];
  54872. useVertexAlpha?: boolean;
  54873. }, scene?: Nullable<Scene>): LinesMesh;
  54874. /**
  54875. * Creates a dashed line mesh
  54876. * * 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
  54877. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  54878. * * The parameter `points` is an array successive Vector3
  54879. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  54880. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  54881. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  54882. * * 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
  54883. * * When updating an instance, remember that only point positions can change, not the number of points
  54884. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54885. * @param name defines the name of the mesh
  54886. * @param options defines the options used to create the mesh
  54887. * @param scene defines the hosting scene
  54888. * @returns the dashed line mesh
  54889. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  54890. */
  54891. static CreateDashedLines(name: string, options: {
  54892. points: Vector3[];
  54893. dashSize?: number;
  54894. gapSize?: number;
  54895. dashNb?: number;
  54896. updatable?: boolean;
  54897. instance?: LinesMesh;
  54898. }, scene?: Nullable<Scene>): LinesMesh;
  54899. /**
  54900. * 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.
  54901. * * 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.
  54902. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  54903. * * 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.
  54904. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  54905. * * 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
  54906. * * 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
  54907. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  54908. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54909. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  54910. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  54911. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  54912. * @param name defines the name of the mesh
  54913. * @param options defines the options used to create the mesh
  54914. * @param scene defines the hosting scene
  54915. * @returns the extruded shape mesh
  54916. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54917. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  54918. */
  54919. static ExtrudeShape(name: string, options: {
  54920. shape: Vector3[];
  54921. path: Vector3[];
  54922. scale?: number;
  54923. rotation?: number;
  54924. cap?: number;
  54925. updatable?: boolean;
  54926. sideOrientation?: number;
  54927. frontUVs?: Vector4;
  54928. backUVs?: Vector4;
  54929. instance?: Mesh;
  54930. invertUV?: boolean;
  54931. }, scene?: Nullable<Scene>): Mesh;
  54932. /**
  54933. * Creates an custom extruded shape mesh.
  54934. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  54935. * * 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.
  54936. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  54937. * * 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
  54938. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  54939. * * 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
  54940. * * It must returns a float value that will be the scale value applied to the shape on each path point
  54941. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  54942. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  54943. * * 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
  54944. * * 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
  54945. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  54946. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54947. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  54948. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  54949. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54950. * @param name defines the name of the mesh
  54951. * @param options defines the options used to create the mesh
  54952. * @param scene defines the hosting scene
  54953. * @returns the custom extruded shape mesh
  54954. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  54955. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54956. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  54957. */
  54958. static ExtrudeShapeCustom(name: string, options: {
  54959. shape: Vector3[];
  54960. path: Vector3[];
  54961. scaleFunction?: any;
  54962. rotationFunction?: any;
  54963. ribbonCloseArray?: boolean;
  54964. ribbonClosePath?: boolean;
  54965. cap?: number;
  54966. updatable?: boolean;
  54967. sideOrientation?: number;
  54968. frontUVs?: Vector4;
  54969. backUVs?: Vector4;
  54970. instance?: Mesh;
  54971. invertUV?: boolean;
  54972. }, scene?: Nullable<Scene>): Mesh;
  54973. /**
  54974. * Creates lathe mesh.
  54975. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  54976. * * 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
  54977. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  54978. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  54979. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  54980. * * 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
  54981. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  54982. * * 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
  54983. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54984. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  54985. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  54986. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54987. * @param name defines the name of the mesh
  54988. * @param options defines the options used to create the mesh
  54989. * @param scene defines the hosting scene
  54990. * @returns the lathe mesh
  54991. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  54992. */
  54993. static CreateLathe(name: string, options: {
  54994. shape: Vector3[];
  54995. radius?: number;
  54996. tessellation?: number;
  54997. clip?: number;
  54998. arc?: number;
  54999. closed?: boolean;
  55000. updatable?: boolean;
  55001. sideOrientation?: number;
  55002. frontUVs?: Vector4;
  55003. backUVs?: Vector4;
  55004. cap?: number;
  55005. invertUV?: boolean;
  55006. }, scene?: Nullable<Scene>): Mesh;
  55007. /**
  55008. * Creates a tiled plane mesh
  55009. * * You can set a limited pattern arrangement with the tiles
  55010. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55011. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55012. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55013. * @param name defines the name of the mesh
  55014. * @param options defines the options used to create the mesh
  55015. * @param scene defines the hosting scene
  55016. * @returns the plane mesh
  55017. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  55018. */
  55019. static CreateTiledPlane(name: string, options: {
  55020. pattern?: number;
  55021. tileSize?: number;
  55022. tileWidth?: number;
  55023. tileHeight?: number;
  55024. size?: number;
  55025. width?: number;
  55026. height?: number;
  55027. alignHorizontal?: number;
  55028. alignVertical?: number;
  55029. sideOrientation?: number;
  55030. frontUVs?: Vector4;
  55031. backUVs?: Vector4;
  55032. updatable?: boolean;
  55033. }, scene?: Nullable<Scene>): Mesh;
  55034. /**
  55035. * Creates a plane mesh
  55036. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  55037. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  55038. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  55039. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55040. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55041. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55042. * @param name defines the name of the mesh
  55043. * @param options defines the options used to create the mesh
  55044. * @param scene defines the hosting scene
  55045. * @returns the plane mesh
  55046. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  55047. */
  55048. static CreatePlane(name: string, options: {
  55049. size?: number;
  55050. width?: number;
  55051. height?: number;
  55052. sideOrientation?: number;
  55053. frontUVs?: Vector4;
  55054. backUVs?: Vector4;
  55055. updatable?: boolean;
  55056. sourcePlane?: Plane;
  55057. }, scene?: Nullable<Scene>): Mesh;
  55058. /**
  55059. * Creates a ground mesh
  55060. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  55061. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  55062. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55063. * @param name defines the name of the mesh
  55064. * @param options defines the options used to create the mesh
  55065. * @param scene defines the hosting scene
  55066. * @returns the ground mesh
  55067. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  55068. */
  55069. static CreateGround(name: string, options: {
  55070. width?: number;
  55071. height?: number;
  55072. subdivisions?: number;
  55073. subdivisionsX?: number;
  55074. subdivisionsY?: number;
  55075. updatable?: boolean;
  55076. }, scene?: Nullable<Scene>): Mesh;
  55077. /**
  55078. * Creates a tiled ground mesh
  55079. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  55080. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  55081. * * 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
  55082. * * 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
  55083. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55084. * @param name defines the name of the mesh
  55085. * @param options defines the options used to create the mesh
  55086. * @param scene defines the hosting scene
  55087. * @returns the tiled ground mesh
  55088. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  55089. */
  55090. static CreateTiledGround(name: string, options: {
  55091. xmin: number;
  55092. zmin: number;
  55093. xmax: number;
  55094. zmax: number;
  55095. subdivisions?: {
  55096. w: number;
  55097. h: number;
  55098. };
  55099. precision?: {
  55100. w: number;
  55101. h: number;
  55102. };
  55103. updatable?: boolean;
  55104. }, scene?: Nullable<Scene>): Mesh;
  55105. /**
  55106. * Creates a ground mesh from a height map
  55107. * * The parameter `url` sets the URL of the height map image resource.
  55108. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  55109. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  55110. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  55111. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  55112. * * 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.
  55113. * * 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).
  55114. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  55115. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55116. * @param name defines the name of the mesh
  55117. * @param url defines the url to the height map
  55118. * @param options defines the options used to create the mesh
  55119. * @param scene defines the hosting scene
  55120. * @returns the ground mesh
  55121. * @see https://doc.babylonjs.com/babylon101/height_map
  55122. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  55123. */
  55124. static CreateGroundFromHeightMap(name: string, url: string, options: {
  55125. width?: number;
  55126. height?: number;
  55127. subdivisions?: number;
  55128. minHeight?: number;
  55129. maxHeight?: number;
  55130. colorFilter?: Color3;
  55131. alphaFilter?: number;
  55132. updatable?: boolean;
  55133. onReady?: (mesh: GroundMesh) => void;
  55134. }, scene?: Nullable<Scene>): GroundMesh;
  55135. /**
  55136. * Creates a polygon mesh
  55137. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  55138. * * 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
  55139. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  55140. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55141. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  55142. * * Remember you can only change the shape positions, not their number when updating a polygon
  55143. * @param name defines the name of the mesh
  55144. * @param options defines the options used to create the mesh
  55145. * @param scene defines the hosting scene
  55146. * @param earcutInjection can be used to inject your own earcut reference
  55147. * @returns the polygon mesh
  55148. */
  55149. static CreatePolygon(name: string, options: {
  55150. shape: Vector3[];
  55151. holes?: Vector3[][];
  55152. depth?: number;
  55153. faceUV?: Vector4[];
  55154. faceColors?: Color4[];
  55155. updatable?: boolean;
  55156. sideOrientation?: number;
  55157. frontUVs?: Vector4;
  55158. backUVs?: Vector4;
  55159. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  55160. /**
  55161. * Creates an extruded polygon mesh, with depth in the Y direction.
  55162. * * 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)
  55163. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  55164. * @param name defines the name of the mesh
  55165. * @param options defines the options used to create the mesh
  55166. * @param scene defines the hosting scene
  55167. * @param earcutInjection can be used to inject your own earcut reference
  55168. * @returns the polygon mesh
  55169. */
  55170. static ExtrudePolygon(name: string, options: {
  55171. shape: Vector3[];
  55172. holes?: Vector3[][];
  55173. depth?: number;
  55174. faceUV?: Vector4[];
  55175. faceColors?: Color4[];
  55176. updatable?: boolean;
  55177. sideOrientation?: number;
  55178. frontUVs?: Vector4;
  55179. backUVs?: Vector4;
  55180. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  55181. /**
  55182. * Creates a tube mesh.
  55183. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  55184. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  55185. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  55186. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  55187. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  55188. * * 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)
  55189. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  55190. * * 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
  55191. * * 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
  55192. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55193. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55194. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55195. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55196. * @param name defines the name of the mesh
  55197. * @param options defines the options used to create the mesh
  55198. * @param scene defines the hosting scene
  55199. * @returns the tube mesh
  55200. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55201. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  55202. */
  55203. static CreateTube(name: string, options: {
  55204. path: Vector3[];
  55205. radius?: number;
  55206. tessellation?: number;
  55207. radiusFunction?: {
  55208. (i: number, distance: number): number;
  55209. };
  55210. cap?: number;
  55211. arc?: number;
  55212. updatable?: boolean;
  55213. sideOrientation?: number;
  55214. frontUVs?: Vector4;
  55215. backUVs?: Vector4;
  55216. instance?: Mesh;
  55217. invertUV?: boolean;
  55218. }, scene?: Nullable<Scene>): Mesh;
  55219. /**
  55220. * Creates a polyhedron mesh
  55221. * * 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
  55222. * * The parameter `size` (positive float, default 1) sets the polygon size
  55223. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  55224. * * 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`
  55225. * * 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
  55226. * * 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)`)
  55227. * * 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
  55228. * * 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
  55229. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55230. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55231. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55232. * @param name defines the name of the mesh
  55233. * @param options defines the options used to create the mesh
  55234. * @param scene defines the hosting scene
  55235. * @returns the polyhedron mesh
  55236. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  55237. */
  55238. static CreatePolyhedron(name: string, options: {
  55239. type?: number;
  55240. size?: number;
  55241. sizeX?: number;
  55242. sizeY?: number;
  55243. sizeZ?: number;
  55244. custom?: any;
  55245. faceUV?: Vector4[];
  55246. faceColors?: Color4[];
  55247. flat?: boolean;
  55248. updatable?: boolean;
  55249. sideOrientation?: number;
  55250. frontUVs?: Vector4;
  55251. backUVs?: Vector4;
  55252. }, scene?: Nullable<Scene>): Mesh;
  55253. /**
  55254. * Creates a decal mesh.
  55255. * 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
  55256. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  55257. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  55258. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  55259. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  55260. * @param name defines the name of the mesh
  55261. * @param sourceMesh defines the mesh where the decal must be applied
  55262. * @param options defines the options used to create the mesh
  55263. * @param scene defines the hosting scene
  55264. * @returns the decal mesh
  55265. * @see https://doc.babylonjs.com/how_to/decals
  55266. */
  55267. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  55268. position?: Vector3;
  55269. normal?: Vector3;
  55270. size?: Vector3;
  55271. angle?: number;
  55272. }): Mesh;
  55273. }
  55274. }
  55275. declare module "babylonjs/Meshes/meshSimplification" {
  55276. import { Mesh } from "babylonjs/Meshes/mesh";
  55277. /**
  55278. * A simplifier interface for future simplification implementations
  55279. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  55280. */
  55281. export interface ISimplifier {
  55282. /**
  55283. * Simplification of a given mesh according to the given settings.
  55284. * Since this requires computation, it is assumed that the function runs async.
  55285. * @param settings The settings of the simplification, including quality and distance
  55286. * @param successCallback A callback that will be called after the mesh was simplified.
  55287. * @param errorCallback in case of an error, this callback will be called. optional.
  55288. */
  55289. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  55290. }
  55291. /**
  55292. * Expected simplification settings.
  55293. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  55294. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  55295. */
  55296. export interface ISimplificationSettings {
  55297. /**
  55298. * Gets or sets the expected quality
  55299. */
  55300. quality: number;
  55301. /**
  55302. * Gets or sets the distance when this optimized version should be used
  55303. */
  55304. distance: number;
  55305. /**
  55306. * Gets an already optimized mesh
  55307. */
  55308. optimizeMesh?: boolean;
  55309. }
  55310. /**
  55311. * Class used to specify simplification options
  55312. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  55313. */
  55314. export class SimplificationSettings implements ISimplificationSettings {
  55315. /** expected quality */
  55316. quality: number;
  55317. /** distance when this optimized version should be used */
  55318. distance: number;
  55319. /** already optimized mesh */
  55320. optimizeMesh?: boolean | undefined;
  55321. /**
  55322. * Creates a SimplificationSettings
  55323. * @param quality expected quality
  55324. * @param distance distance when this optimized version should be used
  55325. * @param optimizeMesh already optimized mesh
  55326. */
  55327. constructor(
  55328. /** expected quality */
  55329. quality: number,
  55330. /** distance when this optimized version should be used */
  55331. distance: number,
  55332. /** already optimized mesh */
  55333. optimizeMesh?: boolean | undefined);
  55334. }
  55335. /**
  55336. * Interface used to define a simplification task
  55337. */
  55338. export interface ISimplificationTask {
  55339. /**
  55340. * Array of settings
  55341. */
  55342. settings: Array<ISimplificationSettings>;
  55343. /**
  55344. * Simplification type
  55345. */
  55346. simplificationType: SimplificationType;
  55347. /**
  55348. * Mesh to simplify
  55349. */
  55350. mesh: Mesh;
  55351. /**
  55352. * Callback called on success
  55353. */
  55354. successCallback?: () => void;
  55355. /**
  55356. * Defines if parallel processing can be used
  55357. */
  55358. parallelProcessing: boolean;
  55359. }
  55360. /**
  55361. * Queue used to order the simplification tasks
  55362. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  55363. */
  55364. export class SimplificationQueue {
  55365. private _simplificationArray;
  55366. /**
  55367. * Gets a boolean indicating that the process is still running
  55368. */
  55369. running: boolean;
  55370. /**
  55371. * Creates a new queue
  55372. */
  55373. constructor();
  55374. /**
  55375. * Adds a new simplification task
  55376. * @param task defines a task to add
  55377. */
  55378. addTask(task: ISimplificationTask): void;
  55379. /**
  55380. * Execute next task
  55381. */
  55382. executeNext(): void;
  55383. /**
  55384. * Execute a simplification task
  55385. * @param task defines the task to run
  55386. */
  55387. runSimplification(task: ISimplificationTask): void;
  55388. private getSimplifier;
  55389. }
  55390. /**
  55391. * The implemented types of simplification
  55392. * At the moment only Quadratic Error Decimation is implemented
  55393. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  55394. */
  55395. export enum SimplificationType {
  55396. /** Quadratic error decimation */
  55397. QUADRATIC = 0
  55398. }
  55399. }
  55400. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  55401. import { Scene } from "babylonjs/scene";
  55402. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  55403. import { ISceneComponent } from "babylonjs/sceneComponent";
  55404. module "babylonjs/scene" {
  55405. interface Scene {
  55406. /** @hidden (Backing field) */
  55407. _simplificationQueue: SimplificationQueue;
  55408. /**
  55409. * Gets or sets the simplification queue attached to the scene
  55410. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  55411. */
  55412. simplificationQueue: SimplificationQueue;
  55413. }
  55414. }
  55415. module "babylonjs/Meshes/mesh" {
  55416. interface Mesh {
  55417. /**
  55418. * Simplify the mesh according to the given array of settings.
  55419. * Function will return immediately and will simplify async
  55420. * @param settings a collection of simplification settings
  55421. * @param parallelProcessing should all levels calculate parallel or one after the other
  55422. * @param simplificationType the type of simplification to run
  55423. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  55424. * @returns the current mesh
  55425. */
  55426. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  55427. }
  55428. }
  55429. /**
  55430. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  55431. * created in a scene
  55432. */
  55433. export class SimplicationQueueSceneComponent implements ISceneComponent {
  55434. /**
  55435. * The component name helpfull to identify the component in the list of scene components.
  55436. */
  55437. readonly name: string;
  55438. /**
  55439. * The scene the component belongs to.
  55440. */
  55441. scene: Scene;
  55442. /**
  55443. * Creates a new instance of the component for the given scene
  55444. * @param scene Defines the scene to register the component in
  55445. */
  55446. constructor(scene: Scene);
  55447. /**
  55448. * Registers the component in a given scene
  55449. */
  55450. register(): void;
  55451. /**
  55452. * Rebuilds the elements related to this component in case of
  55453. * context lost for instance.
  55454. */
  55455. rebuild(): void;
  55456. /**
  55457. * Disposes the component and the associated ressources
  55458. */
  55459. dispose(): void;
  55460. private _beforeCameraUpdate;
  55461. }
  55462. }
  55463. declare module "babylonjs/Meshes/Builders/index" {
  55464. export * from "babylonjs/Meshes/Builders/boxBuilder";
  55465. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  55466. export * from "babylonjs/Meshes/Builders/discBuilder";
  55467. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  55468. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  55469. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  55470. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  55471. export * from "babylonjs/Meshes/Builders/torusBuilder";
  55472. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  55473. export * from "babylonjs/Meshes/Builders/linesBuilder";
  55474. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  55475. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  55476. export * from "babylonjs/Meshes/Builders/latheBuilder";
  55477. export * from "babylonjs/Meshes/Builders/planeBuilder";
  55478. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  55479. export * from "babylonjs/Meshes/Builders/groundBuilder";
  55480. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  55481. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  55482. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  55483. export * from "babylonjs/Meshes/Builders/decalBuilder";
  55484. }
  55485. declare module "babylonjs/Meshes/index" {
  55486. export * from "babylonjs/Meshes/abstractMesh";
  55487. export * from "babylonjs/Meshes/buffer";
  55488. export * from "babylonjs/Meshes/Compression/index";
  55489. export * from "babylonjs/Meshes/csg";
  55490. export * from "babylonjs/Meshes/geometry";
  55491. export * from "babylonjs/Meshes/groundMesh";
  55492. export * from "babylonjs/Meshes/trailMesh";
  55493. export * from "babylonjs/Meshes/instancedMesh";
  55494. export * from "babylonjs/Meshes/linesMesh";
  55495. export * from "babylonjs/Meshes/mesh";
  55496. export * from "babylonjs/Meshes/mesh.vertexData";
  55497. export * from "babylonjs/Meshes/meshBuilder";
  55498. export * from "babylonjs/Meshes/meshSimplification";
  55499. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  55500. export * from "babylonjs/Meshes/polygonMesh";
  55501. export * from "babylonjs/Meshes/subMesh";
  55502. export * from "babylonjs/Meshes/meshLODLevel";
  55503. export * from "babylonjs/Meshes/transformNode";
  55504. export * from "babylonjs/Meshes/Builders/index";
  55505. export * from "babylonjs/Meshes/dataBuffer";
  55506. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  55507. }
  55508. declare module "babylonjs/Morph/index" {
  55509. export * from "babylonjs/Morph/morphTarget";
  55510. export * from "babylonjs/Morph/morphTargetManager";
  55511. }
  55512. declare module "babylonjs/Offline/database" {
  55513. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  55514. /**
  55515. * Class used to enable access to IndexedDB
  55516. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  55517. */
  55518. export class Database implements IOfflineProvider {
  55519. private _callbackManifestChecked;
  55520. private _currentSceneUrl;
  55521. private _db;
  55522. private _enableSceneOffline;
  55523. private _enableTexturesOffline;
  55524. private _manifestVersionFound;
  55525. private _mustUpdateRessources;
  55526. private _hasReachedQuota;
  55527. private _isSupported;
  55528. private _idbFactory;
  55529. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  55530. private static IsUASupportingBlobStorage;
  55531. /**
  55532. * Gets a boolean indicating if Database storate is enabled (off by default)
  55533. */
  55534. static IDBStorageEnabled: boolean;
  55535. /**
  55536. * Gets a boolean indicating if scene must be saved in the database
  55537. */
  55538. readonly enableSceneOffline: boolean;
  55539. /**
  55540. * Gets a boolean indicating if textures must be saved in the database
  55541. */
  55542. readonly enableTexturesOffline: boolean;
  55543. /**
  55544. * Creates a new Database
  55545. * @param urlToScene defines the url to load the scene
  55546. * @param callbackManifestChecked defines the callback to use when manifest is checked
  55547. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  55548. */
  55549. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  55550. private static _ParseURL;
  55551. private static _ReturnFullUrlLocation;
  55552. private _checkManifestFile;
  55553. /**
  55554. * Open the database and make it available
  55555. * @param successCallback defines the callback to call on success
  55556. * @param errorCallback defines the callback to call on error
  55557. */
  55558. open(successCallback: () => void, errorCallback: () => void): void;
  55559. /**
  55560. * Loads an image from the database
  55561. * @param url defines the url to load from
  55562. * @param image defines the target DOM image
  55563. */
  55564. loadImage(url: string, image: HTMLImageElement): void;
  55565. private _loadImageFromDBAsync;
  55566. private _saveImageIntoDBAsync;
  55567. private _checkVersionFromDB;
  55568. private _loadVersionFromDBAsync;
  55569. private _saveVersionIntoDBAsync;
  55570. /**
  55571. * Loads a file from database
  55572. * @param url defines the URL to load from
  55573. * @param sceneLoaded defines a callback to call on success
  55574. * @param progressCallBack defines a callback to call when progress changed
  55575. * @param errorCallback defines a callback to call on error
  55576. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  55577. */
  55578. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  55579. private _loadFileAsync;
  55580. private _saveFileAsync;
  55581. /**
  55582. * Validates if xhr data is correct
  55583. * @param xhr defines the request to validate
  55584. * @param dataType defines the expected data type
  55585. * @returns true if data is correct
  55586. */
  55587. private static _ValidateXHRData;
  55588. }
  55589. }
  55590. declare module "babylonjs/Offline/index" {
  55591. export * from "babylonjs/Offline/database";
  55592. export * from "babylonjs/Offline/IOfflineProvider";
  55593. }
  55594. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  55595. /** @hidden */
  55596. export var gpuUpdateParticlesPixelShader: {
  55597. name: string;
  55598. shader: string;
  55599. };
  55600. }
  55601. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  55602. /** @hidden */
  55603. export var gpuUpdateParticlesVertexShader: {
  55604. name: string;
  55605. shader: string;
  55606. };
  55607. }
  55608. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  55609. /** @hidden */
  55610. export var clipPlaneFragmentDeclaration2: {
  55611. name: string;
  55612. shader: string;
  55613. };
  55614. }
  55615. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  55616. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  55617. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  55618. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  55619. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  55620. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  55621. /** @hidden */
  55622. export var gpuRenderParticlesPixelShader: {
  55623. name: string;
  55624. shader: string;
  55625. };
  55626. }
  55627. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  55628. /** @hidden */
  55629. export var clipPlaneVertexDeclaration2: {
  55630. name: string;
  55631. shader: string;
  55632. };
  55633. }
  55634. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  55635. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  55636. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  55637. /** @hidden */
  55638. export var gpuRenderParticlesVertexShader: {
  55639. name: string;
  55640. shader: string;
  55641. };
  55642. }
  55643. declare module "babylonjs/Particles/gpuParticleSystem" {
  55644. import { Nullable } from "babylonjs/types";
  55645. import { IAnimatable, IValueGradient, Color3Gradient } from "babylonjs/Misc/tools";
  55646. import { Observable } from "babylonjs/Misc/observable";
  55647. import { Color4, Color3 } from "babylonjs/Maths/math";
  55648. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  55649. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  55650. import { Scene, IDisposable } from "babylonjs/scene";
  55651. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  55652. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  55653. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  55654. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  55655. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  55656. /**
  55657. * This represents a GPU particle system in Babylon
  55658. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  55659. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  55660. */
  55661. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  55662. /**
  55663. * The layer mask we are rendering the particles through.
  55664. */
  55665. layerMask: number;
  55666. private _capacity;
  55667. private _activeCount;
  55668. private _currentActiveCount;
  55669. private _accumulatedCount;
  55670. private _renderEffect;
  55671. private _updateEffect;
  55672. private _buffer0;
  55673. private _buffer1;
  55674. private _spriteBuffer;
  55675. private _updateVAO;
  55676. private _renderVAO;
  55677. private _targetIndex;
  55678. private _sourceBuffer;
  55679. private _targetBuffer;
  55680. private _engine;
  55681. private _currentRenderId;
  55682. private _started;
  55683. private _stopped;
  55684. private _timeDelta;
  55685. private _randomTexture;
  55686. private _randomTexture2;
  55687. private _attributesStrideSize;
  55688. private _updateEffectOptions;
  55689. private _randomTextureSize;
  55690. private _actualFrame;
  55691. private readonly _rawTextureWidth;
  55692. /**
  55693. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  55694. */
  55695. static readonly IsSupported: boolean;
  55696. /**
  55697. * An event triggered when the system is disposed.
  55698. */
  55699. onDisposeObservable: Observable<GPUParticleSystem>;
  55700. /**
  55701. * Gets the maximum number of particles active at the same time.
  55702. * @returns The max number of active particles.
  55703. */
  55704. getCapacity(): number;
  55705. /**
  55706. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  55707. * to override the particles.
  55708. */
  55709. forceDepthWrite: boolean;
  55710. /**
  55711. * Gets or set the number of active particles
  55712. */
  55713. activeParticleCount: number;
  55714. private _preWarmDone;
  55715. /**
  55716. * Is this system ready to be used/rendered
  55717. * @return true if the system is ready
  55718. */
  55719. isReady(): boolean;
  55720. /**
  55721. * Gets if the system has been started. (Note: this will still be true after stop is called)
  55722. * @returns True if it has been started, otherwise false.
  55723. */
  55724. isStarted(): boolean;
  55725. /**
  55726. * Starts the particle system and begins to emit
  55727. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  55728. */
  55729. start(delay?: number): void;
  55730. /**
  55731. * Stops the particle system.
  55732. */
  55733. stop(): void;
  55734. /**
  55735. * Remove all active particles
  55736. */
  55737. reset(): void;
  55738. /**
  55739. * Returns the string "GPUParticleSystem"
  55740. * @returns a string containing the class name
  55741. */
  55742. getClassName(): string;
  55743. private _colorGradientsTexture;
  55744. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  55745. /**
  55746. * Adds a new color gradient
  55747. * @param gradient defines the gradient to use (between 0 and 1)
  55748. * @param color1 defines the color to affect to the specified gradient
  55749. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  55750. * @returns the current particle system
  55751. */
  55752. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  55753. /**
  55754. * Remove a specific color gradient
  55755. * @param gradient defines the gradient to remove
  55756. * @returns the current particle system
  55757. */
  55758. removeColorGradient(gradient: number): GPUParticleSystem;
  55759. private _angularSpeedGradientsTexture;
  55760. private _sizeGradientsTexture;
  55761. private _velocityGradientsTexture;
  55762. private _limitVelocityGradientsTexture;
  55763. private _dragGradientsTexture;
  55764. private _addFactorGradient;
  55765. /**
  55766. * Adds a new size gradient
  55767. * @param gradient defines the gradient to use (between 0 and 1)
  55768. * @param factor defines the size factor to affect to the specified gradient
  55769. * @returns the current particle system
  55770. */
  55771. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  55772. /**
  55773. * Remove a specific size gradient
  55774. * @param gradient defines the gradient to remove
  55775. * @returns the current particle system
  55776. */
  55777. removeSizeGradient(gradient: number): GPUParticleSystem;
  55778. /**
  55779. * Adds a new angular speed gradient
  55780. * @param gradient defines the gradient to use (between 0 and 1)
  55781. * @param factor defines the angular speed to affect to the specified gradient
  55782. * @returns the current particle system
  55783. */
  55784. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  55785. /**
  55786. * Remove a specific angular speed gradient
  55787. * @param gradient defines the gradient to remove
  55788. * @returns the current particle system
  55789. */
  55790. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  55791. /**
  55792. * Adds a new velocity gradient
  55793. * @param gradient defines the gradient to use (between 0 and 1)
  55794. * @param factor defines the velocity to affect to the specified gradient
  55795. * @returns the current particle system
  55796. */
  55797. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  55798. /**
  55799. * Remove a specific velocity gradient
  55800. * @param gradient defines the gradient to remove
  55801. * @returns the current particle system
  55802. */
  55803. removeVelocityGradient(gradient: number): GPUParticleSystem;
  55804. /**
  55805. * Adds a new limit velocity gradient
  55806. * @param gradient defines the gradient to use (between 0 and 1)
  55807. * @param factor defines the limit velocity value to affect to the specified gradient
  55808. * @returns the current particle system
  55809. */
  55810. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  55811. /**
  55812. * Remove a specific limit velocity gradient
  55813. * @param gradient defines the gradient to remove
  55814. * @returns the current particle system
  55815. */
  55816. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  55817. /**
  55818. * Adds a new drag gradient
  55819. * @param gradient defines the gradient to use (between 0 and 1)
  55820. * @param factor defines the drag value to affect to the specified gradient
  55821. * @returns the current particle system
  55822. */
  55823. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  55824. /**
  55825. * Remove a specific drag gradient
  55826. * @param gradient defines the gradient to remove
  55827. * @returns the current particle system
  55828. */
  55829. removeDragGradient(gradient: number): GPUParticleSystem;
  55830. /**
  55831. * Not supported by GPUParticleSystem
  55832. * @param gradient defines the gradient to use (between 0 and 1)
  55833. * @param factor defines the emit rate value to affect to the specified gradient
  55834. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  55835. * @returns the current particle system
  55836. */
  55837. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  55838. /**
  55839. * Not supported by GPUParticleSystem
  55840. * @param gradient defines the gradient to remove
  55841. * @returns the current particle system
  55842. */
  55843. removeEmitRateGradient(gradient: number): IParticleSystem;
  55844. /**
  55845. * Not supported by GPUParticleSystem
  55846. * @param gradient defines the gradient to use (between 0 and 1)
  55847. * @param factor defines the start size value to affect to the specified gradient
  55848. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  55849. * @returns the current particle system
  55850. */
  55851. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  55852. /**
  55853. * Not supported by GPUParticleSystem
  55854. * @param gradient defines the gradient to remove
  55855. * @returns the current particle system
  55856. */
  55857. removeStartSizeGradient(gradient: number): IParticleSystem;
  55858. /**
  55859. * Not supported by GPUParticleSystem
  55860. * @param gradient defines the gradient to use (between 0 and 1)
  55861. * @param min defines the color remap minimal range
  55862. * @param max defines the color remap maximal range
  55863. * @returns the current particle system
  55864. */
  55865. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  55866. /**
  55867. * Not supported by GPUParticleSystem
  55868. * @param gradient defines the gradient to remove
  55869. * @returns the current particle system
  55870. */
  55871. removeColorRemapGradient(): IParticleSystem;
  55872. /**
  55873. * Not supported by GPUParticleSystem
  55874. * @param gradient defines the gradient to use (between 0 and 1)
  55875. * @param min defines the alpha remap minimal range
  55876. * @param max defines the alpha remap maximal range
  55877. * @returns the current particle system
  55878. */
  55879. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  55880. /**
  55881. * Not supported by GPUParticleSystem
  55882. * @param gradient defines the gradient to remove
  55883. * @returns the current particle system
  55884. */
  55885. removeAlphaRemapGradient(): IParticleSystem;
  55886. /**
  55887. * Not supported by GPUParticleSystem
  55888. * @param gradient defines the gradient to use (between 0 and 1)
  55889. * @param color defines the color to affect to the specified gradient
  55890. * @returns the current particle system
  55891. */
  55892. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  55893. /**
  55894. * Not supported by GPUParticleSystem
  55895. * @param gradient defines the gradient to remove
  55896. * @returns the current particle system
  55897. */
  55898. removeRampGradient(): IParticleSystem;
  55899. /**
  55900. * Not supported by GPUParticleSystem
  55901. * @returns the list of ramp gradients
  55902. */
  55903. getRampGradients(): Nullable<Array<Color3Gradient>>;
  55904. /**
  55905. * Not supported by GPUParticleSystem
  55906. * Gets or sets a boolean indicating that ramp gradients must be used
  55907. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  55908. */
  55909. useRampGradients: boolean;
  55910. /**
  55911. * Not supported by GPUParticleSystem
  55912. * @param gradient defines the gradient to use (between 0 and 1)
  55913. * @param factor defines the life time factor to affect to the specified gradient
  55914. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  55915. * @returns the current particle system
  55916. */
  55917. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  55918. /**
  55919. * Not supported by GPUParticleSystem
  55920. * @param gradient defines the gradient to remove
  55921. * @returns the current particle system
  55922. */
  55923. removeLifeTimeGradient(gradient: number): IParticleSystem;
  55924. /**
  55925. * Instantiates a GPU particle system.
  55926. * 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.
  55927. * @param name The name of the particle system
  55928. * @param options The options used to create the system
  55929. * @param scene The scene the particle system belongs to
  55930. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  55931. */
  55932. constructor(name: string, options: Partial<{
  55933. capacity: number;
  55934. randomTextureSize: number;
  55935. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  55936. protected _reset(): void;
  55937. private _createUpdateVAO;
  55938. private _createRenderVAO;
  55939. private _initialize;
  55940. /** @hidden */
  55941. _recreateUpdateEffect(): void;
  55942. /** @hidden */
  55943. _recreateRenderEffect(): void;
  55944. /**
  55945. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  55946. * @param preWarm defines if we are in the pre-warmimg phase
  55947. */
  55948. animate(preWarm?: boolean): void;
  55949. private _createFactorGradientTexture;
  55950. private _createSizeGradientTexture;
  55951. private _createAngularSpeedGradientTexture;
  55952. private _createVelocityGradientTexture;
  55953. private _createLimitVelocityGradientTexture;
  55954. private _createDragGradientTexture;
  55955. private _createColorGradientTexture;
  55956. /**
  55957. * Renders the particle system in its current state
  55958. * @param preWarm defines if the system should only update the particles but not render them
  55959. * @returns the current number of particles
  55960. */
  55961. render(preWarm?: boolean): number;
  55962. /**
  55963. * Rebuilds the particle system
  55964. */
  55965. rebuild(): void;
  55966. private _releaseBuffers;
  55967. private _releaseVAOs;
  55968. /**
  55969. * Disposes the particle system and free the associated resources
  55970. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  55971. */
  55972. dispose(disposeTexture?: boolean): void;
  55973. /**
  55974. * Clones the particle system.
  55975. * @param name The name of the cloned object
  55976. * @param newEmitter The new emitter to use
  55977. * @returns the cloned particle system
  55978. */
  55979. clone(name: string, newEmitter: any): GPUParticleSystem;
  55980. /**
  55981. * Serializes the particle system to a JSON object.
  55982. * @returns the JSON object
  55983. */
  55984. serialize(): any;
  55985. /**
  55986. * Parses a JSON object to create a GPU particle system.
  55987. * @param parsedParticleSystem The JSON object to parse
  55988. * @param scene The scene to create the particle system in
  55989. * @param rootUrl The root url to use to load external dependencies like texture
  55990. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  55991. * @returns the parsed GPU particle system
  55992. */
  55993. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  55994. }
  55995. }
  55996. declare module "babylonjs/Particles/particleSystemSet" {
  55997. import { Nullable } from "babylonjs/types";
  55998. import { Color3 } from "babylonjs/Maths/math";
  55999. import { TransformNode } from "babylonjs/Meshes/transformNode";
  56000. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56001. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  56002. import { Scene, IDisposable } from "babylonjs/scene";
  56003. /**
  56004. * Represents a set of particle systems working together to create a specific effect
  56005. */
  56006. export class ParticleSystemSet implements IDisposable {
  56007. private _emitterCreationOptions;
  56008. private _emitterNode;
  56009. /**
  56010. * Gets the particle system list
  56011. */
  56012. systems: IParticleSystem[];
  56013. /**
  56014. * Gets the emitter node used with this set
  56015. */
  56016. readonly emitterNode: Nullable<TransformNode>;
  56017. /**
  56018. * Creates a new emitter mesh as a sphere
  56019. * @param options defines the options used to create the sphere
  56020. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  56021. * @param scene defines the hosting scene
  56022. */
  56023. setEmitterAsSphere(options: {
  56024. diameter: number;
  56025. segments: number;
  56026. color: Color3;
  56027. }, renderingGroupId: number, scene: Scene): void;
  56028. /**
  56029. * Starts all particle systems of the set
  56030. * @param emitter defines an optional mesh to use as emitter for the particle systems
  56031. */
  56032. start(emitter?: AbstractMesh): void;
  56033. /**
  56034. * Release all associated resources
  56035. */
  56036. dispose(): void;
  56037. /**
  56038. * Serialize the set into a JSON compatible object
  56039. * @returns a JSON compatible representation of the set
  56040. */
  56041. serialize(): any;
  56042. /**
  56043. * Parse a new ParticleSystemSet from a serialized source
  56044. * @param data defines a JSON compatible representation of the set
  56045. * @param scene defines the hosting scene
  56046. * @param gpu defines if we want GPU particles or CPU particles
  56047. * @returns a new ParticleSystemSet
  56048. */
  56049. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  56050. }
  56051. }
  56052. declare module "babylonjs/Particles/particleHelper" {
  56053. import { Nullable } from "babylonjs/types";
  56054. import { Scene } from "babylonjs/scene";
  56055. import { Vector3 } from "babylonjs/Maths/math";
  56056. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56057. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  56058. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  56059. /**
  56060. * This class is made for on one-liner static method to help creating particle system set.
  56061. */
  56062. export class ParticleHelper {
  56063. /**
  56064. * Gets or sets base Assets URL
  56065. */
  56066. static BaseAssetsUrl: string;
  56067. /**
  56068. * Create a default particle system that you can tweak
  56069. * @param emitter defines the emitter to use
  56070. * @param capacity defines the system capacity (default is 500 particles)
  56071. * @param scene defines the hosting scene
  56072. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  56073. * @returns the new Particle system
  56074. */
  56075. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  56076. /**
  56077. * This is the main static method (one-liner) of this helper to create different particle systems
  56078. * @param type This string represents the type to the particle system to create
  56079. * @param scene The scene where the particle system should live
  56080. * @param gpu If the system will use gpu
  56081. * @returns the ParticleSystemSet created
  56082. */
  56083. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  56084. /**
  56085. * Static function used to export a particle system to a ParticleSystemSet variable.
  56086. * Please note that the emitter shape is not exported
  56087. * @param systems defines the particle systems to export
  56088. * @returns the created particle system set
  56089. */
  56090. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  56091. }
  56092. }
  56093. declare module "babylonjs/Particles/particleSystemComponent" {
  56094. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  56095. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  56096. import "babylonjs/Shaders/particles.vertex";
  56097. module "babylonjs/Engines/engine" {
  56098. interface Engine {
  56099. /**
  56100. * Create an effect to use with particle systems.
  56101. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  56102. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  56103. * @param uniformsNames defines a list of attribute names
  56104. * @param samplers defines an array of string used to represent textures
  56105. * @param defines defines the string containing the defines to use to compile the shaders
  56106. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  56107. * @param onCompiled defines a function to call when the effect creation is successful
  56108. * @param onError defines a function to call when the effect creation has failed
  56109. * @returns the new Effect
  56110. */
  56111. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  56112. }
  56113. }
  56114. module "babylonjs/Meshes/mesh" {
  56115. interface Mesh {
  56116. /**
  56117. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  56118. * @returns an array of IParticleSystem
  56119. */
  56120. getEmittedParticleSystems(): IParticleSystem[];
  56121. /**
  56122. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  56123. * @returns an array of IParticleSystem
  56124. */
  56125. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  56126. }
  56127. }
  56128. /**
  56129. * @hidden
  56130. */
  56131. export var _IDoNeedToBeInTheBuild: number;
  56132. }
  56133. declare module "babylonjs/Particles/index" {
  56134. export * from "babylonjs/Particles/baseParticleSystem";
  56135. export * from "babylonjs/Particles/EmitterTypes/index";
  56136. export * from "babylonjs/Particles/gpuParticleSystem";
  56137. export * from "babylonjs/Particles/IParticleSystem";
  56138. export * from "babylonjs/Particles/particle";
  56139. export * from "babylonjs/Particles/particleHelper";
  56140. export * from "babylonjs/Particles/particleSystem";
  56141. export * from "babylonjs/Particles/particleSystemComponent";
  56142. export * from "babylonjs/Particles/particleSystemSet";
  56143. export * from "babylonjs/Particles/solidParticle";
  56144. export * from "babylonjs/Particles/solidParticleSystem";
  56145. export * from "babylonjs/Particles/subEmitter";
  56146. }
  56147. declare module "babylonjs/Physics/physicsEngineComponent" {
  56148. import { Nullable } from "babylonjs/types";
  56149. import { Observable, Observer } from "babylonjs/Misc/observable";
  56150. import { Vector3 } from "babylonjs/Maths/math";
  56151. import { Mesh } from "babylonjs/Meshes/mesh";
  56152. import { ISceneComponent } from "babylonjs/sceneComponent";
  56153. import { Scene } from "babylonjs/scene";
  56154. import { Node } from "babylonjs/node";
  56155. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  56156. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  56157. module "babylonjs/scene" {
  56158. interface Scene {
  56159. /** @hidden (Backing field) */
  56160. _physicsEngine: Nullable<IPhysicsEngine>;
  56161. /**
  56162. * Gets the current physics engine
  56163. * @returns a IPhysicsEngine or null if none attached
  56164. */
  56165. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  56166. /**
  56167. * Enables physics to the current scene
  56168. * @param gravity defines the scene's gravity for the physics engine
  56169. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  56170. * @return a boolean indicating if the physics engine was initialized
  56171. */
  56172. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  56173. /**
  56174. * Disables and disposes the physics engine associated with the scene
  56175. */
  56176. disablePhysicsEngine(): void;
  56177. /**
  56178. * Gets a boolean indicating if there is an active physics engine
  56179. * @returns a boolean indicating if there is an active physics engine
  56180. */
  56181. isPhysicsEnabled(): boolean;
  56182. /**
  56183. * Deletes a physics compound impostor
  56184. * @param compound defines the compound to delete
  56185. */
  56186. deleteCompoundImpostor(compound: any): void;
  56187. /**
  56188. * An event triggered when physic simulation is about to be run
  56189. */
  56190. onBeforePhysicsObservable: Observable<Scene>;
  56191. /**
  56192. * An event triggered when physic simulation has been done
  56193. */
  56194. onAfterPhysicsObservable: Observable<Scene>;
  56195. }
  56196. }
  56197. module "babylonjs/Meshes/abstractMesh" {
  56198. interface AbstractMesh {
  56199. /** @hidden */
  56200. _physicsImpostor: Nullable<PhysicsImpostor>;
  56201. /**
  56202. * Gets or sets impostor used for physic simulation
  56203. * @see http://doc.babylonjs.com/features/physics_engine
  56204. */
  56205. physicsImpostor: Nullable<PhysicsImpostor>;
  56206. /**
  56207. * Gets the current physics impostor
  56208. * @see http://doc.babylonjs.com/features/physics_engine
  56209. * @returns a physics impostor or null
  56210. */
  56211. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  56212. /** Apply a physic impulse to the mesh
  56213. * @param force defines the force to apply
  56214. * @param contactPoint defines where to apply the force
  56215. * @returns the current mesh
  56216. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  56217. */
  56218. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  56219. /**
  56220. * Creates a physic joint between two meshes
  56221. * @param otherMesh defines the other mesh to use
  56222. * @param pivot1 defines the pivot to use on this mesh
  56223. * @param pivot2 defines the pivot to use on the other mesh
  56224. * @param options defines additional options (can be plugin dependent)
  56225. * @returns the current mesh
  56226. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  56227. */
  56228. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  56229. /** @hidden */
  56230. _disposePhysicsObserver: Nullable<Observer<Node>>;
  56231. }
  56232. }
  56233. /**
  56234. * Defines the physics engine scene component responsible to manage a physics engine
  56235. */
  56236. export class PhysicsEngineSceneComponent implements ISceneComponent {
  56237. /**
  56238. * The component name helpful to identify the component in the list of scene components.
  56239. */
  56240. readonly name: string;
  56241. /**
  56242. * The scene the component belongs to.
  56243. */
  56244. scene: Scene;
  56245. /**
  56246. * Creates a new instance of the component for the given scene
  56247. * @param scene Defines the scene to register the component in
  56248. */
  56249. constructor(scene: Scene);
  56250. /**
  56251. * Registers the component in a given scene
  56252. */
  56253. register(): void;
  56254. /**
  56255. * Rebuilds the elements related to this component in case of
  56256. * context lost for instance.
  56257. */
  56258. rebuild(): void;
  56259. /**
  56260. * Disposes the component and the associated ressources
  56261. */
  56262. dispose(): void;
  56263. }
  56264. }
  56265. declare module "babylonjs/Physics/physicsHelper" {
  56266. import { Nullable } from "babylonjs/types";
  56267. import { Vector3 } from "babylonjs/Maths/math";
  56268. import { Mesh } from "babylonjs/Meshes/mesh";
  56269. import { Scene } from "babylonjs/scene";
  56270. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  56271. /**
  56272. * A helper for physics simulations
  56273. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56274. */
  56275. export class PhysicsHelper {
  56276. private _scene;
  56277. private _physicsEngine;
  56278. /**
  56279. * Initializes the Physics helper
  56280. * @param scene Babylon.js scene
  56281. */
  56282. constructor(scene: Scene);
  56283. /**
  56284. * Applies a radial explosion impulse
  56285. * @param origin the origin of the explosion
  56286. * @param radiusOrEventOptions the radius or the options of radial explosion
  56287. * @param strength the explosion strength
  56288. * @param falloff possible options: Constant & Linear. Defaults to Constant
  56289. * @returns A physics radial explosion event, or null
  56290. */
  56291. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  56292. /**
  56293. * Applies a radial explosion force
  56294. * @param origin the origin of the explosion
  56295. * @param radiusOrEventOptions the radius or the options of radial explosion
  56296. * @param strength the explosion strength
  56297. * @param falloff possible options: Constant & Linear. Defaults to Constant
  56298. * @returns A physics radial explosion event, or null
  56299. */
  56300. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  56301. /**
  56302. * Creates a gravitational field
  56303. * @param origin the origin of the explosion
  56304. * @param radiusOrEventOptions the radius or the options of radial explosion
  56305. * @param strength the explosion strength
  56306. * @param falloff possible options: Constant & Linear. Defaults to Constant
  56307. * @returns A physics gravitational field event, or null
  56308. */
  56309. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  56310. /**
  56311. * Creates a physics updraft event
  56312. * @param origin the origin of the updraft
  56313. * @param radiusOrEventOptions the radius or the options of the updraft
  56314. * @param strength the strength of the updraft
  56315. * @param height the height of the updraft
  56316. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  56317. * @returns A physics updraft event, or null
  56318. */
  56319. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  56320. /**
  56321. * Creates a physics vortex event
  56322. * @param origin the of the vortex
  56323. * @param radiusOrEventOptions the radius or the options of the vortex
  56324. * @param strength the strength of the vortex
  56325. * @param height the height of the vortex
  56326. * @returns a Physics vortex event, or null
  56327. * A physics vortex event or null
  56328. */
  56329. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  56330. }
  56331. /**
  56332. * Represents a physics radial explosion event
  56333. */
  56334. class PhysicsRadialExplosionEvent {
  56335. private _scene;
  56336. private _options;
  56337. private _sphere;
  56338. private _dataFetched;
  56339. /**
  56340. * Initializes a radial explosioin event
  56341. * @param _scene BabylonJS scene
  56342. * @param _options The options for the vortex event
  56343. */
  56344. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  56345. /**
  56346. * Returns the data related to the radial explosion event (sphere).
  56347. * @returns The radial explosion event data
  56348. */
  56349. getData(): PhysicsRadialExplosionEventData;
  56350. /**
  56351. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  56352. * @param impostor A physics imposter
  56353. * @param origin the origin of the explosion
  56354. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  56355. */
  56356. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  56357. /**
  56358. * Triggers affecterd impostors callbacks
  56359. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  56360. */
  56361. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  56362. /**
  56363. * Disposes the sphere.
  56364. * @param force Specifies if the sphere should be disposed by force
  56365. */
  56366. dispose(force?: boolean): void;
  56367. /*** Helpers ***/
  56368. private _prepareSphere;
  56369. private _intersectsWithSphere;
  56370. }
  56371. /**
  56372. * Represents a gravitational field event
  56373. */
  56374. class PhysicsGravitationalFieldEvent {
  56375. private _physicsHelper;
  56376. private _scene;
  56377. private _origin;
  56378. private _options;
  56379. private _tickCallback;
  56380. private _sphere;
  56381. private _dataFetched;
  56382. /**
  56383. * Initializes the physics gravitational field event
  56384. * @param _physicsHelper A physics helper
  56385. * @param _scene BabylonJS scene
  56386. * @param _origin The origin position of the gravitational field event
  56387. * @param _options The options for the vortex event
  56388. */
  56389. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  56390. /**
  56391. * Returns the data related to the gravitational field event (sphere).
  56392. * @returns A gravitational field event
  56393. */
  56394. getData(): PhysicsGravitationalFieldEventData;
  56395. /**
  56396. * Enables the gravitational field.
  56397. */
  56398. enable(): void;
  56399. /**
  56400. * Disables the gravitational field.
  56401. */
  56402. disable(): void;
  56403. /**
  56404. * Disposes the sphere.
  56405. * @param force The force to dispose from the gravitational field event
  56406. */
  56407. dispose(force?: boolean): void;
  56408. private _tick;
  56409. }
  56410. /**
  56411. * Represents a physics updraft event
  56412. */
  56413. class PhysicsUpdraftEvent {
  56414. private _scene;
  56415. private _origin;
  56416. private _options;
  56417. private _physicsEngine;
  56418. private _originTop;
  56419. private _originDirection;
  56420. private _tickCallback;
  56421. private _cylinder;
  56422. private _cylinderPosition;
  56423. private _dataFetched;
  56424. /**
  56425. * Initializes the physics updraft event
  56426. * @param _scene BabylonJS scene
  56427. * @param _origin The origin position of the updraft
  56428. * @param _options The options for the updraft event
  56429. */
  56430. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  56431. /**
  56432. * Returns the data related to the updraft event (cylinder).
  56433. * @returns A physics updraft event
  56434. */
  56435. getData(): PhysicsUpdraftEventData;
  56436. /**
  56437. * Enables the updraft.
  56438. */
  56439. enable(): void;
  56440. /**
  56441. * Disables the updraft.
  56442. */
  56443. disable(): void;
  56444. /**
  56445. * Disposes the cylinder.
  56446. * @param force Specifies if the updraft should be disposed by force
  56447. */
  56448. dispose(force?: boolean): void;
  56449. private getImpostorHitData;
  56450. private _tick;
  56451. /*** Helpers ***/
  56452. private _prepareCylinder;
  56453. private _intersectsWithCylinder;
  56454. }
  56455. /**
  56456. * Represents a physics vortex event
  56457. */
  56458. class PhysicsVortexEvent {
  56459. private _scene;
  56460. private _origin;
  56461. private _options;
  56462. private _physicsEngine;
  56463. private _originTop;
  56464. private _tickCallback;
  56465. private _cylinder;
  56466. private _cylinderPosition;
  56467. private _dataFetched;
  56468. /**
  56469. * Initializes the physics vortex event
  56470. * @param _scene The BabylonJS scene
  56471. * @param _origin The origin position of the vortex
  56472. * @param _options The options for the vortex event
  56473. */
  56474. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  56475. /**
  56476. * Returns the data related to the vortex event (cylinder).
  56477. * @returns The physics vortex event data
  56478. */
  56479. getData(): PhysicsVortexEventData;
  56480. /**
  56481. * Enables the vortex.
  56482. */
  56483. enable(): void;
  56484. /**
  56485. * Disables the cortex.
  56486. */
  56487. disable(): void;
  56488. /**
  56489. * Disposes the sphere.
  56490. * @param force
  56491. */
  56492. dispose(force?: boolean): void;
  56493. private getImpostorHitData;
  56494. private _tick;
  56495. /*** Helpers ***/
  56496. private _prepareCylinder;
  56497. private _intersectsWithCylinder;
  56498. }
  56499. /**
  56500. * Options fot the radial explosion event
  56501. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56502. */
  56503. export class PhysicsRadialExplosionEventOptions {
  56504. /**
  56505. * The radius of the sphere for the radial explosion.
  56506. */
  56507. radius: number;
  56508. /**
  56509. * The strenth of the explosion.
  56510. */
  56511. strength: number;
  56512. /**
  56513. * The strenght of the force in correspondence to the distance of the affected object
  56514. */
  56515. falloff: PhysicsRadialImpulseFalloff;
  56516. /**
  56517. * Sphere options for the radial explosion.
  56518. */
  56519. sphere: {
  56520. segments: number;
  56521. diameter: number;
  56522. };
  56523. /**
  56524. * Sphere options for the radial explosion.
  56525. */
  56526. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  56527. }
  56528. /**
  56529. * Options fot the updraft event
  56530. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56531. */
  56532. export class PhysicsUpdraftEventOptions {
  56533. /**
  56534. * The radius of the cylinder for the vortex
  56535. */
  56536. radius: number;
  56537. /**
  56538. * The strenth of the updraft.
  56539. */
  56540. strength: number;
  56541. /**
  56542. * The height of the cylinder for the updraft.
  56543. */
  56544. height: number;
  56545. /**
  56546. * The mode for the the updraft.
  56547. */
  56548. updraftMode: PhysicsUpdraftMode;
  56549. }
  56550. /**
  56551. * Options fot the vortex event
  56552. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56553. */
  56554. export class PhysicsVortexEventOptions {
  56555. /**
  56556. * The radius of the cylinder for the vortex
  56557. */
  56558. radius: number;
  56559. /**
  56560. * The strenth of the vortex.
  56561. */
  56562. strength: number;
  56563. /**
  56564. * The height of the cylinder for the vortex.
  56565. */
  56566. height: number;
  56567. /**
  56568. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  56569. */
  56570. centripetalForceThreshold: number;
  56571. /**
  56572. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  56573. */
  56574. centripetalForceMultiplier: number;
  56575. /**
  56576. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  56577. */
  56578. centrifugalForceMultiplier: number;
  56579. /**
  56580. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  56581. */
  56582. updraftForceMultiplier: number;
  56583. }
  56584. /**
  56585. * The strenght of the force in correspondence to the distance of the affected object
  56586. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56587. */
  56588. export enum PhysicsRadialImpulseFalloff {
  56589. /** Defines that impulse is constant in strength across it's whole radius */
  56590. Constant = 0,
  56591. /** Defines that impulse gets weaker if it's further from the origin */
  56592. Linear = 1
  56593. }
  56594. /**
  56595. * The strength of the force in correspondence to the distance of the affected object
  56596. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56597. */
  56598. export enum PhysicsUpdraftMode {
  56599. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  56600. Center = 0,
  56601. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  56602. Perpendicular = 1
  56603. }
  56604. /**
  56605. * Interface for a physics hit data
  56606. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56607. */
  56608. export interface PhysicsHitData {
  56609. /**
  56610. * The force applied at the contact point
  56611. */
  56612. force: Vector3;
  56613. /**
  56614. * The contact point
  56615. */
  56616. contactPoint: Vector3;
  56617. /**
  56618. * The distance from the origin to the contact point
  56619. */
  56620. distanceFromOrigin: number;
  56621. }
  56622. /**
  56623. * Interface for radial explosion event data
  56624. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56625. */
  56626. export interface PhysicsRadialExplosionEventData {
  56627. /**
  56628. * A sphere used for the radial explosion event
  56629. */
  56630. sphere: Mesh;
  56631. }
  56632. /**
  56633. * Interface for gravitational field event data
  56634. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56635. */
  56636. export interface PhysicsGravitationalFieldEventData {
  56637. /**
  56638. * A sphere mesh used for the gravitational field event
  56639. */
  56640. sphere: Mesh;
  56641. }
  56642. /**
  56643. * Interface for updraft event data
  56644. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56645. */
  56646. export interface PhysicsUpdraftEventData {
  56647. /**
  56648. * A cylinder used for the updraft event
  56649. */
  56650. cylinder: Mesh;
  56651. }
  56652. /**
  56653. * Interface for vortex event data
  56654. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56655. */
  56656. export interface PhysicsVortexEventData {
  56657. /**
  56658. * A cylinder used for the vortex event
  56659. */
  56660. cylinder: Mesh;
  56661. }
  56662. /**
  56663. * Interface for an affected physics impostor
  56664. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56665. */
  56666. export interface PhysicsAffectedImpostorWithData {
  56667. /**
  56668. * The impostor affected by the effect
  56669. */
  56670. impostor: PhysicsImpostor;
  56671. /**
  56672. * The data about the hit/horce from the explosion
  56673. */
  56674. hitData: PhysicsHitData;
  56675. }
  56676. }
  56677. declare module "babylonjs/Physics/Plugins/index" {
  56678. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  56679. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  56680. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  56681. }
  56682. declare module "babylonjs/Physics/index" {
  56683. export * from "babylonjs/Physics/IPhysicsEngine";
  56684. export * from "babylonjs/Physics/physicsEngine";
  56685. export * from "babylonjs/Physics/physicsEngineComponent";
  56686. export * from "babylonjs/Physics/physicsHelper";
  56687. export * from "babylonjs/Physics/physicsImpostor";
  56688. export * from "babylonjs/Physics/physicsJoint";
  56689. export * from "babylonjs/Physics/Plugins/index";
  56690. }
  56691. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  56692. /** @hidden */
  56693. export var blackAndWhitePixelShader: {
  56694. name: string;
  56695. shader: string;
  56696. };
  56697. }
  56698. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  56699. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  56700. import { Camera } from "babylonjs/Cameras/camera";
  56701. import { Engine } from "babylonjs/Engines/engine";
  56702. import "babylonjs/Shaders/blackAndWhite.fragment";
  56703. /**
  56704. * Post process used to render in black and white
  56705. */
  56706. export class BlackAndWhitePostProcess extends PostProcess {
  56707. /**
  56708. * Linear about to convert he result to black and white (default: 1)
  56709. */
  56710. degree: number;
  56711. /**
  56712. * Creates a black and white post process
  56713. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  56714. * @param name The name of the effect.
  56715. * @param options The required width/height ratio to downsize to before computing the render pass.
  56716. * @param camera The camera to apply the render pass to.
  56717. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  56718. * @param engine The engine which the post process will be applied. (default: current engine)
  56719. * @param reusable If the post process can be reused on the same frame. (default: false)
  56720. */
  56721. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  56722. }
  56723. }
  56724. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  56725. import { Nullable } from "babylonjs/types";
  56726. import { Camera } from "babylonjs/Cameras/camera";
  56727. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  56728. import { Engine } from "babylonjs/Engines/engine";
  56729. /**
  56730. * This represents a set of one or more post processes in Babylon.
  56731. * A post process can be used to apply a shader to a texture after it is rendered.
  56732. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  56733. */
  56734. export class PostProcessRenderEffect {
  56735. private _postProcesses;
  56736. private _getPostProcesses;
  56737. private _singleInstance;
  56738. private _cameras;
  56739. private _indicesForCamera;
  56740. /**
  56741. * Name of the effect
  56742. * @hidden
  56743. */
  56744. _name: string;
  56745. /**
  56746. * Instantiates a post process render effect.
  56747. * A post process can be used to apply a shader to a texture after it is rendered.
  56748. * @param engine The engine the effect is tied to
  56749. * @param name The name of the effect
  56750. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  56751. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  56752. */
  56753. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  56754. /**
  56755. * Checks if all the post processes in the effect are supported.
  56756. */
  56757. readonly isSupported: boolean;
  56758. /**
  56759. * Updates the current state of the effect
  56760. * @hidden
  56761. */
  56762. _update(): void;
  56763. /**
  56764. * Attaches the effect on cameras
  56765. * @param cameras The camera to attach to.
  56766. * @hidden
  56767. */
  56768. _attachCameras(cameras: Camera): void;
  56769. /**
  56770. * Attaches the effect on cameras
  56771. * @param cameras The camera to attach to.
  56772. * @hidden
  56773. */
  56774. _attachCameras(cameras: Camera[]): void;
  56775. /**
  56776. * Detaches the effect on cameras
  56777. * @param cameras The camera to detatch from.
  56778. * @hidden
  56779. */
  56780. _detachCameras(cameras: Camera): void;
  56781. /**
  56782. * Detatches the effect on cameras
  56783. * @param cameras The camera to detatch from.
  56784. * @hidden
  56785. */
  56786. _detachCameras(cameras: Camera[]): void;
  56787. /**
  56788. * Enables the effect on given cameras
  56789. * @param cameras The camera to enable.
  56790. * @hidden
  56791. */
  56792. _enable(cameras: Camera): void;
  56793. /**
  56794. * Enables the effect on given cameras
  56795. * @param cameras The camera to enable.
  56796. * @hidden
  56797. */
  56798. _enable(cameras: Nullable<Camera[]>): void;
  56799. /**
  56800. * Disables the effect on the given cameras
  56801. * @param cameras The camera to disable.
  56802. * @hidden
  56803. */
  56804. _disable(cameras: Camera): void;
  56805. /**
  56806. * Disables the effect on the given cameras
  56807. * @param cameras The camera to disable.
  56808. * @hidden
  56809. */
  56810. _disable(cameras: Nullable<Camera[]>): void;
  56811. /**
  56812. * Gets a list of the post processes contained in the effect.
  56813. * @param camera The camera to get the post processes on.
  56814. * @returns The list of the post processes in the effect.
  56815. */
  56816. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  56817. }
  56818. }
  56819. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  56820. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56821. /** @hidden */
  56822. export var extractHighlightsPixelShader: {
  56823. name: string;
  56824. shader: string;
  56825. };
  56826. }
  56827. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  56828. import { Nullable } from "babylonjs/types";
  56829. import { Camera } from "babylonjs/Cameras/camera";
  56830. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  56831. import { Engine } from "babylonjs/Engines/engine";
  56832. import "babylonjs/Shaders/extractHighlights.fragment";
  56833. /**
  56834. * 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.
  56835. */
  56836. export class ExtractHighlightsPostProcess extends PostProcess {
  56837. /**
  56838. * The luminance threshold, pixels below this value will be set to black.
  56839. */
  56840. threshold: number;
  56841. /** @hidden */
  56842. _exposure: number;
  56843. /**
  56844. * Post process which has the input texture to be used when performing highlight extraction
  56845. * @hidden
  56846. */
  56847. _inputPostProcess: Nullable<PostProcess>;
  56848. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  56849. }
  56850. }
  56851. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  56852. /** @hidden */
  56853. export var bloomMergePixelShader: {
  56854. name: string;
  56855. shader: string;
  56856. };
  56857. }
  56858. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  56859. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  56860. import { Nullable } from "babylonjs/types";
  56861. import { Engine } from "babylonjs/Engines/engine";
  56862. import { Camera } from "babylonjs/Cameras/camera";
  56863. import "babylonjs/Shaders/bloomMerge.fragment";
  56864. /**
  56865. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  56866. */
  56867. export class BloomMergePostProcess extends PostProcess {
  56868. /** Weight of the bloom to be added to the original input. */
  56869. weight: number;
  56870. /**
  56871. * Creates a new instance of @see BloomMergePostProcess
  56872. * @param name The name of the effect.
  56873. * @param originalFromInput Post process which's input will be used for the merge.
  56874. * @param blurred Blurred highlights post process which's output will be used.
  56875. * @param weight Weight of the bloom to be added to the original input.
  56876. * @param options The required width/height ratio to downsize to before computing the render pass.
  56877. * @param camera The camera to apply the render pass to.
  56878. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  56879. * @param engine The engine which the post process will be applied. (default: current engine)
  56880. * @param reusable If the post process can be reused on the same frame. (default: false)
  56881. * @param textureType Type of textures used when performing the post process. (default: 0)
  56882. * @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)
  56883. */
  56884. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  56885. /** Weight of the bloom to be added to the original input. */
  56886. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  56887. }
  56888. }
  56889. declare module "babylonjs/PostProcesses/bloomEffect" {
  56890. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  56891. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  56892. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  56893. import { Camera } from "babylonjs/Cameras/camera";
  56894. import { Scene } from "babylonjs/scene";
  56895. /**
  56896. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  56897. */
  56898. export class BloomEffect extends PostProcessRenderEffect {
  56899. private bloomScale;
  56900. /**
  56901. * @hidden Internal
  56902. */
  56903. _effects: Array<PostProcess>;
  56904. /**
  56905. * @hidden Internal
  56906. */
  56907. _downscale: ExtractHighlightsPostProcess;
  56908. private _blurX;
  56909. private _blurY;
  56910. private _merge;
  56911. /**
  56912. * The luminance threshold to find bright areas of the image to bloom.
  56913. */
  56914. threshold: number;
  56915. /**
  56916. * The strength of the bloom.
  56917. */
  56918. weight: number;
  56919. /**
  56920. * Specifies the size of the bloom blur kernel, relative to the final output size
  56921. */
  56922. kernel: number;
  56923. /**
  56924. * Creates a new instance of @see BloomEffect
  56925. * @param scene The scene the effect belongs to.
  56926. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  56927. * @param bloomKernel The size of the kernel to be used when applying the blur.
  56928. * @param bloomWeight The the strength of bloom.
  56929. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  56930. * @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)
  56931. */
  56932. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  56933. /**
  56934. * Disposes each of the internal effects for a given camera.
  56935. * @param camera The camera to dispose the effect on.
  56936. */
  56937. disposeEffects(camera: Camera): void;
  56938. /**
  56939. * @hidden Internal
  56940. */
  56941. _updateEffects(): void;
  56942. /**
  56943. * Internal
  56944. * @returns if all the contained post processes are ready.
  56945. * @hidden
  56946. */
  56947. _isReady(): boolean;
  56948. }
  56949. }
  56950. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  56951. /** @hidden */
  56952. export var chromaticAberrationPixelShader: {
  56953. name: string;
  56954. shader: string;
  56955. };
  56956. }
  56957. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  56958. import { Vector2 } from "babylonjs/Maths/math";
  56959. import { Nullable } from "babylonjs/types";
  56960. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  56961. import { Camera } from "babylonjs/Cameras/camera";
  56962. import { Engine } from "babylonjs/Engines/engine";
  56963. import "babylonjs/Shaders/chromaticAberration.fragment";
  56964. /**
  56965. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  56966. */
  56967. export class ChromaticAberrationPostProcess extends PostProcess {
  56968. /**
  56969. * The amount of seperation of rgb channels (default: 30)
  56970. */
  56971. aberrationAmount: number;
  56972. /**
  56973. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  56974. */
  56975. radialIntensity: number;
  56976. /**
  56977. * 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))
  56978. */
  56979. direction: Vector2;
  56980. /**
  56981. * 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))
  56982. */
  56983. centerPosition: Vector2;
  56984. /**
  56985. * Creates a new instance ChromaticAberrationPostProcess
  56986. * @param name The name of the effect.
  56987. * @param screenWidth The width of the screen to apply the effect on.
  56988. * @param screenHeight The height of the screen to apply the effect on.
  56989. * @param options The required width/height ratio to downsize to before computing the render pass.
  56990. * @param camera The camera to apply the render pass to.
  56991. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  56992. * @param engine The engine which the post process will be applied. (default: current engine)
  56993. * @param reusable If the post process can be reused on the same frame. (default: false)
  56994. * @param textureType Type of textures used when performing the post process. (default: 0)
  56995. * @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)
  56996. */
  56997. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  56998. }
  56999. }
  57000. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  57001. /** @hidden */
  57002. export var circleOfConfusionPixelShader: {
  57003. name: string;
  57004. shader: string;
  57005. };
  57006. }
  57007. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  57008. import { Nullable } from "babylonjs/types";
  57009. import { Engine } from "babylonjs/Engines/engine";
  57010. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  57011. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  57012. import { Camera } from "babylonjs/Cameras/camera";
  57013. import "babylonjs/Shaders/circleOfConfusion.fragment";
  57014. /**
  57015. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  57016. */
  57017. export class CircleOfConfusionPostProcess extends PostProcess {
  57018. /**
  57019. * 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.
  57020. */
  57021. lensSize: number;
  57022. /**
  57023. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  57024. */
  57025. fStop: number;
  57026. /**
  57027. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  57028. */
  57029. focusDistance: number;
  57030. /**
  57031. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  57032. */
  57033. focalLength: number;
  57034. private _depthTexture;
  57035. /**
  57036. * Creates a new instance CircleOfConfusionPostProcess
  57037. * @param name The name of the effect.
  57038. * @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.
  57039. * @param options The required width/height ratio to downsize to before computing the render pass.
  57040. * @param camera The camera to apply the render pass to.
  57041. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57042. * @param engine The engine which the post process will be applied. (default: current engine)
  57043. * @param reusable If the post process can be reused on the same frame. (default: false)
  57044. * @param textureType Type of textures used when performing the post process. (default: 0)
  57045. * @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)
  57046. */
  57047. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  57048. /**
  57049. * 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.
  57050. */
  57051. depthTexture: RenderTargetTexture;
  57052. }
  57053. }
  57054. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  57055. /** @hidden */
  57056. export var colorCorrectionPixelShader: {
  57057. name: string;
  57058. shader: string;
  57059. };
  57060. }
  57061. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  57062. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  57063. import { Engine } from "babylonjs/Engines/engine";
  57064. import { Camera } from "babylonjs/Cameras/camera";
  57065. import "babylonjs/Shaders/colorCorrection.fragment";
  57066. /**
  57067. *
  57068. * This post-process allows the modification of rendered colors by using
  57069. * a 'look-up table' (LUT). This effect is also called Color Grading.
  57070. *
  57071. * The object needs to be provided an url to a texture containing the color
  57072. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  57073. * Use an image editing software to tweak the LUT to match your needs.
  57074. *
  57075. * For an example of a color LUT, see here:
  57076. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  57077. * For explanations on color grading, see here:
  57078. * @see http://udn.epicgames.com/Three/ColorGrading.html
  57079. *
  57080. */
  57081. export class ColorCorrectionPostProcess extends PostProcess {
  57082. private _colorTableTexture;
  57083. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  57084. }
  57085. }
  57086. declare module "babylonjs/Shaders/convolution.fragment" {
  57087. /** @hidden */
  57088. export var convolutionPixelShader: {
  57089. name: string;
  57090. shader: string;
  57091. };
  57092. }
  57093. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  57094. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  57095. import { Nullable } from "babylonjs/types";
  57096. import { Camera } from "babylonjs/Cameras/camera";
  57097. import { Engine } from "babylonjs/Engines/engine";
  57098. import "babylonjs/Shaders/convolution.fragment";
  57099. /**
  57100. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  57101. * input texture to perform effects such as edge detection or sharpening
  57102. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  57103. */
  57104. export class ConvolutionPostProcess extends PostProcess {
  57105. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  57106. kernel: number[];
  57107. /**
  57108. * Creates a new instance ConvolutionPostProcess
  57109. * @param name The name of the effect.
  57110. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  57111. * @param options The required width/height ratio to downsize to before computing the render pass.
  57112. * @param camera The camera to apply the render pass to.
  57113. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57114. * @param engine The engine which the post process will be applied. (default: current engine)
  57115. * @param reusable If the post process can be reused on the same frame. (default: false)
  57116. * @param textureType Type of textures used when performing the post process. (default: 0)
  57117. */
  57118. constructor(name: string,
  57119. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  57120. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  57121. /**
  57122. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  57123. */
  57124. static EdgeDetect0Kernel: number[];
  57125. /**
  57126. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  57127. */
  57128. static EdgeDetect1Kernel: number[];
  57129. /**
  57130. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  57131. */
  57132. static EdgeDetect2Kernel: number[];
  57133. /**
  57134. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  57135. */
  57136. static SharpenKernel: number[];
  57137. /**
  57138. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  57139. */
  57140. static EmbossKernel: number[];
  57141. /**
  57142. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  57143. */
  57144. static GaussianKernel: number[];
  57145. }
  57146. }
  57147. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  57148. import { Nullable } from "babylonjs/types";
  57149. import { Vector2 } from "babylonjs/Maths/math";
  57150. import { Camera } from "babylonjs/Cameras/camera";
  57151. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  57152. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  57153. import { Engine } from "babylonjs/Engines/engine";
  57154. import { Scene } from "babylonjs/scene";
  57155. /**
  57156. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  57157. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  57158. * based on samples that have a large difference in distance than the center pixel.
  57159. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  57160. */
  57161. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  57162. direction: Vector2;
  57163. /**
  57164. * Creates a new instance CircleOfConfusionPostProcess
  57165. * @param name The name of the effect.
  57166. * @param scene The scene the effect belongs to.
  57167. * @param direction The direction the blur should be applied.
  57168. * @param kernel The size of the kernel used to blur.
  57169. * @param options The required width/height ratio to downsize to before computing the render pass.
  57170. * @param camera The camera to apply the render pass to.
  57171. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  57172. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  57173. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57174. * @param engine The engine which the post process will be applied. (default: current engine)
  57175. * @param reusable If the post process can be reused on the same frame. (default: false)
  57176. * @param textureType Type of textures used when performing the post process. (default: 0)
  57177. * @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)
  57178. */
  57179. 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);
  57180. }
  57181. }
  57182. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  57183. /** @hidden */
  57184. export var depthOfFieldMergePixelShader: {
  57185. name: string;
  57186. shader: string;
  57187. };
  57188. }
  57189. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  57190. import { Nullable } from "babylonjs/types";
  57191. import { Camera } from "babylonjs/Cameras/camera";
  57192. import { Effect } from "babylonjs/Materials/effect";
  57193. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  57194. import { Engine } from "babylonjs/Engines/engine";
  57195. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  57196. /**
  57197. * Options to be set when merging outputs from the default pipeline.
  57198. */
  57199. export class DepthOfFieldMergePostProcessOptions {
  57200. /**
  57201. * The original image to merge on top of
  57202. */
  57203. originalFromInput: PostProcess;
  57204. /**
  57205. * Parameters to perform the merge of the depth of field effect
  57206. */
  57207. depthOfField?: {
  57208. circleOfConfusion: PostProcess;
  57209. blurSteps: Array<PostProcess>;
  57210. };
  57211. /**
  57212. * Parameters to perform the merge of bloom effect
  57213. */
  57214. bloom?: {
  57215. blurred: PostProcess;
  57216. weight: number;
  57217. };
  57218. }
  57219. /**
  57220. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  57221. */
  57222. export class DepthOfFieldMergePostProcess extends PostProcess {
  57223. private blurSteps;
  57224. /**
  57225. * Creates a new instance of DepthOfFieldMergePostProcess
  57226. * @param name The name of the effect.
  57227. * @param originalFromInput Post process which's input will be used for the merge.
  57228. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  57229. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  57230. * @param options The required width/height ratio to downsize to before computing the render pass.
  57231. * @param camera The camera to apply the render pass to.
  57232. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57233. * @param engine The engine which the post process will be applied. (default: current engine)
  57234. * @param reusable If the post process can be reused on the same frame. (default: false)
  57235. * @param textureType Type of textures used when performing the post process. (default: 0)
  57236. * @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)
  57237. */
  57238. 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);
  57239. /**
  57240. * Updates the effect with the current post process compile time values and recompiles the shader.
  57241. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  57242. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  57243. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  57244. * @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
  57245. * @param onCompiled Called when the shader has been compiled.
  57246. * @param onError Called if there is an error when compiling a shader.
  57247. */
  57248. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  57249. }
  57250. }
  57251. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  57252. import { Nullable } from "babylonjs/types";
  57253. import { Camera } from "babylonjs/Cameras/camera";
  57254. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  57255. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  57256. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  57257. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  57258. import { Scene } from "babylonjs/scene";
  57259. /**
  57260. * Specifies the level of max blur that should be applied when using the depth of field effect
  57261. */
  57262. export enum DepthOfFieldEffectBlurLevel {
  57263. /**
  57264. * Subtle blur
  57265. */
  57266. Low = 0,
  57267. /**
  57268. * Medium blur
  57269. */
  57270. Medium = 1,
  57271. /**
  57272. * Large blur
  57273. */
  57274. High = 2
  57275. }
  57276. /**
  57277. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  57278. */
  57279. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  57280. private _circleOfConfusion;
  57281. /**
  57282. * @hidden Internal, blurs from high to low
  57283. */
  57284. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  57285. private _depthOfFieldBlurY;
  57286. private _dofMerge;
  57287. /**
  57288. * @hidden Internal post processes in depth of field effect
  57289. */
  57290. _effects: Array<PostProcess>;
  57291. /**
  57292. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  57293. */
  57294. focalLength: number;
  57295. /**
  57296. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  57297. */
  57298. fStop: number;
  57299. /**
  57300. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  57301. */
  57302. focusDistance: number;
  57303. /**
  57304. * 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.
  57305. */
  57306. lensSize: number;
  57307. /**
  57308. * Creates a new instance DepthOfFieldEffect
  57309. * @param scene The scene the effect belongs to.
  57310. * @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.
  57311. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  57312. * @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)
  57313. */
  57314. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  57315. /**
  57316. * Get the current class name of the current effet
  57317. * @returns "DepthOfFieldEffect"
  57318. */
  57319. getClassName(): string;
  57320. /**
  57321. * 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.
  57322. */
  57323. depthTexture: RenderTargetTexture;
  57324. /**
  57325. * Disposes each of the internal effects for a given camera.
  57326. * @param camera The camera to dispose the effect on.
  57327. */
  57328. disposeEffects(camera: Camera): void;
  57329. /**
  57330. * @hidden Internal
  57331. */
  57332. _updateEffects(): void;
  57333. /**
  57334. * Internal
  57335. * @returns if all the contained post processes are ready.
  57336. * @hidden
  57337. */
  57338. _isReady(): boolean;
  57339. }
  57340. }
  57341. declare module "babylonjs/Shaders/displayPass.fragment" {
  57342. /** @hidden */
  57343. export var displayPassPixelShader: {
  57344. name: string;
  57345. shader: string;
  57346. };
  57347. }
  57348. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  57349. import { Nullable } from "babylonjs/types";
  57350. import { Camera } from "babylonjs/Cameras/camera";
  57351. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  57352. import { Engine } from "babylonjs/Engines/engine";
  57353. import "babylonjs/Shaders/displayPass.fragment";
  57354. /**
  57355. * DisplayPassPostProcess which produces an output the same as it's input
  57356. */
  57357. export class DisplayPassPostProcess extends PostProcess {
  57358. /**
  57359. * Creates the DisplayPassPostProcess
  57360. * @param name The name of the effect.
  57361. * @param options The required width/height ratio to downsize to before computing the render pass.
  57362. * @param camera The camera to apply the render pass to.
  57363. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57364. * @param engine The engine which the post process will be applied. (default: current engine)
  57365. * @param reusable If the post process can be reused on the same frame. (default: false)
  57366. */
  57367. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  57368. }
  57369. }
  57370. declare module "babylonjs/Shaders/filter.fragment" {
  57371. /** @hidden */
  57372. export var filterPixelShader: {
  57373. name: string;
  57374. shader: string;
  57375. };
  57376. }
  57377. declare module "babylonjs/PostProcesses/filterPostProcess" {
  57378. import { Nullable } from "babylonjs/types";
  57379. import { Matrix } from "babylonjs/Maths/math";
  57380. import { Camera } from "babylonjs/Cameras/camera";
  57381. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  57382. import { Engine } from "babylonjs/Engines/engine";
  57383. import "babylonjs/Shaders/filter.fragment";
  57384. /**
  57385. * Applies a kernel filter to the image
  57386. */
  57387. export class FilterPostProcess extends PostProcess {
  57388. /** The matrix to be applied to the image */
  57389. kernelMatrix: Matrix;
  57390. /**
  57391. *
  57392. * @param name The name of the effect.
  57393. * @param kernelMatrix The matrix to be applied to the image
  57394. * @param options The required width/height ratio to downsize to before computing the render pass.
  57395. * @param camera The camera to apply the render pass to.
  57396. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57397. * @param engine The engine which the post process will be applied. (default: current engine)
  57398. * @param reusable If the post process can be reused on the same frame. (default: false)
  57399. */
  57400. constructor(name: string,
  57401. /** The matrix to be applied to the image */
  57402. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  57403. }
  57404. }
  57405. declare module "babylonjs/Shaders/fxaa.fragment" {
  57406. /** @hidden */
  57407. export var fxaaPixelShader: {
  57408. name: string;
  57409. shader: string;
  57410. };
  57411. }
  57412. declare module "babylonjs/Shaders/fxaa.vertex" {
  57413. /** @hidden */
  57414. export var fxaaVertexShader: {
  57415. name: string;
  57416. shader: string;
  57417. };
  57418. }
  57419. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  57420. import { Nullable } from "babylonjs/types";
  57421. import { Camera } from "babylonjs/Cameras/camera";
  57422. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  57423. import { Engine } from "babylonjs/Engines/engine";
  57424. import "babylonjs/Shaders/fxaa.fragment";
  57425. import "babylonjs/Shaders/fxaa.vertex";
  57426. /**
  57427. * Fxaa post process
  57428. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  57429. */
  57430. export class FxaaPostProcess extends PostProcess {
  57431. /** @hidden */
  57432. texelWidth: number;
  57433. /** @hidden */
  57434. texelHeight: number;
  57435. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  57436. private _getDefines;
  57437. }
  57438. }
  57439. declare module "babylonjs/Shaders/grain.fragment" {
  57440. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  57441. /** @hidden */
  57442. export var grainPixelShader: {
  57443. name: string;
  57444. shader: string;
  57445. };
  57446. }
  57447. declare module "babylonjs/PostProcesses/grainPostProcess" {
  57448. import { Nullable } from "babylonjs/types";
  57449. import { Camera } from "babylonjs/Cameras/camera";
  57450. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  57451. import { Engine } from "babylonjs/Engines/engine";
  57452. import "babylonjs/Shaders/grain.fragment";
  57453. /**
  57454. * The GrainPostProcess adds noise to the image at mid luminance levels
  57455. */
  57456. export class GrainPostProcess extends PostProcess {
  57457. /**
  57458. * The intensity of the grain added (default: 30)
  57459. */
  57460. intensity: number;
  57461. /**
  57462. * If the grain should be randomized on every frame
  57463. */
  57464. animated: boolean;
  57465. /**
  57466. * Creates a new instance of @see GrainPostProcess
  57467. * @param name The name of the effect.
  57468. * @param options The required width/height ratio to downsize to before computing the render pass.
  57469. * @param camera The camera to apply the render pass to.
  57470. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57471. * @param engine The engine which the post process will be applied. (default: current engine)
  57472. * @param reusable If the post process can be reused on the same frame. (default: false)
  57473. * @param textureType Type of textures used when performing the post process. (default: 0)
  57474. * @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)
  57475. */
  57476. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  57477. }
  57478. }
  57479. declare module "babylonjs/Shaders/highlights.fragment" {
  57480. /** @hidden */
  57481. export var highlightsPixelShader: {
  57482. name: string;
  57483. shader: string;
  57484. };
  57485. }
  57486. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  57487. import { Nullable } from "babylonjs/types";
  57488. import { Camera } from "babylonjs/Cameras/camera";
  57489. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  57490. import { Engine } from "babylonjs/Engines/engine";
  57491. import "babylonjs/Shaders/highlights.fragment";
  57492. /**
  57493. * Extracts highlights from the image
  57494. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  57495. */
  57496. export class HighlightsPostProcess extends PostProcess {
  57497. /**
  57498. * Extracts highlights from the image
  57499. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  57500. * @param name The name of the effect.
  57501. * @param options The required width/height ratio to downsize to before computing the render pass.
  57502. * @param camera The camera to apply the render pass to.
  57503. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57504. * @param engine The engine which the post process will be applied. (default: current engine)
  57505. * @param reusable If the post process can be reused on the same frame. (default: false)
  57506. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  57507. */
  57508. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  57509. }
  57510. }
  57511. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  57512. /** @hidden */
  57513. export var mrtFragmentDeclaration: {
  57514. name: string;
  57515. shader: string;
  57516. };
  57517. }
  57518. declare module "babylonjs/Shaders/geometry.fragment" {
  57519. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  57520. /** @hidden */
  57521. export var geometryPixelShader: {
  57522. name: string;
  57523. shader: string;
  57524. };
  57525. }
  57526. declare module "babylonjs/Shaders/geometry.vertex" {
  57527. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  57528. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  57529. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  57530. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  57531. /** @hidden */
  57532. export var geometryVertexShader: {
  57533. name: string;
  57534. shader: string;
  57535. };
  57536. }
  57537. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  57538. import { Matrix } from "babylonjs/Maths/math";
  57539. import { SubMesh } from "babylonjs/Meshes/subMesh";
  57540. import { Mesh } from "babylonjs/Meshes/mesh";
  57541. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  57542. import { Effect } from "babylonjs/Materials/effect";
  57543. import { Scene } from "babylonjs/scene";
  57544. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57545. import "babylonjs/Shaders/geometry.fragment";
  57546. import "babylonjs/Shaders/geometry.vertex";
  57547. /** @hidden */
  57548. interface ISavedTransformationMatrix {
  57549. world: Matrix;
  57550. viewProjection: Matrix;
  57551. }
  57552. /**
  57553. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  57554. */
  57555. export class GeometryBufferRenderer {
  57556. /**
  57557. * Constant used to retrieve the position texture index in the G-Buffer textures array
  57558. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  57559. */
  57560. static readonly POSITION_TEXTURE_TYPE: number;
  57561. /**
  57562. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  57563. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  57564. */
  57565. static readonly VELOCITY_TEXTURE_TYPE: number;
  57566. /**
  57567. * Dictionary used to store the previous transformation matrices of each rendered mesh
  57568. * in order to compute objects velocities when enableVelocity is set to "true"
  57569. * @hidden
  57570. */
  57571. _previousTransformationMatrices: {
  57572. [index: number]: ISavedTransformationMatrix;
  57573. };
  57574. /**
  57575. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  57576. * in order to compute objects velocities when enableVelocity is set to "true"
  57577. * @hidden
  57578. */
  57579. _previousBonesTransformationMatrices: {
  57580. [index: number]: Float32Array;
  57581. };
  57582. /**
  57583. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  57584. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  57585. */
  57586. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  57587. private _scene;
  57588. private _multiRenderTarget;
  57589. private _ratio;
  57590. private _enablePosition;
  57591. private _enableVelocity;
  57592. private _positionIndex;
  57593. private _velocityIndex;
  57594. protected _effect: Effect;
  57595. protected _cachedDefines: string;
  57596. /**
  57597. * Set the render list (meshes to be rendered) used in the G buffer.
  57598. */
  57599. renderList: Mesh[];
  57600. /**
  57601. * Gets wether or not G buffer are supported by the running hardware.
  57602. * This requires draw buffer supports
  57603. */
  57604. readonly isSupported: boolean;
  57605. /**
  57606. * Returns the index of the given texture type in the G-Buffer textures array
  57607. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  57608. * @returns the index of the given texture type in the G-Buffer textures array
  57609. */
  57610. getTextureIndex(textureType: number): number;
  57611. /**
  57612. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  57613. */
  57614. /**
  57615. * Sets whether or not objects positions are enabled for the G buffer.
  57616. */
  57617. enablePosition: boolean;
  57618. /**
  57619. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  57620. */
  57621. /**
  57622. * Sets wether or not objects velocities are enabled for the G buffer.
  57623. */
  57624. enableVelocity: boolean;
  57625. /**
  57626. * Gets the scene associated with the buffer.
  57627. */
  57628. readonly scene: Scene;
  57629. /**
  57630. * Gets the ratio used by the buffer during its creation.
  57631. * How big is the buffer related to the main canvas.
  57632. */
  57633. readonly ratio: number;
  57634. /** @hidden */
  57635. static _SceneComponentInitialization: (scene: Scene) => void;
  57636. /**
  57637. * Creates a new G Buffer for the scene
  57638. * @param scene The scene the buffer belongs to
  57639. * @param ratio How big is the buffer related to the main canvas.
  57640. */
  57641. constructor(scene: Scene, ratio?: number);
  57642. /**
  57643. * Checks wether everything is ready to render a submesh to the G buffer.
  57644. * @param subMesh the submesh to check readiness for
  57645. * @param useInstances is the mesh drawn using instance or not
  57646. * @returns true if ready otherwise false
  57647. */
  57648. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  57649. /**
  57650. * Gets the current underlying G Buffer.
  57651. * @returns the buffer
  57652. */
  57653. getGBuffer(): MultiRenderTarget;
  57654. /**
  57655. * Gets the number of samples used to render the buffer (anti aliasing).
  57656. */
  57657. /**
  57658. * Sets the number of samples used to render the buffer (anti aliasing).
  57659. */
  57660. samples: number;
  57661. /**
  57662. * Disposes the renderer and frees up associated resources.
  57663. */
  57664. dispose(): void;
  57665. protected _createRenderTargets(): void;
  57666. private _copyBonesTransformationMatrices;
  57667. }
  57668. }
  57669. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  57670. import { Nullable } from "babylonjs/types";
  57671. import { Scene } from "babylonjs/scene";
  57672. import { ISceneComponent } from "babylonjs/sceneComponent";
  57673. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  57674. module "babylonjs/scene" {
  57675. interface Scene {
  57676. /** @hidden (Backing field) */
  57677. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  57678. /**
  57679. * Gets or Sets the current geometry buffer associated to the scene.
  57680. */
  57681. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  57682. /**
  57683. * Enables a GeometryBufferRender and associates it with the scene
  57684. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  57685. * @returns the GeometryBufferRenderer
  57686. */
  57687. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  57688. /**
  57689. * Disables the GeometryBufferRender associated with the scene
  57690. */
  57691. disableGeometryBufferRenderer(): void;
  57692. }
  57693. }
  57694. /**
  57695. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  57696. * in several rendering techniques.
  57697. */
  57698. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  57699. /**
  57700. * The component name helpful to identify the component in the list of scene components.
  57701. */
  57702. readonly name: string;
  57703. /**
  57704. * The scene the component belongs to.
  57705. */
  57706. scene: Scene;
  57707. /**
  57708. * Creates a new instance of the component for the given scene
  57709. * @param scene Defines the scene to register the component in
  57710. */
  57711. constructor(scene: Scene);
  57712. /**
  57713. * Registers the component in a given scene
  57714. */
  57715. register(): void;
  57716. /**
  57717. * Rebuilds the elements related to this component in case of
  57718. * context lost for instance.
  57719. */
  57720. rebuild(): void;
  57721. /**
  57722. * Disposes the component and the associated ressources
  57723. */
  57724. dispose(): void;
  57725. private _gatherRenderTargets;
  57726. }
  57727. }
  57728. declare module "babylonjs/Shaders/motionBlur.fragment" {
  57729. /** @hidden */
  57730. export var motionBlurPixelShader: {
  57731. name: string;
  57732. shader: string;
  57733. };
  57734. }
  57735. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  57736. import { Nullable } from "babylonjs/types";
  57737. import { Camera } from "babylonjs/Cameras/camera";
  57738. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  57739. import { Scene } from "babylonjs/scene";
  57740. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57741. import "babylonjs/Animations/animatable";
  57742. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  57743. import "babylonjs/Shaders/motionBlur.fragment";
  57744. import { Engine } from "babylonjs/Engines/engine";
  57745. /**
  57746. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  57747. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  57748. * As an example, all you have to do is to create the post-process:
  57749. * var mb = new BABYLON.MotionBlurPostProcess(
  57750. * 'mb', // The name of the effect.
  57751. * scene, // The scene containing the objects to blur according to their velocity.
  57752. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  57753. * camera // The camera to apply the render pass to.
  57754. * );
  57755. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  57756. */
  57757. export class MotionBlurPostProcess extends PostProcess {
  57758. /**
  57759. * Defines how much the image is blurred by the movement. Default value is equal to 1
  57760. */
  57761. motionStrength: number;
  57762. /**
  57763. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  57764. */
  57765. /**
  57766. * Sets the number of iterations to be used for motion blur quality
  57767. */
  57768. motionBlurSamples: number;
  57769. private _motionBlurSamples;
  57770. private _geometryBufferRenderer;
  57771. /**
  57772. * Creates a new instance MotionBlurPostProcess
  57773. * @param name The name of the effect.
  57774. * @param scene The scene containing the objects to blur according to their velocity.
  57775. * @param options The required width/height ratio to downsize to before computing the render pass.
  57776. * @param camera The camera to apply the render pass to.
  57777. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57778. * @param engine The engine which the post process will be applied. (default: current engine)
  57779. * @param reusable If the post process can be reused on the same frame. (default: false)
  57780. * @param textureType Type of textures used when performing the post process. (default: 0)
  57781. * @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)
  57782. */
  57783. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  57784. /**
  57785. * Excludes the given skinned mesh from computing bones velocities.
  57786. * 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.
  57787. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  57788. */
  57789. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  57790. /**
  57791. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  57792. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  57793. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  57794. */
  57795. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  57796. /**
  57797. * Disposes the post process.
  57798. * @param camera The camera to dispose the post process on.
  57799. */
  57800. dispose(camera?: Camera): void;
  57801. }
  57802. }
  57803. declare module "babylonjs/Shaders/refraction.fragment" {
  57804. /** @hidden */
  57805. export var refractionPixelShader: {
  57806. name: string;
  57807. shader: string;
  57808. };
  57809. }
  57810. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  57811. import { Color3 } from "babylonjs/Maths/math";
  57812. import { Camera } from "babylonjs/Cameras/camera";
  57813. import { Texture } from "babylonjs/Materials/Textures/texture";
  57814. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  57815. import { Engine } from "babylonjs/Engines/engine";
  57816. import "babylonjs/Shaders/refraction.fragment";
  57817. /**
  57818. * Post process which applies a refractin texture
  57819. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  57820. */
  57821. export class RefractionPostProcess extends PostProcess {
  57822. /** the base color of the refraction (used to taint the rendering) */
  57823. color: Color3;
  57824. /** simulated refraction depth */
  57825. depth: number;
  57826. /** the coefficient of the base color (0 to remove base color tainting) */
  57827. colorLevel: number;
  57828. private _refTexture;
  57829. private _ownRefractionTexture;
  57830. /**
  57831. * Gets or sets the refraction texture
  57832. * Please note that you are responsible for disposing the texture if you set it manually
  57833. */
  57834. refractionTexture: Texture;
  57835. /**
  57836. * Initializes the RefractionPostProcess
  57837. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  57838. * @param name The name of the effect.
  57839. * @param refractionTextureUrl Url of the refraction texture to use
  57840. * @param color the base color of the refraction (used to taint the rendering)
  57841. * @param depth simulated refraction depth
  57842. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  57843. * @param camera The camera to apply the render pass to.
  57844. * @param options The required width/height ratio to downsize to before computing the render pass.
  57845. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57846. * @param engine The engine which the post process will be applied. (default: current engine)
  57847. * @param reusable If the post process can be reused on the same frame. (default: false)
  57848. */
  57849. constructor(name: string, refractionTextureUrl: string,
  57850. /** the base color of the refraction (used to taint the rendering) */
  57851. color: Color3,
  57852. /** simulated refraction depth */
  57853. depth: number,
  57854. /** the coefficient of the base color (0 to remove base color tainting) */
  57855. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  57856. /**
  57857. * Disposes of the post process
  57858. * @param camera Camera to dispose post process on
  57859. */
  57860. dispose(camera: Camera): void;
  57861. }
  57862. }
  57863. declare module "babylonjs/Shaders/sharpen.fragment" {
  57864. /** @hidden */
  57865. export var sharpenPixelShader: {
  57866. name: string;
  57867. shader: string;
  57868. };
  57869. }
  57870. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  57871. import { Nullable } from "babylonjs/types";
  57872. import { Camera } from "babylonjs/Cameras/camera";
  57873. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  57874. import "babylonjs/Shaders/sharpen.fragment";
  57875. import { Engine } from "babylonjs/Engines/engine";
  57876. /**
  57877. * The SharpenPostProcess applies a sharpen kernel to every pixel
  57878. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  57879. */
  57880. export class SharpenPostProcess extends PostProcess {
  57881. /**
  57882. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  57883. */
  57884. colorAmount: number;
  57885. /**
  57886. * How much sharpness should be applied (default: 0.3)
  57887. */
  57888. edgeAmount: number;
  57889. /**
  57890. * Creates a new instance ConvolutionPostProcess
  57891. * @param name The name of the effect.
  57892. * @param options The required width/height ratio to downsize to before computing the render pass.
  57893. * @param camera The camera to apply the render pass to.
  57894. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57895. * @param engine The engine which the post process will be applied. (default: current engine)
  57896. * @param reusable If the post process can be reused on the same frame. (default: false)
  57897. * @param textureType Type of textures used when performing the post process. (default: 0)
  57898. * @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)
  57899. */
  57900. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  57901. }
  57902. }
  57903. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  57904. import { Nullable } from "babylonjs/types";
  57905. import { Camera } from "babylonjs/Cameras/camera";
  57906. import { Engine } from "babylonjs/Engines/engine";
  57907. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  57908. import { IInspectable } from "babylonjs/Misc/iInspectable";
  57909. /**
  57910. * PostProcessRenderPipeline
  57911. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  57912. */
  57913. export class PostProcessRenderPipeline {
  57914. private engine;
  57915. private _renderEffects;
  57916. private _renderEffectsForIsolatedPass;
  57917. /**
  57918. * List of inspectable custom properties (used by the Inspector)
  57919. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  57920. */
  57921. inspectableCustomProperties: IInspectable[];
  57922. /**
  57923. * @hidden
  57924. */
  57925. protected _cameras: Camera[];
  57926. /** @hidden */
  57927. _name: string;
  57928. /**
  57929. * Gets pipeline name
  57930. */
  57931. readonly name: string;
  57932. /**
  57933. * Initializes a PostProcessRenderPipeline
  57934. * @param engine engine to add the pipeline to
  57935. * @param name name of the pipeline
  57936. */
  57937. constructor(engine: Engine, name: string);
  57938. /**
  57939. * Gets the class name
  57940. * @returns "PostProcessRenderPipeline"
  57941. */
  57942. getClassName(): string;
  57943. /**
  57944. * If all the render effects in the pipeline are supported
  57945. */
  57946. readonly isSupported: boolean;
  57947. /**
  57948. * Adds an effect to the pipeline
  57949. * @param renderEffect the effect to add
  57950. */
  57951. addEffect(renderEffect: PostProcessRenderEffect): void;
  57952. /** @hidden */
  57953. _rebuild(): void;
  57954. /** @hidden */
  57955. _enableEffect(renderEffectName: string, cameras: Camera): void;
  57956. /** @hidden */
  57957. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  57958. /** @hidden */
  57959. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  57960. /** @hidden */
  57961. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  57962. /** @hidden */
  57963. _attachCameras(cameras: Camera, unique: boolean): void;
  57964. /** @hidden */
  57965. _attachCameras(cameras: Camera[], unique: boolean): void;
  57966. /** @hidden */
  57967. _detachCameras(cameras: Camera): void;
  57968. /** @hidden */
  57969. _detachCameras(cameras: Nullable<Camera[]>): void;
  57970. /** @hidden */
  57971. _update(): void;
  57972. /** @hidden */
  57973. _reset(): void;
  57974. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  57975. /**
  57976. * Disposes of the pipeline
  57977. */
  57978. dispose(): void;
  57979. }
  57980. }
  57981. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  57982. import { Camera } from "babylonjs/Cameras/camera";
  57983. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  57984. /**
  57985. * PostProcessRenderPipelineManager class
  57986. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  57987. */
  57988. export class PostProcessRenderPipelineManager {
  57989. private _renderPipelines;
  57990. /**
  57991. * Initializes a PostProcessRenderPipelineManager
  57992. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  57993. */
  57994. constructor();
  57995. /**
  57996. * Gets the list of supported render pipelines
  57997. */
  57998. readonly supportedPipelines: PostProcessRenderPipeline[];
  57999. /**
  58000. * Adds a pipeline to the manager
  58001. * @param renderPipeline The pipeline to add
  58002. */
  58003. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  58004. /**
  58005. * Attaches a camera to the pipeline
  58006. * @param renderPipelineName The name of the pipeline to attach to
  58007. * @param cameras the camera to attach
  58008. * @param unique if the camera can be attached multiple times to the pipeline
  58009. */
  58010. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  58011. /**
  58012. * Detaches a camera from the pipeline
  58013. * @param renderPipelineName The name of the pipeline to detach from
  58014. * @param cameras the camera to detach
  58015. */
  58016. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  58017. /**
  58018. * Enables an effect by name on a pipeline
  58019. * @param renderPipelineName the name of the pipeline to enable the effect in
  58020. * @param renderEffectName the name of the effect to enable
  58021. * @param cameras the cameras that the effect should be enabled on
  58022. */
  58023. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  58024. /**
  58025. * Disables an effect by name on a pipeline
  58026. * @param renderPipelineName the name of the pipeline to disable the effect in
  58027. * @param renderEffectName the name of the effect to disable
  58028. * @param cameras the cameras that the effect should be disabled on
  58029. */
  58030. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  58031. /**
  58032. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  58033. */
  58034. update(): void;
  58035. /** @hidden */
  58036. _rebuild(): void;
  58037. /**
  58038. * Disposes of the manager and pipelines
  58039. */
  58040. dispose(): void;
  58041. }
  58042. }
  58043. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  58044. import { ISceneComponent } from "babylonjs/sceneComponent";
  58045. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  58046. import { Scene } from "babylonjs/scene";
  58047. module "babylonjs/scene" {
  58048. interface Scene {
  58049. /** @hidden (Backing field) */
  58050. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  58051. /**
  58052. * Gets the postprocess render pipeline manager
  58053. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  58054. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  58055. */
  58056. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  58057. }
  58058. }
  58059. /**
  58060. * Defines the Render Pipeline scene component responsible to rendering pipelines
  58061. */
  58062. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  58063. /**
  58064. * The component name helpfull to identify the component in the list of scene components.
  58065. */
  58066. readonly name: string;
  58067. /**
  58068. * The scene the component belongs to.
  58069. */
  58070. scene: Scene;
  58071. /**
  58072. * Creates a new instance of the component for the given scene
  58073. * @param scene Defines the scene to register the component in
  58074. */
  58075. constructor(scene: Scene);
  58076. /**
  58077. * Registers the component in a given scene
  58078. */
  58079. register(): void;
  58080. /**
  58081. * Rebuilds the elements related to this component in case of
  58082. * context lost for instance.
  58083. */
  58084. rebuild(): void;
  58085. /**
  58086. * Disposes the component and the associated ressources
  58087. */
  58088. dispose(): void;
  58089. private _gatherRenderTargets;
  58090. }
  58091. }
  58092. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  58093. import { Nullable } from "babylonjs/types";
  58094. import { IAnimatable } from "babylonjs/Misc/tools";
  58095. import { Camera } from "babylonjs/Cameras/camera";
  58096. import { IDisposable } from "babylonjs/scene";
  58097. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  58098. import { Scene } from "babylonjs/scene";
  58099. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  58100. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  58101. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  58102. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  58103. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  58104. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  58105. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  58106. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  58107. import { Animation } from "babylonjs/Animations/animation";
  58108. /**
  58109. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  58110. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  58111. */
  58112. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  58113. private _scene;
  58114. private _camerasToBeAttached;
  58115. /**
  58116. * ID of the sharpen post process,
  58117. */
  58118. private readonly SharpenPostProcessId;
  58119. /**
  58120. * @ignore
  58121. * ID of the image processing post process;
  58122. */
  58123. readonly ImageProcessingPostProcessId: string;
  58124. /**
  58125. * @ignore
  58126. * ID of the Fast Approximate Anti-Aliasing post process;
  58127. */
  58128. readonly FxaaPostProcessId: string;
  58129. /**
  58130. * ID of the chromatic aberration post process,
  58131. */
  58132. private readonly ChromaticAberrationPostProcessId;
  58133. /**
  58134. * ID of the grain post process
  58135. */
  58136. private readonly GrainPostProcessId;
  58137. /**
  58138. * Sharpen post process which will apply a sharpen convolution to enhance edges
  58139. */
  58140. sharpen: SharpenPostProcess;
  58141. private _sharpenEffect;
  58142. private bloom;
  58143. /**
  58144. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  58145. */
  58146. depthOfField: DepthOfFieldEffect;
  58147. /**
  58148. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  58149. */
  58150. fxaa: FxaaPostProcess;
  58151. /**
  58152. * Image post processing pass used to perform operations such as tone mapping or color grading.
  58153. */
  58154. imageProcessing: ImageProcessingPostProcess;
  58155. /**
  58156. * Chromatic aberration post process which will shift rgb colors in the image
  58157. */
  58158. chromaticAberration: ChromaticAberrationPostProcess;
  58159. private _chromaticAberrationEffect;
  58160. /**
  58161. * Grain post process which add noise to the image
  58162. */
  58163. grain: GrainPostProcess;
  58164. private _grainEffect;
  58165. /**
  58166. * Glow post process which adds a glow to emissive areas of the image
  58167. */
  58168. private _glowLayer;
  58169. /**
  58170. * Animations which can be used to tweak settings over a period of time
  58171. */
  58172. animations: Animation[];
  58173. private _imageProcessingConfigurationObserver;
  58174. private _sharpenEnabled;
  58175. private _bloomEnabled;
  58176. private _depthOfFieldEnabled;
  58177. private _depthOfFieldBlurLevel;
  58178. private _fxaaEnabled;
  58179. private _imageProcessingEnabled;
  58180. private _defaultPipelineTextureType;
  58181. private _bloomScale;
  58182. private _chromaticAberrationEnabled;
  58183. private _grainEnabled;
  58184. private _buildAllowed;
  58185. /**
  58186. * Gets active scene
  58187. */
  58188. readonly scene: Scene;
  58189. /**
  58190. * Enable or disable the sharpen process from the pipeline
  58191. */
  58192. sharpenEnabled: boolean;
  58193. private _resizeObserver;
  58194. private _hardwareScaleLevel;
  58195. private _bloomKernel;
  58196. /**
  58197. * Specifies the size of the bloom blur kernel, relative to the final output size
  58198. */
  58199. bloomKernel: number;
  58200. /**
  58201. * Specifies the weight of the bloom in the final rendering
  58202. */
  58203. private _bloomWeight;
  58204. /**
  58205. * Specifies the luma threshold for the area that will be blurred by the bloom
  58206. */
  58207. private _bloomThreshold;
  58208. private _hdr;
  58209. /**
  58210. * The strength of the bloom.
  58211. */
  58212. bloomWeight: number;
  58213. /**
  58214. * The strength of the bloom.
  58215. */
  58216. bloomThreshold: number;
  58217. /**
  58218. * The scale of the bloom, lower value will provide better performance.
  58219. */
  58220. bloomScale: number;
  58221. /**
  58222. * Enable or disable the bloom from the pipeline
  58223. */
  58224. bloomEnabled: boolean;
  58225. private _rebuildBloom;
  58226. /**
  58227. * If the depth of field is enabled.
  58228. */
  58229. depthOfFieldEnabled: boolean;
  58230. /**
  58231. * Blur level of the depth of field effect. (Higher blur will effect performance)
  58232. */
  58233. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  58234. /**
  58235. * If the anti aliasing is enabled.
  58236. */
  58237. fxaaEnabled: boolean;
  58238. private _samples;
  58239. /**
  58240. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  58241. */
  58242. samples: number;
  58243. /**
  58244. * If image processing is enabled.
  58245. */
  58246. imageProcessingEnabled: boolean;
  58247. /**
  58248. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  58249. */
  58250. glowLayerEnabled: boolean;
  58251. /**
  58252. * Gets the glow layer (or null if not defined)
  58253. */
  58254. readonly glowLayer: Nullable<GlowLayer>;
  58255. /**
  58256. * Enable or disable the chromaticAberration process from the pipeline
  58257. */
  58258. chromaticAberrationEnabled: boolean;
  58259. /**
  58260. * Enable or disable the grain process from the pipeline
  58261. */
  58262. grainEnabled: boolean;
  58263. /**
  58264. * @constructor
  58265. * @param name - The rendering pipeline name (default: "")
  58266. * @param hdr - If high dynamic range textures should be used (default: true)
  58267. * @param scene - The scene linked to this pipeline (default: the last created scene)
  58268. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  58269. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  58270. */
  58271. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  58272. /**
  58273. * Get the class name
  58274. * @returns "DefaultRenderingPipeline"
  58275. */
  58276. getClassName(): string;
  58277. /**
  58278. * Force the compilation of the entire pipeline.
  58279. */
  58280. prepare(): void;
  58281. private _hasCleared;
  58282. private _prevPostProcess;
  58283. private _prevPrevPostProcess;
  58284. private _setAutoClearAndTextureSharing;
  58285. private _depthOfFieldSceneObserver;
  58286. private _buildPipeline;
  58287. private _disposePostProcesses;
  58288. /**
  58289. * Adds a camera to the pipeline
  58290. * @param camera the camera to be added
  58291. */
  58292. addCamera(camera: Camera): void;
  58293. /**
  58294. * Removes a camera from the pipeline
  58295. * @param camera the camera to remove
  58296. */
  58297. removeCamera(camera: Camera): void;
  58298. /**
  58299. * Dispose of the pipeline and stop all post processes
  58300. */
  58301. dispose(): void;
  58302. /**
  58303. * Serialize the rendering pipeline (Used when exporting)
  58304. * @returns the serialized object
  58305. */
  58306. serialize(): any;
  58307. /**
  58308. * Parse the serialized pipeline
  58309. * @param source Source pipeline.
  58310. * @param scene The scene to load the pipeline to.
  58311. * @param rootUrl The URL of the serialized pipeline.
  58312. * @returns An instantiated pipeline from the serialized object.
  58313. */
  58314. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  58315. }
  58316. }
  58317. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  58318. /** @hidden */
  58319. export var lensHighlightsPixelShader: {
  58320. name: string;
  58321. shader: string;
  58322. };
  58323. }
  58324. declare module "babylonjs/Shaders/depthOfField.fragment" {
  58325. /** @hidden */
  58326. export var depthOfFieldPixelShader: {
  58327. name: string;
  58328. shader: string;
  58329. };
  58330. }
  58331. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  58332. import { Camera } from "babylonjs/Cameras/camera";
  58333. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  58334. import { Scene } from "babylonjs/scene";
  58335. import "babylonjs/Shaders/chromaticAberration.fragment";
  58336. import "babylonjs/Shaders/lensHighlights.fragment";
  58337. import "babylonjs/Shaders/depthOfField.fragment";
  58338. /**
  58339. * BABYLON.JS Chromatic Aberration GLSL Shader
  58340. * Author: Olivier Guyot
  58341. * Separates very slightly R, G and B colors on the edges of the screen
  58342. * Inspired by Francois Tarlier & Martins Upitis
  58343. */
  58344. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  58345. /**
  58346. * @ignore
  58347. * The chromatic aberration PostProcess id in the pipeline
  58348. */
  58349. LensChromaticAberrationEffect: string;
  58350. /**
  58351. * @ignore
  58352. * The highlights enhancing PostProcess id in the pipeline
  58353. */
  58354. HighlightsEnhancingEffect: string;
  58355. /**
  58356. * @ignore
  58357. * The depth-of-field PostProcess id in the pipeline
  58358. */
  58359. LensDepthOfFieldEffect: string;
  58360. private _scene;
  58361. private _depthTexture;
  58362. private _grainTexture;
  58363. private _chromaticAberrationPostProcess;
  58364. private _highlightsPostProcess;
  58365. private _depthOfFieldPostProcess;
  58366. private _edgeBlur;
  58367. private _grainAmount;
  58368. private _chromaticAberration;
  58369. private _distortion;
  58370. private _highlightsGain;
  58371. private _highlightsThreshold;
  58372. private _dofDistance;
  58373. private _dofAperture;
  58374. private _dofDarken;
  58375. private _dofPentagon;
  58376. private _blurNoise;
  58377. /**
  58378. * @constructor
  58379. *
  58380. * Effect parameters are as follow:
  58381. * {
  58382. * chromatic_aberration: number; // from 0 to x (1 for realism)
  58383. * edge_blur: number; // from 0 to x (1 for realism)
  58384. * distortion: number; // from 0 to x (1 for realism)
  58385. * grain_amount: number; // from 0 to 1
  58386. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  58387. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  58388. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  58389. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  58390. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  58391. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  58392. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  58393. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  58394. * }
  58395. * Note: if an effect parameter is unset, effect is disabled
  58396. *
  58397. * @param name The rendering pipeline name
  58398. * @param parameters - An object containing all parameters (see above)
  58399. * @param scene The scene linked to this pipeline
  58400. * @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)
  58401. * @param cameras The array of cameras that the rendering pipeline will be attached to
  58402. */
  58403. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  58404. /**
  58405. * Get the class name
  58406. * @returns "LensRenderingPipeline"
  58407. */
  58408. getClassName(): string;
  58409. /**
  58410. * Gets associated scene
  58411. */
  58412. readonly scene: Scene;
  58413. /**
  58414. * Gets or sets the edge blur
  58415. */
  58416. edgeBlur: number;
  58417. /**
  58418. * Gets or sets the grain amount
  58419. */
  58420. grainAmount: number;
  58421. /**
  58422. * Gets or sets the chromatic aberration amount
  58423. */
  58424. chromaticAberration: number;
  58425. /**
  58426. * Gets or sets the depth of field aperture
  58427. */
  58428. dofAperture: number;
  58429. /**
  58430. * Gets or sets the edge distortion
  58431. */
  58432. edgeDistortion: number;
  58433. /**
  58434. * Gets or sets the depth of field distortion
  58435. */
  58436. dofDistortion: number;
  58437. /**
  58438. * Gets or sets the darken out of focus amount
  58439. */
  58440. darkenOutOfFocus: number;
  58441. /**
  58442. * Gets or sets a boolean indicating if blur noise is enabled
  58443. */
  58444. blurNoise: boolean;
  58445. /**
  58446. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  58447. */
  58448. pentagonBokeh: boolean;
  58449. /**
  58450. * Gets or sets the highlight grain amount
  58451. */
  58452. highlightsGain: number;
  58453. /**
  58454. * Gets or sets the highlight threshold
  58455. */
  58456. highlightsThreshold: number;
  58457. /**
  58458. * Sets the amount of blur at the edges
  58459. * @param amount blur amount
  58460. */
  58461. setEdgeBlur(amount: number): void;
  58462. /**
  58463. * Sets edge blur to 0
  58464. */
  58465. disableEdgeBlur(): void;
  58466. /**
  58467. * Sets the amout of grain
  58468. * @param amount Amount of grain
  58469. */
  58470. setGrainAmount(amount: number): void;
  58471. /**
  58472. * Set grain amount to 0
  58473. */
  58474. disableGrain(): void;
  58475. /**
  58476. * Sets the chromatic aberration amount
  58477. * @param amount amount of chromatic aberration
  58478. */
  58479. setChromaticAberration(amount: number): void;
  58480. /**
  58481. * Sets chromatic aberration amount to 0
  58482. */
  58483. disableChromaticAberration(): void;
  58484. /**
  58485. * Sets the EdgeDistortion amount
  58486. * @param amount amount of EdgeDistortion
  58487. */
  58488. setEdgeDistortion(amount: number): void;
  58489. /**
  58490. * Sets edge distortion to 0
  58491. */
  58492. disableEdgeDistortion(): void;
  58493. /**
  58494. * Sets the FocusDistance amount
  58495. * @param amount amount of FocusDistance
  58496. */
  58497. setFocusDistance(amount: number): void;
  58498. /**
  58499. * Disables depth of field
  58500. */
  58501. disableDepthOfField(): void;
  58502. /**
  58503. * Sets the Aperture amount
  58504. * @param amount amount of Aperture
  58505. */
  58506. setAperture(amount: number): void;
  58507. /**
  58508. * Sets the DarkenOutOfFocus amount
  58509. * @param amount amount of DarkenOutOfFocus
  58510. */
  58511. setDarkenOutOfFocus(amount: number): void;
  58512. private _pentagonBokehIsEnabled;
  58513. /**
  58514. * Creates a pentagon bokeh effect
  58515. */
  58516. enablePentagonBokeh(): void;
  58517. /**
  58518. * Disables the pentagon bokeh effect
  58519. */
  58520. disablePentagonBokeh(): void;
  58521. /**
  58522. * Enables noise blur
  58523. */
  58524. enableNoiseBlur(): void;
  58525. /**
  58526. * Disables noise blur
  58527. */
  58528. disableNoiseBlur(): void;
  58529. /**
  58530. * Sets the HighlightsGain amount
  58531. * @param amount amount of HighlightsGain
  58532. */
  58533. setHighlightsGain(amount: number): void;
  58534. /**
  58535. * Sets the HighlightsThreshold amount
  58536. * @param amount amount of HighlightsThreshold
  58537. */
  58538. setHighlightsThreshold(amount: number): void;
  58539. /**
  58540. * Disables highlights
  58541. */
  58542. disableHighlights(): void;
  58543. /**
  58544. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  58545. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  58546. */
  58547. dispose(disableDepthRender?: boolean): void;
  58548. private _createChromaticAberrationPostProcess;
  58549. private _createHighlightsPostProcess;
  58550. private _createDepthOfFieldPostProcess;
  58551. private _createGrainTexture;
  58552. }
  58553. }
  58554. declare module "babylonjs/Shaders/ssao2.fragment" {
  58555. /** @hidden */
  58556. export var ssao2PixelShader: {
  58557. name: string;
  58558. shader: string;
  58559. };
  58560. }
  58561. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  58562. /** @hidden */
  58563. export var ssaoCombinePixelShader: {
  58564. name: string;
  58565. shader: string;
  58566. };
  58567. }
  58568. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  58569. import { Camera } from "babylonjs/Cameras/camera";
  58570. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  58571. import { Scene } from "babylonjs/scene";
  58572. import "babylonjs/Shaders/ssao2.fragment";
  58573. import "babylonjs/Shaders/ssaoCombine.fragment";
  58574. /**
  58575. * Render pipeline to produce ssao effect
  58576. */
  58577. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  58578. /**
  58579. * @ignore
  58580. * The PassPostProcess id in the pipeline that contains the original scene color
  58581. */
  58582. SSAOOriginalSceneColorEffect: string;
  58583. /**
  58584. * @ignore
  58585. * The SSAO PostProcess id in the pipeline
  58586. */
  58587. SSAORenderEffect: string;
  58588. /**
  58589. * @ignore
  58590. * The horizontal blur PostProcess id in the pipeline
  58591. */
  58592. SSAOBlurHRenderEffect: string;
  58593. /**
  58594. * @ignore
  58595. * The vertical blur PostProcess id in the pipeline
  58596. */
  58597. SSAOBlurVRenderEffect: string;
  58598. /**
  58599. * @ignore
  58600. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  58601. */
  58602. SSAOCombineRenderEffect: string;
  58603. /**
  58604. * The output strength of the SSAO post-process. Default value is 1.0.
  58605. */
  58606. totalStrength: number;
  58607. /**
  58608. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  58609. */
  58610. maxZ: number;
  58611. /**
  58612. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  58613. */
  58614. minZAspect: number;
  58615. private _samples;
  58616. /**
  58617. * Number of samples used for the SSAO calculations. Default value is 8
  58618. */
  58619. samples: number;
  58620. private _textureSamples;
  58621. /**
  58622. * Number of samples to use for antialiasing
  58623. */
  58624. textureSamples: number;
  58625. /**
  58626. * Ratio object used for SSAO ratio and blur ratio
  58627. */
  58628. private _ratio;
  58629. /**
  58630. * Dynamically generated sphere sampler.
  58631. */
  58632. private _sampleSphere;
  58633. /**
  58634. * Blur filter offsets
  58635. */
  58636. private _samplerOffsets;
  58637. private _expensiveBlur;
  58638. /**
  58639. * If bilateral blur should be used
  58640. */
  58641. expensiveBlur: boolean;
  58642. /**
  58643. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  58644. */
  58645. radius: number;
  58646. /**
  58647. * The base color of the SSAO post-process
  58648. * The final result is "base + ssao" between [0, 1]
  58649. */
  58650. base: number;
  58651. /**
  58652. * Support test.
  58653. */
  58654. static readonly IsSupported: boolean;
  58655. private _scene;
  58656. private _depthTexture;
  58657. private _normalTexture;
  58658. private _randomTexture;
  58659. private _originalColorPostProcess;
  58660. private _ssaoPostProcess;
  58661. private _blurHPostProcess;
  58662. private _blurVPostProcess;
  58663. private _ssaoCombinePostProcess;
  58664. private _firstUpdate;
  58665. /**
  58666. * Gets active scene
  58667. */
  58668. readonly scene: Scene;
  58669. /**
  58670. * @constructor
  58671. * @param name The rendering pipeline name
  58672. * @param scene The scene linked to this pipeline
  58673. * @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 }
  58674. * @param cameras The array of cameras that the rendering pipeline will be attached to
  58675. */
  58676. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  58677. /**
  58678. * Get the class name
  58679. * @returns "SSAO2RenderingPipeline"
  58680. */
  58681. getClassName(): string;
  58682. /**
  58683. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  58684. */
  58685. dispose(disableGeometryBufferRenderer?: boolean): void;
  58686. private _createBlurPostProcess;
  58687. /** @hidden */
  58688. _rebuild(): void;
  58689. private _bits;
  58690. private _radicalInverse_VdC;
  58691. private _hammersley;
  58692. private _hemisphereSample_uniform;
  58693. private _generateHemisphere;
  58694. private _createSSAOPostProcess;
  58695. private _createSSAOCombinePostProcess;
  58696. private _createRandomTexture;
  58697. /**
  58698. * Serialize the rendering pipeline (Used when exporting)
  58699. * @returns the serialized object
  58700. */
  58701. serialize(): any;
  58702. /**
  58703. * Parse the serialized pipeline
  58704. * @param source Source pipeline.
  58705. * @param scene The scene to load the pipeline to.
  58706. * @param rootUrl The URL of the serialized pipeline.
  58707. * @returns An instantiated pipeline from the serialized object.
  58708. */
  58709. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  58710. }
  58711. }
  58712. declare module "babylonjs/Shaders/ssao.fragment" {
  58713. /** @hidden */
  58714. export var ssaoPixelShader: {
  58715. name: string;
  58716. shader: string;
  58717. };
  58718. }
  58719. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  58720. import { Camera } from "babylonjs/Cameras/camera";
  58721. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  58722. import { Scene } from "babylonjs/scene";
  58723. import "babylonjs/Shaders/ssao.fragment";
  58724. import "babylonjs/Shaders/ssaoCombine.fragment";
  58725. /**
  58726. * Render pipeline to produce ssao effect
  58727. */
  58728. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  58729. /**
  58730. * @ignore
  58731. * The PassPostProcess id in the pipeline that contains the original scene color
  58732. */
  58733. SSAOOriginalSceneColorEffect: string;
  58734. /**
  58735. * @ignore
  58736. * The SSAO PostProcess id in the pipeline
  58737. */
  58738. SSAORenderEffect: string;
  58739. /**
  58740. * @ignore
  58741. * The horizontal blur PostProcess id in the pipeline
  58742. */
  58743. SSAOBlurHRenderEffect: string;
  58744. /**
  58745. * @ignore
  58746. * The vertical blur PostProcess id in the pipeline
  58747. */
  58748. SSAOBlurVRenderEffect: string;
  58749. /**
  58750. * @ignore
  58751. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  58752. */
  58753. SSAOCombineRenderEffect: string;
  58754. /**
  58755. * The output strength of the SSAO post-process. Default value is 1.0.
  58756. */
  58757. totalStrength: number;
  58758. /**
  58759. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  58760. */
  58761. radius: number;
  58762. /**
  58763. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  58764. * Must not be equal to fallOff and superior to fallOff.
  58765. * Default value is 0.0075
  58766. */
  58767. area: number;
  58768. /**
  58769. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  58770. * Must not be equal to area and inferior to area.
  58771. * Default value is 0.000001
  58772. */
  58773. fallOff: number;
  58774. /**
  58775. * The base color of the SSAO post-process
  58776. * The final result is "base + ssao" between [0, 1]
  58777. */
  58778. base: number;
  58779. private _scene;
  58780. private _depthTexture;
  58781. private _randomTexture;
  58782. private _originalColorPostProcess;
  58783. private _ssaoPostProcess;
  58784. private _blurHPostProcess;
  58785. private _blurVPostProcess;
  58786. private _ssaoCombinePostProcess;
  58787. private _firstUpdate;
  58788. /**
  58789. * Gets active scene
  58790. */
  58791. readonly scene: Scene;
  58792. /**
  58793. * @constructor
  58794. * @param name - The rendering pipeline name
  58795. * @param scene - The scene linked to this pipeline
  58796. * @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 }
  58797. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  58798. */
  58799. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  58800. /**
  58801. * Get the class name
  58802. * @returns "SSAORenderingPipeline"
  58803. */
  58804. getClassName(): string;
  58805. /**
  58806. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  58807. */
  58808. dispose(disableDepthRender?: boolean): void;
  58809. private _createBlurPostProcess;
  58810. /** @hidden */
  58811. _rebuild(): void;
  58812. private _createSSAOPostProcess;
  58813. private _createSSAOCombinePostProcess;
  58814. private _createRandomTexture;
  58815. }
  58816. }
  58817. declare module "babylonjs/Shaders/standard.fragment" {
  58818. /** @hidden */
  58819. export var standardPixelShader: {
  58820. name: string;
  58821. shader: string;
  58822. };
  58823. }
  58824. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  58825. import { Nullable } from "babylonjs/types";
  58826. import { IAnimatable } from "babylonjs/Misc/tools";
  58827. import { Camera } from "babylonjs/Cameras/camera";
  58828. import { Texture } from "babylonjs/Materials/Textures/texture";
  58829. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  58830. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  58831. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  58832. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  58833. import { IDisposable } from "babylonjs/scene";
  58834. import { SpotLight } from "babylonjs/Lights/spotLight";
  58835. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  58836. import { Scene } from "babylonjs/scene";
  58837. import { Animation } from "babylonjs/Animations/animation";
  58838. import "babylonjs/Shaders/standard.fragment";
  58839. /**
  58840. * Standard rendering pipeline
  58841. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  58842. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  58843. */
  58844. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  58845. /**
  58846. * Public members
  58847. */
  58848. /**
  58849. * Post-process which contains the original scene color before the pipeline applies all the effects
  58850. */
  58851. originalPostProcess: Nullable<PostProcess>;
  58852. /**
  58853. * Post-process used to down scale an image x4
  58854. */
  58855. downSampleX4PostProcess: Nullable<PostProcess>;
  58856. /**
  58857. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  58858. */
  58859. brightPassPostProcess: Nullable<PostProcess>;
  58860. /**
  58861. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  58862. */
  58863. blurHPostProcesses: PostProcess[];
  58864. /**
  58865. * Post-process array storing all the vertical blur post-processes used by the pipeline
  58866. */
  58867. blurVPostProcesses: PostProcess[];
  58868. /**
  58869. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  58870. */
  58871. textureAdderPostProcess: Nullable<PostProcess>;
  58872. /**
  58873. * Post-process used to create volumetric lighting effect
  58874. */
  58875. volumetricLightPostProcess: Nullable<PostProcess>;
  58876. /**
  58877. * Post-process used to smooth the previous volumetric light post-process on the X axis
  58878. */
  58879. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  58880. /**
  58881. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  58882. */
  58883. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  58884. /**
  58885. * Post-process used to merge the volumetric light effect and the real scene color
  58886. */
  58887. volumetricLightMergePostProces: Nullable<PostProcess>;
  58888. /**
  58889. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  58890. */
  58891. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  58892. /**
  58893. * Base post-process used to calculate the average luminance of the final image for HDR
  58894. */
  58895. luminancePostProcess: Nullable<PostProcess>;
  58896. /**
  58897. * Post-processes used to create down sample post-processes in order to get
  58898. * the average luminance of the final image for HDR
  58899. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  58900. */
  58901. luminanceDownSamplePostProcesses: PostProcess[];
  58902. /**
  58903. * Post-process used to create a HDR effect (light adaptation)
  58904. */
  58905. hdrPostProcess: Nullable<PostProcess>;
  58906. /**
  58907. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  58908. */
  58909. textureAdderFinalPostProcess: Nullable<PostProcess>;
  58910. /**
  58911. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  58912. */
  58913. lensFlareFinalPostProcess: Nullable<PostProcess>;
  58914. /**
  58915. * Post-process used to merge the final HDR post-process and the real scene color
  58916. */
  58917. hdrFinalPostProcess: Nullable<PostProcess>;
  58918. /**
  58919. * Post-process used to create a lens flare effect
  58920. */
  58921. lensFlarePostProcess: Nullable<PostProcess>;
  58922. /**
  58923. * Post-process that merges the result of the lens flare post-process and the real scene color
  58924. */
  58925. lensFlareComposePostProcess: Nullable<PostProcess>;
  58926. /**
  58927. * Post-process used to create a motion blur effect
  58928. */
  58929. motionBlurPostProcess: Nullable<PostProcess>;
  58930. /**
  58931. * Post-process used to create a depth of field effect
  58932. */
  58933. depthOfFieldPostProcess: Nullable<PostProcess>;
  58934. /**
  58935. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  58936. */
  58937. fxaaPostProcess: Nullable<FxaaPostProcess>;
  58938. /**
  58939. * Represents the brightness threshold in order to configure the illuminated surfaces
  58940. */
  58941. brightThreshold: number;
  58942. /**
  58943. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  58944. */
  58945. blurWidth: number;
  58946. /**
  58947. * Sets if the blur for highlighted surfaces must be only horizontal
  58948. */
  58949. horizontalBlur: boolean;
  58950. /**
  58951. * Gets the overall exposure used by the pipeline
  58952. */
  58953. /**
  58954. * Sets the overall exposure used by the pipeline
  58955. */
  58956. exposure: number;
  58957. /**
  58958. * Texture used typically to simulate "dirty" on camera lens
  58959. */
  58960. lensTexture: Nullable<Texture>;
  58961. /**
  58962. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  58963. */
  58964. volumetricLightCoefficient: number;
  58965. /**
  58966. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  58967. */
  58968. volumetricLightPower: number;
  58969. /**
  58970. * Used the set the blur intensity to smooth the volumetric lights
  58971. */
  58972. volumetricLightBlurScale: number;
  58973. /**
  58974. * Light (spot or directional) used to generate the volumetric lights rays
  58975. * The source light must have a shadow generate so the pipeline can get its
  58976. * depth map
  58977. */
  58978. sourceLight: Nullable<SpotLight | DirectionalLight>;
  58979. /**
  58980. * For eye adaptation, represents the minimum luminance the eye can see
  58981. */
  58982. hdrMinimumLuminance: number;
  58983. /**
  58984. * For eye adaptation, represents the decrease luminance speed
  58985. */
  58986. hdrDecreaseRate: number;
  58987. /**
  58988. * For eye adaptation, represents the increase luminance speed
  58989. */
  58990. hdrIncreaseRate: number;
  58991. /**
  58992. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  58993. */
  58994. /**
  58995. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  58996. */
  58997. hdrAutoExposure: boolean;
  58998. /**
  58999. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  59000. */
  59001. lensColorTexture: Nullable<Texture>;
  59002. /**
  59003. * The overall strengh for the lens flare effect
  59004. */
  59005. lensFlareStrength: number;
  59006. /**
  59007. * Dispersion coefficient for lens flare ghosts
  59008. */
  59009. lensFlareGhostDispersal: number;
  59010. /**
  59011. * Main lens flare halo width
  59012. */
  59013. lensFlareHaloWidth: number;
  59014. /**
  59015. * Based on the lens distortion effect, defines how much the lens flare result
  59016. * is distorted
  59017. */
  59018. lensFlareDistortionStrength: number;
  59019. /**
  59020. * Lens star texture must be used to simulate rays on the flares and is available
  59021. * in the documentation
  59022. */
  59023. lensStarTexture: Nullable<Texture>;
  59024. /**
  59025. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  59026. * flare effect by taking account of the dirt texture
  59027. */
  59028. lensFlareDirtTexture: Nullable<Texture>;
  59029. /**
  59030. * Represents the focal length for the depth of field effect
  59031. */
  59032. depthOfFieldDistance: number;
  59033. /**
  59034. * Represents the blur intensity for the blurred part of the depth of field effect
  59035. */
  59036. depthOfFieldBlurWidth: number;
  59037. /**
  59038. * Gets how much the image is blurred by the movement while using the motion blur post-process
  59039. */
  59040. /**
  59041. * Sets how much the image is blurred by the movement while using the motion blur post-process
  59042. */
  59043. motionStrength: number;
  59044. /**
  59045. * Gets wether or not the motion blur post-process is object based or screen based.
  59046. */
  59047. /**
  59048. * Sets wether or not the motion blur post-process should be object based or screen based
  59049. */
  59050. objectBasedMotionBlur: boolean;
  59051. /**
  59052. * List of animations for the pipeline (IAnimatable implementation)
  59053. */
  59054. animations: Animation[];
  59055. /**
  59056. * Private members
  59057. */
  59058. private _scene;
  59059. private _currentDepthOfFieldSource;
  59060. private _basePostProcess;
  59061. private _fixedExposure;
  59062. private _currentExposure;
  59063. private _hdrAutoExposure;
  59064. private _hdrCurrentLuminance;
  59065. private _motionStrength;
  59066. private _isObjectBasedMotionBlur;
  59067. private _floatTextureType;
  59068. private _ratio;
  59069. private _bloomEnabled;
  59070. private _depthOfFieldEnabled;
  59071. private _vlsEnabled;
  59072. private _lensFlareEnabled;
  59073. private _hdrEnabled;
  59074. private _motionBlurEnabled;
  59075. private _fxaaEnabled;
  59076. private _motionBlurSamples;
  59077. private _volumetricLightStepsCount;
  59078. private _samples;
  59079. /**
  59080. * @ignore
  59081. * Specifies if the bloom pipeline is enabled
  59082. */
  59083. BloomEnabled: boolean;
  59084. /**
  59085. * @ignore
  59086. * Specifies if the depth of field pipeline is enabed
  59087. */
  59088. DepthOfFieldEnabled: boolean;
  59089. /**
  59090. * @ignore
  59091. * Specifies if the lens flare pipeline is enabed
  59092. */
  59093. LensFlareEnabled: boolean;
  59094. /**
  59095. * @ignore
  59096. * Specifies if the HDR pipeline is enabled
  59097. */
  59098. HDREnabled: boolean;
  59099. /**
  59100. * @ignore
  59101. * Specifies if the volumetric lights scattering effect is enabled
  59102. */
  59103. VLSEnabled: boolean;
  59104. /**
  59105. * @ignore
  59106. * Specifies if the motion blur effect is enabled
  59107. */
  59108. MotionBlurEnabled: boolean;
  59109. /**
  59110. * Specifies if anti-aliasing is enabled
  59111. */
  59112. fxaaEnabled: boolean;
  59113. /**
  59114. * Specifies the number of steps used to calculate the volumetric lights
  59115. * Typically in interval [50, 200]
  59116. */
  59117. volumetricLightStepsCount: number;
  59118. /**
  59119. * Specifies the number of samples used for the motion blur effect
  59120. * Typically in interval [16, 64]
  59121. */
  59122. motionBlurSamples: number;
  59123. /**
  59124. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  59125. */
  59126. samples: number;
  59127. /**
  59128. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  59129. * @constructor
  59130. * @param name The rendering pipeline name
  59131. * @param scene The scene linked to this pipeline
  59132. * @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)
  59133. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  59134. * @param cameras The array of cameras that the rendering pipeline will be attached to
  59135. */
  59136. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  59137. private _buildPipeline;
  59138. private _createDownSampleX4PostProcess;
  59139. private _createBrightPassPostProcess;
  59140. private _createBlurPostProcesses;
  59141. private _createTextureAdderPostProcess;
  59142. private _createVolumetricLightPostProcess;
  59143. private _createLuminancePostProcesses;
  59144. private _createHdrPostProcess;
  59145. private _createLensFlarePostProcess;
  59146. private _createDepthOfFieldPostProcess;
  59147. private _createMotionBlurPostProcess;
  59148. private _getDepthTexture;
  59149. private _disposePostProcesses;
  59150. /**
  59151. * Dispose of the pipeline and stop all post processes
  59152. */
  59153. dispose(): void;
  59154. /**
  59155. * Serialize the rendering pipeline (Used when exporting)
  59156. * @returns the serialized object
  59157. */
  59158. serialize(): any;
  59159. /**
  59160. * Parse the serialized pipeline
  59161. * @param source Source pipeline.
  59162. * @param scene The scene to load the pipeline to.
  59163. * @param rootUrl The URL of the serialized pipeline.
  59164. * @returns An instantiated pipeline from the serialized object.
  59165. */
  59166. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  59167. /**
  59168. * Luminance steps
  59169. */
  59170. static LuminanceSteps: number;
  59171. }
  59172. }
  59173. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  59174. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  59175. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  59176. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  59177. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  59178. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  59179. }
  59180. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  59181. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  59182. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  59183. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  59184. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  59185. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  59186. }
  59187. declare module "babylonjs/Shaders/tonemap.fragment" {
  59188. /** @hidden */
  59189. export var tonemapPixelShader: {
  59190. name: string;
  59191. shader: string;
  59192. };
  59193. }
  59194. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  59195. import { Camera } from "babylonjs/Cameras/camera";
  59196. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  59197. import "babylonjs/Shaders/tonemap.fragment";
  59198. import { Engine } from "babylonjs/Engines/engine";
  59199. /** Defines operator used for tonemapping */
  59200. export enum TonemappingOperator {
  59201. /** Hable */
  59202. Hable = 0,
  59203. /** Reinhard */
  59204. Reinhard = 1,
  59205. /** HejiDawson */
  59206. HejiDawson = 2,
  59207. /** Photographic */
  59208. Photographic = 3
  59209. }
  59210. /**
  59211. * Defines a post process to apply tone mapping
  59212. */
  59213. export class TonemapPostProcess extends PostProcess {
  59214. private _operator;
  59215. /** Defines the required exposure adjustement */
  59216. exposureAdjustment: number;
  59217. /**
  59218. * Creates a new TonemapPostProcess
  59219. * @param name defines the name of the postprocess
  59220. * @param _operator defines the operator to use
  59221. * @param exposureAdjustment defines the required exposure adjustement
  59222. * @param camera defines the camera to use (can be null)
  59223. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  59224. * @param engine defines the hosting engine (can be ignore if camera is set)
  59225. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  59226. */
  59227. constructor(name: string, _operator: TonemappingOperator,
  59228. /** Defines the required exposure adjustement */
  59229. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  59230. }
  59231. }
  59232. declare module "babylonjs/Shaders/depth.vertex" {
  59233. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  59234. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  59235. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  59236. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  59237. /** @hidden */
  59238. export var depthVertexShader: {
  59239. name: string;
  59240. shader: string;
  59241. };
  59242. }
  59243. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  59244. /** @hidden */
  59245. export var volumetricLightScatteringPixelShader: {
  59246. name: string;
  59247. shader: string;
  59248. };
  59249. }
  59250. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  59251. /** @hidden */
  59252. export var volumetricLightScatteringPassPixelShader: {
  59253. name: string;
  59254. shader: string;
  59255. };
  59256. }
  59257. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  59258. import { Vector3 } from "babylonjs/Maths/math";
  59259. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59260. import { Mesh } from "babylonjs/Meshes/mesh";
  59261. import { Camera } from "babylonjs/Cameras/camera";
  59262. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  59263. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  59264. import { Scene } from "babylonjs/scene";
  59265. import "babylonjs/Meshes/Builders/planeBuilder";
  59266. import "babylonjs/Shaders/depth.vertex";
  59267. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  59268. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  59269. import { Engine } from "babylonjs/Engines/engine";
  59270. /**
  59271. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  59272. */
  59273. export class VolumetricLightScatteringPostProcess extends PostProcess {
  59274. private _volumetricLightScatteringPass;
  59275. private _volumetricLightScatteringRTT;
  59276. private _viewPort;
  59277. private _screenCoordinates;
  59278. private _cachedDefines;
  59279. /**
  59280. * If not undefined, the mesh position is computed from the attached node position
  59281. */
  59282. attachedNode: {
  59283. position: Vector3;
  59284. };
  59285. /**
  59286. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  59287. */
  59288. customMeshPosition: Vector3;
  59289. /**
  59290. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  59291. */
  59292. useCustomMeshPosition: boolean;
  59293. /**
  59294. * If the post-process should inverse the light scattering direction
  59295. */
  59296. invert: boolean;
  59297. /**
  59298. * The internal mesh used by the post-process
  59299. */
  59300. mesh: Mesh;
  59301. /**
  59302. * @hidden
  59303. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  59304. */
  59305. useDiffuseColor: boolean;
  59306. /**
  59307. * Array containing the excluded meshes not rendered in the internal pass
  59308. */
  59309. excludedMeshes: AbstractMesh[];
  59310. /**
  59311. * Controls the overall intensity of the post-process
  59312. */
  59313. exposure: number;
  59314. /**
  59315. * Dissipates each sample's contribution in range [0, 1]
  59316. */
  59317. decay: number;
  59318. /**
  59319. * Controls the overall intensity of each sample
  59320. */
  59321. weight: number;
  59322. /**
  59323. * Controls the density of each sample
  59324. */
  59325. density: number;
  59326. /**
  59327. * @constructor
  59328. * @param name The post-process name
  59329. * @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)
  59330. * @param camera The camera that the post-process will be attached to
  59331. * @param mesh The mesh used to create the light scattering
  59332. * @param samples The post-process quality, default 100
  59333. * @param samplingModeThe post-process filtering mode
  59334. * @param engine The babylon engine
  59335. * @param reusable If the post-process is reusable
  59336. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  59337. */
  59338. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  59339. /**
  59340. * Returns the string "VolumetricLightScatteringPostProcess"
  59341. * @returns "VolumetricLightScatteringPostProcess"
  59342. */
  59343. getClassName(): string;
  59344. private _isReady;
  59345. /**
  59346. * Sets the new light position for light scattering effect
  59347. * @param position The new custom light position
  59348. */
  59349. setCustomMeshPosition(position: Vector3): void;
  59350. /**
  59351. * Returns the light position for light scattering effect
  59352. * @return Vector3 The custom light position
  59353. */
  59354. getCustomMeshPosition(): Vector3;
  59355. /**
  59356. * Disposes the internal assets and detaches the post-process from the camera
  59357. */
  59358. dispose(camera: Camera): void;
  59359. /**
  59360. * Returns the render target texture used by the post-process
  59361. * @return the render target texture used by the post-process
  59362. */
  59363. getPass(): RenderTargetTexture;
  59364. private _meshExcluded;
  59365. private _createPass;
  59366. private _updateMeshScreenCoordinates;
  59367. /**
  59368. * Creates a default mesh for the Volumeric Light Scattering post-process
  59369. * @param name The mesh name
  59370. * @param scene The scene where to create the mesh
  59371. * @return the default mesh
  59372. */
  59373. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  59374. }
  59375. }
  59376. declare module "babylonjs/PostProcesses/index" {
  59377. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  59378. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  59379. export * from "babylonjs/PostProcesses/bloomEffect";
  59380. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  59381. export * from "babylonjs/PostProcesses/blurPostProcess";
  59382. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  59383. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  59384. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  59385. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  59386. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  59387. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  59388. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  59389. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  59390. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  59391. export * from "babylonjs/PostProcesses/filterPostProcess";
  59392. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  59393. export * from "babylonjs/PostProcesses/grainPostProcess";
  59394. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  59395. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  59396. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  59397. export * from "babylonjs/PostProcesses/passPostProcess";
  59398. export * from "babylonjs/PostProcesses/postProcess";
  59399. export * from "babylonjs/PostProcesses/postProcessManager";
  59400. export * from "babylonjs/PostProcesses/refractionPostProcess";
  59401. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  59402. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  59403. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  59404. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  59405. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  59406. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  59407. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  59408. }
  59409. declare module "babylonjs/Probes/index" {
  59410. export * from "babylonjs/Probes/reflectionProbe";
  59411. }
  59412. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  59413. import { Scene } from "babylonjs/scene";
  59414. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59415. import { Color3 } from "babylonjs/Maths/math";
  59416. import { SmartArray } from "babylonjs/Misc/smartArray";
  59417. import { ISceneComponent } from "babylonjs/sceneComponent";
  59418. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  59419. import "babylonjs/Meshes/Builders/boxBuilder";
  59420. import "babylonjs/Shaders/color.fragment";
  59421. import "babylonjs/Shaders/color.vertex";
  59422. module "babylonjs/scene" {
  59423. interface Scene {
  59424. /** @hidden (Backing field) */
  59425. _boundingBoxRenderer: BoundingBoxRenderer;
  59426. /** @hidden (Backing field) */
  59427. _forceShowBoundingBoxes: boolean;
  59428. /**
  59429. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  59430. */
  59431. forceShowBoundingBoxes: boolean;
  59432. /**
  59433. * Gets the bounding box renderer associated with the scene
  59434. * @returns a BoundingBoxRenderer
  59435. */
  59436. getBoundingBoxRenderer(): BoundingBoxRenderer;
  59437. }
  59438. }
  59439. module "babylonjs/Meshes/abstractMesh" {
  59440. interface AbstractMesh {
  59441. /** @hidden (Backing field) */
  59442. _showBoundingBox: boolean;
  59443. /**
  59444. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  59445. */
  59446. showBoundingBox: boolean;
  59447. }
  59448. }
  59449. /**
  59450. * Component responsible of rendering the bounding box of the meshes in a scene.
  59451. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  59452. */
  59453. export class BoundingBoxRenderer implements ISceneComponent {
  59454. /**
  59455. * The component name helpfull to identify the component in the list of scene components.
  59456. */
  59457. readonly name: string;
  59458. /**
  59459. * The scene the component belongs to.
  59460. */
  59461. scene: Scene;
  59462. /**
  59463. * Color of the bounding box lines placed in front of an object
  59464. */
  59465. frontColor: Color3;
  59466. /**
  59467. * Color of the bounding box lines placed behind an object
  59468. */
  59469. backColor: Color3;
  59470. /**
  59471. * Defines if the renderer should show the back lines or not
  59472. */
  59473. showBackLines: boolean;
  59474. /**
  59475. * @hidden
  59476. */
  59477. renderList: SmartArray<BoundingBox>;
  59478. private _colorShader;
  59479. private _vertexBuffers;
  59480. private _indexBuffer;
  59481. /**
  59482. * Instantiates a new bounding box renderer in a scene.
  59483. * @param scene the scene the renderer renders in
  59484. */
  59485. constructor(scene: Scene);
  59486. /**
  59487. * Registers the component in a given scene
  59488. */
  59489. register(): void;
  59490. private _evaluateSubMesh;
  59491. private _activeMesh;
  59492. private _prepareRessources;
  59493. private _createIndexBuffer;
  59494. /**
  59495. * Rebuilds the elements related to this component in case of
  59496. * context lost for instance.
  59497. */
  59498. rebuild(): void;
  59499. /**
  59500. * @hidden
  59501. */
  59502. reset(): void;
  59503. /**
  59504. * Render the bounding boxes of a specific rendering group
  59505. * @param renderingGroupId defines the rendering group to render
  59506. */
  59507. render(renderingGroupId: number): void;
  59508. /**
  59509. * In case of occlusion queries, we can render the occlusion bounding box through this method
  59510. * @param mesh Define the mesh to render the occlusion bounding box for
  59511. */
  59512. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  59513. /**
  59514. * Dispose and release the resources attached to this renderer.
  59515. */
  59516. dispose(): void;
  59517. }
  59518. }
  59519. declare module "babylonjs/Shaders/depth.fragment" {
  59520. /** @hidden */
  59521. export var depthPixelShader: {
  59522. name: string;
  59523. shader: string;
  59524. };
  59525. }
  59526. declare module "babylonjs/Rendering/depthRenderer" {
  59527. import { Nullable } from "babylonjs/types";
  59528. import { SubMesh } from "babylonjs/Meshes/subMesh";
  59529. import { Scene } from "babylonjs/scene";
  59530. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  59531. import { Camera } from "babylonjs/Cameras/camera";
  59532. import "babylonjs/Shaders/depth.fragment";
  59533. import "babylonjs/Shaders/depth.vertex";
  59534. /**
  59535. * This represents a depth renderer in Babylon.
  59536. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  59537. */
  59538. export class DepthRenderer {
  59539. private _scene;
  59540. private _depthMap;
  59541. private _effect;
  59542. private _cachedDefines;
  59543. private _camera;
  59544. /**
  59545. * Specifiess that the depth renderer will only be used within
  59546. * the camera it is created for.
  59547. * This can help forcing its rendering during the camera processing.
  59548. */
  59549. useOnlyInActiveCamera: boolean;
  59550. /** @hidden */
  59551. static _SceneComponentInitialization: (scene: Scene) => void;
  59552. /**
  59553. * Instantiates a depth renderer
  59554. * @param scene The scene the renderer belongs to
  59555. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  59556. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  59557. */
  59558. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  59559. /**
  59560. * Creates the depth rendering effect and checks if the effect is ready.
  59561. * @param subMesh The submesh to be used to render the depth map of
  59562. * @param useInstances If multiple world instances should be used
  59563. * @returns if the depth renderer is ready to render the depth map
  59564. */
  59565. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  59566. /**
  59567. * Gets the texture which the depth map will be written to.
  59568. * @returns The depth map texture
  59569. */
  59570. getDepthMap(): RenderTargetTexture;
  59571. /**
  59572. * Disposes of the depth renderer.
  59573. */
  59574. dispose(): void;
  59575. }
  59576. }
  59577. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  59578. import { Nullable } from "babylonjs/types";
  59579. import { Scene } from "babylonjs/scene";
  59580. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  59581. import { Camera } from "babylonjs/Cameras/camera";
  59582. import { ISceneComponent } from "babylonjs/sceneComponent";
  59583. module "babylonjs/scene" {
  59584. interface Scene {
  59585. /** @hidden (Backing field) */
  59586. _depthRenderer: {
  59587. [id: string]: DepthRenderer;
  59588. };
  59589. /**
  59590. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  59591. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  59592. * @returns the created depth renderer
  59593. */
  59594. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  59595. /**
  59596. * Disables a depth renderer for a given camera
  59597. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  59598. */
  59599. disableDepthRenderer(camera?: Nullable<Camera>): void;
  59600. }
  59601. }
  59602. /**
  59603. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  59604. * in several rendering techniques.
  59605. */
  59606. export class DepthRendererSceneComponent implements ISceneComponent {
  59607. /**
  59608. * The component name helpfull to identify the component in the list of scene components.
  59609. */
  59610. readonly name: string;
  59611. /**
  59612. * The scene the component belongs to.
  59613. */
  59614. scene: Scene;
  59615. /**
  59616. * Creates a new instance of the component for the given scene
  59617. * @param scene Defines the scene to register the component in
  59618. */
  59619. constructor(scene: Scene);
  59620. /**
  59621. * Registers the component in a given scene
  59622. */
  59623. register(): void;
  59624. /**
  59625. * Rebuilds the elements related to this component in case of
  59626. * context lost for instance.
  59627. */
  59628. rebuild(): void;
  59629. /**
  59630. * Disposes the component and the associated ressources
  59631. */
  59632. dispose(): void;
  59633. private _gatherRenderTargets;
  59634. private _gatherActiveCameraRenderTargets;
  59635. }
  59636. }
  59637. declare module "babylonjs/Shaders/outline.fragment" {
  59638. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  59639. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  59640. /** @hidden */
  59641. export var outlinePixelShader: {
  59642. name: string;
  59643. shader: string;
  59644. };
  59645. }
  59646. declare module "babylonjs/Shaders/outline.vertex" {
  59647. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  59648. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  59649. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  59650. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  59651. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  59652. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  59653. /** @hidden */
  59654. export var outlineVertexShader: {
  59655. name: string;
  59656. shader: string;
  59657. };
  59658. }
  59659. declare module "babylonjs/Rendering/outlineRenderer" {
  59660. import { SubMesh } from "babylonjs/Meshes/subMesh";
  59661. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  59662. import { Scene } from "babylonjs/scene";
  59663. import { ISceneComponent } from "babylonjs/sceneComponent";
  59664. import "babylonjs/Shaders/outline.fragment";
  59665. import "babylonjs/Shaders/outline.vertex";
  59666. module "babylonjs/scene" {
  59667. interface Scene {
  59668. /** @hidden */
  59669. _outlineRenderer: OutlineRenderer;
  59670. /**
  59671. * Gets the outline renderer associated with the scene
  59672. * @returns a OutlineRenderer
  59673. */
  59674. getOutlineRenderer(): OutlineRenderer;
  59675. }
  59676. }
  59677. module "babylonjs/Meshes/abstractMesh" {
  59678. interface AbstractMesh {
  59679. /** @hidden (Backing field) */
  59680. _renderOutline: boolean;
  59681. /**
  59682. * Gets or sets a boolean indicating if the outline must be rendered as well
  59683. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  59684. */
  59685. renderOutline: boolean;
  59686. /** @hidden (Backing field) */
  59687. _renderOverlay: boolean;
  59688. /**
  59689. * Gets or sets a boolean indicating if the overlay must be rendered as well
  59690. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  59691. */
  59692. renderOverlay: boolean;
  59693. }
  59694. }
  59695. /**
  59696. * This class is responsible to draw bothe outline/overlay of meshes.
  59697. * It should not be used directly but through the available method on mesh.
  59698. */
  59699. export class OutlineRenderer implements ISceneComponent {
  59700. /**
  59701. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  59702. */
  59703. private static _StencilReference;
  59704. /**
  59705. * The name of the component. Each component must have a unique name.
  59706. */
  59707. name: string;
  59708. /**
  59709. * The scene the component belongs to.
  59710. */
  59711. scene: Scene;
  59712. /**
  59713. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  59714. */
  59715. zOffset: number;
  59716. private _engine;
  59717. private _effect;
  59718. private _cachedDefines;
  59719. private _savedDepthWrite;
  59720. /**
  59721. * Instantiates a new outline renderer. (There could be only one per scene).
  59722. * @param scene Defines the scene it belongs to
  59723. */
  59724. constructor(scene: Scene);
  59725. /**
  59726. * Register the component to one instance of a scene.
  59727. */
  59728. register(): void;
  59729. /**
  59730. * Rebuilds the elements related to this component in case of
  59731. * context lost for instance.
  59732. */
  59733. rebuild(): void;
  59734. /**
  59735. * Disposes the component and the associated ressources.
  59736. */
  59737. dispose(): void;
  59738. /**
  59739. * Renders the outline in the canvas.
  59740. * @param subMesh Defines the sumesh to render
  59741. * @param batch Defines the batch of meshes in case of instances
  59742. * @param useOverlay Defines if the rendering is for the overlay or the outline
  59743. */
  59744. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  59745. /**
  59746. * Returns whether or not the outline renderer is ready for a given submesh.
  59747. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  59748. * @param subMesh Defines the submesh to check readyness for
  59749. * @param useInstances Defines wheter wee are trying to render instances or not
  59750. * @returns true if ready otherwise false
  59751. */
  59752. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  59753. private _beforeRenderingMesh;
  59754. private _afterRenderingMesh;
  59755. }
  59756. }
  59757. declare module "babylonjs/Rendering/index" {
  59758. export * from "babylonjs/Rendering/boundingBoxRenderer";
  59759. export * from "babylonjs/Rendering/depthRenderer";
  59760. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  59761. export * from "babylonjs/Rendering/edgesRenderer";
  59762. export * from "babylonjs/Rendering/geometryBufferRenderer";
  59763. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  59764. export * from "babylonjs/Rendering/outlineRenderer";
  59765. export * from "babylonjs/Rendering/renderingGroup";
  59766. export * from "babylonjs/Rendering/renderingManager";
  59767. export * from "babylonjs/Rendering/utilityLayerRenderer";
  59768. }
  59769. declare module "babylonjs/Sprites/index" {
  59770. export * from "babylonjs/Sprites/sprite";
  59771. export * from "babylonjs/Sprites/spriteManager";
  59772. export * from "babylonjs/Sprites/spriteSceneComponent";
  59773. }
  59774. declare module "babylonjs/Misc/assetsManager" {
  59775. import { Scene } from "babylonjs/scene";
  59776. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59777. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  59778. import { Skeleton } from "babylonjs/Bones/skeleton";
  59779. import { Observable } from "babylonjs/Misc/observable";
  59780. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59781. import { Texture } from "babylonjs/Materials/Textures/texture";
  59782. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  59783. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  59784. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  59785. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  59786. /**
  59787. * Defines the list of states available for a task inside a AssetsManager
  59788. */
  59789. export enum AssetTaskState {
  59790. /**
  59791. * Initialization
  59792. */
  59793. INIT = 0,
  59794. /**
  59795. * Running
  59796. */
  59797. RUNNING = 1,
  59798. /**
  59799. * Done
  59800. */
  59801. DONE = 2,
  59802. /**
  59803. * Error
  59804. */
  59805. ERROR = 3
  59806. }
  59807. /**
  59808. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  59809. */
  59810. export abstract class AbstractAssetTask {
  59811. /**
  59812. * Task name
  59813. */ name: string;
  59814. /**
  59815. * Callback called when the task is successful
  59816. */
  59817. onSuccess: (task: any) => void;
  59818. /**
  59819. * Callback called when the task is not successful
  59820. */
  59821. onError: (task: any, message?: string, exception?: any) => void;
  59822. /**
  59823. * Creates a new AssetsManager
  59824. * @param name defines the name of the task
  59825. */
  59826. constructor(
  59827. /**
  59828. * Task name
  59829. */ name: string);
  59830. private _isCompleted;
  59831. private _taskState;
  59832. private _errorObject;
  59833. /**
  59834. * Get if the task is completed
  59835. */
  59836. readonly isCompleted: boolean;
  59837. /**
  59838. * Gets the current state of the task
  59839. */
  59840. readonly taskState: AssetTaskState;
  59841. /**
  59842. * Gets the current error object (if task is in error)
  59843. */
  59844. readonly errorObject: {
  59845. message?: string;
  59846. exception?: any;
  59847. };
  59848. /**
  59849. * Internal only
  59850. * @hidden
  59851. */
  59852. _setErrorObject(message?: string, exception?: any): void;
  59853. /**
  59854. * Execute the current task
  59855. * @param scene defines the scene where you want your assets to be loaded
  59856. * @param onSuccess is a callback called when the task is successfully executed
  59857. * @param onError is a callback called if an error occurs
  59858. */
  59859. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  59860. /**
  59861. * Execute the current task
  59862. * @param scene defines the scene where you want your assets to be loaded
  59863. * @param onSuccess is a callback called when the task is successfully executed
  59864. * @param onError is a callback called if an error occurs
  59865. */
  59866. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  59867. /**
  59868. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  59869. * This can be used with failed tasks that have the reason for failure fixed.
  59870. */
  59871. reset(): void;
  59872. private onErrorCallback;
  59873. private onDoneCallback;
  59874. }
  59875. /**
  59876. * Define the interface used by progress events raised during assets loading
  59877. */
  59878. export interface IAssetsProgressEvent {
  59879. /**
  59880. * Defines the number of remaining tasks to process
  59881. */
  59882. remainingCount: number;
  59883. /**
  59884. * Defines the total number of tasks
  59885. */
  59886. totalCount: number;
  59887. /**
  59888. * Defines the task that was just processed
  59889. */
  59890. task: AbstractAssetTask;
  59891. }
  59892. /**
  59893. * Class used to share progress information about assets loading
  59894. */
  59895. export class AssetsProgressEvent implements IAssetsProgressEvent {
  59896. /**
  59897. * Defines the number of remaining tasks to process
  59898. */
  59899. remainingCount: number;
  59900. /**
  59901. * Defines the total number of tasks
  59902. */
  59903. totalCount: number;
  59904. /**
  59905. * Defines the task that was just processed
  59906. */
  59907. task: AbstractAssetTask;
  59908. /**
  59909. * Creates a AssetsProgressEvent
  59910. * @param remainingCount defines the number of remaining tasks to process
  59911. * @param totalCount defines the total number of tasks
  59912. * @param task defines the task that was just processed
  59913. */
  59914. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  59915. }
  59916. /**
  59917. * Define a task used by AssetsManager to load meshes
  59918. */
  59919. export class MeshAssetTask extends AbstractAssetTask {
  59920. /**
  59921. * Defines the name of the task
  59922. */
  59923. name: string;
  59924. /**
  59925. * Defines the list of mesh's names you want to load
  59926. */
  59927. meshesNames: any;
  59928. /**
  59929. * Defines the root url to use as a base to load your meshes and associated resources
  59930. */
  59931. rootUrl: string;
  59932. /**
  59933. * Defines the filename of the scene to load from
  59934. */
  59935. sceneFilename: string;
  59936. /**
  59937. * Gets the list of loaded meshes
  59938. */
  59939. loadedMeshes: Array<AbstractMesh>;
  59940. /**
  59941. * Gets the list of loaded particle systems
  59942. */
  59943. loadedParticleSystems: Array<IParticleSystem>;
  59944. /**
  59945. * Gets the list of loaded skeletons
  59946. */
  59947. loadedSkeletons: Array<Skeleton>;
  59948. /**
  59949. * Gets the list of loaded animation groups
  59950. */
  59951. loadedAnimationGroups: Array<AnimationGroup>;
  59952. /**
  59953. * Callback called when the task is successful
  59954. */
  59955. onSuccess: (task: MeshAssetTask) => void;
  59956. /**
  59957. * Callback called when the task is successful
  59958. */
  59959. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  59960. /**
  59961. * Creates a new MeshAssetTask
  59962. * @param name defines the name of the task
  59963. * @param meshesNames defines the list of mesh's names you want to load
  59964. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  59965. * @param sceneFilename defines the filename of the scene to load from
  59966. */
  59967. constructor(
  59968. /**
  59969. * Defines the name of the task
  59970. */
  59971. name: string,
  59972. /**
  59973. * Defines the list of mesh's names you want to load
  59974. */
  59975. meshesNames: any,
  59976. /**
  59977. * Defines the root url to use as a base to load your meshes and associated resources
  59978. */
  59979. rootUrl: string,
  59980. /**
  59981. * Defines the filename of the scene to load from
  59982. */
  59983. sceneFilename: string);
  59984. /**
  59985. * Execute the current task
  59986. * @param scene defines the scene where you want your assets to be loaded
  59987. * @param onSuccess is a callback called when the task is successfully executed
  59988. * @param onError is a callback called if an error occurs
  59989. */
  59990. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  59991. }
  59992. /**
  59993. * Define a task used by AssetsManager to load text content
  59994. */
  59995. export class TextFileAssetTask extends AbstractAssetTask {
  59996. /**
  59997. * Defines the name of the task
  59998. */
  59999. name: string;
  60000. /**
  60001. * Defines the location of the file to load
  60002. */
  60003. url: string;
  60004. /**
  60005. * Gets the loaded text string
  60006. */
  60007. text: string;
  60008. /**
  60009. * Callback called when the task is successful
  60010. */
  60011. onSuccess: (task: TextFileAssetTask) => void;
  60012. /**
  60013. * Callback called when the task is successful
  60014. */
  60015. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  60016. /**
  60017. * Creates a new TextFileAssetTask object
  60018. * @param name defines the name of the task
  60019. * @param url defines the location of the file to load
  60020. */
  60021. constructor(
  60022. /**
  60023. * Defines the name of the task
  60024. */
  60025. name: string,
  60026. /**
  60027. * Defines the location of the file to load
  60028. */
  60029. url: string);
  60030. /**
  60031. * Execute the current task
  60032. * @param scene defines the scene where you want your assets to be loaded
  60033. * @param onSuccess is a callback called when the task is successfully executed
  60034. * @param onError is a callback called if an error occurs
  60035. */
  60036. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60037. }
  60038. /**
  60039. * Define a task used by AssetsManager to load binary data
  60040. */
  60041. export class BinaryFileAssetTask extends AbstractAssetTask {
  60042. /**
  60043. * Defines the name of the task
  60044. */
  60045. name: string;
  60046. /**
  60047. * Defines the location of the file to load
  60048. */
  60049. url: string;
  60050. /**
  60051. * Gets the lodaded data (as an array buffer)
  60052. */
  60053. data: ArrayBuffer;
  60054. /**
  60055. * Callback called when the task is successful
  60056. */
  60057. onSuccess: (task: BinaryFileAssetTask) => void;
  60058. /**
  60059. * Callback called when the task is successful
  60060. */
  60061. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  60062. /**
  60063. * Creates a new BinaryFileAssetTask object
  60064. * @param name defines the name of the new task
  60065. * @param url defines the location of the file to load
  60066. */
  60067. constructor(
  60068. /**
  60069. * Defines the name of the task
  60070. */
  60071. name: string,
  60072. /**
  60073. * Defines the location of the file to load
  60074. */
  60075. url: string);
  60076. /**
  60077. * Execute the current task
  60078. * @param scene defines the scene where you want your assets to be loaded
  60079. * @param onSuccess is a callback called when the task is successfully executed
  60080. * @param onError is a callback called if an error occurs
  60081. */
  60082. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60083. }
  60084. /**
  60085. * Define a task used by AssetsManager to load images
  60086. */
  60087. export class ImageAssetTask extends AbstractAssetTask {
  60088. /**
  60089. * Defines the name of the task
  60090. */
  60091. name: string;
  60092. /**
  60093. * Defines the location of the image to load
  60094. */
  60095. url: string;
  60096. /**
  60097. * Gets the loaded images
  60098. */
  60099. image: HTMLImageElement;
  60100. /**
  60101. * Callback called when the task is successful
  60102. */
  60103. onSuccess: (task: ImageAssetTask) => void;
  60104. /**
  60105. * Callback called when the task is successful
  60106. */
  60107. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  60108. /**
  60109. * Creates a new ImageAssetTask
  60110. * @param name defines the name of the task
  60111. * @param url defines the location of the image to load
  60112. */
  60113. constructor(
  60114. /**
  60115. * Defines the name of the task
  60116. */
  60117. name: string,
  60118. /**
  60119. * Defines the location of the image to load
  60120. */
  60121. url: string);
  60122. /**
  60123. * Execute the current task
  60124. * @param scene defines the scene where you want your assets to be loaded
  60125. * @param onSuccess is a callback called when the task is successfully executed
  60126. * @param onError is a callback called if an error occurs
  60127. */
  60128. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60129. }
  60130. /**
  60131. * Defines the interface used by texture loading tasks
  60132. */
  60133. export interface ITextureAssetTask<TEX extends BaseTexture> {
  60134. /**
  60135. * Gets the loaded texture
  60136. */
  60137. texture: TEX;
  60138. }
  60139. /**
  60140. * Define a task used by AssetsManager to load 2D textures
  60141. */
  60142. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  60143. /**
  60144. * Defines the name of the task
  60145. */
  60146. name: string;
  60147. /**
  60148. * Defines the location of the file to load
  60149. */
  60150. url: string;
  60151. /**
  60152. * Defines if mipmap should not be generated (default is false)
  60153. */
  60154. noMipmap?: boolean | undefined;
  60155. /**
  60156. * Defines if texture must be inverted on Y axis (default is false)
  60157. */
  60158. invertY?: boolean | undefined;
  60159. /**
  60160. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  60161. */
  60162. samplingMode: number;
  60163. /**
  60164. * Gets the loaded texture
  60165. */
  60166. texture: Texture;
  60167. /**
  60168. * Callback called when the task is successful
  60169. */
  60170. onSuccess: (task: TextureAssetTask) => void;
  60171. /**
  60172. * Callback called when the task is successful
  60173. */
  60174. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  60175. /**
  60176. * Creates a new TextureAssetTask object
  60177. * @param name defines the name of the task
  60178. * @param url defines the location of the file to load
  60179. * @param noMipmap defines if mipmap should not be generated (default is false)
  60180. * @param invertY defines if texture must be inverted on Y axis (default is false)
  60181. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  60182. */
  60183. constructor(
  60184. /**
  60185. * Defines the name of the task
  60186. */
  60187. name: string,
  60188. /**
  60189. * Defines the location of the file to load
  60190. */
  60191. url: string,
  60192. /**
  60193. * Defines if mipmap should not be generated (default is false)
  60194. */
  60195. noMipmap?: boolean | undefined,
  60196. /**
  60197. * Defines if texture must be inverted on Y axis (default is false)
  60198. */
  60199. invertY?: boolean | undefined,
  60200. /**
  60201. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  60202. */
  60203. samplingMode?: number);
  60204. /**
  60205. * Execute the current task
  60206. * @param scene defines the scene where you want your assets to be loaded
  60207. * @param onSuccess is a callback called when the task is successfully executed
  60208. * @param onError is a callback called if an error occurs
  60209. */
  60210. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60211. }
  60212. /**
  60213. * Define a task used by AssetsManager to load cube textures
  60214. */
  60215. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  60216. /**
  60217. * Defines the name of the task
  60218. */
  60219. name: string;
  60220. /**
  60221. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  60222. */
  60223. url: string;
  60224. /**
  60225. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  60226. */
  60227. extensions?: string[] | undefined;
  60228. /**
  60229. * Defines if mipmaps should not be generated (default is false)
  60230. */
  60231. noMipmap?: boolean | undefined;
  60232. /**
  60233. * Defines the explicit list of files (undefined by default)
  60234. */
  60235. files?: string[] | undefined;
  60236. /**
  60237. * Gets the loaded texture
  60238. */
  60239. texture: CubeTexture;
  60240. /**
  60241. * Callback called when the task is successful
  60242. */
  60243. onSuccess: (task: CubeTextureAssetTask) => void;
  60244. /**
  60245. * Callback called when the task is successful
  60246. */
  60247. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  60248. /**
  60249. * Creates a new CubeTextureAssetTask
  60250. * @param name defines the name of the task
  60251. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  60252. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  60253. * @param noMipmap defines if mipmaps should not be generated (default is false)
  60254. * @param files defines the explicit list of files (undefined by default)
  60255. */
  60256. constructor(
  60257. /**
  60258. * Defines the name of the task
  60259. */
  60260. name: string,
  60261. /**
  60262. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  60263. */
  60264. url: string,
  60265. /**
  60266. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  60267. */
  60268. extensions?: string[] | undefined,
  60269. /**
  60270. * Defines if mipmaps should not be generated (default is false)
  60271. */
  60272. noMipmap?: boolean | undefined,
  60273. /**
  60274. * Defines the explicit list of files (undefined by default)
  60275. */
  60276. files?: string[] | undefined);
  60277. /**
  60278. * Execute the current task
  60279. * @param scene defines the scene where you want your assets to be loaded
  60280. * @param onSuccess is a callback called when the task is successfully executed
  60281. * @param onError is a callback called if an error occurs
  60282. */
  60283. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60284. }
  60285. /**
  60286. * Define a task used by AssetsManager to load HDR cube textures
  60287. */
  60288. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  60289. /**
  60290. * Defines the name of the task
  60291. */
  60292. name: string;
  60293. /**
  60294. * Defines the location of the file to load
  60295. */
  60296. url: string;
  60297. /**
  60298. * Defines the desired size (the more it increases the longer the generation will be)
  60299. */
  60300. size: number;
  60301. /**
  60302. * Defines if mipmaps should not be generated (default is false)
  60303. */
  60304. noMipmap: boolean;
  60305. /**
  60306. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  60307. */
  60308. generateHarmonics: boolean;
  60309. /**
  60310. * 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)
  60311. */
  60312. gammaSpace: boolean;
  60313. /**
  60314. * Internal Use Only
  60315. */
  60316. reserved: boolean;
  60317. /**
  60318. * Gets the loaded texture
  60319. */
  60320. texture: HDRCubeTexture;
  60321. /**
  60322. * Callback called when the task is successful
  60323. */
  60324. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  60325. /**
  60326. * Callback called when the task is successful
  60327. */
  60328. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  60329. /**
  60330. * Creates a new HDRCubeTextureAssetTask object
  60331. * @param name defines the name of the task
  60332. * @param url defines the location of the file to load
  60333. * @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.
  60334. * @param noMipmap defines if mipmaps should not be generated (default is false)
  60335. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  60336. * @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)
  60337. * @param reserved Internal use only
  60338. */
  60339. constructor(
  60340. /**
  60341. * Defines the name of the task
  60342. */
  60343. name: string,
  60344. /**
  60345. * Defines the location of the file to load
  60346. */
  60347. url: string,
  60348. /**
  60349. * Defines the desired size (the more it increases the longer the generation will be)
  60350. */
  60351. size: number,
  60352. /**
  60353. * Defines if mipmaps should not be generated (default is false)
  60354. */
  60355. noMipmap?: boolean,
  60356. /**
  60357. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  60358. */
  60359. generateHarmonics?: boolean,
  60360. /**
  60361. * 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)
  60362. */
  60363. gammaSpace?: boolean,
  60364. /**
  60365. * Internal Use Only
  60366. */
  60367. reserved?: boolean);
  60368. /**
  60369. * Execute the current task
  60370. * @param scene defines the scene where you want your assets to be loaded
  60371. * @param onSuccess is a callback called when the task is successfully executed
  60372. * @param onError is a callback called if an error occurs
  60373. */
  60374. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60375. }
  60376. /**
  60377. * Define a task used by AssetsManager to load Equirectangular cube textures
  60378. */
  60379. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  60380. /**
  60381. * Defines the name of the task
  60382. */
  60383. name: string;
  60384. /**
  60385. * Defines the location of the file to load
  60386. */
  60387. url: string;
  60388. /**
  60389. * Defines the desired size (the more it increases the longer the generation will be)
  60390. */
  60391. size: number;
  60392. /**
  60393. * Defines if mipmaps should not be generated (default is false)
  60394. */
  60395. noMipmap: boolean;
  60396. /**
  60397. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  60398. * but the standard material would require them in Gamma space) (default is true)
  60399. */
  60400. gammaSpace: boolean;
  60401. /**
  60402. * Gets the loaded texture
  60403. */
  60404. texture: EquiRectangularCubeTexture;
  60405. /**
  60406. * Callback called when the task is successful
  60407. */
  60408. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  60409. /**
  60410. * Callback called when the task is successful
  60411. */
  60412. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  60413. /**
  60414. * Creates a new EquiRectangularCubeTextureAssetTask object
  60415. * @param name defines the name of the task
  60416. * @param url defines the location of the file to load
  60417. * @param size defines the desired size (the more it increases the longer the generation will be)
  60418. * If the size is omitted this implies you are using a preprocessed cubemap.
  60419. * @param noMipmap defines if mipmaps should not be generated (default is false)
  60420. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  60421. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  60422. * (default is true)
  60423. */
  60424. constructor(
  60425. /**
  60426. * Defines the name of the task
  60427. */
  60428. name: string,
  60429. /**
  60430. * Defines the location of the file to load
  60431. */
  60432. url: string,
  60433. /**
  60434. * Defines the desired size (the more it increases the longer the generation will be)
  60435. */
  60436. size: number,
  60437. /**
  60438. * Defines if mipmaps should not be generated (default is false)
  60439. */
  60440. noMipmap?: boolean,
  60441. /**
  60442. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  60443. * but the standard material would require them in Gamma space) (default is true)
  60444. */
  60445. gammaSpace?: boolean);
  60446. /**
  60447. * Execute the current task
  60448. * @param scene defines the scene where you want your assets to be loaded
  60449. * @param onSuccess is a callback called when the task is successfully executed
  60450. * @param onError is a callback called if an error occurs
  60451. */
  60452. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60453. }
  60454. /**
  60455. * This class can be used to easily import assets into a scene
  60456. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  60457. */
  60458. export class AssetsManager {
  60459. private _scene;
  60460. private _isLoading;
  60461. protected _tasks: AbstractAssetTask[];
  60462. protected _waitingTasksCount: number;
  60463. protected _totalTasksCount: number;
  60464. /**
  60465. * Callback called when all tasks are processed
  60466. */
  60467. onFinish: (tasks: AbstractAssetTask[]) => void;
  60468. /**
  60469. * Callback called when a task is successful
  60470. */
  60471. onTaskSuccess: (task: AbstractAssetTask) => void;
  60472. /**
  60473. * Callback called when a task had an error
  60474. */
  60475. onTaskError: (task: AbstractAssetTask) => void;
  60476. /**
  60477. * Callback called when a task is done (whatever the result is)
  60478. */
  60479. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  60480. /**
  60481. * Observable called when all tasks are processed
  60482. */
  60483. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  60484. /**
  60485. * Observable called when a task had an error
  60486. */
  60487. onTaskErrorObservable: Observable<AbstractAssetTask>;
  60488. /**
  60489. * Observable called when all tasks were executed
  60490. */
  60491. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  60492. /**
  60493. * Observable called when a task is done (whatever the result is)
  60494. */
  60495. onProgressObservable: Observable<IAssetsProgressEvent>;
  60496. /**
  60497. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  60498. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  60499. */
  60500. useDefaultLoadingScreen: boolean;
  60501. /**
  60502. * Creates a new AssetsManager
  60503. * @param scene defines the scene to work on
  60504. */
  60505. constructor(scene: Scene);
  60506. /**
  60507. * Add a MeshAssetTask to the list of active tasks
  60508. * @param taskName defines the name of the new task
  60509. * @param meshesNames defines the name of meshes to load
  60510. * @param rootUrl defines the root url to use to locate files
  60511. * @param sceneFilename defines the filename of the scene file
  60512. * @returns a new MeshAssetTask object
  60513. */
  60514. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  60515. /**
  60516. * Add a TextFileAssetTask to the list of active tasks
  60517. * @param taskName defines the name of the new task
  60518. * @param url defines the url of the file to load
  60519. * @returns a new TextFileAssetTask object
  60520. */
  60521. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  60522. /**
  60523. * Add a BinaryFileAssetTask to the list of active tasks
  60524. * @param taskName defines the name of the new task
  60525. * @param url defines the url of the file to load
  60526. * @returns a new BinaryFileAssetTask object
  60527. */
  60528. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  60529. /**
  60530. * Add a ImageAssetTask to the list of active tasks
  60531. * @param taskName defines the name of the new task
  60532. * @param url defines the url of the file to load
  60533. * @returns a new ImageAssetTask object
  60534. */
  60535. addImageTask(taskName: string, url: string): ImageAssetTask;
  60536. /**
  60537. * Add a TextureAssetTask to the list of active tasks
  60538. * @param taskName defines the name of the new task
  60539. * @param url defines the url of the file to load
  60540. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  60541. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  60542. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  60543. * @returns a new TextureAssetTask object
  60544. */
  60545. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  60546. /**
  60547. * Add a CubeTextureAssetTask to the list of active tasks
  60548. * @param taskName defines the name of the new task
  60549. * @param url defines the url of the file to load
  60550. * @param extensions defines the extension to use to load the cube map (can be null)
  60551. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  60552. * @param files defines the list of files to load (can be null)
  60553. * @returns a new CubeTextureAssetTask object
  60554. */
  60555. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  60556. /**
  60557. *
  60558. * Add a HDRCubeTextureAssetTask to the list of active tasks
  60559. * @param taskName defines the name of the new task
  60560. * @param url defines the url of the file to load
  60561. * @param size defines the size you want for the cubemap (can be null)
  60562. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  60563. * @param generateHarmonics defines if you want to automatically generate (true by default)
  60564. * @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)
  60565. * @param reserved Internal use only
  60566. * @returns a new HDRCubeTextureAssetTask object
  60567. */
  60568. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  60569. /**
  60570. *
  60571. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  60572. * @param taskName defines the name of the new task
  60573. * @param url defines the url of the file to load
  60574. * @param size defines the size you want for the cubemap (can be null)
  60575. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  60576. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  60577. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  60578. * @returns a new EquiRectangularCubeTextureAssetTask object
  60579. */
  60580. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  60581. /**
  60582. * Remove a task from the assets manager.
  60583. * @param task the task to remove
  60584. */
  60585. removeTask(task: AbstractAssetTask): void;
  60586. private _decreaseWaitingTasksCount;
  60587. private _runTask;
  60588. /**
  60589. * Reset the AssetsManager and remove all tasks
  60590. * @return the current instance of the AssetsManager
  60591. */
  60592. reset(): AssetsManager;
  60593. /**
  60594. * Start the loading process
  60595. * @return the current instance of the AssetsManager
  60596. */
  60597. load(): AssetsManager;
  60598. /**
  60599. * Start the loading process as an async operation
  60600. * @return a promise returning the list of failed tasks
  60601. */
  60602. loadAsync(): Promise<void>;
  60603. }
  60604. }
  60605. declare module "babylonjs/Misc/deferred" {
  60606. /**
  60607. * Wrapper class for promise with external resolve and reject.
  60608. */
  60609. export class Deferred<T> {
  60610. /**
  60611. * The promise associated with this deferred object.
  60612. */
  60613. readonly promise: Promise<T>;
  60614. private _resolve;
  60615. private _reject;
  60616. /**
  60617. * The resolve method of the promise associated with this deferred object.
  60618. */
  60619. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  60620. /**
  60621. * The reject method of the promise associated with this deferred object.
  60622. */
  60623. readonly reject: (reason?: any) => void;
  60624. /**
  60625. * Constructor for this deferred object.
  60626. */
  60627. constructor();
  60628. }
  60629. }
  60630. declare module "babylonjs/Misc/meshExploder" {
  60631. import { Mesh } from "babylonjs/Meshes/mesh";
  60632. /**
  60633. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  60634. */
  60635. export class MeshExploder {
  60636. private _centerMesh;
  60637. private _meshes;
  60638. private _meshesOrigins;
  60639. private _toCenterVectors;
  60640. private _scaledDirection;
  60641. private _newPosition;
  60642. private _centerPosition;
  60643. /**
  60644. * Explodes meshes from a center mesh.
  60645. * @param meshes The meshes to explode.
  60646. * @param centerMesh The mesh to be center of explosion.
  60647. */
  60648. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  60649. private _setCenterMesh;
  60650. /**
  60651. * Get class name
  60652. * @returns "MeshExploder"
  60653. */
  60654. getClassName(): string;
  60655. /**
  60656. * "Exploded meshes"
  60657. * @returns Array of meshes with the centerMesh at index 0.
  60658. */
  60659. getMeshes(): Array<Mesh>;
  60660. /**
  60661. * Explodes meshes giving a specific direction
  60662. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  60663. */
  60664. explode(direction?: number): void;
  60665. }
  60666. }
  60667. declare module "babylonjs/Misc/filesInput" {
  60668. import { Engine } from "babylonjs/Engines/engine";
  60669. import { Scene } from "babylonjs/scene";
  60670. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  60671. /**
  60672. * Class used to help managing file picking and drag'n'drop
  60673. */
  60674. export class FilesInput {
  60675. /**
  60676. * List of files ready to be loaded
  60677. */
  60678. static readonly FilesToLoad: {
  60679. [key: string]: File;
  60680. };
  60681. /**
  60682. * Callback called when a file is processed
  60683. */
  60684. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  60685. private _engine;
  60686. private _currentScene;
  60687. private _sceneLoadedCallback;
  60688. private _progressCallback;
  60689. private _additionalRenderLoopLogicCallback;
  60690. private _textureLoadingCallback;
  60691. private _startingProcessingFilesCallback;
  60692. private _onReloadCallback;
  60693. private _errorCallback;
  60694. private _elementToMonitor;
  60695. private _sceneFileToLoad;
  60696. private _filesToLoad;
  60697. /**
  60698. * Creates a new FilesInput
  60699. * @param engine defines the rendering engine
  60700. * @param scene defines the hosting scene
  60701. * @param sceneLoadedCallback callback called when scene is loaded
  60702. * @param progressCallback callback called to track progress
  60703. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  60704. * @param textureLoadingCallback callback called when a texture is loading
  60705. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  60706. * @param onReloadCallback callback called when a reload is requested
  60707. * @param errorCallback callback call if an error occurs
  60708. */
  60709. 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);
  60710. private _dragEnterHandler;
  60711. private _dragOverHandler;
  60712. private _dropHandler;
  60713. /**
  60714. * Calls this function to listen to drag'n'drop events on a specific DOM element
  60715. * @param elementToMonitor defines the DOM element to track
  60716. */
  60717. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  60718. /**
  60719. * Release all associated resources
  60720. */
  60721. dispose(): void;
  60722. private renderFunction;
  60723. private drag;
  60724. private drop;
  60725. private _traverseFolder;
  60726. private _processFiles;
  60727. /**
  60728. * Load files from a drop event
  60729. * @param event defines the drop event to use as source
  60730. */
  60731. loadFiles(event: any): void;
  60732. private _processReload;
  60733. /**
  60734. * Reload the current scene from the loaded files
  60735. */
  60736. reload(): void;
  60737. }
  60738. }
  60739. declare module "babylonjs/Misc/HighDynamicRange/index" {
  60740. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  60741. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  60742. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  60743. }
  60744. declare module "babylonjs/Misc/sceneOptimizer" {
  60745. import { Scene, IDisposable } from "babylonjs/scene";
  60746. import { Observable } from "babylonjs/Misc/observable";
  60747. /**
  60748. * Defines the root class used to create scene optimization to use with SceneOptimizer
  60749. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  60750. */
  60751. export class SceneOptimization {
  60752. /**
  60753. * Defines the priority of this optimization (0 by default which means first in the list)
  60754. */
  60755. priority: number;
  60756. /**
  60757. * Gets a string describing the action executed by the current optimization
  60758. * @returns description string
  60759. */
  60760. getDescription(): string;
  60761. /**
  60762. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  60763. * @param scene defines the current scene where to apply this optimization
  60764. * @param optimizer defines the current optimizer
  60765. * @returns true if everything that can be done was applied
  60766. */
  60767. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  60768. /**
  60769. * Creates the SceneOptimization object
  60770. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  60771. * @param desc defines the description associated with the optimization
  60772. */
  60773. constructor(
  60774. /**
  60775. * Defines the priority of this optimization (0 by default which means first in the list)
  60776. */
  60777. priority?: number);
  60778. }
  60779. /**
  60780. * Defines an optimization used to reduce the size of render target textures
  60781. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  60782. */
  60783. export class TextureOptimization extends SceneOptimization {
  60784. /**
  60785. * Defines the priority of this optimization (0 by default which means first in the list)
  60786. */
  60787. priority: number;
  60788. /**
  60789. * 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
  60790. */
  60791. maximumSize: number;
  60792. /**
  60793. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  60794. */
  60795. step: number;
  60796. /**
  60797. * Gets a string describing the action executed by the current optimization
  60798. * @returns description string
  60799. */
  60800. getDescription(): string;
  60801. /**
  60802. * Creates the TextureOptimization object
  60803. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  60804. * @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
  60805. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  60806. */
  60807. constructor(
  60808. /**
  60809. * Defines the priority of this optimization (0 by default which means first in the list)
  60810. */
  60811. priority?: number,
  60812. /**
  60813. * 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
  60814. */
  60815. maximumSize?: number,
  60816. /**
  60817. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  60818. */
  60819. step?: number);
  60820. /**
  60821. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  60822. * @param scene defines the current scene where to apply this optimization
  60823. * @param optimizer defines the current optimizer
  60824. * @returns true if everything that can be done was applied
  60825. */
  60826. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  60827. }
  60828. /**
  60829. * Defines an optimization used to increase or decrease the rendering resolution
  60830. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  60831. */
  60832. export class HardwareScalingOptimization extends SceneOptimization {
  60833. /**
  60834. * Defines the priority of this optimization (0 by default which means first in the list)
  60835. */
  60836. priority: number;
  60837. /**
  60838. * Defines the maximum scale to use (2 by default)
  60839. */
  60840. maximumScale: number;
  60841. /**
  60842. * Defines the step to use between two passes (0.5 by default)
  60843. */
  60844. step: number;
  60845. private _currentScale;
  60846. private _directionOffset;
  60847. /**
  60848. * Gets a string describing the action executed by the current optimization
  60849. * @return description string
  60850. */
  60851. getDescription(): string;
  60852. /**
  60853. * Creates the HardwareScalingOptimization object
  60854. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  60855. * @param maximumScale defines the maximum scale to use (2 by default)
  60856. * @param step defines the step to use between two passes (0.5 by default)
  60857. */
  60858. constructor(
  60859. /**
  60860. * Defines the priority of this optimization (0 by default which means first in the list)
  60861. */
  60862. priority?: number,
  60863. /**
  60864. * Defines the maximum scale to use (2 by default)
  60865. */
  60866. maximumScale?: number,
  60867. /**
  60868. * Defines the step to use between two passes (0.5 by default)
  60869. */
  60870. step?: number);
  60871. /**
  60872. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  60873. * @param scene defines the current scene where to apply this optimization
  60874. * @param optimizer defines the current optimizer
  60875. * @returns true if everything that can be done was applied
  60876. */
  60877. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  60878. }
  60879. /**
  60880. * Defines an optimization used to remove shadows
  60881. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  60882. */
  60883. export class ShadowsOptimization extends SceneOptimization {
  60884. /**
  60885. * Gets a string describing the action executed by the current optimization
  60886. * @return description string
  60887. */
  60888. getDescription(): string;
  60889. /**
  60890. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  60891. * @param scene defines the current scene where to apply this optimization
  60892. * @param optimizer defines the current optimizer
  60893. * @returns true if everything that can be done was applied
  60894. */
  60895. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  60896. }
  60897. /**
  60898. * Defines an optimization used to turn post-processes off
  60899. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  60900. */
  60901. export class PostProcessesOptimization extends SceneOptimization {
  60902. /**
  60903. * Gets a string describing the action executed by the current optimization
  60904. * @return description string
  60905. */
  60906. getDescription(): string;
  60907. /**
  60908. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  60909. * @param scene defines the current scene where to apply this optimization
  60910. * @param optimizer defines the current optimizer
  60911. * @returns true if everything that can be done was applied
  60912. */
  60913. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  60914. }
  60915. /**
  60916. * Defines an optimization used to turn lens flares off
  60917. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  60918. */
  60919. export class LensFlaresOptimization extends SceneOptimization {
  60920. /**
  60921. * Gets a string describing the action executed by the current optimization
  60922. * @return description string
  60923. */
  60924. getDescription(): string;
  60925. /**
  60926. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  60927. * @param scene defines the current scene where to apply this optimization
  60928. * @param optimizer defines the current optimizer
  60929. * @returns true if everything that can be done was applied
  60930. */
  60931. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  60932. }
  60933. /**
  60934. * Defines an optimization based on user defined callback.
  60935. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  60936. */
  60937. export class CustomOptimization extends SceneOptimization {
  60938. /**
  60939. * Callback called to apply the custom optimization.
  60940. */
  60941. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  60942. /**
  60943. * Callback called to get custom description
  60944. */
  60945. onGetDescription: () => string;
  60946. /**
  60947. * Gets a string describing the action executed by the current optimization
  60948. * @returns description string
  60949. */
  60950. getDescription(): string;
  60951. /**
  60952. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  60953. * @param scene defines the current scene where to apply this optimization
  60954. * @param optimizer defines the current optimizer
  60955. * @returns true if everything that can be done was applied
  60956. */
  60957. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  60958. }
  60959. /**
  60960. * Defines an optimization used to turn particles off
  60961. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  60962. */
  60963. export class ParticlesOptimization extends SceneOptimization {
  60964. /**
  60965. * Gets a string describing the action executed by the current optimization
  60966. * @return description string
  60967. */
  60968. getDescription(): string;
  60969. /**
  60970. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  60971. * @param scene defines the current scene where to apply this optimization
  60972. * @param optimizer defines the current optimizer
  60973. * @returns true if everything that can be done was applied
  60974. */
  60975. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  60976. }
  60977. /**
  60978. * Defines an optimization used to turn render targets off
  60979. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  60980. */
  60981. export class RenderTargetsOptimization extends SceneOptimization {
  60982. /**
  60983. * Gets a string describing the action executed by the current optimization
  60984. * @return description string
  60985. */
  60986. getDescription(): string;
  60987. /**
  60988. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  60989. * @param scene defines the current scene where to apply this optimization
  60990. * @param optimizer defines the current optimizer
  60991. * @returns true if everything that can be done was applied
  60992. */
  60993. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  60994. }
  60995. /**
  60996. * Defines an optimization used to merge meshes with compatible materials
  60997. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  60998. */
  60999. export class MergeMeshesOptimization extends SceneOptimization {
  61000. private static _UpdateSelectionTree;
  61001. /**
  61002. * Gets or sets a boolean which defines if optimization octree has to be updated
  61003. */
  61004. /**
  61005. * Gets or sets a boolean which defines if optimization octree has to be updated
  61006. */
  61007. static UpdateSelectionTree: boolean;
  61008. /**
  61009. * Gets a string describing the action executed by the current optimization
  61010. * @return description string
  61011. */
  61012. getDescription(): string;
  61013. private _canBeMerged;
  61014. /**
  61015. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61016. * @param scene defines the current scene where to apply this optimization
  61017. * @param optimizer defines the current optimizer
  61018. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  61019. * @returns true if everything that can be done was applied
  61020. */
  61021. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  61022. }
  61023. /**
  61024. * Defines a list of options used by SceneOptimizer
  61025. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61026. */
  61027. export class SceneOptimizerOptions {
  61028. /**
  61029. * Defines the target frame rate to reach (60 by default)
  61030. */
  61031. targetFrameRate: number;
  61032. /**
  61033. * Defines the interval between two checkes (2000ms by default)
  61034. */
  61035. trackerDuration: number;
  61036. /**
  61037. * Gets the list of optimizations to apply
  61038. */
  61039. optimizations: SceneOptimization[];
  61040. /**
  61041. * Creates a new list of options used by SceneOptimizer
  61042. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  61043. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  61044. */
  61045. constructor(
  61046. /**
  61047. * Defines the target frame rate to reach (60 by default)
  61048. */
  61049. targetFrameRate?: number,
  61050. /**
  61051. * Defines the interval between two checkes (2000ms by default)
  61052. */
  61053. trackerDuration?: number);
  61054. /**
  61055. * Add a new optimization
  61056. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  61057. * @returns the current SceneOptimizerOptions
  61058. */
  61059. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  61060. /**
  61061. * Add a new custom optimization
  61062. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  61063. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  61064. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  61065. * @returns the current SceneOptimizerOptions
  61066. */
  61067. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  61068. /**
  61069. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  61070. * @param targetFrameRate defines the target frame rate (60 by default)
  61071. * @returns a SceneOptimizerOptions object
  61072. */
  61073. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  61074. /**
  61075. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  61076. * @param targetFrameRate defines the target frame rate (60 by default)
  61077. * @returns a SceneOptimizerOptions object
  61078. */
  61079. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  61080. /**
  61081. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  61082. * @param targetFrameRate defines the target frame rate (60 by default)
  61083. * @returns a SceneOptimizerOptions object
  61084. */
  61085. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  61086. }
  61087. /**
  61088. * Class used to run optimizations in order to reach a target frame rate
  61089. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61090. */
  61091. export class SceneOptimizer implements IDisposable {
  61092. private _isRunning;
  61093. private _options;
  61094. private _scene;
  61095. private _currentPriorityLevel;
  61096. private _targetFrameRate;
  61097. private _trackerDuration;
  61098. private _currentFrameRate;
  61099. private _sceneDisposeObserver;
  61100. private _improvementMode;
  61101. /**
  61102. * Defines an observable called when the optimizer reaches the target frame rate
  61103. */
  61104. onSuccessObservable: Observable<SceneOptimizer>;
  61105. /**
  61106. * Defines an observable called when the optimizer enables an optimization
  61107. */
  61108. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  61109. /**
  61110. * Defines an observable called when the optimizer is not able to reach the target frame rate
  61111. */
  61112. onFailureObservable: Observable<SceneOptimizer>;
  61113. /**
  61114. * Gets a boolean indicating if the optimizer is in improvement mode
  61115. */
  61116. readonly isInImprovementMode: boolean;
  61117. /**
  61118. * Gets the current priority level (0 at start)
  61119. */
  61120. readonly currentPriorityLevel: number;
  61121. /**
  61122. * Gets the current frame rate checked by the SceneOptimizer
  61123. */
  61124. readonly currentFrameRate: number;
  61125. /**
  61126. * Gets or sets the current target frame rate (60 by default)
  61127. */
  61128. /**
  61129. * Gets or sets the current target frame rate (60 by default)
  61130. */
  61131. targetFrameRate: number;
  61132. /**
  61133. * Gets or sets the current interval between two checks (every 2000ms by default)
  61134. */
  61135. /**
  61136. * Gets or sets the current interval between two checks (every 2000ms by default)
  61137. */
  61138. trackerDuration: number;
  61139. /**
  61140. * Gets the list of active optimizations
  61141. */
  61142. readonly optimizations: SceneOptimization[];
  61143. /**
  61144. * Creates a new SceneOptimizer
  61145. * @param scene defines the scene to work on
  61146. * @param options defines the options to use with the SceneOptimizer
  61147. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  61148. * @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)
  61149. */
  61150. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  61151. /**
  61152. * Stops the current optimizer
  61153. */
  61154. stop(): void;
  61155. /**
  61156. * Reset the optimizer to initial step (current priority level = 0)
  61157. */
  61158. reset(): void;
  61159. /**
  61160. * Start the optimizer. By default it will try to reach a specific framerate
  61161. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  61162. */
  61163. start(): void;
  61164. private _checkCurrentState;
  61165. /**
  61166. * Release all resources
  61167. */
  61168. dispose(): void;
  61169. /**
  61170. * Helper function to create a SceneOptimizer with one single line of code
  61171. * @param scene defines the scene to work on
  61172. * @param options defines the options to use with the SceneOptimizer
  61173. * @param onSuccess defines a callback to call on success
  61174. * @param onFailure defines a callback to call on failure
  61175. * @returns the new SceneOptimizer object
  61176. */
  61177. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  61178. }
  61179. }
  61180. declare module "babylonjs/Misc/sceneSerializer" {
  61181. import { Scene } from "babylonjs/scene";
  61182. /**
  61183. * Class used to serialize a scene into a string
  61184. */
  61185. export class SceneSerializer {
  61186. /**
  61187. * Clear cache used by a previous serialization
  61188. */
  61189. static ClearCache(): void;
  61190. /**
  61191. * Serialize a scene into a JSON compatible object
  61192. * @param scene defines the scene to serialize
  61193. * @returns a JSON compatible object
  61194. */
  61195. static Serialize(scene: Scene): any;
  61196. /**
  61197. * Serialize a mesh into a JSON compatible object
  61198. * @param toSerialize defines the mesh to serialize
  61199. * @param withParents defines if parents must be serialized as well
  61200. * @param withChildren defines if children must be serialized as well
  61201. * @returns a JSON compatible object
  61202. */
  61203. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  61204. }
  61205. }
  61206. declare module "babylonjs/Misc/textureTools" {
  61207. import { Texture } from "babylonjs/Materials/Textures/texture";
  61208. /**
  61209. * Class used to host texture specific utilities
  61210. */
  61211. export class TextureTools {
  61212. /**
  61213. * Uses the GPU to create a copy texture rescaled at a given size
  61214. * @param texture Texture to copy from
  61215. * @param width defines the desired width
  61216. * @param height defines the desired height
  61217. * @param useBilinearMode defines if bilinear mode has to be used
  61218. * @return the generated texture
  61219. */
  61220. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  61221. }
  61222. }
  61223. declare module "babylonjs/Misc/videoRecorder" {
  61224. import { Nullable } from "babylonjs/types";
  61225. import { Engine } from "babylonjs/Engines/engine";
  61226. /**
  61227. * This represents the different options avilable for the video capture.
  61228. */
  61229. export interface VideoRecorderOptions {
  61230. /** Defines the mime type of the video */
  61231. mimeType: string;
  61232. /** Defines the video the video should be recorded at */
  61233. fps: number;
  61234. /** Defines the chunk size for the recording data */
  61235. recordChunckSize: number;
  61236. /** The audio tracks to attach to the record */
  61237. audioTracks?: MediaStreamTrack[];
  61238. }
  61239. /**
  61240. * This can helps recording videos from BabylonJS.
  61241. * This is based on the available WebRTC functionalities of the browser.
  61242. *
  61243. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  61244. */
  61245. export class VideoRecorder {
  61246. private static readonly _defaultOptions;
  61247. /**
  61248. * Returns wehther or not the VideoRecorder is available in your browser.
  61249. * @param engine Defines the Babylon Engine to check the support for
  61250. * @returns true if supported otherwise false
  61251. */
  61252. static IsSupported(engine: Engine): boolean;
  61253. private readonly _options;
  61254. private _canvas;
  61255. private _mediaRecorder;
  61256. private _recordedChunks;
  61257. private _fileName;
  61258. private _resolve;
  61259. private _reject;
  61260. /**
  61261. * True wether a recording is already in progress.
  61262. */
  61263. readonly isRecording: boolean;
  61264. /**
  61265. * Create a new VideoCapture object which can help converting what you see in Babylon to
  61266. * a video file.
  61267. * @param engine Defines the BabylonJS Engine you wish to record
  61268. * @param options Defines options that can be used to customized the capture
  61269. */
  61270. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  61271. /**
  61272. * Stops the current recording before the default capture timeout passed in the startRecording
  61273. * functions.
  61274. */
  61275. stopRecording(): void;
  61276. /**
  61277. * Starts recording the canvas for a max duration specified in parameters.
  61278. * @param fileName Defines the name of the file to be downloaded when the recording stop. If null no automatic download will start and you can rely on the promise to get the data back.
  61279. * @param maxDuration Defines the maximum recording time in seconds.
  61280. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  61281. * @return a promise callback at the end of the recording with the video data in Blob.
  61282. */
  61283. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  61284. /**
  61285. * Releases internal resources used during the recording.
  61286. */
  61287. dispose(): void;
  61288. private _handleDataAvailable;
  61289. private _handleError;
  61290. private _handleStop;
  61291. }
  61292. }
  61293. declare module "babylonjs/Misc/screenshotTools" {
  61294. import { Camera } from "babylonjs/Cameras/camera";
  61295. import { Engine } from "babylonjs/Engines/engine";
  61296. /**
  61297. * Class containing a set of static utilities functions for screenshots
  61298. */
  61299. export class ScreenshotTools {
  61300. /**
  61301. * Captures a screenshot of the current rendering
  61302. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  61303. * @param engine defines the rendering engine
  61304. * @param camera defines the source camera
  61305. * @param size This parameter can be set to a single number or to an object with the
  61306. * following (optional) properties: precision, width, height. If a single number is passed,
  61307. * it will be used for both width and height. If an object is passed, the screenshot size
  61308. * will be derived from the parameters. The precision property is a multiplier allowing
  61309. * rendering at a higher or lower resolution
  61310. * @param successCallback defines the callback receives a single parameter which contains the
  61311. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  61312. * src parameter of an <img> to display it
  61313. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  61314. * Check your browser for supported MIME types
  61315. */
  61316. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  61317. /**
  61318. * Generates an image screenshot from the specified camera.
  61319. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  61320. * @param engine The engine to use for rendering
  61321. * @param camera The camera to use for rendering
  61322. * @param size This parameter can be set to a single number or to an object with the
  61323. * following (optional) properties: precision, width, height. If a single number is passed,
  61324. * it will be used for both width and height. If an object is passed, the screenshot size
  61325. * will be derived from the parameters. The precision property is a multiplier allowing
  61326. * rendering at a higher or lower resolution
  61327. * @param successCallback The callback receives a single parameter which contains the
  61328. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  61329. * src parameter of an <img> to display it
  61330. * @param mimeType The MIME type of the screenshot image (default: image/png).
  61331. * Check your browser for supported MIME types
  61332. * @param samples Texture samples (default: 1)
  61333. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  61334. * @param fileName A name for for the downloaded file.
  61335. */
  61336. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  61337. }
  61338. }
  61339. declare module "babylonjs/Misc/index" {
  61340. export * from "babylonjs/Misc/andOrNotEvaluator";
  61341. export * from "babylonjs/Misc/assetsManager";
  61342. export * from "babylonjs/Misc/dds";
  61343. export * from "babylonjs/Misc/decorators";
  61344. export * from "babylonjs/Misc/deferred";
  61345. export * from "babylonjs/Misc/environmentTextureTools";
  61346. export * from "babylonjs/Misc/meshExploder";
  61347. export * from "babylonjs/Misc/filesInput";
  61348. export * from "babylonjs/Misc/HighDynamicRange/index";
  61349. export * from "babylonjs/Misc/khronosTextureContainer";
  61350. export * from "babylonjs/Misc/observable";
  61351. export * from "babylonjs/Misc/performanceMonitor";
  61352. export * from "babylonjs/Misc/promise";
  61353. export * from "babylonjs/Misc/sceneOptimizer";
  61354. export * from "babylonjs/Misc/sceneSerializer";
  61355. export * from "babylonjs/Misc/smartArray";
  61356. export * from "babylonjs/Misc/stringDictionary";
  61357. export * from "babylonjs/Misc/tags";
  61358. export * from "babylonjs/Misc/textureTools";
  61359. export * from "babylonjs/Misc/tga";
  61360. export * from "babylonjs/Misc/tools";
  61361. export * from "babylonjs/Misc/videoRecorder";
  61362. export * from "babylonjs/Misc/virtualJoystick";
  61363. export * from "babylonjs/Misc/workerPool";
  61364. export * from "babylonjs/Misc/logger";
  61365. export * from "babylonjs/Misc/typeStore";
  61366. export * from "babylonjs/Misc/filesInputStore";
  61367. export * from "babylonjs/Misc/deepCopier";
  61368. export * from "babylonjs/Misc/pivotTools";
  61369. export * from "babylonjs/Misc/precisionDate";
  61370. export * from "babylonjs/Misc/screenshotTools";
  61371. export * from "babylonjs/Misc/typeStore";
  61372. export * from "babylonjs/Misc/webRequest";
  61373. export * from "babylonjs/Misc/iInspectable";
  61374. }
  61375. declare module "babylonjs/index" {
  61376. export * from "babylonjs/abstractScene";
  61377. export * from "babylonjs/Actions/index";
  61378. export * from "babylonjs/Animations/index";
  61379. export * from "babylonjs/assetContainer";
  61380. export * from "babylonjs/Audio/index";
  61381. export * from "babylonjs/Behaviors/index";
  61382. export * from "babylonjs/Bones/index";
  61383. export * from "babylonjs/Cameras/index";
  61384. export * from "babylonjs/Collisions/index";
  61385. export * from "babylonjs/Culling/index";
  61386. export * from "babylonjs/Debug/index";
  61387. export * from "babylonjs/Engines/index";
  61388. export * from "babylonjs/Events/index";
  61389. export * from "babylonjs/Gamepads/index";
  61390. export * from "babylonjs/Gizmos/index";
  61391. export * from "babylonjs/Helpers/index";
  61392. export * from "babylonjs/Instrumentation/index";
  61393. export * from "babylonjs/Layers/index";
  61394. export * from "babylonjs/LensFlares/index";
  61395. export * from "babylonjs/Lights/index";
  61396. export * from "babylonjs/Loading/index";
  61397. export * from "babylonjs/Materials/index";
  61398. export * from "babylonjs/Maths/index";
  61399. export * from "babylonjs/Meshes/index";
  61400. export * from "babylonjs/Morph/index";
  61401. export * from "babylonjs/node";
  61402. export * from "babylonjs/Offline/index";
  61403. export * from "babylonjs/Particles/index";
  61404. export * from "babylonjs/Physics/index";
  61405. export * from "babylonjs/PostProcesses/index";
  61406. export * from "babylonjs/Probes/index";
  61407. export * from "babylonjs/Rendering/index";
  61408. export * from "babylonjs/scene";
  61409. export * from "babylonjs/sceneComponent";
  61410. export * from "babylonjs/Sprites/index";
  61411. export * from "babylonjs/States/index";
  61412. export * from "babylonjs/Misc/index";
  61413. export * from "babylonjs/types";
  61414. }
  61415. declare module "babylonjs/Animations/pathCursor" {
  61416. import { Path2, Vector3 } from "babylonjs/Maths/math";
  61417. /**
  61418. * A cursor which tracks a point on a path
  61419. */
  61420. export class PathCursor {
  61421. private path;
  61422. /**
  61423. * Stores path cursor callbacks for when an onchange event is triggered
  61424. */
  61425. private _onchange;
  61426. /**
  61427. * The value of the path cursor
  61428. */
  61429. value: number;
  61430. /**
  61431. * The animation array of the path cursor
  61432. */
  61433. animations: Animation[];
  61434. /**
  61435. * Initializes the path cursor
  61436. * @param path The path to track
  61437. */
  61438. constructor(path: Path2);
  61439. /**
  61440. * Gets the cursor point on the path
  61441. * @returns A point on the path cursor at the cursor location
  61442. */
  61443. getPoint(): Vector3;
  61444. /**
  61445. * Moves the cursor ahead by the step amount
  61446. * @param step The amount to move the cursor forward
  61447. * @returns This path cursor
  61448. */
  61449. moveAhead(step?: number): PathCursor;
  61450. /**
  61451. * Moves the cursor behind by the step amount
  61452. * @param step The amount to move the cursor back
  61453. * @returns This path cursor
  61454. */
  61455. moveBack(step?: number): PathCursor;
  61456. /**
  61457. * Moves the cursor by the step amount
  61458. * If the step amount is greater than one, an exception is thrown
  61459. * @param step The amount to move the cursor
  61460. * @returns This path cursor
  61461. */
  61462. move(step: number): PathCursor;
  61463. /**
  61464. * Ensures that the value is limited between zero and one
  61465. * @returns This path cursor
  61466. */
  61467. private ensureLimits;
  61468. /**
  61469. * Runs onchange callbacks on change (used by the animation engine)
  61470. * @returns This path cursor
  61471. */
  61472. private raiseOnChange;
  61473. /**
  61474. * Executes a function on change
  61475. * @param f A path cursor onchange callback
  61476. * @returns This path cursor
  61477. */
  61478. onchange(f: (cursor: PathCursor) => void): PathCursor;
  61479. }
  61480. }
  61481. declare module "babylonjs/Legacy/legacy" {
  61482. import * as Babylon from "babylonjs/index";
  61483. export * from "babylonjs/index";
  61484. }
  61485. declare module "babylonjs/Shaders/blur.fragment" {
  61486. /** @hidden */
  61487. export var blurPixelShader: {
  61488. name: string;
  61489. shader: string;
  61490. };
  61491. }
  61492. declare module "babylonjs/Shaders/ShadersInclude/bones300Declaration" {
  61493. /** @hidden */
  61494. export var bones300Declaration: {
  61495. name: string;
  61496. shader: string;
  61497. };
  61498. }
  61499. declare module "babylonjs/Shaders/ShadersInclude/instances300Declaration" {
  61500. /** @hidden */
  61501. export var instances300Declaration: {
  61502. name: string;
  61503. shader: string;
  61504. };
  61505. }
  61506. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  61507. /** @hidden */
  61508. export var pointCloudVertexDeclaration: {
  61509. name: string;
  61510. shader: string;
  61511. };
  61512. }
  61513. // Mixins
  61514. interface Window {
  61515. mozIndexedDB: IDBFactory;
  61516. webkitIndexedDB: IDBFactory;
  61517. msIndexedDB: IDBFactory;
  61518. webkitURL: typeof URL;
  61519. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  61520. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  61521. WebGLRenderingContext: WebGLRenderingContext;
  61522. MSGesture: MSGesture;
  61523. CANNON: any;
  61524. AudioContext: AudioContext;
  61525. webkitAudioContext: AudioContext;
  61526. PointerEvent: any;
  61527. Math: Math;
  61528. Uint8Array: Uint8ArrayConstructor;
  61529. Float32Array: Float32ArrayConstructor;
  61530. mozURL: typeof URL;
  61531. msURL: typeof URL;
  61532. VRFrameData: any; // WebVR, from specs 1.1
  61533. DracoDecoderModule: any;
  61534. setImmediate(handler: (...args: any[]) => void): number;
  61535. }
  61536. interface HTMLCanvasElement {
  61537. requestPointerLock(): void;
  61538. msRequestPointerLock?(): void;
  61539. mozRequestPointerLock?(): void;
  61540. webkitRequestPointerLock?(): void;
  61541. /** Track wether a record is in progress */
  61542. isRecording: boolean;
  61543. /** Capture Stream method defined by some browsers */
  61544. captureStream(fps?: number): MediaStream;
  61545. }
  61546. interface CanvasRenderingContext2D {
  61547. msImageSmoothingEnabled: boolean;
  61548. }
  61549. interface MouseEvent {
  61550. mozMovementX: number;
  61551. mozMovementY: number;
  61552. webkitMovementX: number;
  61553. webkitMovementY: number;
  61554. msMovementX: number;
  61555. msMovementY: number;
  61556. }
  61557. interface Navigator {
  61558. mozGetVRDevices: (any: any) => any;
  61559. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  61560. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  61561. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  61562. webkitGetGamepads(): Gamepad[];
  61563. msGetGamepads(): Gamepad[];
  61564. webkitGamepads(): Gamepad[];
  61565. }
  61566. interface HTMLVideoElement {
  61567. mozSrcObject: any;
  61568. }
  61569. interface Math {
  61570. fround(x: number): number;
  61571. imul(a: number, b: number): number;
  61572. }
  61573. interface WebGLRenderingContext {
  61574. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  61575. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  61576. vertexAttribDivisor(index: number, divisor: number): void;
  61577. createVertexArray(): any;
  61578. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  61579. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  61580. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  61581. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  61582. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  61583. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  61584. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  61585. // Queries
  61586. createQuery(): WebGLQuery;
  61587. deleteQuery(query: WebGLQuery): void;
  61588. beginQuery(target: number, query: WebGLQuery): void;
  61589. endQuery(target: number): void;
  61590. getQueryParameter(query: WebGLQuery, pname: number): any;
  61591. getQuery(target: number, pname: number): any;
  61592. MAX_SAMPLES: number;
  61593. RGBA8: number;
  61594. READ_FRAMEBUFFER: number;
  61595. DRAW_FRAMEBUFFER: number;
  61596. UNIFORM_BUFFER: number;
  61597. HALF_FLOAT_OES: number;
  61598. RGBA16F: number;
  61599. RGBA32F: number;
  61600. R32F: number;
  61601. RG32F: number;
  61602. RGB32F: number;
  61603. R16F: number;
  61604. RG16F: number;
  61605. RGB16F: number;
  61606. RED: number;
  61607. RG: number;
  61608. R8: number;
  61609. RG8: number;
  61610. UNSIGNED_INT_24_8: number;
  61611. DEPTH24_STENCIL8: number;
  61612. /* Multiple Render Targets */
  61613. drawBuffers(buffers: number[]): void;
  61614. readBuffer(src: number): void;
  61615. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  61616. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  61617. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  61618. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  61619. // Occlusion Query
  61620. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  61621. ANY_SAMPLES_PASSED: number;
  61622. QUERY_RESULT_AVAILABLE: number;
  61623. QUERY_RESULT: number;
  61624. }
  61625. interface WebGLProgram {
  61626. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  61627. }
  61628. interface EXT_disjoint_timer_query {
  61629. QUERY_COUNTER_BITS_EXT: number;
  61630. TIME_ELAPSED_EXT: number;
  61631. TIMESTAMP_EXT: number;
  61632. GPU_DISJOINT_EXT: number;
  61633. QUERY_RESULT_EXT: number;
  61634. QUERY_RESULT_AVAILABLE_EXT: number;
  61635. queryCounterEXT(query: WebGLQuery, target: number): void;
  61636. createQueryEXT(): WebGLQuery;
  61637. beginQueryEXT(target: number, query: WebGLQuery): void;
  61638. endQueryEXT(target: number): void;
  61639. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  61640. deleteQueryEXT(query: WebGLQuery): void;
  61641. }
  61642. interface WebGLUniformLocation {
  61643. _currentState: any;
  61644. }
  61645. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  61646. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  61647. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  61648. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  61649. interface WebGLRenderingContext {
  61650. readonly RASTERIZER_DISCARD: number;
  61651. readonly DEPTH_COMPONENT24: number;
  61652. readonly TEXTURE_3D: number;
  61653. readonly TEXTURE_2D_ARRAY: number;
  61654. readonly TEXTURE_COMPARE_FUNC: number;
  61655. readonly TEXTURE_COMPARE_MODE: number;
  61656. readonly COMPARE_REF_TO_TEXTURE: number;
  61657. readonly TEXTURE_WRAP_R: number;
  61658. readonly HALF_FLOAT: number;
  61659. readonly RGB8: number;
  61660. readonly RED_INTEGER: number;
  61661. readonly RG_INTEGER: number;
  61662. readonly RGB_INTEGER: number;
  61663. readonly RGBA_INTEGER: number;
  61664. readonly R8_SNORM: number;
  61665. readonly RG8_SNORM: number;
  61666. readonly RGB8_SNORM: number;
  61667. readonly RGBA8_SNORM: number;
  61668. readonly R8I: number;
  61669. readonly RG8I: number;
  61670. readonly RGB8I: number;
  61671. readonly RGBA8I: number;
  61672. readonly R8UI: number;
  61673. readonly RG8UI: number;
  61674. readonly RGB8UI: number;
  61675. readonly RGBA8UI: number;
  61676. readonly R16I: number;
  61677. readonly RG16I: number;
  61678. readonly RGB16I: number;
  61679. readonly RGBA16I: number;
  61680. readonly R16UI: number;
  61681. readonly RG16UI: number;
  61682. readonly RGB16UI: number;
  61683. readonly RGBA16UI: number;
  61684. readonly R32I: number;
  61685. readonly RG32I: number;
  61686. readonly RGB32I: number;
  61687. readonly RGBA32I: number;
  61688. readonly R32UI: number;
  61689. readonly RG32UI: number;
  61690. readonly RGB32UI: number;
  61691. readonly RGBA32UI: number;
  61692. readonly RGB10_A2UI: number;
  61693. readonly R11F_G11F_B10F: number;
  61694. readonly RGB9_E5: number;
  61695. readonly RGB10_A2: number;
  61696. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  61697. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  61698. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  61699. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  61700. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  61701. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  61702. 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;
  61703. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  61704. readonly TRANSFORM_FEEDBACK: number;
  61705. readonly INTERLEAVED_ATTRIBS: number;
  61706. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  61707. createTransformFeedback(): WebGLTransformFeedback;
  61708. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  61709. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  61710. beginTransformFeedback(primitiveMode: number): void;
  61711. endTransformFeedback(): void;
  61712. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  61713. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  61714. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  61715. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  61716. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  61717. }
  61718. interface ImageBitmap {
  61719. readonly width: number;
  61720. readonly height: number;
  61721. close(): void;
  61722. }
  61723. interface WebGLQuery extends WebGLObject {
  61724. }
  61725. declare var WebGLQuery: {
  61726. prototype: WebGLQuery;
  61727. new(): WebGLQuery;
  61728. };
  61729. interface WebGLSampler extends WebGLObject {
  61730. }
  61731. declare var WebGLSampler: {
  61732. prototype: WebGLSampler;
  61733. new(): WebGLSampler;
  61734. };
  61735. interface WebGLSync extends WebGLObject {
  61736. }
  61737. declare var WebGLSync: {
  61738. prototype: WebGLSync;
  61739. new(): WebGLSync;
  61740. };
  61741. interface WebGLTransformFeedback extends WebGLObject {
  61742. }
  61743. declare var WebGLTransformFeedback: {
  61744. prototype: WebGLTransformFeedback;
  61745. new(): WebGLTransformFeedback;
  61746. };
  61747. interface WebGLVertexArrayObject extends WebGLObject {
  61748. }
  61749. declare var WebGLVertexArrayObject: {
  61750. prototype: WebGLVertexArrayObject;
  61751. new(): WebGLVertexArrayObject;
  61752. };
  61753. // Type definitions for WebVR API
  61754. // Project: https://w3c.github.io/webvr/
  61755. // Definitions by: six a <https://github.com/lostfictions>
  61756. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  61757. interface VRDisplay extends EventTarget {
  61758. /**
  61759. * Dictionary of capabilities describing the VRDisplay.
  61760. */
  61761. readonly capabilities: VRDisplayCapabilities;
  61762. /**
  61763. * z-depth defining the far plane of the eye view frustum
  61764. * enables mapping of values in the render target depth
  61765. * attachment to scene coordinates. Initially set to 10000.0.
  61766. */
  61767. depthFar: number;
  61768. /**
  61769. * z-depth defining the near plane of the eye view frustum
  61770. * enables mapping of values in the render target depth
  61771. * attachment to scene coordinates. Initially set to 0.01.
  61772. */
  61773. depthNear: number;
  61774. /**
  61775. * An identifier for this distinct VRDisplay. Used as an
  61776. * association point in the Gamepad API.
  61777. */
  61778. readonly displayId: number;
  61779. /**
  61780. * A display name, a user-readable name identifying it.
  61781. */
  61782. readonly displayName: string;
  61783. readonly isConnected: boolean;
  61784. readonly isPresenting: boolean;
  61785. /**
  61786. * If this VRDisplay supports room-scale experiences, the optional
  61787. * stage attribute contains details on the room-scale parameters.
  61788. */
  61789. readonly stageParameters: VRStageParameters | null;
  61790. /**
  61791. * Passing the value returned by `requestAnimationFrame` to
  61792. * `cancelAnimationFrame` will unregister the callback.
  61793. * @param handle Define the hanle of the request to cancel
  61794. */
  61795. cancelAnimationFrame(handle: number): void;
  61796. /**
  61797. * Stops presenting to the VRDisplay.
  61798. * @returns a promise to know when it stopped
  61799. */
  61800. exitPresent(): Promise<void>;
  61801. /**
  61802. * Return the current VREyeParameters for the given eye.
  61803. * @param whichEye Define the eye we want the parameter for
  61804. * @returns the eye parameters
  61805. */
  61806. getEyeParameters(whichEye: string): VREyeParameters;
  61807. /**
  61808. * Populates the passed VRFrameData with the information required to render
  61809. * the current frame.
  61810. * @param frameData Define the data structure to populate
  61811. * @returns true if ok otherwise false
  61812. */
  61813. getFrameData(frameData: VRFrameData): boolean;
  61814. /**
  61815. * Get the layers currently being presented.
  61816. * @returns the list of VR layers
  61817. */
  61818. getLayers(): VRLayer[];
  61819. /**
  61820. * Return a VRPose containing the future predicted pose of the VRDisplay
  61821. * when the current frame will be presented. The value returned will not
  61822. * change until JavaScript has returned control to the browser.
  61823. *
  61824. * The VRPose will contain the position, orientation, velocity,
  61825. * and acceleration of each of these properties.
  61826. * @returns the pose object
  61827. */
  61828. getPose(): VRPose;
  61829. /**
  61830. * Return the current instantaneous pose of the VRDisplay, with no
  61831. * prediction applied.
  61832. * @returns the current instantaneous pose
  61833. */
  61834. getImmediatePose(): VRPose;
  61835. /**
  61836. * The callback passed to `requestAnimationFrame` will be called
  61837. * any time a new frame should be rendered. When the VRDisplay is
  61838. * presenting the callback will be called at the native refresh
  61839. * rate of the HMD. When not presenting this function acts
  61840. * identically to how window.requestAnimationFrame acts. Content should
  61841. * make no assumptions of frame rate or vsync behavior as the HMD runs
  61842. * asynchronously from other displays and at differing refresh rates.
  61843. * @param callback Define the eaction to run next frame
  61844. * @returns the request handle it
  61845. */
  61846. requestAnimationFrame(callback: FrameRequestCallback): number;
  61847. /**
  61848. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  61849. * Repeat calls while already presenting will update the VRLayers being displayed.
  61850. * @param layers Define the list of layer to present
  61851. * @returns a promise to know when the request has been fulfilled
  61852. */
  61853. requestPresent(layers: VRLayer[]): Promise<void>;
  61854. /**
  61855. * Reset the pose for this display, treating its current position and
  61856. * orientation as the "origin/zero" values. VRPose.position,
  61857. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  61858. * updated when calling resetPose(). This should be called in only
  61859. * sitting-space experiences.
  61860. */
  61861. resetPose(): void;
  61862. /**
  61863. * The VRLayer provided to the VRDisplay will be captured and presented
  61864. * in the HMD. Calling this function has the same effect on the source
  61865. * canvas as any other operation that uses its source image, and canvases
  61866. * created without preserveDrawingBuffer set to true will be cleared.
  61867. * @param pose Define the pose to submit
  61868. */
  61869. submitFrame(pose?: VRPose): void;
  61870. }
  61871. declare var VRDisplay: {
  61872. prototype: VRDisplay;
  61873. new(): VRDisplay;
  61874. };
  61875. interface VRLayer {
  61876. leftBounds?: number[] | Float32Array | null;
  61877. rightBounds?: number[] | Float32Array | null;
  61878. source?: HTMLCanvasElement | null;
  61879. }
  61880. interface VRDisplayCapabilities {
  61881. readonly canPresent: boolean;
  61882. readonly hasExternalDisplay: boolean;
  61883. readonly hasOrientation: boolean;
  61884. readonly hasPosition: boolean;
  61885. readonly maxLayers: number;
  61886. }
  61887. interface VREyeParameters {
  61888. /** @deprecated */
  61889. readonly fieldOfView: VRFieldOfView;
  61890. readonly offset: Float32Array;
  61891. readonly renderHeight: number;
  61892. readonly renderWidth: number;
  61893. }
  61894. interface VRFieldOfView {
  61895. readonly downDegrees: number;
  61896. readonly leftDegrees: number;
  61897. readonly rightDegrees: number;
  61898. readonly upDegrees: number;
  61899. }
  61900. interface VRFrameData {
  61901. readonly leftProjectionMatrix: Float32Array;
  61902. readonly leftViewMatrix: Float32Array;
  61903. readonly pose: VRPose;
  61904. readonly rightProjectionMatrix: Float32Array;
  61905. readonly rightViewMatrix: Float32Array;
  61906. readonly timestamp: number;
  61907. }
  61908. interface VRPose {
  61909. readonly angularAcceleration: Float32Array | null;
  61910. readonly angularVelocity: Float32Array | null;
  61911. readonly linearAcceleration: Float32Array | null;
  61912. readonly linearVelocity: Float32Array | null;
  61913. readonly orientation: Float32Array | null;
  61914. readonly position: Float32Array | null;
  61915. readonly timestamp: number;
  61916. }
  61917. interface VRStageParameters {
  61918. sittingToStandingTransform?: Float32Array;
  61919. sizeX?: number;
  61920. sizeY?: number;
  61921. }
  61922. interface Navigator {
  61923. getVRDisplays(): Promise<VRDisplay[]>;
  61924. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  61925. }
  61926. interface Window {
  61927. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  61928. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  61929. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  61930. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  61931. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  61932. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  61933. }
  61934. interface Gamepad {
  61935. readonly displayId: number;
  61936. }
  61937. interface XRDevice {
  61938. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  61939. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  61940. }
  61941. interface XRSession {
  61942. getInputSources(): Array<any>;
  61943. baseLayer: XRWebGLLayer;
  61944. requestFrameOfReference(type: string): Promise<void>;
  61945. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  61946. end(): Promise<void>;
  61947. requestAnimationFrame: Function;
  61948. addEventListener: Function;
  61949. }
  61950. interface XRSessionCreationOptions {
  61951. outputContext?: WebGLRenderingContext | null;
  61952. immersive?: boolean;
  61953. environmentIntegration?: boolean;
  61954. }
  61955. interface XRLayer {
  61956. getViewport: Function;
  61957. framebufferWidth: number;
  61958. framebufferHeight: number;
  61959. }
  61960. interface XRView {
  61961. projectionMatrix: Float32Array;
  61962. }
  61963. interface XRFrame {
  61964. getDevicePose: Function;
  61965. getInputPose: Function;
  61966. views: Array<XRView>;
  61967. baseLayer: XRLayer;
  61968. }
  61969. interface XRFrameOfReference {
  61970. }
  61971. interface XRWebGLLayer extends XRLayer {
  61972. framebuffer: WebGLFramebuffer;
  61973. }
  61974. declare var XRWebGLLayer: {
  61975. prototype: XRWebGLLayer;
  61976. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  61977. };
  61978. declare module "babylonjs" {
  61979. export * from "babylonjs/Legacy/legacy";
  61980. }
  61981. declare module BABYLON {
  61982. /** Alias type for value that can be null */
  61983. export type Nullable<T> = T | null;
  61984. /**
  61985. * Alias type for number that are floats
  61986. * @ignorenaming
  61987. */
  61988. export type float = number;
  61989. /**
  61990. * Alias type for number that are doubles.
  61991. * @ignorenaming
  61992. */
  61993. export type double = number;
  61994. /**
  61995. * Alias type for number that are integer
  61996. * @ignorenaming
  61997. */
  61998. export type int = number;
  61999. /** Alias type for number array or Float32Array */
  62000. export type FloatArray = number[] | Float32Array;
  62001. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  62002. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  62003. /**
  62004. * Alias for types that can be used by a Buffer or VertexBuffer.
  62005. */
  62006. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  62007. /**
  62008. * Alias type for primitive types
  62009. * @ignorenaming
  62010. */
  62011. type Primitive = undefined | null | boolean | string | number | Function;
  62012. /**
  62013. * Type modifier to make all the properties of an object Readonly
  62014. */
  62015. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  62016. /**
  62017. * Type modifier to make all the properties of an object Readonly recursively
  62018. */
  62019. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  62020. /** @hidden */
  62021. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  62022. }
  62023. /** @hidden */
  62024. /** @hidden */
  62025. type DeepImmutableObject<T> = {
  62026. readonly [K in keyof T]: DeepImmutable<T[K]>;
  62027. };
  62028. }
  62029. declare module BABYLON {
  62030. /**
  62031. * Class containing a set of static utilities functions for arrays.
  62032. */
  62033. export class ArrayTools {
  62034. /**
  62035. * Returns an array of the given size filled with element built from the given constructor and the paramters
  62036. * @param size the number of element to construct and put in the array
  62037. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  62038. * @returns a new array filled with new objects
  62039. */
  62040. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  62041. }
  62042. }
  62043. declare module BABYLON {
  62044. /**
  62045. * Scalar computation library
  62046. */
  62047. export class Scalar {
  62048. /**
  62049. * Two pi constants convenient for computation.
  62050. */
  62051. static TwoPi: number;
  62052. /**
  62053. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  62054. * @param a number
  62055. * @param b number
  62056. * @param epsilon (default = 1.401298E-45)
  62057. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  62058. */
  62059. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  62060. /**
  62061. * Returns a string : the upper case translation of the number i to hexadecimal.
  62062. * @param i number
  62063. * @returns the upper case translation of the number i to hexadecimal.
  62064. */
  62065. static ToHex(i: number): string;
  62066. /**
  62067. * Returns -1 if value is negative and +1 is value is positive.
  62068. * @param value the value
  62069. * @returns the value itself if it's equal to zero.
  62070. */
  62071. static Sign(value: number): number;
  62072. /**
  62073. * Returns the value itself if it's between min and max.
  62074. * Returns min if the value is lower than min.
  62075. * Returns max if the value is greater than max.
  62076. * @param value the value to clmap
  62077. * @param min the min value to clamp to (default: 0)
  62078. * @param max the max value to clamp to (default: 1)
  62079. * @returns the clamped value
  62080. */
  62081. static Clamp(value: number, min?: number, max?: number): number;
  62082. /**
  62083. * the log2 of value.
  62084. * @param value the value to compute log2 of
  62085. * @returns the log2 of value.
  62086. */
  62087. static Log2(value: number): number;
  62088. /**
  62089. * Loops the value, so that it is never larger than length and never smaller than 0.
  62090. *
  62091. * This is similar to the modulo operator but it works with floating point numbers.
  62092. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  62093. * With t = 5 and length = 2.5, the result would be 0.0.
  62094. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  62095. * @param value the value
  62096. * @param length the length
  62097. * @returns the looped value
  62098. */
  62099. static Repeat(value: number, length: number): number;
  62100. /**
  62101. * Normalize the value between 0.0 and 1.0 using min and max values
  62102. * @param value value to normalize
  62103. * @param min max to normalize between
  62104. * @param max min to normalize between
  62105. * @returns the normalized value
  62106. */
  62107. static Normalize(value: number, min: number, max: number): number;
  62108. /**
  62109. * Denormalize the value from 0.0 and 1.0 using min and max values
  62110. * @param normalized value to denormalize
  62111. * @param min max to denormalize between
  62112. * @param max min to denormalize between
  62113. * @returns the denormalized value
  62114. */
  62115. static Denormalize(normalized: number, min: number, max: number): number;
  62116. /**
  62117. * Calculates the shortest difference between two given angles given in degrees.
  62118. * @param current current angle in degrees
  62119. * @param target target angle in degrees
  62120. * @returns the delta
  62121. */
  62122. static DeltaAngle(current: number, target: number): number;
  62123. /**
  62124. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  62125. * @param tx value
  62126. * @param length length
  62127. * @returns The returned value will move back and forth between 0 and length
  62128. */
  62129. static PingPong(tx: number, length: number): number;
  62130. /**
  62131. * Interpolates between min and max with smoothing at the limits.
  62132. *
  62133. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  62134. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  62135. * @param from from
  62136. * @param to to
  62137. * @param tx value
  62138. * @returns the smooth stepped value
  62139. */
  62140. static SmoothStep(from: number, to: number, tx: number): number;
  62141. /**
  62142. * Moves a value current towards target.
  62143. *
  62144. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  62145. * Negative values of maxDelta pushes the value away from target.
  62146. * @param current current value
  62147. * @param target target value
  62148. * @param maxDelta max distance to move
  62149. * @returns resulting value
  62150. */
  62151. static MoveTowards(current: number, target: number, maxDelta: number): number;
  62152. /**
  62153. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  62154. *
  62155. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  62156. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  62157. * @param current current value
  62158. * @param target target value
  62159. * @param maxDelta max distance to move
  62160. * @returns resulting angle
  62161. */
  62162. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  62163. /**
  62164. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  62165. * @param start start value
  62166. * @param end target value
  62167. * @param amount amount to lerp between
  62168. * @returns the lerped value
  62169. */
  62170. static Lerp(start: number, end: number, amount: number): number;
  62171. /**
  62172. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  62173. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  62174. * @param start start value
  62175. * @param end target value
  62176. * @param amount amount to lerp between
  62177. * @returns the lerped value
  62178. */
  62179. static LerpAngle(start: number, end: number, amount: number): number;
  62180. /**
  62181. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  62182. * @param a start value
  62183. * @param b target value
  62184. * @param value value between a and b
  62185. * @returns the inverseLerp value
  62186. */
  62187. static InverseLerp(a: number, b: number, value: number): number;
  62188. /**
  62189. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  62190. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  62191. * @param value1 spline value
  62192. * @param tangent1 spline value
  62193. * @param value2 spline value
  62194. * @param tangent2 spline value
  62195. * @param amount input value
  62196. * @returns hermite result
  62197. */
  62198. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  62199. /**
  62200. * Returns a random float number between and min and max values
  62201. * @param min min value of random
  62202. * @param max max value of random
  62203. * @returns random value
  62204. */
  62205. static RandomRange(min: number, max: number): number;
  62206. /**
  62207. * This function returns percentage of a number in a given range.
  62208. *
  62209. * RangeToPercent(40,20,60) will return 0.5 (50%)
  62210. * RangeToPercent(34,0,100) will return 0.34 (34%)
  62211. * @param number to convert to percentage
  62212. * @param min min range
  62213. * @param max max range
  62214. * @returns the percentage
  62215. */
  62216. static RangeToPercent(number: number, min: number, max: number): number;
  62217. /**
  62218. * This function returns number that corresponds to the percentage in a given range.
  62219. *
  62220. * PercentToRange(0.34,0,100) will return 34.
  62221. * @param percent to convert to number
  62222. * @param min min range
  62223. * @param max max range
  62224. * @returns the number
  62225. */
  62226. static PercentToRange(percent: number, min: number, max: number): number;
  62227. /**
  62228. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  62229. * @param angle The angle to normalize in radian.
  62230. * @return The converted angle.
  62231. */
  62232. static NormalizeRadians(angle: number): number;
  62233. }
  62234. }
  62235. declare module BABYLON {
  62236. /**
  62237. * Constant used to convert a value to gamma space
  62238. * @ignorenaming
  62239. */
  62240. export const ToGammaSpace: number;
  62241. /**
  62242. * Constant used to convert a value to linear space
  62243. * @ignorenaming
  62244. */
  62245. export const ToLinearSpace = 2.2;
  62246. /**
  62247. * Constant used to define the minimal number value in Babylon.js
  62248. * @ignorenaming
  62249. */
  62250. let Epsilon: number;
  62251. /**
  62252. * Class used to hold a RBG color
  62253. */
  62254. export class Color3 {
  62255. /**
  62256. * Defines the red component (between 0 and 1, default is 0)
  62257. */
  62258. r: number;
  62259. /**
  62260. * Defines the green component (between 0 and 1, default is 0)
  62261. */
  62262. g: number;
  62263. /**
  62264. * Defines the blue component (between 0 and 1, default is 0)
  62265. */
  62266. b: number;
  62267. /**
  62268. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  62269. * @param r defines the red component (between 0 and 1, default is 0)
  62270. * @param g defines the green component (between 0 and 1, default is 0)
  62271. * @param b defines the blue component (between 0 and 1, default is 0)
  62272. */
  62273. constructor(
  62274. /**
  62275. * Defines the red component (between 0 and 1, default is 0)
  62276. */
  62277. r?: number,
  62278. /**
  62279. * Defines the green component (between 0 and 1, default is 0)
  62280. */
  62281. g?: number,
  62282. /**
  62283. * Defines the blue component (between 0 and 1, default is 0)
  62284. */
  62285. b?: number);
  62286. /**
  62287. * Creates a string with the Color3 current values
  62288. * @returns the string representation of the Color3 object
  62289. */
  62290. toString(): string;
  62291. /**
  62292. * Returns the string "Color3"
  62293. * @returns "Color3"
  62294. */
  62295. getClassName(): string;
  62296. /**
  62297. * Compute the Color3 hash code
  62298. * @returns an unique number that can be used to hash Color3 objects
  62299. */
  62300. getHashCode(): number;
  62301. /**
  62302. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  62303. * @param array defines the array where to store the r,g,b components
  62304. * @param index defines an optional index in the target array to define where to start storing values
  62305. * @returns the current Color3 object
  62306. */
  62307. toArray(array: FloatArray, index?: number): Color3;
  62308. /**
  62309. * Returns a new Color4 object from the current Color3 and the given alpha
  62310. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  62311. * @returns a new Color4 object
  62312. */
  62313. toColor4(alpha?: number): Color4;
  62314. /**
  62315. * Returns a new array populated with 3 numeric elements : red, green and blue values
  62316. * @returns the new array
  62317. */
  62318. asArray(): number[];
  62319. /**
  62320. * Returns the luminance value
  62321. * @returns a float value
  62322. */
  62323. toLuminance(): number;
  62324. /**
  62325. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  62326. * @param otherColor defines the second operand
  62327. * @returns the new Color3 object
  62328. */
  62329. multiply(otherColor: DeepImmutable<Color3>): Color3;
  62330. /**
  62331. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  62332. * @param otherColor defines the second operand
  62333. * @param result defines the Color3 object where to store the result
  62334. * @returns the current Color3
  62335. */
  62336. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  62337. /**
  62338. * Determines equality between Color3 objects
  62339. * @param otherColor defines the second operand
  62340. * @returns true if the rgb values are equal to the given ones
  62341. */
  62342. equals(otherColor: DeepImmutable<Color3>): boolean;
  62343. /**
  62344. * Determines equality between the current Color3 object and a set of r,b,g values
  62345. * @param r defines the red component to check
  62346. * @param g defines the green component to check
  62347. * @param b defines the blue component to check
  62348. * @returns true if the rgb values are equal to the given ones
  62349. */
  62350. equalsFloats(r: number, g: number, b: number): boolean;
  62351. /**
  62352. * Multiplies in place each rgb value by scale
  62353. * @param scale defines the scaling factor
  62354. * @returns the updated Color3
  62355. */
  62356. scale(scale: number): Color3;
  62357. /**
  62358. * Multiplies the rgb values by scale and stores the result into "result"
  62359. * @param scale defines the scaling factor
  62360. * @param result defines the Color3 object where to store the result
  62361. * @returns the unmodified current Color3
  62362. */
  62363. scaleToRef(scale: number, result: Color3): Color3;
  62364. /**
  62365. * Scale the current Color3 values by a factor and add the result to a given Color3
  62366. * @param scale defines the scale factor
  62367. * @param result defines color to store the result into
  62368. * @returns the unmodified current Color3
  62369. */
  62370. scaleAndAddToRef(scale: number, result: Color3): Color3;
  62371. /**
  62372. * Clamps the rgb values by the min and max values and stores the result into "result"
  62373. * @param min defines minimum clamping value (default is 0)
  62374. * @param max defines maximum clamping value (default is 1)
  62375. * @param result defines color to store the result into
  62376. * @returns the original Color3
  62377. */
  62378. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  62379. /**
  62380. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  62381. * @param otherColor defines the second operand
  62382. * @returns the new Color3
  62383. */
  62384. add(otherColor: DeepImmutable<Color3>): Color3;
  62385. /**
  62386. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  62387. * @param otherColor defines the second operand
  62388. * @param result defines Color3 object to store the result into
  62389. * @returns the unmodified current Color3
  62390. */
  62391. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  62392. /**
  62393. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  62394. * @param otherColor defines the second operand
  62395. * @returns the new Color3
  62396. */
  62397. subtract(otherColor: DeepImmutable<Color3>): Color3;
  62398. /**
  62399. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  62400. * @param otherColor defines the second operand
  62401. * @param result defines Color3 object to store the result into
  62402. * @returns the unmodified current Color3
  62403. */
  62404. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  62405. /**
  62406. * Copy the current object
  62407. * @returns a new Color3 copied the current one
  62408. */
  62409. clone(): Color3;
  62410. /**
  62411. * Copies the rgb values from the source in the current Color3
  62412. * @param source defines the source Color3 object
  62413. * @returns the updated Color3 object
  62414. */
  62415. copyFrom(source: DeepImmutable<Color3>): Color3;
  62416. /**
  62417. * Updates the Color3 rgb values from the given floats
  62418. * @param r defines the red component to read from
  62419. * @param g defines the green component to read from
  62420. * @param b defines the blue component to read from
  62421. * @returns the current Color3 object
  62422. */
  62423. copyFromFloats(r: number, g: number, b: number): Color3;
  62424. /**
  62425. * Updates the Color3 rgb values from the given floats
  62426. * @param r defines the red component to read from
  62427. * @param g defines the green component to read from
  62428. * @param b defines the blue component to read from
  62429. * @returns the current Color3 object
  62430. */
  62431. set(r: number, g: number, b: number): Color3;
  62432. /**
  62433. * Compute the Color3 hexadecimal code as a string
  62434. * @returns a string containing the hexadecimal representation of the Color3 object
  62435. */
  62436. toHexString(): string;
  62437. /**
  62438. * Computes a new Color3 converted from the current one to linear space
  62439. * @returns a new Color3 object
  62440. */
  62441. toLinearSpace(): Color3;
  62442. /**
  62443. * Converts current color in rgb space to HSV values
  62444. * @returns a new color3 representing the HSV values
  62445. */
  62446. toHSV(): Color3;
  62447. /**
  62448. * Converts current color in rgb space to HSV values
  62449. * @param result defines the Color3 where to store the HSV values
  62450. */
  62451. toHSVToRef(result: Color3): void;
  62452. /**
  62453. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  62454. * @param convertedColor defines the Color3 object where to store the linear space version
  62455. * @returns the unmodified Color3
  62456. */
  62457. toLinearSpaceToRef(convertedColor: Color3): Color3;
  62458. /**
  62459. * Computes a new Color3 converted from the current one to gamma space
  62460. * @returns a new Color3 object
  62461. */
  62462. toGammaSpace(): Color3;
  62463. /**
  62464. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  62465. * @param convertedColor defines the Color3 object where to store the gamma space version
  62466. * @returns the unmodified Color3
  62467. */
  62468. toGammaSpaceToRef(convertedColor: Color3): Color3;
  62469. private static _BlackReadOnly;
  62470. /**
  62471. * Convert Hue, saturation and value to a Color3 (RGB)
  62472. * @param hue defines the hue
  62473. * @param saturation defines the saturation
  62474. * @param value defines the value
  62475. * @param result defines the Color3 where to store the RGB values
  62476. */
  62477. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  62478. /**
  62479. * Creates a new Color3 from the string containing valid hexadecimal values
  62480. * @param hex defines a string containing valid hexadecimal values
  62481. * @returns a new Color3 object
  62482. */
  62483. static FromHexString(hex: string): Color3;
  62484. /**
  62485. * Creates a new Color3 from the starting index of the given array
  62486. * @param array defines the source array
  62487. * @param offset defines an offset in the source array
  62488. * @returns a new Color3 object
  62489. */
  62490. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  62491. /**
  62492. * Creates a new Color3 from integer values (< 256)
  62493. * @param r defines the red component to read from (value between 0 and 255)
  62494. * @param g defines the green component to read from (value between 0 and 255)
  62495. * @param b defines the blue component to read from (value between 0 and 255)
  62496. * @returns a new Color3 object
  62497. */
  62498. static FromInts(r: number, g: number, b: number): Color3;
  62499. /**
  62500. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  62501. * @param start defines the start Color3 value
  62502. * @param end defines the end Color3 value
  62503. * @param amount defines the gradient value between start and end
  62504. * @returns a new Color3 object
  62505. */
  62506. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  62507. /**
  62508. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  62509. * @param left defines the start value
  62510. * @param right defines the end value
  62511. * @param amount defines the gradient factor
  62512. * @param result defines the Color3 object where to store the result
  62513. */
  62514. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  62515. /**
  62516. * Returns a Color3 value containing a red color
  62517. * @returns a new Color3 object
  62518. */
  62519. static Red(): Color3;
  62520. /**
  62521. * Returns a Color3 value containing a green color
  62522. * @returns a new Color3 object
  62523. */
  62524. static Green(): Color3;
  62525. /**
  62526. * Returns a Color3 value containing a blue color
  62527. * @returns a new Color3 object
  62528. */
  62529. static Blue(): Color3;
  62530. /**
  62531. * Returns a Color3 value containing a black color
  62532. * @returns a new Color3 object
  62533. */
  62534. static Black(): Color3;
  62535. /**
  62536. * Gets a Color3 value containing a black color that must not be updated
  62537. */
  62538. static readonly BlackReadOnly: DeepImmutable<Color3>;
  62539. /**
  62540. * Returns a Color3 value containing a white color
  62541. * @returns a new Color3 object
  62542. */
  62543. static White(): Color3;
  62544. /**
  62545. * Returns a Color3 value containing a purple color
  62546. * @returns a new Color3 object
  62547. */
  62548. static Purple(): Color3;
  62549. /**
  62550. * Returns a Color3 value containing a magenta color
  62551. * @returns a new Color3 object
  62552. */
  62553. static Magenta(): Color3;
  62554. /**
  62555. * Returns a Color3 value containing a yellow color
  62556. * @returns a new Color3 object
  62557. */
  62558. static Yellow(): Color3;
  62559. /**
  62560. * Returns a Color3 value containing a gray color
  62561. * @returns a new Color3 object
  62562. */
  62563. static Gray(): Color3;
  62564. /**
  62565. * Returns a Color3 value containing a teal color
  62566. * @returns a new Color3 object
  62567. */
  62568. static Teal(): Color3;
  62569. /**
  62570. * Returns a Color3 value containing a random color
  62571. * @returns a new Color3 object
  62572. */
  62573. static Random(): Color3;
  62574. }
  62575. /**
  62576. * Class used to hold a RBGA color
  62577. */
  62578. export class Color4 {
  62579. /**
  62580. * Defines the red component (between 0 and 1, default is 0)
  62581. */
  62582. r: number;
  62583. /**
  62584. * Defines the green component (between 0 and 1, default is 0)
  62585. */
  62586. g: number;
  62587. /**
  62588. * Defines the blue component (between 0 and 1, default is 0)
  62589. */
  62590. b: number;
  62591. /**
  62592. * Defines the alpha component (between 0 and 1, default is 1)
  62593. */
  62594. a: number;
  62595. /**
  62596. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  62597. * @param r defines the red component (between 0 and 1, default is 0)
  62598. * @param g defines the green component (between 0 and 1, default is 0)
  62599. * @param b defines the blue component (between 0 and 1, default is 0)
  62600. * @param a defines the alpha component (between 0 and 1, default is 1)
  62601. */
  62602. constructor(
  62603. /**
  62604. * Defines the red component (between 0 and 1, default is 0)
  62605. */
  62606. r?: number,
  62607. /**
  62608. * Defines the green component (between 0 and 1, default is 0)
  62609. */
  62610. g?: number,
  62611. /**
  62612. * Defines the blue component (between 0 and 1, default is 0)
  62613. */
  62614. b?: number,
  62615. /**
  62616. * Defines the alpha component (between 0 and 1, default is 1)
  62617. */
  62618. a?: number);
  62619. /**
  62620. * Adds in place the given Color4 values to the current Color4 object
  62621. * @param right defines the second operand
  62622. * @returns the current updated Color4 object
  62623. */
  62624. addInPlace(right: DeepImmutable<Color4>): Color4;
  62625. /**
  62626. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  62627. * @returns the new array
  62628. */
  62629. asArray(): number[];
  62630. /**
  62631. * Stores from the starting index in the given array the Color4 successive values
  62632. * @param array defines the array where to store the r,g,b components
  62633. * @param index defines an optional index in the target array to define where to start storing values
  62634. * @returns the current Color4 object
  62635. */
  62636. toArray(array: number[], index?: number): Color4;
  62637. /**
  62638. * Determines equality between Color4 objects
  62639. * @param otherColor defines the second operand
  62640. * @returns true if the rgba values are equal to the given ones
  62641. */
  62642. equals(otherColor: DeepImmutable<Color4>): boolean;
  62643. /**
  62644. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  62645. * @param right defines the second operand
  62646. * @returns a new Color4 object
  62647. */
  62648. add(right: DeepImmutable<Color4>): Color4;
  62649. /**
  62650. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  62651. * @param right defines the second operand
  62652. * @returns a new Color4 object
  62653. */
  62654. subtract(right: DeepImmutable<Color4>): Color4;
  62655. /**
  62656. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  62657. * @param right defines the second operand
  62658. * @param result defines the Color4 object where to store the result
  62659. * @returns the current Color4 object
  62660. */
  62661. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  62662. /**
  62663. * Creates a new Color4 with the current Color4 values multiplied by scale
  62664. * @param scale defines the scaling factor to apply
  62665. * @returns a new Color4 object
  62666. */
  62667. scale(scale: number): Color4;
  62668. /**
  62669. * Multiplies the current Color4 values by scale and stores the result in "result"
  62670. * @param scale defines the scaling factor to apply
  62671. * @param result defines the Color4 object where to store the result
  62672. * @returns the current unmodified Color4
  62673. */
  62674. scaleToRef(scale: number, result: Color4): Color4;
  62675. /**
  62676. * Scale the current Color4 values by a factor and add the result to a given Color4
  62677. * @param scale defines the scale factor
  62678. * @param result defines the Color4 object where to store the result
  62679. * @returns the unmodified current Color4
  62680. */
  62681. scaleAndAddToRef(scale: number, result: Color4): Color4;
  62682. /**
  62683. * Clamps the rgb values by the min and max values and stores the result into "result"
  62684. * @param min defines minimum clamping value (default is 0)
  62685. * @param max defines maximum clamping value (default is 1)
  62686. * @param result defines color to store the result into.
  62687. * @returns the cuurent Color4
  62688. */
  62689. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  62690. /**
  62691. * Multipy an Color4 value by another and return a new Color4 object
  62692. * @param color defines the Color4 value to multiply by
  62693. * @returns a new Color4 object
  62694. */
  62695. multiply(color: Color4): Color4;
  62696. /**
  62697. * Multipy a Color4 value by another and push the result in a reference value
  62698. * @param color defines the Color4 value to multiply by
  62699. * @param result defines the Color4 to fill the result in
  62700. * @returns the result Color4
  62701. */
  62702. multiplyToRef(color: Color4, result: Color4): Color4;
  62703. /**
  62704. * Creates a string with the Color4 current values
  62705. * @returns the string representation of the Color4 object
  62706. */
  62707. toString(): string;
  62708. /**
  62709. * Returns the string "Color4"
  62710. * @returns "Color4"
  62711. */
  62712. getClassName(): string;
  62713. /**
  62714. * Compute the Color4 hash code
  62715. * @returns an unique number that can be used to hash Color4 objects
  62716. */
  62717. getHashCode(): number;
  62718. /**
  62719. * Creates a new Color4 copied from the current one
  62720. * @returns a new Color4 object
  62721. */
  62722. clone(): Color4;
  62723. /**
  62724. * Copies the given Color4 values into the current one
  62725. * @param source defines the source Color4 object
  62726. * @returns the current updated Color4 object
  62727. */
  62728. copyFrom(source: Color4): Color4;
  62729. /**
  62730. * Copies the given float values into the current one
  62731. * @param r defines the red component to read from
  62732. * @param g defines the green component to read from
  62733. * @param b defines the blue component to read from
  62734. * @param a defines the alpha component to read from
  62735. * @returns the current updated Color4 object
  62736. */
  62737. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  62738. /**
  62739. * Copies the given float values into the current one
  62740. * @param r defines the red component to read from
  62741. * @param g defines the green component to read from
  62742. * @param b defines the blue component to read from
  62743. * @param a defines the alpha component to read from
  62744. * @returns the current updated Color4 object
  62745. */
  62746. set(r: number, g: number, b: number, a: number): Color4;
  62747. /**
  62748. * Compute the Color4 hexadecimal code as a string
  62749. * @returns a string containing the hexadecimal representation of the Color4 object
  62750. */
  62751. toHexString(): string;
  62752. /**
  62753. * Computes a new Color4 converted from the current one to linear space
  62754. * @returns a new Color4 object
  62755. */
  62756. toLinearSpace(): Color4;
  62757. /**
  62758. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  62759. * @param convertedColor defines the Color4 object where to store the linear space version
  62760. * @returns the unmodified Color4
  62761. */
  62762. toLinearSpaceToRef(convertedColor: Color4): Color4;
  62763. /**
  62764. * Computes a new Color4 converted from the current one to gamma space
  62765. * @returns a new Color4 object
  62766. */
  62767. toGammaSpace(): Color4;
  62768. /**
  62769. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  62770. * @param convertedColor defines the Color4 object where to store the gamma space version
  62771. * @returns the unmodified Color4
  62772. */
  62773. toGammaSpaceToRef(convertedColor: Color4): Color4;
  62774. /**
  62775. * Creates a new Color4 from the string containing valid hexadecimal values
  62776. * @param hex defines a string containing valid hexadecimal values
  62777. * @returns a new Color4 object
  62778. */
  62779. static FromHexString(hex: string): Color4;
  62780. /**
  62781. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  62782. * @param left defines the start value
  62783. * @param right defines the end value
  62784. * @param amount defines the gradient factor
  62785. * @returns a new Color4 object
  62786. */
  62787. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  62788. /**
  62789. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  62790. * @param left defines the start value
  62791. * @param right defines the end value
  62792. * @param amount defines the gradient factor
  62793. * @param result defines the Color4 object where to store data
  62794. */
  62795. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  62796. /**
  62797. * Creates a new Color4 from a Color3 and an alpha value
  62798. * @param color3 defines the source Color3 to read from
  62799. * @param alpha defines the alpha component (1.0 by default)
  62800. * @returns a new Color4 object
  62801. */
  62802. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  62803. /**
  62804. * Creates a new Color4 from the starting index element of the given array
  62805. * @param array defines the source array to read from
  62806. * @param offset defines the offset in the source array
  62807. * @returns a new Color4 object
  62808. */
  62809. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  62810. /**
  62811. * Creates a new Color3 from integer values (< 256)
  62812. * @param r defines the red component to read from (value between 0 and 255)
  62813. * @param g defines the green component to read from (value between 0 and 255)
  62814. * @param b defines the blue component to read from (value between 0 and 255)
  62815. * @param a defines the alpha component to read from (value between 0 and 255)
  62816. * @returns a new Color3 object
  62817. */
  62818. static FromInts(r: number, g: number, b: number, a: number): Color4;
  62819. /**
  62820. * Check the content of a given array and convert it to an array containing RGBA data
  62821. * If the original array was already containing count * 4 values then it is returned directly
  62822. * @param colors defines the array to check
  62823. * @param count defines the number of RGBA data to expect
  62824. * @returns an array containing count * 4 values (RGBA)
  62825. */
  62826. static CheckColors4(colors: number[], count: number): number[];
  62827. }
  62828. /**
  62829. * Class representing a vector containing 2 coordinates
  62830. */
  62831. export class Vector2 {
  62832. /** defines the first coordinate */
  62833. x: number;
  62834. /** defines the second coordinate */
  62835. y: number;
  62836. /**
  62837. * Creates a new Vector2 from the given x and y coordinates
  62838. * @param x defines the first coordinate
  62839. * @param y defines the second coordinate
  62840. */
  62841. constructor(
  62842. /** defines the first coordinate */
  62843. x?: number,
  62844. /** defines the second coordinate */
  62845. y?: number);
  62846. /**
  62847. * Gets a string with the Vector2 coordinates
  62848. * @returns a string with the Vector2 coordinates
  62849. */
  62850. toString(): string;
  62851. /**
  62852. * Gets class name
  62853. * @returns the string "Vector2"
  62854. */
  62855. getClassName(): string;
  62856. /**
  62857. * Gets current vector hash code
  62858. * @returns the Vector2 hash code as a number
  62859. */
  62860. getHashCode(): number;
  62861. /**
  62862. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  62863. * @param array defines the source array
  62864. * @param index defines the offset in source array
  62865. * @returns the current Vector2
  62866. */
  62867. toArray(array: FloatArray, index?: number): Vector2;
  62868. /**
  62869. * Copy the current vector to an array
  62870. * @returns a new array with 2 elements: the Vector2 coordinates.
  62871. */
  62872. asArray(): number[];
  62873. /**
  62874. * Sets the Vector2 coordinates with the given Vector2 coordinates
  62875. * @param source defines the source Vector2
  62876. * @returns the current updated Vector2
  62877. */
  62878. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  62879. /**
  62880. * Sets the Vector2 coordinates with the given floats
  62881. * @param x defines the first coordinate
  62882. * @param y defines the second coordinate
  62883. * @returns the current updated Vector2
  62884. */
  62885. copyFromFloats(x: number, y: number): Vector2;
  62886. /**
  62887. * Sets the Vector2 coordinates with the given floats
  62888. * @param x defines the first coordinate
  62889. * @param y defines the second coordinate
  62890. * @returns the current updated Vector2
  62891. */
  62892. set(x: number, y: number): Vector2;
  62893. /**
  62894. * Add another vector with the current one
  62895. * @param otherVector defines the other vector
  62896. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  62897. */
  62898. add(otherVector: DeepImmutable<Vector2>): Vector2;
  62899. /**
  62900. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  62901. * @param otherVector defines the other vector
  62902. * @param result defines the target vector
  62903. * @returns the unmodified current Vector2
  62904. */
  62905. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  62906. /**
  62907. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  62908. * @param otherVector defines the other vector
  62909. * @returns the current updated Vector2
  62910. */
  62911. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  62912. /**
  62913. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  62914. * @param otherVector defines the other vector
  62915. * @returns a new Vector2
  62916. */
  62917. addVector3(otherVector: Vector3): Vector2;
  62918. /**
  62919. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  62920. * @param otherVector defines the other vector
  62921. * @returns a new Vector2
  62922. */
  62923. subtract(otherVector: Vector2): Vector2;
  62924. /**
  62925. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  62926. * @param otherVector defines the other vector
  62927. * @param result defines the target vector
  62928. * @returns the unmodified current Vector2
  62929. */
  62930. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  62931. /**
  62932. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  62933. * @param otherVector defines the other vector
  62934. * @returns the current updated Vector2
  62935. */
  62936. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  62937. /**
  62938. * Multiplies in place the current Vector2 coordinates by the given ones
  62939. * @param otherVector defines the other vector
  62940. * @returns the current updated Vector2
  62941. */
  62942. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  62943. /**
  62944. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  62945. * @param otherVector defines the other vector
  62946. * @returns a new Vector2
  62947. */
  62948. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  62949. /**
  62950. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  62951. * @param otherVector defines the other vector
  62952. * @param result defines the target vector
  62953. * @returns the unmodified current Vector2
  62954. */
  62955. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  62956. /**
  62957. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  62958. * @param x defines the first coordinate
  62959. * @param y defines the second coordinate
  62960. * @returns a new Vector2
  62961. */
  62962. multiplyByFloats(x: number, y: number): Vector2;
  62963. /**
  62964. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  62965. * @param otherVector defines the other vector
  62966. * @returns a new Vector2
  62967. */
  62968. divide(otherVector: Vector2): Vector2;
  62969. /**
  62970. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  62971. * @param otherVector defines the other vector
  62972. * @param result defines the target vector
  62973. * @returns the unmodified current Vector2
  62974. */
  62975. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  62976. /**
  62977. * Divides the current Vector2 coordinates by the given ones
  62978. * @param otherVector defines the other vector
  62979. * @returns the current updated Vector2
  62980. */
  62981. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  62982. /**
  62983. * Gets a new Vector2 with current Vector2 negated coordinates
  62984. * @returns a new Vector2
  62985. */
  62986. negate(): Vector2;
  62987. /**
  62988. * Multiply the Vector2 coordinates by scale
  62989. * @param scale defines the scaling factor
  62990. * @returns the current updated Vector2
  62991. */
  62992. scaleInPlace(scale: number): Vector2;
  62993. /**
  62994. * Returns a new Vector2 scaled by "scale" from the current Vector2
  62995. * @param scale defines the scaling factor
  62996. * @returns a new Vector2
  62997. */
  62998. scale(scale: number): Vector2;
  62999. /**
  63000. * Scale the current Vector2 values by a factor to a given Vector2
  63001. * @param scale defines the scale factor
  63002. * @param result defines the Vector2 object where to store the result
  63003. * @returns the unmodified current Vector2
  63004. */
  63005. scaleToRef(scale: number, result: Vector2): Vector2;
  63006. /**
  63007. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  63008. * @param scale defines the scale factor
  63009. * @param result defines the Vector2 object where to store the result
  63010. * @returns the unmodified current Vector2
  63011. */
  63012. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  63013. /**
  63014. * Gets a boolean if two vectors are equals
  63015. * @param otherVector defines the other vector
  63016. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  63017. */
  63018. equals(otherVector: DeepImmutable<Vector2>): boolean;
  63019. /**
  63020. * Gets a boolean if two vectors are equals (using an epsilon value)
  63021. * @param otherVector defines the other vector
  63022. * @param epsilon defines the minimal distance to consider equality
  63023. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  63024. */
  63025. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  63026. /**
  63027. * Gets a new Vector2 from current Vector2 floored values
  63028. * @returns a new Vector2
  63029. */
  63030. floor(): Vector2;
  63031. /**
  63032. * Gets a new Vector2 from current Vector2 floored values
  63033. * @returns a new Vector2
  63034. */
  63035. fract(): Vector2;
  63036. /**
  63037. * Gets the length of the vector
  63038. * @returns the vector length (float)
  63039. */
  63040. length(): number;
  63041. /**
  63042. * Gets the vector squared length
  63043. * @returns the vector squared length (float)
  63044. */
  63045. lengthSquared(): number;
  63046. /**
  63047. * Normalize the vector
  63048. * @returns the current updated Vector2
  63049. */
  63050. normalize(): Vector2;
  63051. /**
  63052. * Gets a new Vector2 copied from the Vector2
  63053. * @returns a new Vector2
  63054. */
  63055. clone(): Vector2;
  63056. /**
  63057. * Gets a new Vector2(0, 0)
  63058. * @returns a new Vector2
  63059. */
  63060. static Zero(): Vector2;
  63061. /**
  63062. * Gets a new Vector2(1, 1)
  63063. * @returns a new Vector2
  63064. */
  63065. static One(): Vector2;
  63066. /**
  63067. * Gets a new Vector2 set from the given index element of the given array
  63068. * @param array defines the data source
  63069. * @param offset defines the offset in the data source
  63070. * @returns a new Vector2
  63071. */
  63072. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  63073. /**
  63074. * Sets "result" from the given index element of the given array
  63075. * @param array defines the data source
  63076. * @param offset defines the offset in the data source
  63077. * @param result defines the target vector
  63078. */
  63079. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  63080. /**
  63081. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  63082. * @param value1 defines 1st point of control
  63083. * @param value2 defines 2nd point of control
  63084. * @param value3 defines 3rd point of control
  63085. * @param value4 defines 4th point of control
  63086. * @param amount defines the interpolation factor
  63087. * @returns a new Vector2
  63088. */
  63089. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  63090. /**
  63091. * 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".
  63092. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  63093. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  63094. * @param value defines the value to clamp
  63095. * @param min defines the lower limit
  63096. * @param max defines the upper limit
  63097. * @returns a new Vector2
  63098. */
  63099. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  63100. /**
  63101. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  63102. * @param value1 defines the 1st control point
  63103. * @param tangent1 defines the outgoing tangent
  63104. * @param value2 defines the 2nd control point
  63105. * @param tangent2 defines the incoming tangent
  63106. * @param amount defines the interpolation factor
  63107. * @returns a new Vector2
  63108. */
  63109. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  63110. /**
  63111. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  63112. * @param start defines the start vector
  63113. * @param end defines the end vector
  63114. * @param amount defines the interpolation factor
  63115. * @returns a new Vector2
  63116. */
  63117. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  63118. /**
  63119. * Gets the dot product of the vector "left" and the vector "right"
  63120. * @param left defines first vector
  63121. * @param right defines second vector
  63122. * @returns the dot product (float)
  63123. */
  63124. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  63125. /**
  63126. * Returns a new Vector2 equal to the normalized given vector
  63127. * @param vector defines the vector to normalize
  63128. * @returns a new Vector2
  63129. */
  63130. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  63131. /**
  63132. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  63133. * @param left defines 1st vector
  63134. * @param right defines 2nd vector
  63135. * @returns a new Vector2
  63136. */
  63137. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  63138. /**
  63139. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  63140. * @param left defines 1st vector
  63141. * @param right defines 2nd vector
  63142. * @returns a new Vector2
  63143. */
  63144. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  63145. /**
  63146. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  63147. * @param vector defines the vector to transform
  63148. * @param transformation defines the matrix to apply
  63149. * @returns a new Vector2
  63150. */
  63151. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  63152. /**
  63153. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  63154. * @param vector defines the vector to transform
  63155. * @param transformation defines the matrix to apply
  63156. * @param result defines the target vector
  63157. */
  63158. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  63159. /**
  63160. * Determines if a given vector is included in a triangle
  63161. * @param p defines the vector to test
  63162. * @param p0 defines 1st triangle point
  63163. * @param p1 defines 2nd triangle point
  63164. * @param p2 defines 3rd triangle point
  63165. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  63166. */
  63167. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  63168. /**
  63169. * Gets the distance between the vectors "value1" and "value2"
  63170. * @param value1 defines first vector
  63171. * @param value2 defines second vector
  63172. * @returns the distance between vectors
  63173. */
  63174. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  63175. /**
  63176. * Returns the squared distance between the vectors "value1" and "value2"
  63177. * @param value1 defines first vector
  63178. * @param value2 defines second vector
  63179. * @returns the squared distance between vectors
  63180. */
  63181. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  63182. /**
  63183. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  63184. * @param value1 defines first vector
  63185. * @param value2 defines second vector
  63186. * @returns a new Vector2
  63187. */
  63188. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  63189. /**
  63190. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  63191. * @param p defines the middle point
  63192. * @param segA defines one point of the segment
  63193. * @param segB defines the other point of the segment
  63194. * @returns the shortest distance
  63195. */
  63196. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  63197. }
  63198. /**
  63199. * Classed used to store (x,y,z) vector representation
  63200. * A Vector3 is the main object used in 3D geometry
  63201. * It can represent etiher the coordinates of a point the space, either a direction
  63202. * Reminder: js uses a left handed forward facing system
  63203. */
  63204. export class Vector3 {
  63205. /**
  63206. * Defines the first coordinates (on X axis)
  63207. */
  63208. x: number;
  63209. /**
  63210. * Defines the second coordinates (on Y axis)
  63211. */
  63212. y: number;
  63213. /**
  63214. * Defines the third coordinates (on Z axis)
  63215. */
  63216. z: number;
  63217. private static _UpReadOnly;
  63218. private static _ZeroReadOnly;
  63219. /**
  63220. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  63221. * @param x defines the first coordinates (on X axis)
  63222. * @param y defines the second coordinates (on Y axis)
  63223. * @param z defines the third coordinates (on Z axis)
  63224. */
  63225. constructor(
  63226. /**
  63227. * Defines the first coordinates (on X axis)
  63228. */
  63229. x?: number,
  63230. /**
  63231. * Defines the second coordinates (on Y axis)
  63232. */
  63233. y?: number,
  63234. /**
  63235. * Defines the third coordinates (on Z axis)
  63236. */
  63237. z?: number);
  63238. /**
  63239. * Creates a string representation of the Vector3
  63240. * @returns a string with the Vector3 coordinates.
  63241. */
  63242. toString(): string;
  63243. /**
  63244. * Gets the class name
  63245. * @returns the string "Vector3"
  63246. */
  63247. getClassName(): string;
  63248. /**
  63249. * Creates the Vector3 hash code
  63250. * @returns a number which tends to be unique between Vector3 instances
  63251. */
  63252. getHashCode(): number;
  63253. /**
  63254. * Creates an array containing three elements : the coordinates of the Vector3
  63255. * @returns a new array of numbers
  63256. */
  63257. asArray(): number[];
  63258. /**
  63259. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  63260. * @param array defines the destination array
  63261. * @param index defines the offset in the destination array
  63262. * @returns the current Vector3
  63263. */
  63264. toArray(array: FloatArray, index?: number): Vector3;
  63265. /**
  63266. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  63267. * @returns a new Quaternion object, computed from the Vector3 coordinates
  63268. */
  63269. toQuaternion(): Quaternion;
  63270. /**
  63271. * Adds the given vector to the current Vector3
  63272. * @param otherVector defines the second operand
  63273. * @returns the current updated Vector3
  63274. */
  63275. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  63276. /**
  63277. * Adds the given coordinates to the current Vector3
  63278. * @param x defines the x coordinate of the operand
  63279. * @param y defines the y coordinate of the operand
  63280. * @param z defines the z coordinate of the operand
  63281. * @returns the current updated Vector3
  63282. */
  63283. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  63284. /**
  63285. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  63286. * @param otherVector defines the second operand
  63287. * @returns the resulting Vector3
  63288. */
  63289. add(otherVector: DeepImmutable<Vector3>): Vector3;
  63290. /**
  63291. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  63292. * @param otherVector defines the second operand
  63293. * @param result defines the Vector3 object where to store the result
  63294. * @returns the current Vector3
  63295. */
  63296. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  63297. /**
  63298. * Subtract the given vector from the current Vector3
  63299. * @param otherVector defines the second operand
  63300. * @returns the current updated Vector3
  63301. */
  63302. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  63303. /**
  63304. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  63305. * @param otherVector defines the second operand
  63306. * @returns the resulting Vector3
  63307. */
  63308. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  63309. /**
  63310. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  63311. * @param otherVector defines the second operand
  63312. * @param result defines the Vector3 object where to store the result
  63313. * @returns the current Vector3
  63314. */
  63315. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  63316. /**
  63317. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  63318. * @param x defines the x coordinate of the operand
  63319. * @param y defines the y coordinate of the operand
  63320. * @param z defines the z coordinate of the operand
  63321. * @returns the resulting Vector3
  63322. */
  63323. subtractFromFloats(x: number, y: number, z: number): Vector3;
  63324. /**
  63325. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  63326. * @param x defines the x coordinate of the operand
  63327. * @param y defines the y coordinate of the operand
  63328. * @param z defines the z coordinate of the operand
  63329. * @param result defines the Vector3 object where to store the result
  63330. * @returns the current Vector3
  63331. */
  63332. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  63333. /**
  63334. * Gets a new Vector3 set with the current Vector3 negated coordinates
  63335. * @returns a new Vector3
  63336. */
  63337. negate(): Vector3;
  63338. /**
  63339. * Multiplies the Vector3 coordinates by the float "scale"
  63340. * @param scale defines the multiplier factor
  63341. * @returns the current updated Vector3
  63342. */
  63343. scaleInPlace(scale: number): Vector3;
  63344. /**
  63345. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  63346. * @param scale defines the multiplier factor
  63347. * @returns a new Vector3
  63348. */
  63349. scale(scale: number): Vector3;
  63350. /**
  63351. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  63352. * @param scale defines the multiplier factor
  63353. * @param result defines the Vector3 object where to store the result
  63354. * @returns the current Vector3
  63355. */
  63356. scaleToRef(scale: number, result: Vector3): Vector3;
  63357. /**
  63358. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  63359. * @param scale defines the scale factor
  63360. * @param result defines the Vector3 object where to store the result
  63361. * @returns the unmodified current Vector3
  63362. */
  63363. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  63364. /**
  63365. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  63366. * @param otherVector defines the second operand
  63367. * @returns true if both vectors are equals
  63368. */
  63369. equals(otherVector: DeepImmutable<Vector3>): boolean;
  63370. /**
  63371. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  63372. * @param otherVector defines the second operand
  63373. * @param epsilon defines the minimal distance to define values as equals
  63374. * @returns true if both vectors are distant less than epsilon
  63375. */
  63376. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  63377. /**
  63378. * Returns true if the current Vector3 coordinates equals the given floats
  63379. * @param x defines the x coordinate of the operand
  63380. * @param y defines the y coordinate of the operand
  63381. * @param z defines the z coordinate of the operand
  63382. * @returns true if both vectors are equals
  63383. */
  63384. equalsToFloats(x: number, y: number, z: number): boolean;
  63385. /**
  63386. * Multiplies the current Vector3 coordinates by the given ones
  63387. * @param otherVector defines the second operand
  63388. * @returns the current updated Vector3
  63389. */
  63390. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  63391. /**
  63392. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  63393. * @param otherVector defines the second operand
  63394. * @returns the new Vector3
  63395. */
  63396. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  63397. /**
  63398. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  63399. * @param otherVector defines the second operand
  63400. * @param result defines the Vector3 object where to store the result
  63401. * @returns the current Vector3
  63402. */
  63403. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  63404. /**
  63405. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  63406. * @param x defines the x coordinate of the operand
  63407. * @param y defines the y coordinate of the operand
  63408. * @param z defines the z coordinate of the operand
  63409. * @returns the new Vector3
  63410. */
  63411. multiplyByFloats(x: number, y: number, z: number): Vector3;
  63412. /**
  63413. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  63414. * @param otherVector defines the second operand
  63415. * @returns the new Vector3
  63416. */
  63417. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  63418. /**
  63419. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  63420. * @param otherVector defines the second operand
  63421. * @param result defines the Vector3 object where to store the result
  63422. * @returns the current Vector3
  63423. */
  63424. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  63425. /**
  63426. * Divides the current Vector3 coordinates by the given ones.
  63427. * @param otherVector defines the second operand
  63428. * @returns the current updated Vector3
  63429. */
  63430. divideInPlace(otherVector: Vector3): Vector3;
  63431. /**
  63432. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  63433. * @param other defines the second operand
  63434. * @returns the current updated Vector3
  63435. */
  63436. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  63437. /**
  63438. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  63439. * @param other defines the second operand
  63440. * @returns the current updated Vector3
  63441. */
  63442. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  63443. /**
  63444. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  63445. * @param x defines the x coordinate of the operand
  63446. * @param y defines the y coordinate of the operand
  63447. * @param z defines the z coordinate of the operand
  63448. * @returns the current updated Vector3
  63449. */
  63450. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  63451. /**
  63452. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  63453. * @param x defines the x coordinate of the operand
  63454. * @param y defines the y coordinate of the operand
  63455. * @param z defines the z coordinate of the operand
  63456. * @returns the current updated Vector3
  63457. */
  63458. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  63459. /**
  63460. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  63461. * Check if is non uniform within a certain amount of decimal places to account for this
  63462. * @param epsilon the amount the values can differ
  63463. * @returns if the the vector is non uniform to a certain number of decimal places
  63464. */
  63465. isNonUniformWithinEpsilon(epsilon: number): boolean;
  63466. /**
  63467. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  63468. */
  63469. readonly isNonUniform: boolean;
  63470. /**
  63471. * Gets a new Vector3 from current Vector3 floored values
  63472. * @returns a new Vector3
  63473. */
  63474. floor(): Vector3;
  63475. /**
  63476. * Gets a new Vector3 from current Vector3 floored values
  63477. * @returns a new Vector3
  63478. */
  63479. fract(): Vector3;
  63480. /**
  63481. * Gets the length of the Vector3
  63482. * @returns the length of the Vecto3
  63483. */
  63484. length(): number;
  63485. /**
  63486. * Gets the squared length of the Vector3
  63487. * @returns squared length of the Vector3
  63488. */
  63489. lengthSquared(): number;
  63490. /**
  63491. * Normalize the current Vector3.
  63492. * Please note that this is an in place operation.
  63493. * @returns the current updated Vector3
  63494. */
  63495. normalize(): Vector3;
  63496. /**
  63497. * Reorders the x y z properties of the vector in place
  63498. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  63499. * @returns the current updated vector
  63500. */
  63501. reorderInPlace(order: string): this;
  63502. /**
  63503. * Rotates the vector around 0,0,0 by a quaternion
  63504. * @param quaternion the rotation quaternion
  63505. * @param result vector to store the result
  63506. * @returns the resulting vector
  63507. */
  63508. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  63509. /**
  63510. * Rotates a vector around a given point
  63511. * @param quaternion the rotation quaternion
  63512. * @param point the point to rotate around
  63513. * @param result vector to store the result
  63514. * @returns the resulting vector
  63515. */
  63516. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  63517. /**
  63518. * Normalize the current Vector3 with the given input length.
  63519. * Please note that this is an in place operation.
  63520. * @param len the length of the vector
  63521. * @returns the current updated Vector3
  63522. */
  63523. normalizeFromLength(len: number): Vector3;
  63524. /**
  63525. * Normalize the current Vector3 to a new vector
  63526. * @returns the new Vector3
  63527. */
  63528. normalizeToNew(): Vector3;
  63529. /**
  63530. * Normalize the current Vector3 to the reference
  63531. * @param reference define the Vector3 to update
  63532. * @returns the updated Vector3
  63533. */
  63534. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  63535. /**
  63536. * Creates a new Vector3 copied from the current Vector3
  63537. * @returns the new Vector3
  63538. */
  63539. clone(): Vector3;
  63540. /**
  63541. * Copies the given vector coordinates to the current Vector3 ones
  63542. * @param source defines the source Vector3
  63543. * @returns the current updated Vector3
  63544. */
  63545. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  63546. /**
  63547. * Copies the given floats to the current Vector3 coordinates
  63548. * @param x defines the x coordinate of the operand
  63549. * @param y defines the y coordinate of the operand
  63550. * @param z defines the z coordinate of the operand
  63551. * @returns the current updated Vector3
  63552. */
  63553. copyFromFloats(x: number, y: number, z: number): Vector3;
  63554. /**
  63555. * Copies the given floats to the current Vector3 coordinates
  63556. * @param x defines the x coordinate of the operand
  63557. * @param y defines the y coordinate of the operand
  63558. * @param z defines the z coordinate of the operand
  63559. * @returns the current updated Vector3
  63560. */
  63561. set(x: number, y: number, z: number): Vector3;
  63562. /**
  63563. * Copies the given float to the current Vector3 coordinates
  63564. * @param v defines the x, y and z coordinates of the operand
  63565. * @returns the current updated Vector3
  63566. */
  63567. setAll(v: number): Vector3;
  63568. /**
  63569. * Get the clip factor between two vectors
  63570. * @param vector0 defines the first operand
  63571. * @param vector1 defines the second operand
  63572. * @param axis defines the axis to use
  63573. * @param size defines the size along the axis
  63574. * @returns the clip factor
  63575. */
  63576. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  63577. /**
  63578. * Get angle between two vectors
  63579. * @param vector0 angle between vector0 and vector1
  63580. * @param vector1 angle between vector0 and vector1
  63581. * @param normal direction of the normal
  63582. * @return the angle between vector0 and vector1
  63583. */
  63584. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  63585. /**
  63586. * Returns a new Vector3 set from the index "offset" of the given array
  63587. * @param array defines the source array
  63588. * @param offset defines the offset in the source array
  63589. * @returns the new Vector3
  63590. */
  63591. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  63592. /**
  63593. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  63594. * This function is deprecated. Use FromArray instead
  63595. * @param array defines the source array
  63596. * @param offset defines the offset in the source array
  63597. * @returns the new Vector3
  63598. */
  63599. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  63600. /**
  63601. * Sets the given vector "result" with the element values from the index "offset" of the given array
  63602. * @param array defines the source array
  63603. * @param offset defines the offset in the source array
  63604. * @param result defines the Vector3 where to store the result
  63605. */
  63606. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  63607. /**
  63608. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  63609. * This function is deprecated. Use FromArrayToRef instead.
  63610. * @param array defines the source array
  63611. * @param offset defines the offset in the source array
  63612. * @param result defines the Vector3 where to store the result
  63613. */
  63614. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  63615. /**
  63616. * Sets the given vector "result" with the given floats.
  63617. * @param x defines the x coordinate of the source
  63618. * @param y defines the y coordinate of the source
  63619. * @param z defines the z coordinate of the source
  63620. * @param result defines the Vector3 where to store the result
  63621. */
  63622. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  63623. /**
  63624. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  63625. * @returns a new empty Vector3
  63626. */
  63627. static Zero(): Vector3;
  63628. /**
  63629. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  63630. * @returns a new unit Vector3
  63631. */
  63632. static One(): Vector3;
  63633. /**
  63634. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  63635. * @returns a new up Vector3
  63636. */
  63637. static Up(): Vector3;
  63638. /**
  63639. * Gets a up Vector3 that must not be updated
  63640. */
  63641. static readonly UpReadOnly: DeepImmutable<Vector3>;
  63642. /**
  63643. * Gets a zero Vector3 that must not be updated
  63644. */
  63645. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  63646. /**
  63647. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  63648. * @returns a new down Vector3
  63649. */
  63650. static Down(): Vector3;
  63651. /**
  63652. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  63653. * @returns a new forward Vector3
  63654. */
  63655. static Forward(): Vector3;
  63656. /**
  63657. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  63658. * @returns a new forward Vector3
  63659. */
  63660. static Backward(): Vector3;
  63661. /**
  63662. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  63663. * @returns a new right Vector3
  63664. */
  63665. static Right(): Vector3;
  63666. /**
  63667. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  63668. * @returns a new left Vector3
  63669. */
  63670. static Left(): Vector3;
  63671. /**
  63672. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  63673. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  63674. * @param vector defines the Vector3 to transform
  63675. * @param transformation defines the transformation matrix
  63676. * @returns the transformed Vector3
  63677. */
  63678. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  63679. /**
  63680. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  63681. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  63682. * @param vector defines the Vector3 to transform
  63683. * @param transformation defines the transformation matrix
  63684. * @param result defines the Vector3 where to store the result
  63685. */
  63686. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  63687. /**
  63688. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  63689. * This method computes tranformed coordinates only, not transformed direction vectors
  63690. * @param x define the x coordinate of the source vector
  63691. * @param y define the y coordinate of the source vector
  63692. * @param z define the z coordinate of the source vector
  63693. * @param transformation defines the transformation matrix
  63694. * @param result defines the Vector3 where to store the result
  63695. */
  63696. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  63697. /**
  63698. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  63699. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  63700. * @param vector defines the Vector3 to transform
  63701. * @param transformation defines the transformation matrix
  63702. * @returns the new Vector3
  63703. */
  63704. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  63705. /**
  63706. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  63707. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  63708. * @param vector defines the Vector3 to transform
  63709. * @param transformation defines the transformation matrix
  63710. * @param result defines the Vector3 where to store the result
  63711. */
  63712. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  63713. /**
  63714. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  63715. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  63716. * @param x define the x coordinate of the source vector
  63717. * @param y define the y coordinate of the source vector
  63718. * @param z define the z coordinate of the source vector
  63719. * @param transformation defines the transformation matrix
  63720. * @param result defines the Vector3 where to store the result
  63721. */
  63722. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  63723. /**
  63724. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  63725. * @param value1 defines the first control point
  63726. * @param value2 defines the second control point
  63727. * @param value3 defines the third control point
  63728. * @param value4 defines the fourth control point
  63729. * @param amount defines the amount on the spline to use
  63730. * @returns the new Vector3
  63731. */
  63732. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  63733. /**
  63734. * 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"
  63735. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  63736. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  63737. * @param value defines the current value
  63738. * @param min defines the lower range value
  63739. * @param max defines the upper range value
  63740. * @returns the new Vector3
  63741. */
  63742. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  63743. /**
  63744. * 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"
  63745. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  63746. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  63747. * @param value defines the current value
  63748. * @param min defines the lower range value
  63749. * @param max defines the upper range value
  63750. * @param result defines the Vector3 where to store the result
  63751. */
  63752. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  63753. /**
  63754. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  63755. * @param value1 defines the first control point
  63756. * @param tangent1 defines the first tangent vector
  63757. * @param value2 defines the second control point
  63758. * @param tangent2 defines the second tangent vector
  63759. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  63760. * @returns the new Vector3
  63761. */
  63762. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  63763. /**
  63764. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  63765. * @param start defines the start value
  63766. * @param end defines the end value
  63767. * @param amount max defines amount between both (between 0 and 1)
  63768. * @returns the new Vector3
  63769. */
  63770. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  63771. /**
  63772. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  63773. * @param start defines the start value
  63774. * @param end defines the end value
  63775. * @param amount max defines amount between both (between 0 and 1)
  63776. * @param result defines the Vector3 where to store the result
  63777. */
  63778. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  63779. /**
  63780. * Returns the dot product (float) between the vectors "left" and "right"
  63781. * @param left defines the left operand
  63782. * @param right defines the right operand
  63783. * @returns the dot product
  63784. */
  63785. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  63786. /**
  63787. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  63788. * The cross product is then orthogonal to both "left" and "right"
  63789. * @param left defines the left operand
  63790. * @param right defines the right operand
  63791. * @returns the cross product
  63792. */
  63793. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  63794. /**
  63795. * Sets the given vector "result" with the cross product of "left" and "right"
  63796. * The cross product is then orthogonal to both "left" and "right"
  63797. * @param left defines the left operand
  63798. * @param right defines the right operand
  63799. * @param result defines the Vector3 where to store the result
  63800. */
  63801. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  63802. /**
  63803. * Returns a new Vector3 as the normalization of the given vector
  63804. * @param vector defines the Vector3 to normalize
  63805. * @returns the new Vector3
  63806. */
  63807. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  63808. /**
  63809. * Sets the given vector "result" with the normalization of the given first vector
  63810. * @param vector defines the Vector3 to normalize
  63811. * @param result defines the Vector3 where to store the result
  63812. */
  63813. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  63814. /**
  63815. * Project a Vector3 onto screen space
  63816. * @param vector defines the Vector3 to project
  63817. * @param world defines the world matrix to use
  63818. * @param transform defines the transform (view x projection) matrix to use
  63819. * @param viewport defines the screen viewport to use
  63820. * @returns the new Vector3
  63821. */
  63822. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  63823. /** @hidden */
  63824. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  63825. /**
  63826. * Unproject from screen space to object space
  63827. * @param source defines the screen space Vector3 to use
  63828. * @param viewportWidth defines the current width of the viewport
  63829. * @param viewportHeight defines the current height of the viewport
  63830. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  63831. * @param transform defines the transform (view x projection) matrix to use
  63832. * @returns the new Vector3
  63833. */
  63834. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  63835. /**
  63836. * Unproject from screen space to object space
  63837. * @param source defines the screen space Vector3 to use
  63838. * @param viewportWidth defines the current width of the viewport
  63839. * @param viewportHeight defines the current height of the viewport
  63840. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  63841. * @param view defines the view matrix to use
  63842. * @param projection defines the projection matrix to use
  63843. * @returns the new Vector3
  63844. */
  63845. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  63846. /**
  63847. * Unproject from screen space to object space
  63848. * @param source defines the screen space Vector3 to use
  63849. * @param viewportWidth defines the current width of the viewport
  63850. * @param viewportHeight defines the current height of the viewport
  63851. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  63852. * @param view defines the view matrix to use
  63853. * @param projection defines the projection matrix to use
  63854. * @param result defines the Vector3 where to store the result
  63855. */
  63856. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  63857. /**
  63858. * Unproject from screen space to object space
  63859. * @param sourceX defines the screen space x coordinate to use
  63860. * @param sourceY defines the screen space y coordinate to use
  63861. * @param sourceZ defines the screen space z coordinate to use
  63862. * @param viewportWidth defines the current width of the viewport
  63863. * @param viewportHeight defines the current height of the viewport
  63864. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  63865. * @param view defines the view matrix to use
  63866. * @param projection defines the projection matrix to use
  63867. * @param result defines the Vector3 where to store the result
  63868. */
  63869. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  63870. /**
  63871. * Gets the minimal coordinate values between two Vector3
  63872. * @param left defines the first operand
  63873. * @param right defines the second operand
  63874. * @returns the new Vector3
  63875. */
  63876. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  63877. /**
  63878. * Gets the maximal coordinate values between two Vector3
  63879. * @param left defines the first operand
  63880. * @param right defines the second operand
  63881. * @returns the new Vector3
  63882. */
  63883. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  63884. /**
  63885. * Returns the distance between the vectors "value1" and "value2"
  63886. * @param value1 defines the first operand
  63887. * @param value2 defines the second operand
  63888. * @returns the distance
  63889. */
  63890. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  63891. /**
  63892. * Returns the squared distance between the vectors "value1" and "value2"
  63893. * @param value1 defines the first operand
  63894. * @param value2 defines the second operand
  63895. * @returns the squared distance
  63896. */
  63897. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  63898. /**
  63899. * Returns a new Vector3 located at the center between "value1" and "value2"
  63900. * @param value1 defines the first operand
  63901. * @param value2 defines the second operand
  63902. * @returns the new Vector3
  63903. */
  63904. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  63905. /**
  63906. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  63907. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  63908. * to something in order to rotate it from its local system to the given target system
  63909. * Note: axis1, axis2 and axis3 are normalized during this operation
  63910. * @param axis1 defines the first axis
  63911. * @param axis2 defines the second axis
  63912. * @param axis3 defines the third axis
  63913. * @returns a new Vector3
  63914. */
  63915. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  63916. /**
  63917. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  63918. * @param axis1 defines the first axis
  63919. * @param axis2 defines the second axis
  63920. * @param axis3 defines the third axis
  63921. * @param ref defines the Vector3 where to store the result
  63922. */
  63923. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  63924. }
  63925. /**
  63926. * Vector4 class created for EulerAngle class conversion to Quaternion
  63927. */
  63928. export class Vector4 {
  63929. /** x value of the vector */
  63930. x: number;
  63931. /** y value of the vector */
  63932. y: number;
  63933. /** z value of the vector */
  63934. z: number;
  63935. /** w value of the vector */
  63936. w: number;
  63937. /**
  63938. * Creates a Vector4 object from the given floats.
  63939. * @param x x value of the vector
  63940. * @param y y value of the vector
  63941. * @param z z value of the vector
  63942. * @param w w value of the vector
  63943. */
  63944. constructor(
  63945. /** x value of the vector */
  63946. x: number,
  63947. /** y value of the vector */
  63948. y: number,
  63949. /** z value of the vector */
  63950. z: number,
  63951. /** w value of the vector */
  63952. w: number);
  63953. /**
  63954. * Returns the string with the Vector4 coordinates.
  63955. * @returns a string containing all the vector values
  63956. */
  63957. toString(): string;
  63958. /**
  63959. * Returns the string "Vector4".
  63960. * @returns "Vector4"
  63961. */
  63962. getClassName(): string;
  63963. /**
  63964. * Returns the Vector4 hash code.
  63965. * @returns a unique hash code
  63966. */
  63967. getHashCode(): number;
  63968. /**
  63969. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  63970. * @returns the resulting array
  63971. */
  63972. asArray(): number[];
  63973. /**
  63974. * Populates the given array from the given index with the Vector4 coordinates.
  63975. * @param array array to populate
  63976. * @param index index of the array to start at (default: 0)
  63977. * @returns the Vector4.
  63978. */
  63979. toArray(array: FloatArray, index?: number): Vector4;
  63980. /**
  63981. * Adds the given vector to the current Vector4.
  63982. * @param otherVector the vector to add
  63983. * @returns the updated Vector4.
  63984. */
  63985. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  63986. /**
  63987. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  63988. * @param otherVector the vector to add
  63989. * @returns the resulting vector
  63990. */
  63991. add(otherVector: DeepImmutable<Vector4>): Vector4;
  63992. /**
  63993. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  63994. * @param otherVector the vector to add
  63995. * @param result the vector to store the result
  63996. * @returns the current Vector4.
  63997. */
  63998. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  63999. /**
  64000. * Subtract in place the given vector from the current Vector4.
  64001. * @param otherVector the vector to subtract
  64002. * @returns the updated Vector4.
  64003. */
  64004. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  64005. /**
  64006. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  64007. * @param otherVector the vector to add
  64008. * @returns the new vector with the result
  64009. */
  64010. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  64011. /**
  64012. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  64013. * @param otherVector the vector to subtract
  64014. * @param result the vector to store the result
  64015. * @returns the current Vector4.
  64016. */
  64017. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  64018. /**
  64019. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  64020. */
  64021. /**
  64022. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  64023. * @param x value to subtract
  64024. * @param y value to subtract
  64025. * @param z value to subtract
  64026. * @param w value to subtract
  64027. * @returns new vector containing the result
  64028. */
  64029. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  64030. /**
  64031. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  64032. * @param x value to subtract
  64033. * @param y value to subtract
  64034. * @param z value to subtract
  64035. * @param w value to subtract
  64036. * @param result the vector to store the result in
  64037. * @returns the current Vector4.
  64038. */
  64039. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  64040. /**
  64041. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  64042. * @returns a new vector with the negated values
  64043. */
  64044. negate(): Vector4;
  64045. /**
  64046. * Multiplies the current Vector4 coordinates by scale (float).
  64047. * @param scale the number to scale with
  64048. * @returns the updated Vector4.
  64049. */
  64050. scaleInPlace(scale: number): Vector4;
  64051. /**
  64052. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  64053. * @param scale the number to scale with
  64054. * @returns a new vector with the result
  64055. */
  64056. scale(scale: number): Vector4;
  64057. /**
  64058. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  64059. * @param scale the number to scale with
  64060. * @param result a vector to store the result in
  64061. * @returns the current Vector4.
  64062. */
  64063. scaleToRef(scale: number, result: Vector4): Vector4;
  64064. /**
  64065. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  64066. * @param scale defines the scale factor
  64067. * @param result defines the Vector4 object where to store the result
  64068. * @returns the unmodified current Vector4
  64069. */
  64070. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  64071. /**
  64072. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  64073. * @param otherVector the vector to compare against
  64074. * @returns true if they are equal
  64075. */
  64076. equals(otherVector: DeepImmutable<Vector4>): boolean;
  64077. /**
  64078. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  64079. * @param otherVector vector to compare against
  64080. * @param epsilon (Default: very small number)
  64081. * @returns true if they are equal
  64082. */
  64083. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  64084. /**
  64085. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  64086. * @param x x value to compare against
  64087. * @param y y value to compare against
  64088. * @param z z value to compare against
  64089. * @param w w value to compare against
  64090. * @returns true if equal
  64091. */
  64092. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  64093. /**
  64094. * Multiplies in place the current Vector4 by the given one.
  64095. * @param otherVector vector to multiple with
  64096. * @returns the updated Vector4.
  64097. */
  64098. multiplyInPlace(otherVector: Vector4): Vector4;
  64099. /**
  64100. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  64101. * @param otherVector vector to multiple with
  64102. * @returns resulting new vector
  64103. */
  64104. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  64105. /**
  64106. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  64107. * @param otherVector vector to multiple with
  64108. * @param result vector to store the result
  64109. * @returns the current Vector4.
  64110. */
  64111. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  64112. /**
  64113. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  64114. * @param x x value multiply with
  64115. * @param y y value multiply with
  64116. * @param z z value multiply with
  64117. * @param w w value multiply with
  64118. * @returns resulting new vector
  64119. */
  64120. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  64121. /**
  64122. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  64123. * @param otherVector vector to devide with
  64124. * @returns resulting new vector
  64125. */
  64126. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  64127. /**
  64128. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  64129. * @param otherVector vector to devide with
  64130. * @param result vector to store the result
  64131. * @returns the current Vector4.
  64132. */
  64133. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  64134. /**
  64135. * Divides the current Vector3 coordinates by the given ones.
  64136. * @param otherVector vector to devide with
  64137. * @returns the updated Vector3.
  64138. */
  64139. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  64140. /**
  64141. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  64142. * @param other defines the second operand
  64143. * @returns the current updated Vector4
  64144. */
  64145. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  64146. /**
  64147. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  64148. * @param other defines the second operand
  64149. * @returns the current updated Vector4
  64150. */
  64151. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  64152. /**
  64153. * Gets a new Vector4 from current Vector4 floored values
  64154. * @returns a new Vector4
  64155. */
  64156. floor(): Vector4;
  64157. /**
  64158. * Gets a new Vector4 from current Vector3 floored values
  64159. * @returns a new Vector4
  64160. */
  64161. fract(): Vector4;
  64162. /**
  64163. * Returns the Vector4 length (float).
  64164. * @returns the length
  64165. */
  64166. length(): number;
  64167. /**
  64168. * Returns the Vector4 squared length (float).
  64169. * @returns the length squared
  64170. */
  64171. lengthSquared(): number;
  64172. /**
  64173. * Normalizes in place the Vector4.
  64174. * @returns the updated Vector4.
  64175. */
  64176. normalize(): Vector4;
  64177. /**
  64178. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  64179. * @returns this converted to a new vector3
  64180. */
  64181. toVector3(): Vector3;
  64182. /**
  64183. * Returns a new Vector4 copied from the current one.
  64184. * @returns the new cloned vector
  64185. */
  64186. clone(): Vector4;
  64187. /**
  64188. * Updates the current Vector4 with the given one coordinates.
  64189. * @param source the source vector to copy from
  64190. * @returns the updated Vector4.
  64191. */
  64192. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  64193. /**
  64194. * Updates the current Vector4 coordinates with the given floats.
  64195. * @param x float to copy from
  64196. * @param y float to copy from
  64197. * @param z float to copy from
  64198. * @param w float to copy from
  64199. * @returns the updated Vector4.
  64200. */
  64201. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  64202. /**
  64203. * Updates the current Vector4 coordinates with the given floats.
  64204. * @param x float to set from
  64205. * @param y float to set from
  64206. * @param z float to set from
  64207. * @param w float to set from
  64208. * @returns the updated Vector4.
  64209. */
  64210. set(x: number, y: number, z: number, w: number): Vector4;
  64211. /**
  64212. * Copies the given float to the current Vector3 coordinates
  64213. * @param v defines the x, y, z and w coordinates of the operand
  64214. * @returns the current updated Vector3
  64215. */
  64216. setAll(v: number): Vector4;
  64217. /**
  64218. * Returns a new Vector4 set from the starting index of the given array.
  64219. * @param array the array to pull values from
  64220. * @param offset the offset into the array to start at
  64221. * @returns the new vector
  64222. */
  64223. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  64224. /**
  64225. * Updates the given vector "result" from the starting index of the given array.
  64226. * @param array the array to pull values from
  64227. * @param offset the offset into the array to start at
  64228. * @param result the vector to store the result in
  64229. */
  64230. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  64231. /**
  64232. * Updates the given vector "result" from the starting index of the given Float32Array.
  64233. * @param array the array to pull values from
  64234. * @param offset the offset into the array to start at
  64235. * @param result the vector to store the result in
  64236. */
  64237. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  64238. /**
  64239. * Updates the given vector "result" coordinates from the given floats.
  64240. * @param x float to set from
  64241. * @param y float to set from
  64242. * @param z float to set from
  64243. * @param w float to set from
  64244. * @param result the vector to the floats in
  64245. */
  64246. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  64247. /**
  64248. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  64249. * @returns the new vector
  64250. */
  64251. static Zero(): Vector4;
  64252. /**
  64253. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  64254. * @returns the new vector
  64255. */
  64256. static One(): Vector4;
  64257. /**
  64258. * Returns a new normalized Vector4 from the given one.
  64259. * @param vector the vector to normalize
  64260. * @returns the vector
  64261. */
  64262. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  64263. /**
  64264. * Updates the given vector "result" from the normalization of the given one.
  64265. * @param vector the vector to normalize
  64266. * @param result the vector to store the result in
  64267. */
  64268. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  64269. /**
  64270. * Returns a vector with the minimum values from the left and right vectors
  64271. * @param left left vector to minimize
  64272. * @param right right vector to minimize
  64273. * @returns a new vector with the minimum of the left and right vector values
  64274. */
  64275. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  64276. /**
  64277. * Returns a vector with the maximum values from the left and right vectors
  64278. * @param left left vector to maximize
  64279. * @param right right vector to maximize
  64280. * @returns a new vector with the maximum of the left and right vector values
  64281. */
  64282. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  64283. /**
  64284. * Returns the distance (float) between the vectors "value1" and "value2".
  64285. * @param value1 value to calulate the distance between
  64286. * @param value2 value to calulate the distance between
  64287. * @return the distance between the two vectors
  64288. */
  64289. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  64290. /**
  64291. * Returns the squared distance (float) between the vectors "value1" and "value2".
  64292. * @param value1 value to calulate the distance between
  64293. * @param value2 value to calulate the distance between
  64294. * @return the distance between the two vectors squared
  64295. */
  64296. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  64297. /**
  64298. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  64299. * @param value1 value to calulate the center between
  64300. * @param value2 value to calulate the center between
  64301. * @return the center between the two vectors
  64302. */
  64303. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  64304. /**
  64305. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  64306. * This methods computes transformed normalized direction vectors only.
  64307. * @param vector the vector to transform
  64308. * @param transformation the transformation matrix to apply
  64309. * @returns the new vector
  64310. */
  64311. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  64312. /**
  64313. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  64314. * This methods computes transformed normalized direction vectors only.
  64315. * @param vector the vector to transform
  64316. * @param transformation the transformation matrix to apply
  64317. * @param result the vector to store the result in
  64318. */
  64319. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  64320. /**
  64321. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  64322. * This methods computes transformed normalized direction vectors only.
  64323. * @param x value to transform
  64324. * @param y value to transform
  64325. * @param z value to transform
  64326. * @param w value to transform
  64327. * @param transformation the transformation matrix to apply
  64328. * @param result the vector to store the results in
  64329. */
  64330. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  64331. /**
  64332. * Creates a new Vector4 from a Vector3
  64333. * @param source defines the source data
  64334. * @param w defines the 4th component (default is 0)
  64335. * @returns a new Vector4
  64336. */
  64337. static FromVector3(source: Vector3, w?: number): Vector4;
  64338. }
  64339. /**
  64340. * Interface for the size containing width and height
  64341. */
  64342. export interface ISize {
  64343. /**
  64344. * Width
  64345. */
  64346. width: number;
  64347. /**
  64348. * Heighht
  64349. */
  64350. height: number;
  64351. }
  64352. /**
  64353. * Size containing widht and height
  64354. */
  64355. export class Size implements ISize {
  64356. /**
  64357. * Width
  64358. */
  64359. width: number;
  64360. /**
  64361. * Height
  64362. */
  64363. height: number;
  64364. /**
  64365. * Creates a Size object from the given width and height (floats).
  64366. * @param width width of the new size
  64367. * @param height height of the new size
  64368. */
  64369. constructor(width: number, height: number);
  64370. /**
  64371. * Returns a string with the Size width and height
  64372. * @returns a string with the Size width and height
  64373. */
  64374. toString(): string;
  64375. /**
  64376. * "Size"
  64377. * @returns the string "Size"
  64378. */
  64379. getClassName(): string;
  64380. /**
  64381. * Returns the Size hash code.
  64382. * @returns a hash code for a unique width and height
  64383. */
  64384. getHashCode(): number;
  64385. /**
  64386. * Updates the current size from the given one.
  64387. * @param src the given size
  64388. */
  64389. copyFrom(src: Size): void;
  64390. /**
  64391. * Updates in place the current Size from the given floats.
  64392. * @param width width of the new size
  64393. * @param height height of the new size
  64394. * @returns the updated Size.
  64395. */
  64396. copyFromFloats(width: number, height: number): Size;
  64397. /**
  64398. * Updates in place the current Size from the given floats.
  64399. * @param width width to set
  64400. * @param height height to set
  64401. * @returns the updated Size.
  64402. */
  64403. set(width: number, height: number): Size;
  64404. /**
  64405. * Multiplies the width and height by numbers
  64406. * @param w factor to multiple the width by
  64407. * @param h factor to multiple the height by
  64408. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  64409. */
  64410. multiplyByFloats(w: number, h: number): Size;
  64411. /**
  64412. * Clones the size
  64413. * @returns a new Size copied from the given one.
  64414. */
  64415. clone(): Size;
  64416. /**
  64417. * True if the current Size and the given one width and height are strictly equal.
  64418. * @param other the other size to compare against
  64419. * @returns True if the current Size and the given one width and height are strictly equal.
  64420. */
  64421. equals(other: Size): boolean;
  64422. /**
  64423. * The surface of the Size : width * height (float).
  64424. */
  64425. readonly surface: number;
  64426. /**
  64427. * Create a new size of zero
  64428. * @returns a new Size set to (0.0, 0.0)
  64429. */
  64430. static Zero(): Size;
  64431. /**
  64432. * Sums the width and height of two sizes
  64433. * @param otherSize size to add to this size
  64434. * @returns a new Size set as the addition result of the current Size and the given one.
  64435. */
  64436. add(otherSize: Size): Size;
  64437. /**
  64438. * Subtracts the width and height of two
  64439. * @param otherSize size to subtract to this size
  64440. * @returns a new Size set as the subtraction result of the given one from the current Size.
  64441. */
  64442. subtract(otherSize: Size): Size;
  64443. /**
  64444. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  64445. * @param start starting size to lerp between
  64446. * @param end end size to lerp between
  64447. * @param amount amount to lerp between the start and end values
  64448. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  64449. */
  64450. static Lerp(start: Size, end: Size, amount: number): Size;
  64451. }
  64452. /**
  64453. * Class used to store quaternion data
  64454. * @see https://en.wikipedia.org/wiki/Quaternion
  64455. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  64456. */
  64457. export class Quaternion {
  64458. /** defines the first component (0 by default) */
  64459. x: number;
  64460. /** defines the second component (0 by default) */
  64461. y: number;
  64462. /** defines the third component (0 by default) */
  64463. z: number;
  64464. /** defines the fourth component (1.0 by default) */
  64465. w: number;
  64466. /**
  64467. * Creates a new Quaternion from the given floats
  64468. * @param x defines the first component (0 by default)
  64469. * @param y defines the second component (0 by default)
  64470. * @param z defines the third component (0 by default)
  64471. * @param w defines the fourth component (1.0 by default)
  64472. */
  64473. constructor(
  64474. /** defines the first component (0 by default) */
  64475. x?: number,
  64476. /** defines the second component (0 by default) */
  64477. y?: number,
  64478. /** defines the third component (0 by default) */
  64479. z?: number,
  64480. /** defines the fourth component (1.0 by default) */
  64481. w?: number);
  64482. /**
  64483. * Gets a string representation for the current quaternion
  64484. * @returns a string with the Quaternion coordinates
  64485. */
  64486. toString(): string;
  64487. /**
  64488. * Gets the class name of the quaternion
  64489. * @returns the string "Quaternion"
  64490. */
  64491. getClassName(): string;
  64492. /**
  64493. * Gets a hash code for this quaternion
  64494. * @returns the quaternion hash code
  64495. */
  64496. getHashCode(): number;
  64497. /**
  64498. * Copy the quaternion to an array
  64499. * @returns a new array populated with 4 elements from the quaternion coordinates
  64500. */
  64501. asArray(): number[];
  64502. /**
  64503. * Check if two quaternions are equals
  64504. * @param otherQuaternion defines the second operand
  64505. * @return true if the current quaternion and the given one coordinates are strictly equals
  64506. */
  64507. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  64508. /**
  64509. * Clone the current quaternion
  64510. * @returns a new quaternion copied from the current one
  64511. */
  64512. clone(): Quaternion;
  64513. /**
  64514. * Copy a quaternion to the current one
  64515. * @param other defines the other quaternion
  64516. * @returns the updated current quaternion
  64517. */
  64518. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  64519. /**
  64520. * Updates the current quaternion with the given float coordinates
  64521. * @param x defines the x coordinate
  64522. * @param y defines the y coordinate
  64523. * @param z defines the z coordinate
  64524. * @param w defines the w coordinate
  64525. * @returns the updated current quaternion
  64526. */
  64527. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  64528. /**
  64529. * Updates the current quaternion from the given float coordinates
  64530. * @param x defines the x coordinate
  64531. * @param y defines the y coordinate
  64532. * @param z defines the z coordinate
  64533. * @param w defines the w coordinate
  64534. * @returns the updated current quaternion
  64535. */
  64536. set(x: number, y: number, z: number, w: number): Quaternion;
  64537. /**
  64538. * Adds two quaternions
  64539. * @param other defines the second operand
  64540. * @returns a new quaternion as the addition result of the given one and the current quaternion
  64541. */
  64542. add(other: DeepImmutable<Quaternion>): Quaternion;
  64543. /**
  64544. * Add a quaternion to the current one
  64545. * @param other defines the quaternion to add
  64546. * @returns the current quaternion
  64547. */
  64548. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  64549. /**
  64550. * Subtract two quaternions
  64551. * @param other defines the second operand
  64552. * @returns a new quaternion as the subtraction result of the given one from the current one
  64553. */
  64554. subtract(other: Quaternion): Quaternion;
  64555. /**
  64556. * Multiplies the current quaternion by a scale factor
  64557. * @param value defines the scale factor
  64558. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  64559. */
  64560. scale(value: number): Quaternion;
  64561. /**
  64562. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  64563. * @param scale defines the scale factor
  64564. * @param result defines the Quaternion object where to store the result
  64565. * @returns the unmodified current quaternion
  64566. */
  64567. scaleToRef(scale: number, result: Quaternion): Quaternion;
  64568. /**
  64569. * Multiplies in place the current quaternion by a scale factor
  64570. * @param value defines the scale factor
  64571. * @returns the current modified quaternion
  64572. */
  64573. scaleInPlace(value: number): Quaternion;
  64574. /**
  64575. * Scale the current quaternion values by a factor and add the result to a given quaternion
  64576. * @param scale defines the scale factor
  64577. * @param result defines the Quaternion object where to store the result
  64578. * @returns the unmodified current quaternion
  64579. */
  64580. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  64581. /**
  64582. * Multiplies two quaternions
  64583. * @param q1 defines the second operand
  64584. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  64585. */
  64586. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  64587. /**
  64588. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  64589. * @param q1 defines the second operand
  64590. * @param result defines the target quaternion
  64591. * @returns the current quaternion
  64592. */
  64593. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  64594. /**
  64595. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  64596. * @param q1 defines the second operand
  64597. * @returns the currentupdated quaternion
  64598. */
  64599. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  64600. /**
  64601. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  64602. * @param ref defines the target quaternion
  64603. * @returns the current quaternion
  64604. */
  64605. conjugateToRef(ref: Quaternion): Quaternion;
  64606. /**
  64607. * Conjugates in place (1-q) the current quaternion
  64608. * @returns the current updated quaternion
  64609. */
  64610. conjugateInPlace(): Quaternion;
  64611. /**
  64612. * Conjugates in place (1-q) the current quaternion
  64613. * @returns a new quaternion
  64614. */
  64615. conjugate(): Quaternion;
  64616. /**
  64617. * Gets length of current quaternion
  64618. * @returns the quaternion length (float)
  64619. */
  64620. length(): number;
  64621. /**
  64622. * Normalize in place the current quaternion
  64623. * @returns the current updated quaternion
  64624. */
  64625. normalize(): Quaternion;
  64626. /**
  64627. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  64628. * @param order is a reserved parameter and is ignore for now
  64629. * @returns a new Vector3 containing the Euler angles
  64630. */
  64631. toEulerAngles(order?: string): Vector3;
  64632. /**
  64633. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  64634. * @param result defines the vector which will be filled with the Euler angles
  64635. * @param order is a reserved parameter and is ignore for now
  64636. * @returns the current unchanged quaternion
  64637. */
  64638. toEulerAnglesToRef(result: Vector3): Quaternion;
  64639. /**
  64640. * Updates the given rotation matrix with the current quaternion values
  64641. * @param result defines the target matrix
  64642. * @returns the current unchanged quaternion
  64643. */
  64644. toRotationMatrix(result: Matrix): Quaternion;
  64645. /**
  64646. * Updates the current quaternion from the given rotation matrix values
  64647. * @param matrix defines the source matrix
  64648. * @returns the current updated quaternion
  64649. */
  64650. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  64651. /**
  64652. * Creates a new quaternion from a rotation matrix
  64653. * @param matrix defines the source matrix
  64654. * @returns a new quaternion created from the given rotation matrix values
  64655. */
  64656. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  64657. /**
  64658. * Updates the given quaternion with the given rotation matrix values
  64659. * @param matrix defines the source matrix
  64660. * @param result defines the target quaternion
  64661. */
  64662. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  64663. /**
  64664. * Returns the dot product (float) between the quaternions "left" and "right"
  64665. * @param left defines the left operand
  64666. * @param right defines the right operand
  64667. * @returns the dot product
  64668. */
  64669. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  64670. /**
  64671. * Checks if the two quaternions are close to each other
  64672. * @param quat0 defines the first quaternion to check
  64673. * @param quat1 defines the second quaternion to check
  64674. * @returns true if the two quaternions are close to each other
  64675. */
  64676. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  64677. /**
  64678. * Creates an empty quaternion
  64679. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  64680. */
  64681. static Zero(): Quaternion;
  64682. /**
  64683. * Inverse a given quaternion
  64684. * @param q defines the source quaternion
  64685. * @returns a new quaternion as the inverted current quaternion
  64686. */
  64687. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  64688. /**
  64689. * Inverse a given quaternion
  64690. * @param q defines the source quaternion
  64691. * @param result the quaternion the result will be stored in
  64692. * @returns the result quaternion
  64693. */
  64694. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  64695. /**
  64696. * Creates an identity quaternion
  64697. * @returns the identity quaternion
  64698. */
  64699. static Identity(): Quaternion;
  64700. /**
  64701. * Gets a boolean indicating if the given quaternion is identity
  64702. * @param quaternion defines the quaternion to check
  64703. * @returns true if the quaternion is identity
  64704. */
  64705. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  64706. /**
  64707. * Creates a quaternion from a rotation around an axis
  64708. * @param axis defines the axis to use
  64709. * @param angle defines the angle to use
  64710. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  64711. */
  64712. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  64713. /**
  64714. * Creates a rotation around an axis and stores it into the given quaternion
  64715. * @param axis defines the axis to use
  64716. * @param angle defines the angle to use
  64717. * @param result defines the target quaternion
  64718. * @returns the target quaternion
  64719. */
  64720. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  64721. /**
  64722. * Creates a new quaternion from data stored into an array
  64723. * @param array defines the data source
  64724. * @param offset defines the offset in the source array where the data starts
  64725. * @returns a new quaternion
  64726. */
  64727. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  64728. /**
  64729. * Create a quaternion from Euler rotation angles
  64730. * @param x Pitch
  64731. * @param y Yaw
  64732. * @param z Roll
  64733. * @returns the new Quaternion
  64734. */
  64735. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  64736. /**
  64737. * Updates a quaternion from Euler rotation angles
  64738. * @param x Pitch
  64739. * @param y Yaw
  64740. * @param z Roll
  64741. * @param result the quaternion to store the result
  64742. * @returns the updated quaternion
  64743. */
  64744. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  64745. /**
  64746. * Create a quaternion from Euler rotation vector
  64747. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  64748. * @returns the new Quaternion
  64749. */
  64750. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  64751. /**
  64752. * Updates a quaternion from Euler rotation vector
  64753. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  64754. * @param result the quaternion to store the result
  64755. * @returns the updated quaternion
  64756. */
  64757. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  64758. /**
  64759. * Creates a new quaternion from the given Euler float angles (y, x, z)
  64760. * @param yaw defines the rotation around Y axis
  64761. * @param pitch defines the rotation around X axis
  64762. * @param roll defines the rotation around Z axis
  64763. * @returns the new quaternion
  64764. */
  64765. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  64766. /**
  64767. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  64768. * @param yaw defines the rotation around Y axis
  64769. * @param pitch defines the rotation around X axis
  64770. * @param roll defines the rotation around Z axis
  64771. * @param result defines the target quaternion
  64772. */
  64773. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  64774. /**
  64775. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  64776. * @param alpha defines the rotation around first axis
  64777. * @param beta defines the rotation around second axis
  64778. * @param gamma defines the rotation around third axis
  64779. * @returns the new quaternion
  64780. */
  64781. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  64782. /**
  64783. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  64784. * @param alpha defines the rotation around first axis
  64785. * @param beta defines the rotation around second axis
  64786. * @param gamma defines the rotation around third axis
  64787. * @param result defines the target quaternion
  64788. */
  64789. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  64790. /**
  64791. * 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)
  64792. * @param axis1 defines the first axis
  64793. * @param axis2 defines the second axis
  64794. * @param axis3 defines the third axis
  64795. * @returns the new quaternion
  64796. */
  64797. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  64798. /**
  64799. * 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
  64800. * @param axis1 defines the first axis
  64801. * @param axis2 defines the second axis
  64802. * @param axis3 defines the third axis
  64803. * @param ref defines the target quaternion
  64804. */
  64805. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  64806. /**
  64807. * Interpolates between two quaternions
  64808. * @param left defines first quaternion
  64809. * @param right defines second quaternion
  64810. * @param amount defines the gradient to use
  64811. * @returns the new interpolated quaternion
  64812. */
  64813. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  64814. /**
  64815. * Interpolates between two quaternions and stores it into a target quaternion
  64816. * @param left defines first quaternion
  64817. * @param right defines second quaternion
  64818. * @param amount defines the gradient to use
  64819. * @param result defines the target quaternion
  64820. */
  64821. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  64822. /**
  64823. * Interpolate between two quaternions using Hermite interpolation
  64824. * @param value1 defines first quaternion
  64825. * @param tangent1 defines the incoming tangent
  64826. * @param value2 defines second quaternion
  64827. * @param tangent2 defines the outgoing tangent
  64828. * @param amount defines the target quaternion
  64829. * @returns the new interpolated quaternion
  64830. */
  64831. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  64832. }
  64833. /**
  64834. * Class used to store matrix data (4x4)
  64835. */
  64836. export class Matrix {
  64837. private static _updateFlagSeed;
  64838. private static _identityReadOnly;
  64839. private _isIdentity;
  64840. private _isIdentityDirty;
  64841. private _isIdentity3x2;
  64842. private _isIdentity3x2Dirty;
  64843. /**
  64844. * Gets the update flag of the matrix which is an unique number for the matrix.
  64845. * It will be incremented every time the matrix data change.
  64846. * You can use it to speed the comparison between two versions of the same matrix.
  64847. */
  64848. updateFlag: number;
  64849. private readonly _m;
  64850. /**
  64851. * Gets the internal data of the matrix
  64852. */
  64853. readonly m: DeepImmutable<Float32Array>;
  64854. /** @hidden */
  64855. _markAsUpdated(): void;
  64856. /** @hidden */
  64857. private _updateIdentityStatus;
  64858. /**
  64859. * Creates an empty matrix (filled with zeros)
  64860. */
  64861. constructor();
  64862. /**
  64863. * Check if the current matrix is identity
  64864. * @returns true is the matrix is the identity matrix
  64865. */
  64866. isIdentity(): boolean;
  64867. /**
  64868. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  64869. * @returns true is the matrix is the identity matrix
  64870. */
  64871. isIdentityAs3x2(): boolean;
  64872. /**
  64873. * Gets the determinant of the matrix
  64874. * @returns the matrix determinant
  64875. */
  64876. determinant(): number;
  64877. /**
  64878. * Returns the matrix as a Float32Array
  64879. * @returns the matrix underlying array
  64880. */
  64881. toArray(): DeepImmutable<Float32Array>;
  64882. /**
  64883. * Returns the matrix as a Float32Array
  64884. * @returns the matrix underlying array.
  64885. */
  64886. asArray(): DeepImmutable<Float32Array>;
  64887. /**
  64888. * Inverts the current matrix in place
  64889. * @returns the current inverted matrix
  64890. */
  64891. invert(): Matrix;
  64892. /**
  64893. * Sets all the matrix elements to zero
  64894. * @returns the current matrix
  64895. */
  64896. reset(): Matrix;
  64897. /**
  64898. * Adds the current matrix with a second one
  64899. * @param other defines the matrix to add
  64900. * @returns a new matrix as the addition of the current matrix and the given one
  64901. */
  64902. add(other: DeepImmutable<Matrix>): Matrix;
  64903. /**
  64904. * Sets the given matrix "result" to the addition of the current matrix and the given one
  64905. * @param other defines the matrix to add
  64906. * @param result defines the target matrix
  64907. * @returns the current matrix
  64908. */
  64909. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  64910. /**
  64911. * Adds in place the given matrix to the current matrix
  64912. * @param other defines the second operand
  64913. * @returns the current updated matrix
  64914. */
  64915. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  64916. /**
  64917. * Sets the given matrix to the current inverted Matrix
  64918. * @param other defines the target matrix
  64919. * @returns the unmodified current matrix
  64920. */
  64921. invertToRef(other: Matrix): Matrix;
  64922. /**
  64923. * add a value at the specified position in the current Matrix
  64924. * @param index the index of the value within the matrix. between 0 and 15.
  64925. * @param value the value to be added
  64926. * @returns the current updated matrix
  64927. */
  64928. addAtIndex(index: number, value: number): Matrix;
  64929. /**
  64930. * mutiply the specified position in the current Matrix by a value
  64931. * @param index the index of the value within the matrix. between 0 and 15.
  64932. * @param value the value to be added
  64933. * @returns the current updated matrix
  64934. */
  64935. multiplyAtIndex(index: number, value: number): Matrix;
  64936. /**
  64937. * Inserts the translation vector (using 3 floats) in the current matrix
  64938. * @param x defines the 1st component of the translation
  64939. * @param y defines the 2nd component of the translation
  64940. * @param z defines the 3rd component of the translation
  64941. * @returns the current updated matrix
  64942. */
  64943. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  64944. /**
  64945. * Adds the translation vector (using 3 floats) in the current matrix
  64946. * @param x defines the 1st component of the translation
  64947. * @param y defines the 2nd component of the translation
  64948. * @param z defines the 3rd component of the translation
  64949. * @returns the current updated matrix
  64950. */
  64951. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  64952. /**
  64953. * Inserts the translation vector in the current matrix
  64954. * @param vector3 defines the translation to insert
  64955. * @returns the current updated matrix
  64956. */
  64957. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  64958. /**
  64959. * Gets the translation value of the current matrix
  64960. * @returns a new Vector3 as the extracted translation from the matrix
  64961. */
  64962. getTranslation(): Vector3;
  64963. /**
  64964. * Fill a Vector3 with the extracted translation from the matrix
  64965. * @param result defines the Vector3 where to store the translation
  64966. * @returns the current matrix
  64967. */
  64968. getTranslationToRef(result: Vector3): Matrix;
  64969. /**
  64970. * Remove rotation and scaling part from the matrix
  64971. * @returns the updated matrix
  64972. */
  64973. removeRotationAndScaling(): Matrix;
  64974. /**
  64975. * Multiply two matrices
  64976. * @param other defines the second operand
  64977. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  64978. */
  64979. multiply(other: DeepImmutable<Matrix>): Matrix;
  64980. /**
  64981. * Copy the current matrix from the given one
  64982. * @param other defines the source matrix
  64983. * @returns the current updated matrix
  64984. */
  64985. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  64986. /**
  64987. * Populates the given array from the starting index with the current matrix values
  64988. * @param array defines the target array
  64989. * @param offset defines the offset in the target array where to start storing values
  64990. * @returns the current matrix
  64991. */
  64992. copyToArray(array: Float32Array, offset?: number): Matrix;
  64993. /**
  64994. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  64995. * @param other defines the second operand
  64996. * @param result defines the matrix where to store the multiplication
  64997. * @returns the current matrix
  64998. */
  64999. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  65000. /**
  65001. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  65002. * @param other defines the second operand
  65003. * @param result defines the array where to store the multiplication
  65004. * @param offset defines the offset in the target array where to start storing values
  65005. * @returns the current matrix
  65006. */
  65007. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  65008. /**
  65009. * Check equality between this matrix and a second one
  65010. * @param value defines the second matrix to compare
  65011. * @returns true is the current matrix and the given one values are strictly equal
  65012. */
  65013. equals(value: DeepImmutable<Matrix>): boolean;
  65014. /**
  65015. * Clone the current matrix
  65016. * @returns a new matrix from the current matrix
  65017. */
  65018. clone(): Matrix;
  65019. /**
  65020. * Returns the name of the current matrix class
  65021. * @returns the string "Matrix"
  65022. */
  65023. getClassName(): string;
  65024. /**
  65025. * Gets the hash code of the current matrix
  65026. * @returns the hash code
  65027. */
  65028. getHashCode(): number;
  65029. /**
  65030. * Decomposes the current Matrix into a translation, rotation and scaling components
  65031. * @param scale defines the scale vector3 given as a reference to update
  65032. * @param rotation defines the rotation quaternion given as a reference to update
  65033. * @param translation defines the translation vector3 given as a reference to update
  65034. * @returns true if operation was successful
  65035. */
  65036. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  65037. /**
  65038. * Gets specific row of the matrix
  65039. * @param index defines the number of the row to get
  65040. * @returns the index-th row of the current matrix as a new Vector4
  65041. */
  65042. getRow(index: number): Nullable<Vector4>;
  65043. /**
  65044. * Sets the index-th row of the current matrix to the vector4 values
  65045. * @param index defines the number of the row to set
  65046. * @param row defines the target vector4
  65047. * @returns the updated current matrix
  65048. */
  65049. setRow(index: number, row: Vector4): Matrix;
  65050. /**
  65051. * Compute the transpose of the matrix
  65052. * @returns the new transposed matrix
  65053. */
  65054. transpose(): Matrix;
  65055. /**
  65056. * Compute the transpose of the matrix and store it in a given matrix
  65057. * @param result defines the target matrix
  65058. * @returns the current matrix
  65059. */
  65060. transposeToRef(result: Matrix): Matrix;
  65061. /**
  65062. * Sets the index-th row of the current matrix with the given 4 x float values
  65063. * @param index defines the row index
  65064. * @param x defines the x component to set
  65065. * @param y defines the y component to set
  65066. * @param z defines the z component to set
  65067. * @param w defines the w component to set
  65068. * @returns the updated current matrix
  65069. */
  65070. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  65071. /**
  65072. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  65073. * @param scale defines the scale factor
  65074. * @returns a new matrix
  65075. */
  65076. scale(scale: number): Matrix;
  65077. /**
  65078. * Scale the current matrix values by a factor to a given result matrix
  65079. * @param scale defines the scale factor
  65080. * @param result defines the matrix to store the result
  65081. * @returns the current matrix
  65082. */
  65083. scaleToRef(scale: number, result: Matrix): Matrix;
  65084. /**
  65085. * Scale the current matrix values by a factor and add the result to a given matrix
  65086. * @param scale defines the scale factor
  65087. * @param result defines the Matrix to store the result
  65088. * @returns the current matrix
  65089. */
  65090. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  65091. /**
  65092. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  65093. * @param ref matrix to store the result
  65094. */
  65095. toNormalMatrix(ref: Matrix): void;
  65096. /**
  65097. * Gets only rotation part of the current matrix
  65098. * @returns a new matrix sets to the extracted rotation matrix from the current one
  65099. */
  65100. getRotationMatrix(): Matrix;
  65101. /**
  65102. * Extracts the rotation matrix from the current one and sets it as the given "result"
  65103. * @param result defines the target matrix to store data to
  65104. * @returns the current matrix
  65105. */
  65106. getRotationMatrixToRef(result: Matrix): Matrix;
  65107. /**
  65108. * Toggles model matrix from being right handed to left handed in place and vice versa
  65109. */
  65110. toggleModelMatrixHandInPlace(): void;
  65111. /**
  65112. * Toggles projection matrix from being right handed to left handed in place and vice versa
  65113. */
  65114. toggleProjectionMatrixHandInPlace(): void;
  65115. /**
  65116. * Creates a matrix from an array
  65117. * @param array defines the source array
  65118. * @param offset defines an offset in the source array
  65119. * @returns a new Matrix set from the starting index of the given array
  65120. */
  65121. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  65122. /**
  65123. * Copy the content of an array into a given matrix
  65124. * @param array defines the source array
  65125. * @param offset defines an offset in the source array
  65126. * @param result defines the target matrix
  65127. */
  65128. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  65129. /**
  65130. * Stores an array into a matrix after having multiplied each component by a given factor
  65131. * @param array defines the source array
  65132. * @param offset defines the offset in the source array
  65133. * @param scale defines the scaling factor
  65134. * @param result defines the target matrix
  65135. */
  65136. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  65137. /**
  65138. * Gets an identity matrix that must not be updated
  65139. */
  65140. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  65141. /**
  65142. * Stores a list of values (16) inside a given matrix
  65143. * @param initialM11 defines 1st value of 1st row
  65144. * @param initialM12 defines 2nd value of 1st row
  65145. * @param initialM13 defines 3rd value of 1st row
  65146. * @param initialM14 defines 4th value of 1st row
  65147. * @param initialM21 defines 1st value of 2nd row
  65148. * @param initialM22 defines 2nd value of 2nd row
  65149. * @param initialM23 defines 3rd value of 2nd row
  65150. * @param initialM24 defines 4th value of 2nd row
  65151. * @param initialM31 defines 1st value of 3rd row
  65152. * @param initialM32 defines 2nd value of 3rd row
  65153. * @param initialM33 defines 3rd value of 3rd row
  65154. * @param initialM34 defines 4th value of 3rd row
  65155. * @param initialM41 defines 1st value of 4th row
  65156. * @param initialM42 defines 2nd value of 4th row
  65157. * @param initialM43 defines 3rd value of 4th row
  65158. * @param initialM44 defines 4th value of 4th row
  65159. * @param result defines the target matrix
  65160. */
  65161. 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;
  65162. /**
  65163. * Creates new matrix from a list of values (16)
  65164. * @param initialM11 defines 1st value of 1st row
  65165. * @param initialM12 defines 2nd value of 1st row
  65166. * @param initialM13 defines 3rd value of 1st row
  65167. * @param initialM14 defines 4th value of 1st row
  65168. * @param initialM21 defines 1st value of 2nd row
  65169. * @param initialM22 defines 2nd value of 2nd row
  65170. * @param initialM23 defines 3rd value of 2nd row
  65171. * @param initialM24 defines 4th value of 2nd row
  65172. * @param initialM31 defines 1st value of 3rd row
  65173. * @param initialM32 defines 2nd value of 3rd row
  65174. * @param initialM33 defines 3rd value of 3rd row
  65175. * @param initialM34 defines 4th value of 3rd row
  65176. * @param initialM41 defines 1st value of 4th row
  65177. * @param initialM42 defines 2nd value of 4th row
  65178. * @param initialM43 defines 3rd value of 4th row
  65179. * @param initialM44 defines 4th value of 4th row
  65180. * @returns the new matrix
  65181. */
  65182. 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;
  65183. /**
  65184. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  65185. * @param scale defines the scale vector3
  65186. * @param rotation defines the rotation quaternion
  65187. * @param translation defines the translation vector3
  65188. * @returns a new matrix
  65189. */
  65190. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  65191. /**
  65192. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  65193. * @param scale defines the scale vector3
  65194. * @param rotation defines the rotation quaternion
  65195. * @param translation defines the translation vector3
  65196. * @param result defines the target matrix
  65197. */
  65198. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  65199. /**
  65200. * Creates a new identity matrix
  65201. * @returns a new identity matrix
  65202. */
  65203. static Identity(): Matrix;
  65204. /**
  65205. * Creates a new identity matrix and stores the result in a given matrix
  65206. * @param result defines the target matrix
  65207. */
  65208. static IdentityToRef(result: Matrix): void;
  65209. /**
  65210. * Creates a new zero matrix
  65211. * @returns a new zero matrix
  65212. */
  65213. static Zero(): Matrix;
  65214. /**
  65215. * Creates a new rotation matrix for "angle" radians around the X axis
  65216. * @param angle defines the angle (in radians) to use
  65217. * @return the new matrix
  65218. */
  65219. static RotationX(angle: number): Matrix;
  65220. /**
  65221. * Creates a new matrix as the invert of a given matrix
  65222. * @param source defines the source matrix
  65223. * @returns the new matrix
  65224. */
  65225. static Invert(source: DeepImmutable<Matrix>): Matrix;
  65226. /**
  65227. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  65228. * @param angle defines the angle (in radians) to use
  65229. * @param result defines the target matrix
  65230. */
  65231. static RotationXToRef(angle: number, result: Matrix): void;
  65232. /**
  65233. * Creates a new rotation matrix for "angle" radians around the Y axis
  65234. * @param angle defines the angle (in radians) to use
  65235. * @return the new matrix
  65236. */
  65237. static RotationY(angle: number): Matrix;
  65238. /**
  65239. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  65240. * @param angle defines the angle (in radians) to use
  65241. * @param result defines the target matrix
  65242. */
  65243. static RotationYToRef(angle: number, result: Matrix): void;
  65244. /**
  65245. * Creates a new rotation matrix for "angle" radians around the Z axis
  65246. * @param angle defines the angle (in radians) to use
  65247. * @return the new matrix
  65248. */
  65249. static RotationZ(angle: number): Matrix;
  65250. /**
  65251. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  65252. * @param angle defines the angle (in radians) to use
  65253. * @param result defines the target matrix
  65254. */
  65255. static RotationZToRef(angle: number, result: Matrix): void;
  65256. /**
  65257. * Creates a new rotation matrix for "angle" radians around the given axis
  65258. * @param axis defines the axis to use
  65259. * @param angle defines the angle (in radians) to use
  65260. * @return the new matrix
  65261. */
  65262. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  65263. /**
  65264. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  65265. * @param axis defines the axis to use
  65266. * @param angle defines the angle (in radians) to use
  65267. * @param result defines the target matrix
  65268. */
  65269. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  65270. /**
  65271. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  65272. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  65273. * @param from defines the vector to align
  65274. * @param to defines the vector to align to
  65275. * @param result defines the target matrix
  65276. */
  65277. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  65278. /**
  65279. * Creates a rotation matrix
  65280. * @param yaw defines the yaw angle in radians (Y axis)
  65281. * @param pitch defines the pitch angle in radians (X axis)
  65282. * @param roll defines the roll angle in radians (X axis)
  65283. * @returns the new rotation matrix
  65284. */
  65285. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  65286. /**
  65287. * Creates a rotation matrix and stores it in a given matrix
  65288. * @param yaw defines the yaw angle in radians (Y axis)
  65289. * @param pitch defines the pitch angle in radians (X axis)
  65290. * @param roll defines the roll angle in radians (X axis)
  65291. * @param result defines the target matrix
  65292. */
  65293. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  65294. /**
  65295. * Creates a scaling matrix
  65296. * @param x defines the scale factor on X axis
  65297. * @param y defines the scale factor on Y axis
  65298. * @param z defines the scale factor on Z axis
  65299. * @returns the new matrix
  65300. */
  65301. static Scaling(x: number, y: number, z: number): Matrix;
  65302. /**
  65303. * Creates a scaling matrix and stores it in a given matrix
  65304. * @param x defines the scale factor on X axis
  65305. * @param y defines the scale factor on Y axis
  65306. * @param z defines the scale factor on Z axis
  65307. * @param result defines the target matrix
  65308. */
  65309. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  65310. /**
  65311. * Creates a translation matrix
  65312. * @param x defines the translation on X axis
  65313. * @param y defines the translation on Y axis
  65314. * @param z defines the translationon Z axis
  65315. * @returns the new matrix
  65316. */
  65317. static Translation(x: number, y: number, z: number): Matrix;
  65318. /**
  65319. * Creates a translation matrix and stores it in a given matrix
  65320. * @param x defines the translation on X axis
  65321. * @param y defines the translation on Y axis
  65322. * @param z defines the translationon Z axis
  65323. * @param result defines the target matrix
  65324. */
  65325. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  65326. /**
  65327. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  65328. * @param startValue defines the start value
  65329. * @param endValue defines the end value
  65330. * @param gradient defines the gradient factor
  65331. * @returns the new matrix
  65332. */
  65333. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  65334. /**
  65335. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  65336. * @param startValue defines the start value
  65337. * @param endValue defines the end value
  65338. * @param gradient defines the gradient factor
  65339. * @param result defines the Matrix object where to store data
  65340. */
  65341. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  65342. /**
  65343. * Builds a new matrix whose values are computed by:
  65344. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  65345. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  65346. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  65347. * @param startValue defines the first matrix
  65348. * @param endValue defines the second matrix
  65349. * @param gradient defines the gradient between the two matrices
  65350. * @returns the new matrix
  65351. */
  65352. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  65353. /**
  65354. * Update a matrix to values which are computed by:
  65355. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  65356. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  65357. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  65358. * @param startValue defines the first matrix
  65359. * @param endValue defines the second matrix
  65360. * @param gradient defines the gradient between the two matrices
  65361. * @param result defines the target matrix
  65362. */
  65363. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  65364. /**
  65365. * 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"
  65366. * This function works in left handed mode
  65367. * @param eye defines the final position of the entity
  65368. * @param target defines where the entity should look at
  65369. * @param up defines the up vector for the entity
  65370. * @returns the new matrix
  65371. */
  65372. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  65373. /**
  65374. * 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".
  65375. * This function works in left handed mode
  65376. * @param eye defines the final position of the entity
  65377. * @param target defines where the entity should look at
  65378. * @param up defines the up vector for the entity
  65379. * @param result defines the target matrix
  65380. */
  65381. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  65382. /**
  65383. * 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"
  65384. * This function works in right handed mode
  65385. * @param eye defines the final position of the entity
  65386. * @param target defines where the entity should look at
  65387. * @param up defines the up vector for the entity
  65388. * @returns the new matrix
  65389. */
  65390. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  65391. /**
  65392. * 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".
  65393. * This function works in right handed mode
  65394. * @param eye defines the final position of the entity
  65395. * @param target defines where the entity should look at
  65396. * @param up defines the up vector for the entity
  65397. * @param result defines the target matrix
  65398. */
  65399. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  65400. /**
  65401. * Create a left-handed orthographic projection matrix
  65402. * @param width defines the viewport width
  65403. * @param height defines the viewport height
  65404. * @param znear defines the near clip plane
  65405. * @param zfar defines the far clip plane
  65406. * @returns a new matrix as a left-handed orthographic projection matrix
  65407. */
  65408. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  65409. /**
  65410. * Store a left-handed orthographic projection to a given matrix
  65411. * @param width defines the viewport width
  65412. * @param height defines the viewport height
  65413. * @param znear defines the near clip plane
  65414. * @param zfar defines the far clip plane
  65415. * @param result defines the target matrix
  65416. */
  65417. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  65418. /**
  65419. * Create a left-handed orthographic projection matrix
  65420. * @param left defines the viewport left coordinate
  65421. * @param right defines the viewport right coordinate
  65422. * @param bottom defines the viewport bottom coordinate
  65423. * @param top defines the viewport top coordinate
  65424. * @param znear defines the near clip plane
  65425. * @param zfar defines the far clip plane
  65426. * @returns a new matrix as a left-handed orthographic projection matrix
  65427. */
  65428. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  65429. /**
  65430. * Stores a left-handed orthographic projection into a given matrix
  65431. * @param left defines the viewport left coordinate
  65432. * @param right defines the viewport right coordinate
  65433. * @param bottom defines the viewport bottom coordinate
  65434. * @param top defines the viewport top coordinate
  65435. * @param znear defines the near clip plane
  65436. * @param zfar defines the far clip plane
  65437. * @param result defines the target matrix
  65438. */
  65439. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  65440. /**
  65441. * Creates a right-handed orthographic projection matrix
  65442. * @param left defines the viewport left coordinate
  65443. * @param right defines the viewport right coordinate
  65444. * @param bottom defines the viewport bottom coordinate
  65445. * @param top defines the viewport top coordinate
  65446. * @param znear defines the near clip plane
  65447. * @param zfar defines the far clip plane
  65448. * @returns a new matrix as a right-handed orthographic projection matrix
  65449. */
  65450. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  65451. /**
  65452. * Stores a right-handed orthographic projection into a given matrix
  65453. * @param left defines the viewport left coordinate
  65454. * @param right defines the viewport right coordinate
  65455. * @param bottom defines the viewport bottom coordinate
  65456. * @param top defines the viewport top coordinate
  65457. * @param znear defines the near clip plane
  65458. * @param zfar defines the far clip plane
  65459. * @param result defines the target matrix
  65460. */
  65461. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  65462. /**
  65463. * Creates a left-handed perspective projection matrix
  65464. * @param width defines the viewport width
  65465. * @param height defines the viewport height
  65466. * @param znear defines the near clip plane
  65467. * @param zfar defines the far clip plane
  65468. * @returns a new matrix as a left-handed perspective projection matrix
  65469. */
  65470. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  65471. /**
  65472. * Creates a left-handed perspective projection matrix
  65473. * @param fov defines the horizontal field of view
  65474. * @param aspect defines the aspect ratio
  65475. * @param znear defines the near clip plane
  65476. * @param zfar defines the far clip plane
  65477. * @returns a new matrix as a left-handed perspective projection matrix
  65478. */
  65479. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  65480. /**
  65481. * Stores a left-handed perspective projection into a given matrix
  65482. * @param fov defines the horizontal field of view
  65483. * @param aspect defines the aspect ratio
  65484. * @param znear defines the near clip plane
  65485. * @param zfar defines the far clip plane
  65486. * @param result defines the target matrix
  65487. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  65488. */
  65489. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  65490. /**
  65491. * Creates a right-handed perspective projection matrix
  65492. * @param fov defines the horizontal field of view
  65493. * @param aspect defines the aspect ratio
  65494. * @param znear defines the near clip plane
  65495. * @param zfar defines the far clip plane
  65496. * @returns a new matrix as a right-handed perspective projection matrix
  65497. */
  65498. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  65499. /**
  65500. * Stores a right-handed perspective projection into a given matrix
  65501. * @param fov defines the horizontal field of view
  65502. * @param aspect defines the aspect ratio
  65503. * @param znear defines the near clip plane
  65504. * @param zfar defines the far clip plane
  65505. * @param result defines the target matrix
  65506. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  65507. */
  65508. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  65509. /**
  65510. * Stores a perspective projection for WebVR info a given matrix
  65511. * @param fov defines the field of view
  65512. * @param znear defines the near clip plane
  65513. * @param zfar defines the far clip plane
  65514. * @param result defines the target matrix
  65515. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  65516. */
  65517. static PerspectiveFovWebVRToRef(fov: {
  65518. upDegrees: number;
  65519. downDegrees: number;
  65520. leftDegrees: number;
  65521. rightDegrees: number;
  65522. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  65523. /**
  65524. * Computes a complete transformation matrix
  65525. * @param viewport defines the viewport to use
  65526. * @param world defines the world matrix
  65527. * @param view defines the view matrix
  65528. * @param projection defines the projection matrix
  65529. * @param zmin defines the near clip plane
  65530. * @param zmax defines the far clip plane
  65531. * @returns the transformation matrix
  65532. */
  65533. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  65534. /**
  65535. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  65536. * @param matrix defines the matrix to use
  65537. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  65538. */
  65539. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  65540. /**
  65541. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  65542. * @param matrix defines the matrix to use
  65543. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  65544. */
  65545. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  65546. /**
  65547. * Compute the transpose of a given matrix
  65548. * @param matrix defines the matrix to transpose
  65549. * @returns the new matrix
  65550. */
  65551. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  65552. /**
  65553. * Compute the transpose of a matrix and store it in a target matrix
  65554. * @param matrix defines the matrix to transpose
  65555. * @param result defines the target matrix
  65556. */
  65557. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  65558. /**
  65559. * Computes a reflection matrix from a plane
  65560. * @param plane defines the reflection plane
  65561. * @returns a new matrix
  65562. */
  65563. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  65564. /**
  65565. * Computes a reflection matrix from a plane
  65566. * @param plane defines the reflection plane
  65567. * @param result defines the target matrix
  65568. */
  65569. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  65570. /**
  65571. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  65572. * @param xaxis defines the value of the 1st axis
  65573. * @param yaxis defines the value of the 2nd axis
  65574. * @param zaxis defines the value of the 3rd axis
  65575. * @param result defines the target matrix
  65576. */
  65577. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  65578. /**
  65579. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  65580. * @param quat defines the quaternion to use
  65581. * @param result defines the target matrix
  65582. */
  65583. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  65584. }
  65585. /**
  65586. * Represens a plane by the equation ax + by + cz + d = 0
  65587. */
  65588. export class Plane {
  65589. /**
  65590. * Normal of the plane (a,b,c)
  65591. */
  65592. normal: Vector3;
  65593. /**
  65594. * d component of the plane
  65595. */
  65596. d: number;
  65597. /**
  65598. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  65599. * @param a a component of the plane
  65600. * @param b b component of the plane
  65601. * @param c c component of the plane
  65602. * @param d d component of the plane
  65603. */
  65604. constructor(a: number, b: number, c: number, d: number);
  65605. /**
  65606. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  65607. */
  65608. asArray(): number[];
  65609. /**
  65610. * @returns a new plane copied from the current Plane.
  65611. */
  65612. clone(): Plane;
  65613. /**
  65614. * @returns the string "Plane".
  65615. */
  65616. getClassName(): string;
  65617. /**
  65618. * @returns the Plane hash code.
  65619. */
  65620. getHashCode(): number;
  65621. /**
  65622. * Normalize the current Plane in place.
  65623. * @returns the updated Plane.
  65624. */
  65625. normalize(): Plane;
  65626. /**
  65627. * Applies a transformation the plane and returns the result
  65628. * @param transformation the transformation matrix to be applied to the plane
  65629. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  65630. */
  65631. transform(transformation: DeepImmutable<Matrix>): Plane;
  65632. /**
  65633. * Calcualtte the dot product between the point and the plane normal
  65634. * @param point point to calculate the dot product with
  65635. * @returns the dot product (float) of the point coordinates and the plane normal.
  65636. */
  65637. dotCoordinate(point: DeepImmutable<Vector3>): number;
  65638. /**
  65639. * Updates the current Plane from the plane defined by the three given points.
  65640. * @param point1 one of the points used to contruct the plane
  65641. * @param point2 one of the points used to contruct the plane
  65642. * @param point3 one of the points used to contruct the plane
  65643. * @returns the updated Plane.
  65644. */
  65645. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  65646. /**
  65647. * Checks if the plane is facing a given direction
  65648. * @param direction the direction to check if the plane is facing
  65649. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  65650. * @returns True is the vector "direction" is the same side than the plane normal.
  65651. */
  65652. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  65653. /**
  65654. * Calculates the distance to a point
  65655. * @param point point to calculate distance to
  65656. * @returns the signed distance (float) from the given point to the Plane.
  65657. */
  65658. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  65659. /**
  65660. * Creates a plane from an array
  65661. * @param array the array to create a plane from
  65662. * @returns a new Plane from the given array.
  65663. */
  65664. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  65665. /**
  65666. * Creates a plane from three points
  65667. * @param point1 point used to create the plane
  65668. * @param point2 point used to create the plane
  65669. * @param point3 point used to create the plane
  65670. * @returns a new Plane defined by the three given points.
  65671. */
  65672. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  65673. /**
  65674. * Creates a plane from an origin point and a normal
  65675. * @param origin origin of the plane to be constructed
  65676. * @param normal normal of the plane to be constructed
  65677. * @returns a new Plane the normal vector to this plane at the given origin point.
  65678. * Note : the vector "normal" is updated because normalized.
  65679. */
  65680. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  65681. /**
  65682. * Calculates the distance from a plane and a point
  65683. * @param origin origin of the plane to be constructed
  65684. * @param normal normal of the plane to be constructed
  65685. * @param point point to calculate distance to
  65686. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  65687. */
  65688. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  65689. }
  65690. /**
  65691. * Class used to represent a viewport on screen
  65692. */
  65693. export class Viewport {
  65694. /** viewport left coordinate */
  65695. x: number;
  65696. /** viewport top coordinate */
  65697. y: number;
  65698. /**viewport width */
  65699. width: number;
  65700. /** viewport height */
  65701. height: number;
  65702. /**
  65703. * Creates a Viewport object located at (x, y) and sized (width, height)
  65704. * @param x defines viewport left coordinate
  65705. * @param y defines viewport top coordinate
  65706. * @param width defines the viewport width
  65707. * @param height defines the viewport height
  65708. */
  65709. constructor(
  65710. /** viewport left coordinate */
  65711. x: number,
  65712. /** viewport top coordinate */
  65713. y: number,
  65714. /**viewport width */
  65715. width: number,
  65716. /** viewport height */
  65717. height: number);
  65718. /**
  65719. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  65720. * @param renderWidth defines the rendering width
  65721. * @param renderHeight defines the rendering height
  65722. * @returns a new Viewport
  65723. */
  65724. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  65725. /**
  65726. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  65727. * @param renderWidth defines the rendering width
  65728. * @param renderHeight defines the rendering height
  65729. * @param ref defines the target viewport
  65730. * @returns the current viewport
  65731. */
  65732. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  65733. /**
  65734. * Returns a new Viewport copied from the current one
  65735. * @returns a new Viewport
  65736. */
  65737. clone(): Viewport;
  65738. }
  65739. /**
  65740. * Reprasents a camera frustum
  65741. */
  65742. export class Frustum {
  65743. /**
  65744. * Gets the planes representing the frustum
  65745. * @param transform matrix to be applied to the returned planes
  65746. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  65747. */
  65748. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  65749. /**
  65750. * Gets the near frustum plane transformed by the transform matrix
  65751. * @param transform transformation matrix to be applied to the resulting frustum plane
  65752. * @param frustumPlane the resuling frustum plane
  65753. */
  65754. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  65755. /**
  65756. * Gets the far frustum plane transformed by the transform matrix
  65757. * @param transform transformation matrix to be applied to the resulting frustum plane
  65758. * @param frustumPlane the resuling frustum plane
  65759. */
  65760. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  65761. /**
  65762. * Gets the left frustum plane transformed by the transform matrix
  65763. * @param transform transformation matrix to be applied to the resulting frustum plane
  65764. * @param frustumPlane the resuling frustum plane
  65765. */
  65766. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  65767. /**
  65768. * Gets the right frustum plane transformed by the transform matrix
  65769. * @param transform transformation matrix to be applied to the resulting frustum plane
  65770. * @param frustumPlane the resuling frustum plane
  65771. */
  65772. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  65773. /**
  65774. * Gets the top frustum plane transformed by the transform matrix
  65775. * @param transform transformation matrix to be applied to the resulting frustum plane
  65776. * @param frustumPlane the resuling frustum plane
  65777. */
  65778. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  65779. /**
  65780. * Gets the bottom frustum plane transformed by the transform matrix
  65781. * @param transform transformation matrix to be applied to the resulting frustum plane
  65782. * @param frustumPlane the resuling frustum plane
  65783. */
  65784. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  65785. /**
  65786. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  65787. * @param transform transformation matrix to be applied to the resulting frustum planes
  65788. * @param frustumPlanes the resuling frustum planes
  65789. */
  65790. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  65791. }
  65792. /** Defines supported spaces */
  65793. export enum Space {
  65794. /** Local (object) space */
  65795. LOCAL = 0,
  65796. /** World space */
  65797. WORLD = 1,
  65798. /** Bone space */
  65799. BONE = 2
  65800. }
  65801. /** Defines the 3 main axes */
  65802. export class Axis {
  65803. /** X axis */
  65804. static X: Vector3;
  65805. /** Y axis */
  65806. static Y: Vector3;
  65807. /** Z axis */
  65808. static Z: Vector3;
  65809. }
  65810. /** Class used to represent a Bezier curve */
  65811. export class BezierCurve {
  65812. /**
  65813. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  65814. * @param t defines the time
  65815. * @param x1 defines the left coordinate on X axis
  65816. * @param y1 defines the left coordinate on Y axis
  65817. * @param x2 defines the right coordinate on X axis
  65818. * @param y2 defines the right coordinate on Y axis
  65819. * @returns the interpolated value
  65820. */
  65821. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  65822. }
  65823. /**
  65824. * Defines potential orientation for back face culling
  65825. */
  65826. export enum Orientation {
  65827. /**
  65828. * Clockwise
  65829. */
  65830. CW = 0,
  65831. /** Counter clockwise */
  65832. CCW = 1
  65833. }
  65834. /**
  65835. * Defines angle representation
  65836. */
  65837. export class Angle {
  65838. private _radians;
  65839. /**
  65840. * Creates an Angle object of "radians" radians (float).
  65841. * @param radians the angle in radians
  65842. */
  65843. constructor(radians: number);
  65844. /**
  65845. * Get value in degrees
  65846. * @returns the Angle value in degrees (float)
  65847. */
  65848. degrees(): number;
  65849. /**
  65850. * Get value in radians
  65851. * @returns the Angle value in radians (float)
  65852. */
  65853. radians(): number;
  65854. /**
  65855. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  65856. * @param a defines first vector
  65857. * @param b defines second vector
  65858. * @returns a new Angle
  65859. */
  65860. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  65861. /**
  65862. * Gets a new Angle object from the given float in radians
  65863. * @param radians defines the angle value in radians
  65864. * @returns a new Angle
  65865. */
  65866. static FromRadians(radians: number): Angle;
  65867. /**
  65868. * Gets a new Angle object from the given float in degrees
  65869. * @param degrees defines the angle value in degrees
  65870. * @returns a new Angle
  65871. */
  65872. static FromDegrees(degrees: number): Angle;
  65873. }
  65874. /**
  65875. * This represents an arc in a 2d space.
  65876. */
  65877. export class Arc2 {
  65878. /** Defines the start point of the arc */
  65879. startPoint: Vector2;
  65880. /** Defines the mid point of the arc */
  65881. midPoint: Vector2;
  65882. /** Defines the end point of the arc */
  65883. endPoint: Vector2;
  65884. /**
  65885. * Defines the center point of the arc.
  65886. */
  65887. centerPoint: Vector2;
  65888. /**
  65889. * Defines the radius of the arc.
  65890. */
  65891. radius: number;
  65892. /**
  65893. * Defines the angle of the arc (from mid point to end point).
  65894. */
  65895. angle: Angle;
  65896. /**
  65897. * Defines the start angle of the arc (from start point to middle point).
  65898. */
  65899. startAngle: Angle;
  65900. /**
  65901. * Defines the orientation of the arc (clock wise/counter clock wise).
  65902. */
  65903. orientation: Orientation;
  65904. /**
  65905. * Creates an Arc object from the three given points : start, middle and end.
  65906. * @param startPoint Defines the start point of the arc
  65907. * @param midPoint Defines the midlle point of the arc
  65908. * @param endPoint Defines the end point of the arc
  65909. */
  65910. constructor(
  65911. /** Defines the start point of the arc */
  65912. startPoint: Vector2,
  65913. /** Defines the mid point of the arc */
  65914. midPoint: Vector2,
  65915. /** Defines the end point of the arc */
  65916. endPoint: Vector2);
  65917. }
  65918. /**
  65919. * Represents a 2D path made up of multiple 2D points
  65920. */
  65921. export class Path2 {
  65922. private _points;
  65923. private _length;
  65924. /**
  65925. * If the path start and end point are the same
  65926. */
  65927. closed: boolean;
  65928. /**
  65929. * Creates a Path2 object from the starting 2D coordinates x and y.
  65930. * @param x the starting points x value
  65931. * @param y the starting points y value
  65932. */
  65933. constructor(x: number, y: number);
  65934. /**
  65935. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  65936. * @param x the added points x value
  65937. * @param y the added points y value
  65938. * @returns the updated Path2.
  65939. */
  65940. addLineTo(x: number, y: number): Path2;
  65941. /**
  65942. * 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.
  65943. * @param midX middle point x value
  65944. * @param midY middle point y value
  65945. * @param endX end point x value
  65946. * @param endY end point y value
  65947. * @param numberOfSegments (default: 36)
  65948. * @returns the updated Path2.
  65949. */
  65950. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  65951. /**
  65952. * Closes the Path2.
  65953. * @returns the Path2.
  65954. */
  65955. close(): Path2;
  65956. /**
  65957. * Gets the sum of the distance between each sequential point in the path
  65958. * @returns the Path2 total length (float).
  65959. */
  65960. length(): number;
  65961. /**
  65962. * Gets the points which construct the path
  65963. * @returns the Path2 internal array of points.
  65964. */
  65965. getPoints(): Vector2[];
  65966. /**
  65967. * Retreives the point at the distance aways from the starting point
  65968. * @param normalizedLengthPosition the length along the path to retreive the point from
  65969. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  65970. */
  65971. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  65972. /**
  65973. * Creates a new path starting from an x and y position
  65974. * @param x starting x value
  65975. * @param y starting y value
  65976. * @returns a new Path2 starting at the coordinates (x, y).
  65977. */
  65978. static StartingAt(x: number, y: number): Path2;
  65979. }
  65980. /**
  65981. * Represents a 3D path made up of multiple 3D points
  65982. */
  65983. export class Path3D {
  65984. /**
  65985. * an array of Vector3, the curve axis of the Path3D
  65986. */
  65987. path: Vector3[];
  65988. private _curve;
  65989. private _distances;
  65990. private _tangents;
  65991. private _normals;
  65992. private _binormals;
  65993. private _raw;
  65994. /**
  65995. * new Path3D(path, normal, raw)
  65996. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  65997. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  65998. * @param path an array of Vector3, the curve axis of the Path3D
  65999. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  66000. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  66001. */
  66002. constructor(
  66003. /**
  66004. * an array of Vector3, the curve axis of the Path3D
  66005. */
  66006. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  66007. /**
  66008. * Returns the Path3D array of successive Vector3 designing its curve.
  66009. * @returns the Path3D array of successive Vector3 designing its curve.
  66010. */
  66011. getCurve(): Vector3[];
  66012. /**
  66013. * Returns an array populated with tangent vectors on each Path3D curve point.
  66014. * @returns an array populated with tangent vectors on each Path3D curve point.
  66015. */
  66016. getTangents(): Vector3[];
  66017. /**
  66018. * Returns an array populated with normal vectors on each Path3D curve point.
  66019. * @returns an array populated with normal vectors on each Path3D curve point.
  66020. */
  66021. getNormals(): Vector3[];
  66022. /**
  66023. * Returns an array populated with binormal vectors on each Path3D curve point.
  66024. * @returns an array populated with binormal vectors on each Path3D curve point.
  66025. */
  66026. getBinormals(): Vector3[];
  66027. /**
  66028. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  66029. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  66030. */
  66031. getDistances(): number[];
  66032. /**
  66033. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  66034. * @param path path which all values are copied into the curves points
  66035. * @param firstNormal which should be projected onto the curve
  66036. * @returns the same object updated.
  66037. */
  66038. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  66039. private _compute;
  66040. private _getFirstNonNullVector;
  66041. private _getLastNonNullVector;
  66042. private _normalVector;
  66043. }
  66044. /**
  66045. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  66046. * A Curve3 is designed from a series of successive Vector3.
  66047. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  66048. */
  66049. export class Curve3 {
  66050. private _points;
  66051. private _length;
  66052. /**
  66053. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  66054. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  66055. * @param v1 (Vector3) the control point
  66056. * @param v2 (Vector3) the end point of the Quadratic Bezier
  66057. * @param nbPoints (integer) the wanted number of points in the curve
  66058. * @returns the created Curve3
  66059. */
  66060. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  66061. /**
  66062. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  66063. * @param v0 (Vector3) the origin point of the Cubic Bezier
  66064. * @param v1 (Vector3) the first control point
  66065. * @param v2 (Vector3) the second control point
  66066. * @param v3 (Vector3) the end point of the Cubic Bezier
  66067. * @param nbPoints (integer) the wanted number of points in the curve
  66068. * @returns the created Curve3
  66069. */
  66070. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  66071. /**
  66072. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  66073. * @param p1 (Vector3) the origin point of the Hermite Spline
  66074. * @param t1 (Vector3) the tangent vector at the origin point
  66075. * @param p2 (Vector3) the end point of the Hermite Spline
  66076. * @param t2 (Vector3) the tangent vector at the end point
  66077. * @param nbPoints (integer) the wanted number of points in the curve
  66078. * @returns the created Curve3
  66079. */
  66080. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  66081. /**
  66082. * Returns a Curve3 object along a CatmullRom Spline curve :
  66083. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  66084. * @param nbPoints (integer) the wanted number of points between each curve control points
  66085. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  66086. * @returns the created Curve3
  66087. */
  66088. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  66089. /**
  66090. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  66091. * A Curve3 is designed from a series of successive Vector3.
  66092. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  66093. * @param points points which make up the curve
  66094. */
  66095. constructor(points: Vector3[]);
  66096. /**
  66097. * @returns the Curve3 stored array of successive Vector3
  66098. */
  66099. getPoints(): Vector3[];
  66100. /**
  66101. * @returns the computed length (float) of the curve.
  66102. */
  66103. length(): number;
  66104. /**
  66105. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  66106. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  66107. * curveA and curveB keep unchanged.
  66108. * @param curve the curve to continue from this curve
  66109. * @returns the newly constructed curve
  66110. */
  66111. continue(curve: DeepImmutable<Curve3>): Curve3;
  66112. private _computeLength;
  66113. }
  66114. /**
  66115. * Contains position and normal vectors for a vertex
  66116. */
  66117. export class PositionNormalVertex {
  66118. /** the position of the vertex (defaut: 0,0,0) */
  66119. position: Vector3;
  66120. /** the normal of the vertex (defaut: 0,1,0) */
  66121. normal: Vector3;
  66122. /**
  66123. * Creates a PositionNormalVertex
  66124. * @param position the position of the vertex (defaut: 0,0,0)
  66125. * @param normal the normal of the vertex (defaut: 0,1,0)
  66126. */
  66127. constructor(
  66128. /** the position of the vertex (defaut: 0,0,0) */
  66129. position?: Vector3,
  66130. /** the normal of the vertex (defaut: 0,1,0) */
  66131. normal?: Vector3);
  66132. /**
  66133. * Clones the PositionNormalVertex
  66134. * @returns the cloned PositionNormalVertex
  66135. */
  66136. clone(): PositionNormalVertex;
  66137. }
  66138. /**
  66139. * Contains position, normal and uv vectors for a vertex
  66140. */
  66141. export class PositionNormalTextureVertex {
  66142. /** the position of the vertex (defaut: 0,0,0) */
  66143. position: Vector3;
  66144. /** the normal of the vertex (defaut: 0,1,0) */
  66145. normal: Vector3;
  66146. /** the uv of the vertex (default: 0,0) */
  66147. uv: Vector2;
  66148. /**
  66149. * Creates a PositionNormalTextureVertex
  66150. * @param position the position of the vertex (defaut: 0,0,0)
  66151. * @param normal the normal of the vertex (defaut: 0,1,0)
  66152. * @param uv the uv of the vertex (default: 0,0)
  66153. */
  66154. constructor(
  66155. /** the position of the vertex (defaut: 0,0,0) */
  66156. position?: Vector3,
  66157. /** the normal of the vertex (defaut: 0,1,0) */
  66158. normal?: Vector3,
  66159. /** the uv of the vertex (default: 0,0) */
  66160. uv?: Vector2);
  66161. /**
  66162. * Clones the PositionNormalTextureVertex
  66163. * @returns the cloned PositionNormalTextureVertex
  66164. */
  66165. clone(): PositionNormalTextureVertex;
  66166. }
  66167. /**
  66168. * @hidden
  66169. */
  66170. export class Tmp {
  66171. static Color3: Color3[];
  66172. static Color4: Color4[];
  66173. static Vector2: Vector2[];
  66174. static Vector3: Vector3[];
  66175. static Vector4: Vector4[];
  66176. static Quaternion: Quaternion[];
  66177. static Matrix: Matrix[];
  66178. }
  66179. }
  66180. declare module BABYLON {
  66181. /**
  66182. * Class used to enable access to offline support
  66183. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  66184. */
  66185. export interface IOfflineProvider {
  66186. /**
  66187. * Gets a boolean indicating if scene must be saved in the database
  66188. */
  66189. enableSceneOffline: boolean;
  66190. /**
  66191. * Gets a boolean indicating if textures must be saved in the database
  66192. */
  66193. enableTexturesOffline: boolean;
  66194. /**
  66195. * Open the offline support and make it available
  66196. * @param successCallback defines the callback to call on success
  66197. * @param errorCallback defines the callback to call on error
  66198. */
  66199. open(successCallback: () => void, errorCallback: () => void): void;
  66200. /**
  66201. * Loads an image from the offline support
  66202. * @param url defines the url to load from
  66203. * @param image defines the target DOM image
  66204. */
  66205. loadImage(url: string, image: HTMLImageElement): void;
  66206. /**
  66207. * Loads a file from offline support
  66208. * @param url defines the URL to load from
  66209. * @param sceneLoaded defines a callback to call on success
  66210. * @param progressCallBack defines a callback to call when progress changed
  66211. * @param errorCallback defines a callback to call on error
  66212. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  66213. */
  66214. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  66215. }
  66216. }
  66217. declare module BABYLON {
  66218. /**
  66219. * A class serves as a medium between the observable and its observers
  66220. */
  66221. export class EventState {
  66222. /**
  66223. * Create a new EventState
  66224. * @param mask defines the mask associated with this state
  66225. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  66226. * @param target defines the original target of the state
  66227. * @param currentTarget defines the current target of the state
  66228. */
  66229. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  66230. /**
  66231. * Initialize the current event state
  66232. * @param mask defines the mask associated with this state
  66233. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  66234. * @param target defines the original target of the state
  66235. * @param currentTarget defines the current target of the state
  66236. * @returns the current event state
  66237. */
  66238. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  66239. /**
  66240. * An Observer can set this property to true to prevent subsequent observers of being notified
  66241. */
  66242. skipNextObservers: boolean;
  66243. /**
  66244. * Get the mask value that were used to trigger the event corresponding to this EventState object
  66245. */
  66246. mask: number;
  66247. /**
  66248. * The object that originally notified the event
  66249. */
  66250. target?: any;
  66251. /**
  66252. * The current object in the bubbling phase
  66253. */
  66254. currentTarget?: any;
  66255. /**
  66256. * This will be populated with the return value of the last function that was executed.
  66257. * If it is the first function in the callback chain it will be the event data.
  66258. */
  66259. lastReturnValue?: any;
  66260. }
  66261. /**
  66262. * Represent an Observer registered to a given Observable object.
  66263. */
  66264. export class Observer<T> {
  66265. /**
  66266. * Defines the callback to call when the observer is notified
  66267. */
  66268. callback: (eventData: T, eventState: EventState) => void;
  66269. /**
  66270. * Defines the mask of the observer (used to filter notifications)
  66271. */
  66272. mask: number;
  66273. /**
  66274. * Defines the current scope used to restore the JS context
  66275. */
  66276. scope: any;
  66277. /** @hidden */
  66278. _willBeUnregistered: boolean;
  66279. /**
  66280. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  66281. */
  66282. unregisterOnNextCall: boolean;
  66283. /**
  66284. * Creates a new observer
  66285. * @param callback defines the callback to call when the observer is notified
  66286. * @param mask defines the mask of the observer (used to filter notifications)
  66287. * @param scope defines the current scope used to restore the JS context
  66288. */
  66289. constructor(
  66290. /**
  66291. * Defines the callback to call when the observer is notified
  66292. */
  66293. callback: (eventData: T, eventState: EventState) => void,
  66294. /**
  66295. * Defines the mask of the observer (used to filter notifications)
  66296. */
  66297. mask: number,
  66298. /**
  66299. * Defines the current scope used to restore the JS context
  66300. */
  66301. scope?: any);
  66302. }
  66303. /**
  66304. * Represent a list of observers registered to multiple Observables object.
  66305. */
  66306. export class MultiObserver<T> {
  66307. private _observers;
  66308. private _observables;
  66309. /**
  66310. * Release associated resources
  66311. */
  66312. dispose(): void;
  66313. /**
  66314. * Raise a callback when one of the observable will notify
  66315. * @param observables defines a list of observables to watch
  66316. * @param callback defines the callback to call on notification
  66317. * @param mask defines the mask used to filter notifications
  66318. * @param scope defines the current scope used to restore the JS context
  66319. * @returns the new MultiObserver
  66320. */
  66321. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  66322. }
  66323. /**
  66324. * The Observable class is a simple implementation of the Observable pattern.
  66325. *
  66326. * 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.
  66327. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  66328. * 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).
  66329. * 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.
  66330. */
  66331. export class Observable<T> {
  66332. private _observers;
  66333. private _eventState;
  66334. private _onObserverAdded;
  66335. /**
  66336. * Creates a new observable
  66337. * @param onObserverAdded defines a callback to call when a new observer is added
  66338. */
  66339. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  66340. /**
  66341. * Create a new Observer with the specified callback
  66342. * @param callback the callback that will be executed for that Observer
  66343. * @param mask the mask used to filter observers
  66344. * @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.
  66345. * @param scope optional scope for the callback to be called from
  66346. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  66347. * @returns the new observer created for the callback
  66348. */
  66349. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  66350. /**
  66351. * Create a new Observer with the specified callback and unregisters after the next notification
  66352. * @param callback the callback that will be executed for that Observer
  66353. * @returns the new observer created for the callback
  66354. */
  66355. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  66356. /**
  66357. * Remove an Observer from the Observable object
  66358. * @param observer the instance of the Observer to remove
  66359. * @returns false if it doesn't belong to this Observable
  66360. */
  66361. remove(observer: Nullable<Observer<T>>): boolean;
  66362. /**
  66363. * Remove a callback from the Observable object
  66364. * @param callback the callback to remove
  66365. * @param scope optional scope. If used only the callbacks with this scope will be removed
  66366. * @returns false if it doesn't belong to this Observable
  66367. */
  66368. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  66369. private _deferUnregister;
  66370. private _remove;
  66371. /**
  66372. * Moves the observable to the top of the observer list making it get called first when notified
  66373. * @param observer the observer to move
  66374. */
  66375. makeObserverTopPriority(observer: Observer<T>): void;
  66376. /**
  66377. * Moves the observable to the bottom of the observer list making it get called last when notified
  66378. * @param observer the observer to move
  66379. */
  66380. makeObserverBottomPriority(observer: Observer<T>): void;
  66381. /**
  66382. * Notify all Observers by calling their respective callback with the given data
  66383. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  66384. * @param eventData defines the data to send to all observers
  66385. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  66386. * @param target defines the original target of the state
  66387. * @param currentTarget defines the current target of the state
  66388. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  66389. */
  66390. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  66391. /**
  66392. * Calling this will execute each callback, expecting it to be a promise or return a value.
  66393. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  66394. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  66395. * and it is crucial that all callbacks will be executed.
  66396. * The order of the callbacks is kept, callbacks are not executed parallel.
  66397. *
  66398. * @param eventData The data to be sent to each callback
  66399. * @param mask is used to filter observers defaults to -1
  66400. * @param target defines the callback target (see EventState)
  66401. * @param currentTarget defines he current object in the bubbling phase
  66402. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  66403. */
  66404. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  66405. /**
  66406. * Notify a specific observer
  66407. * @param observer defines the observer to notify
  66408. * @param eventData defines the data to be sent to each callback
  66409. * @param mask is used to filter observers defaults to -1
  66410. */
  66411. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  66412. /**
  66413. * Gets a boolean indicating if the observable has at least one observer
  66414. * @returns true is the Observable has at least one Observer registered
  66415. */
  66416. hasObservers(): boolean;
  66417. /**
  66418. * Clear the list of observers
  66419. */
  66420. clear(): void;
  66421. /**
  66422. * Clone the current observable
  66423. * @returns a new observable
  66424. */
  66425. clone(): Observable<T>;
  66426. /**
  66427. * Does this observable handles observer registered with a given mask
  66428. * @param mask defines the mask to be tested
  66429. * @return whether or not one observer registered with the given mask is handeled
  66430. **/
  66431. hasSpecificMask(mask?: number): boolean;
  66432. }
  66433. }
  66434. declare module BABYLON {
  66435. /**
  66436. * Class used to help managing file picking and drag'n'drop
  66437. * File Storage
  66438. */
  66439. export class FilesInputStore {
  66440. /**
  66441. * List of files ready to be loaded
  66442. */
  66443. static FilesToLoad: {
  66444. [key: string]: File;
  66445. };
  66446. }
  66447. }
  66448. declare module BABYLON {
  66449. /** Defines the cross module used constants to avoid circular dependncies */
  66450. export class Constants {
  66451. /** Defines that alpha blending is disabled */
  66452. static readonly ALPHA_DISABLE: number;
  66453. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  66454. static readonly ALPHA_ADD: number;
  66455. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  66456. static readonly ALPHA_COMBINE: number;
  66457. /** Defines that alpha blending to DEST - SRC * DEST */
  66458. static readonly ALPHA_SUBTRACT: number;
  66459. /** Defines that alpha blending to SRC * DEST */
  66460. static readonly ALPHA_MULTIPLY: number;
  66461. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  66462. static readonly ALPHA_MAXIMIZED: number;
  66463. /** Defines that alpha blending to SRC + DEST */
  66464. static readonly ALPHA_ONEONE: number;
  66465. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  66466. static readonly ALPHA_PREMULTIPLIED: number;
  66467. /**
  66468. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  66469. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  66470. */
  66471. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  66472. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  66473. static readonly ALPHA_INTERPOLATE: number;
  66474. /**
  66475. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  66476. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  66477. */
  66478. static readonly ALPHA_SCREENMODE: number;
  66479. /** Defines that the ressource is not delayed*/
  66480. static readonly DELAYLOADSTATE_NONE: number;
  66481. /** Defines that the ressource was successfully delay loaded */
  66482. static readonly DELAYLOADSTATE_LOADED: number;
  66483. /** Defines that the ressource is currently delay loading */
  66484. static readonly DELAYLOADSTATE_LOADING: number;
  66485. /** Defines that the ressource is delayed and has not started loading */
  66486. static readonly DELAYLOADSTATE_NOTLOADED: number;
  66487. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  66488. static readonly NEVER: number;
  66489. /** 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 */
  66490. static readonly ALWAYS: number;
  66491. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  66492. static readonly LESS: number;
  66493. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  66494. static readonly EQUAL: number;
  66495. /** 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 */
  66496. static readonly LEQUAL: number;
  66497. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  66498. static readonly GREATER: number;
  66499. /** 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 */
  66500. static readonly GEQUAL: number;
  66501. /** 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 */
  66502. static readonly NOTEQUAL: number;
  66503. /** Passed to stencilOperation to specify that stencil value must be kept */
  66504. static readonly KEEP: number;
  66505. /** Passed to stencilOperation to specify that stencil value must be replaced */
  66506. static readonly REPLACE: number;
  66507. /** Passed to stencilOperation to specify that stencil value must be incremented */
  66508. static readonly INCR: number;
  66509. /** Passed to stencilOperation to specify that stencil value must be decremented */
  66510. static readonly DECR: number;
  66511. /** Passed to stencilOperation to specify that stencil value must be inverted */
  66512. static readonly INVERT: number;
  66513. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  66514. static readonly INCR_WRAP: number;
  66515. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  66516. static readonly DECR_WRAP: number;
  66517. /** Texture is not repeating outside of 0..1 UVs */
  66518. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  66519. /** Texture is repeating outside of 0..1 UVs */
  66520. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  66521. /** Texture is repeating and mirrored */
  66522. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  66523. /** ALPHA */
  66524. static readonly TEXTUREFORMAT_ALPHA: number;
  66525. /** LUMINANCE */
  66526. static readonly TEXTUREFORMAT_LUMINANCE: number;
  66527. /** LUMINANCE_ALPHA */
  66528. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  66529. /** RGB */
  66530. static readonly TEXTUREFORMAT_RGB: number;
  66531. /** RGBA */
  66532. static readonly TEXTUREFORMAT_RGBA: number;
  66533. /** RED */
  66534. static readonly TEXTUREFORMAT_RED: number;
  66535. /** RED (2nd reference) */
  66536. static readonly TEXTUREFORMAT_R: number;
  66537. /** RG */
  66538. static readonly TEXTUREFORMAT_RG: number;
  66539. /** RED_INTEGER */
  66540. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  66541. /** RED_INTEGER (2nd reference) */
  66542. static readonly TEXTUREFORMAT_R_INTEGER: number;
  66543. /** RG_INTEGER */
  66544. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  66545. /** RGB_INTEGER */
  66546. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  66547. /** RGBA_INTEGER */
  66548. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  66549. /** UNSIGNED_BYTE */
  66550. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  66551. /** UNSIGNED_BYTE (2nd reference) */
  66552. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  66553. /** FLOAT */
  66554. static readonly TEXTURETYPE_FLOAT: number;
  66555. /** HALF_FLOAT */
  66556. static readonly TEXTURETYPE_HALF_FLOAT: number;
  66557. /** BYTE */
  66558. static readonly TEXTURETYPE_BYTE: number;
  66559. /** SHORT */
  66560. static readonly TEXTURETYPE_SHORT: number;
  66561. /** UNSIGNED_SHORT */
  66562. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  66563. /** INT */
  66564. static readonly TEXTURETYPE_INT: number;
  66565. /** UNSIGNED_INT */
  66566. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  66567. /** UNSIGNED_SHORT_4_4_4_4 */
  66568. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  66569. /** UNSIGNED_SHORT_5_5_5_1 */
  66570. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  66571. /** UNSIGNED_SHORT_5_6_5 */
  66572. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  66573. /** UNSIGNED_INT_2_10_10_10_REV */
  66574. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  66575. /** UNSIGNED_INT_24_8 */
  66576. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  66577. /** UNSIGNED_INT_10F_11F_11F_REV */
  66578. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  66579. /** UNSIGNED_INT_5_9_9_9_REV */
  66580. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  66581. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  66582. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  66583. /** nearest is mag = nearest and min = nearest and mip = linear */
  66584. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  66585. /** Bilinear is mag = linear and min = linear and mip = nearest */
  66586. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  66587. /** Trilinear is mag = linear and min = linear and mip = linear */
  66588. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  66589. /** nearest is mag = nearest and min = nearest and mip = linear */
  66590. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  66591. /** Bilinear is mag = linear and min = linear and mip = nearest */
  66592. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  66593. /** Trilinear is mag = linear and min = linear and mip = linear */
  66594. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  66595. /** mag = nearest and min = nearest and mip = nearest */
  66596. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  66597. /** mag = nearest and min = linear and mip = nearest */
  66598. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  66599. /** mag = nearest and min = linear and mip = linear */
  66600. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  66601. /** mag = nearest and min = linear and mip = none */
  66602. static readonly TEXTURE_NEAREST_LINEAR: number;
  66603. /** mag = nearest and min = nearest and mip = none */
  66604. static readonly TEXTURE_NEAREST_NEAREST: number;
  66605. /** mag = linear and min = nearest and mip = nearest */
  66606. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  66607. /** mag = linear and min = nearest and mip = linear */
  66608. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  66609. /** mag = linear and min = linear and mip = none */
  66610. static readonly TEXTURE_LINEAR_LINEAR: number;
  66611. /** mag = linear and min = nearest and mip = none */
  66612. static readonly TEXTURE_LINEAR_NEAREST: number;
  66613. /** Explicit coordinates mode */
  66614. static readonly TEXTURE_EXPLICIT_MODE: number;
  66615. /** Spherical coordinates mode */
  66616. static readonly TEXTURE_SPHERICAL_MODE: number;
  66617. /** Planar coordinates mode */
  66618. static readonly TEXTURE_PLANAR_MODE: number;
  66619. /** Cubic coordinates mode */
  66620. static readonly TEXTURE_CUBIC_MODE: number;
  66621. /** Projection coordinates mode */
  66622. static readonly TEXTURE_PROJECTION_MODE: number;
  66623. /** Skybox coordinates mode */
  66624. static readonly TEXTURE_SKYBOX_MODE: number;
  66625. /** Inverse Cubic coordinates mode */
  66626. static readonly TEXTURE_INVCUBIC_MODE: number;
  66627. /** Equirectangular coordinates mode */
  66628. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  66629. /** Equirectangular Fixed coordinates mode */
  66630. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  66631. /** Equirectangular Fixed Mirrored coordinates mode */
  66632. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  66633. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  66634. static readonly SCALEMODE_FLOOR: number;
  66635. /** Defines that texture rescaling will look for the nearest power of 2 size */
  66636. static readonly SCALEMODE_NEAREST: number;
  66637. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  66638. static readonly SCALEMODE_CEILING: number;
  66639. /**
  66640. * The dirty texture flag value
  66641. */
  66642. static readonly MATERIAL_TextureDirtyFlag: number;
  66643. /**
  66644. * The dirty light flag value
  66645. */
  66646. static readonly MATERIAL_LightDirtyFlag: number;
  66647. /**
  66648. * The dirty fresnel flag value
  66649. */
  66650. static readonly MATERIAL_FresnelDirtyFlag: number;
  66651. /**
  66652. * The dirty attribute flag value
  66653. */
  66654. static readonly MATERIAL_AttributesDirtyFlag: number;
  66655. /**
  66656. * The dirty misc flag value
  66657. */
  66658. static readonly MATERIAL_MiscDirtyFlag: number;
  66659. /**
  66660. * The all dirty flag value
  66661. */
  66662. static readonly MATERIAL_AllDirtyFlag: number;
  66663. /**
  66664. * Returns the triangle fill mode
  66665. */
  66666. static readonly MATERIAL_TriangleFillMode: number;
  66667. /**
  66668. * Returns the wireframe mode
  66669. */
  66670. static readonly MATERIAL_WireFrameFillMode: number;
  66671. /**
  66672. * Returns the point fill mode
  66673. */
  66674. static readonly MATERIAL_PointFillMode: number;
  66675. /**
  66676. * Returns the point list draw mode
  66677. */
  66678. static readonly MATERIAL_PointListDrawMode: number;
  66679. /**
  66680. * Returns the line list draw mode
  66681. */
  66682. static readonly MATERIAL_LineListDrawMode: number;
  66683. /**
  66684. * Returns the line loop draw mode
  66685. */
  66686. static readonly MATERIAL_LineLoopDrawMode: number;
  66687. /**
  66688. * Returns the line strip draw mode
  66689. */
  66690. static readonly MATERIAL_LineStripDrawMode: number;
  66691. /**
  66692. * Returns the triangle strip draw mode
  66693. */
  66694. static readonly MATERIAL_TriangleStripDrawMode: number;
  66695. /**
  66696. * Returns the triangle fan draw mode
  66697. */
  66698. static readonly MATERIAL_TriangleFanDrawMode: number;
  66699. /**
  66700. * Stores the clock-wise side orientation
  66701. */
  66702. static readonly MATERIAL_ClockWiseSideOrientation: number;
  66703. /**
  66704. * Stores the counter clock-wise side orientation
  66705. */
  66706. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  66707. /**
  66708. * Nothing
  66709. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  66710. */
  66711. static readonly ACTION_NothingTrigger: number;
  66712. /**
  66713. * On pick
  66714. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  66715. */
  66716. static readonly ACTION_OnPickTrigger: number;
  66717. /**
  66718. * On left pick
  66719. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  66720. */
  66721. static readonly ACTION_OnLeftPickTrigger: number;
  66722. /**
  66723. * On right pick
  66724. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  66725. */
  66726. static readonly ACTION_OnRightPickTrigger: number;
  66727. /**
  66728. * On center pick
  66729. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  66730. */
  66731. static readonly ACTION_OnCenterPickTrigger: number;
  66732. /**
  66733. * On pick down
  66734. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  66735. */
  66736. static readonly ACTION_OnPickDownTrigger: number;
  66737. /**
  66738. * On double pick
  66739. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  66740. */
  66741. static readonly ACTION_OnDoublePickTrigger: number;
  66742. /**
  66743. * On pick up
  66744. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  66745. */
  66746. static readonly ACTION_OnPickUpTrigger: number;
  66747. /**
  66748. * On pick out.
  66749. * This trigger will only be raised if you also declared a OnPickDown
  66750. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  66751. */
  66752. static readonly ACTION_OnPickOutTrigger: number;
  66753. /**
  66754. * On long press
  66755. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  66756. */
  66757. static readonly ACTION_OnLongPressTrigger: number;
  66758. /**
  66759. * On pointer over
  66760. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  66761. */
  66762. static readonly ACTION_OnPointerOverTrigger: number;
  66763. /**
  66764. * On pointer out
  66765. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  66766. */
  66767. static readonly ACTION_OnPointerOutTrigger: number;
  66768. /**
  66769. * On every frame
  66770. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  66771. */
  66772. static readonly ACTION_OnEveryFrameTrigger: number;
  66773. /**
  66774. * On intersection enter
  66775. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  66776. */
  66777. static readonly ACTION_OnIntersectionEnterTrigger: number;
  66778. /**
  66779. * On intersection exit
  66780. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  66781. */
  66782. static readonly ACTION_OnIntersectionExitTrigger: number;
  66783. /**
  66784. * On key down
  66785. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  66786. */
  66787. static readonly ACTION_OnKeyDownTrigger: number;
  66788. /**
  66789. * On key up
  66790. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  66791. */
  66792. static readonly ACTION_OnKeyUpTrigger: number;
  66793. /**
  66794. * Billboard mode will only apply to Y axis
  66795. */
  66796. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  66797. /**
  66798. * Billboard mode will apply to all axes
  66799. */
  66800. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  66801. /**
  66802. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  66803. */
  66804. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  66805. /**
  66806. * Gets or sets base Assets URL
  66807. */
  66808. static readonly PARTICLES_BaseAssetsUrl: string;
  66809. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  66810. * Test order :
  66811. * Is the bounding sphere outside the frustum ?
  66812. * If not, are the bounding box vertices outside the frustum ?
  66813. * It not, then the cullable object is in the frustum.
  66814. */
  66815. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  66816. /** Culling strategy : Bounding Sphere Only.
  66817. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  66818. * It's also less accurate than the standard because some not visible objects can still be selected.
  66819. * Test : is the bounding sphere outside the frustum ?
  66820. * If not, then the cullable object is in the frustum.
  66821. */
  66822. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  66823. /** Culling strategy : Optimistic Inclusion.
  66824. * This in an inclusion test first, then the standard exclusion test.
  66825. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  66826. * 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.
  66827. * Anyway, it's as accurate as the standard strategy.
  66828. * Test :
  66829. * Is the cullable object bounding sphere center in the frustum ?
  66830. * If not, apply the default culling strategy.
  66831. */
  66832. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  66833. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  66834. * This in an inclusion test first, then the bounding sphere only exclusion test.
  66835. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  66836. * 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.
  66837. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  66838. * Test :
  66839. * Is the cullable object bounding sphere center in the frustum ?
  66840. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  66841. */
  66842. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  66843. /**
  66844. * No logging while loading
  66845. */
  66846. static readonly SCENELOADER_NO_LOGGING: number;
  66847. /**
  66848. * Minimal logging while loading
  66849. */
  66850. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  66851. /**
  66852. * Summary logging while loading
  66853. */
  66854. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  66855. /**
  66856. * Detailled logging while loading
  66857. */
  66858. static readonly SCENELOADER_DETAILED_LOGGING: number;
  66859. }
  66860. }
  66861. declare module BABYLON {
  66862. /**
  66863. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  66864. * Babylon.js
  66865. */
  66866. export class DomManagement {
  66867. /**
  66868. * Checks if the window object exists
  66869. * @returns true if the window object exists
  66870. */
  66871. static IsWindowObjectExist(): boolean;
  66872. /**
  66873. * Extracts text content from a DOM element hierarchy
  66874. * @param element defines the root element
  66875. * @returns a string
  66876. */
  66877. static GetDOMTextContent(element: HTMLElement): string;
  66878. }
  66879. }
  66880. declare module BABYLON {
  66881. /**
  66882. * Logger used througouht the application to allow configuration of
  66883. * the log level required for the messages.
  66884. */
  66885. export class Logger {
  66886. /**
  66887. * No log
  66888. */
  66889. static readonly NoneLogLevel: number;
  66890. /**
  66891. * Only message logs
  66892. */
  66893. static readonly MessageLogLevel: number;
  66894. /**
  66895. * Only warning logs
  66896. */
  66897. static readonly WarningLogLevel: number;
  66898. /**
  66899. * Only error logs
  66900. */
  66901. static readonly ErrorLogLevel: number;
  66902. /**
  66903. * All logs
  66904. */
  66905. static readonly AllLogLevel: number;
  66906. private static _LogCache;
  66907. /**
  66908. * Gets a value indicating the number of loading errors
  66909. * @ignorenaming
  66910. */
  66911. static errorsCount: number;
  66912. /**
  66913. * Callback called when a new log is added
  66914. */
  66915. static OnNewCacheEntry: (entry: string) => void;
  66916. private static _AddLogEntry;
  66917. private static _FormatMessage;
  66918. private static _LogDisabled;
  66919. private static _LogEnabled;
  66920. private static _WarnDisabled;
  66921. private static _WarnEnabled;
  66922. private static _ErrorDisabled;
  66923. private static _ErrorEnabled;
  66924. /**
  66925. * Log a message to the console
  66926. */
  66927. static Log: (message: string) => void;
  66928. /**
  66929. * Write a warning message to the console
  66930. */
  66931. static Warn: (message: string) => void;
  66932. /**
  66933. * Write an error message to the console
  66934. */
  66935. static Error: (message: string) => void;
  66936. /**
  66937. * Gets current log cache (list of logs)
  66938. */
  66939. static readonly LogCache: string;
  66940. /**
  66941. * Clears the log cache
  66942. */
  66943. static ClearLogCache(): void;
  66944. /**
  66945. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  66946. */
  66947. static LogLevels: number;
  66948. }
  66949. }
  66950. declare module BABYLON {
  66951. /** @hidden */
  66952. export class _TypeStore {
  66953. /** @hidden */
  66954. static RegisteredTypes: {
  66955. [key: string]: Object;
  66956. };
  66957. /** @hidden */
  66958. static GetClass(fqdn: string): any;
  66959. }
  66960. }
  66961. declare module BABYLON {
  66962. /**
  66963. * Class containing a set of static utilities functions for deep copy.
  66964. */
  66965. export class DeepCopier {
  66966. /**
  66967. * Tries to copy an object by duplicating every property
  66968. * @param source defines the source object
  66969. * @param destination defines the target object
  66970. * @param doNotCopyList defines a list of properties to avoid
  66971. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  66972. */
  66973. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  66974. }
  66975. }
  66976. declare module BABYLON {
  66977. /**
  66978. * Class containing a set of static utilities functions for precision date
  66979. */
  66980. export class PrecisionDate {
  66981. /**
  66982. * Gets either window.performance.now() if supported or Date.now() else
  66983. */
  66984. static readonly Now: number;
  66985. }
  66986. }
  66987. declare module BABYLON {
  66988. /** @hidden */
  66989. export class _DevTools {
  66990. static WarnImport(name: string): string;
  66991. }
  66992. }
  66993. declare module BABYLON {
  66994. /**
  66995. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  66996. */
  66997. export class WebRequest {
  66998. private _xhr;
  66999. /**
  67000. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  67001. * i.e. when loading files, where the server/service expects an Authorization header
  67002. */
  67003. static CustomRequestHeaders: {
  67004. [key: string]: string;
  67005. };
  67006. /**
  67007. * Add callback functions in this array to update all the requests before they get sent to the network
  67008. */
  67009. static CustomRequestModifiers: ((request: XMLHttpRequest) => void)[];
  67010. private _injectCustomRequestHeaders;
  67011. /**
  67012. * Gets or sets a function to be called when loading progress changes
  67013. */
  67014. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  67015. /**
  67016. * Returns client's state
  67017. */
  67018. readonly readyState: number;
  67019. /**
  67020. * Returns client's status
  67021. */
  67022. readonly status: number;
  67023. /**
  67024. * Returns client's status as a text
  67025. */
  67026. readonly statusText: string;
  67027. /**
  67028. * Returns client's response
  67029. */
  67030. readonly response: any;
  67031. /**
  67032. * Returns client's response url
  67033. */
  67034. readonly responseURL: string;
  67035. /**
  67036. * Returns client's response as text
  67037. */
  67038. readonly responseText: string;
  67039. /**
  67040. * Gets or sets the expected response type
  67041. */
  67042. responseType: XMLHttpRequestResponseType;
  67043. /** @hidden */
  67044. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  67045. /** @hidden */
  67046. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  67047. /**
  67048. * Cancels any network activity
  67049. */
  67050. abort(): void;
  67051. /**
  67052. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  67053. * @param body defines an optional request body
  67054. */
  67055. send(body?: Document | BodyInit | null): void;
  67056. /**
  67057. * Sets the request method, request URL
  67058. * @param method defines the method to use (GET, POST, etc..)
  67059. * @param url defines the url to connect with
  67060. */
  67061. open(method: string, url: string): void;
  67062. }
  67063. }
  67064. declare module BABYLON {
  67065. /**
  67066. * Class used to evalaute queries containing `and` and `or` operators
  67067. */
  67068. export class AndOrNotEvaluator {
  67069. /**
  67070. * Evaluate a query
  67071. * @param query defines the query to evaluate
  67072. * @param evaluateCallback defines the callback used to filter result
  67073. * @returns true if the query matches
  67074. */
  67075. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  67076. private static _HandleParenthesisContent;
  67077. private static _SimplifyNegation;
  67078. }
  67079. }
  67080. declare module BABYLON {
  67081. /**
  67082. * Class used to store custom tags
  67083. */
  67084. export class Tags {
  67085. /**
  67086. * Adds support for tags on the given object
  67087. * @param obj defines the object to use
  67088. */
  67089. static EnableFor(obj: any): void;
  67090. /**
  67091. * Removes tags support
  67092. * @param obj defines the object to use
  67093. */
  67094. static DisableFor(obj: any): void;
  67095. /**
  67096. * Gets a boolean indicating if the given object has tags
  67097. * @param obj defines the object to use
  67098. * @returns a boolean
  67099. */
  67100. static HasTags(obj: any): boolean;
  67101. /**
  67102. * Gets the tags available on a given object
  67103. * @param obj defines the object to use
  67104. * @param asString defines if the tags must be returned as a string instead of an array of strings
  67105. * @returns the tags
  67106. */
  67107. static GetTags(obj: any, asString?: boolean): any;
  67108. /**
  67109. * Adds tags to an object
  67110. * @param obj defines the object to use
  67111. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  67112. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  67113. */
  67114. static AddTagsTo(obj: any, tagsString: string): void;
  67115. /**
  67116. * @hidden
  67117. */
  67118. static _AddTagTo(obj: any, tag: string): void;
  67119. /**
  67120. * Removes specific tags from a specific object
  67121. * @param obj defines the object to use
  67122. * @param tagsString defines the tags to remove
  67123. */
  67124. static RemoveTagsFrom(obj: any, tagsString: string): void;
  67125. /**
  67126. * @hidden
  67127. */
  67128. static _RemoveTagFrom(obj: any, tag: string): void;
  67129. /**
  67130. * Defines if tags hosted on an object match a given query
  67131. * @param obj defines the object to use
  67132. * @param tagsQuery defines the tag query
  67133. * @returns a boolean
  67134. */
  67135. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  67136. }
  67137. }
  67138. declare module BABYLON {
  67139. /**
  67140. * Manages the defines for the Material
  67141. */
  67142. export class MaterialDefines {
  67143. /** @hidden */
  67144. protected _keys: string[];
  67145. private _isDirty;
  67146. /** @hidden */
  67147. _renderId: number;
  67148. /** @hidden */
  67149. _areLightsDirty: boolean;
  67150. /** @hidden */
  67151. _areAttributesDirty: boolean;
  67152. /** @hidden */
  67153. _areTexturesDirty: boolean;
  67154. /** @hidden */
  67155. _areFresnelDirty: boolean;
  67156. /** @hidden */
  67157. _areMiscDirty: boolean;
  67158. /** @hidden */
  67159. _areImageProcessingDirty: boolean;
  67160. /** @hidden */
  67161. _normals: boolean;
  67162. /** @hidden */
  67163. _uvs: boolean;
  67164. /** @hidden */
  67165. _needNormals: boolean;
  67166. /** @hidden */
  67167. _needUVs: boolean;
  67168. [id: string]: any;
  67169. /**
  67170. * Specifies if the material needs to be re-calculated
  67171. */
  67172. readonly isDirty: boolean;
  67173. /**
  67174. * Marks the material to indicate that it has been re-calculated
  67175. */
  67176. markAsProcessed(): void;
  67177. /**
  67178. * Marks the material to indicate that it needs to be re-calculated
  67179. */
  67180. markAsUnprocessed(): void;
  67181. /**
  67182. * Marks the material to indicate all of its defines need to be re-calculated
  67183. */
  67184. markAllAsDirty(): void;
  67185. /**
  67186. * Marks the material to indicate that image processing needs to be re-calculated
  67187. */
  67188. markAsImageProcessingDirty(): void;
  67189. /**
  67190. * Marks the material to indicate the lights need to be re-calculated
  67191. */
  67192. markAsLightDirty(): void;
  67193. /**
  67194. * Marks the attribute state as changed
  67195. */
  67196. markAsAttributesDirty(): void;
  67197. /**
  67198. * Marks the texture state as changed
  67199. */
  67200. markAsTexturesDirty(): void;
  67201. /**
  67202. * Marks the fresnel state as changed
  67203. */
  67204. markAsFresnelDirty(): void;
  67205. /**
  67206. * Marks the misc state as changed
  67207. */
  67208. markAsMiscDirty(): void;
  67209. /**
  67210. * Rebuilds the material defines
  67211. */
  67212. rebuild(): void;
  67213. /**
  67214. * Specifies if two material defines are equal
  67215. * @param other - A material define instance to compare to
  67216. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  67217. */
  67218. isEqual(other: MaterialDefines): boolean;
  67219. /**
  67220. * Clones this instance's defines to another instance
  67221. * @param other - material defines to clone values to
  67222. */
  67223. cloneTo(other: MaterialDefines): void;
  67224. /**
  67225. * Resets the material define values
  67226. */
  67227. reset(): void;
  67228. /**
  67229. * Converts the material define values to a string
  67230. * @returns - String of material define information
  67231. */
  67232. toString(): string;
  67233. }
  67234. }
  67235. declare module BABYLON {
  67236. /**
  67237. * Class used to store and describe the pipeline context associated with an effect
  67238. */
  67239. export interface IPipelineContext {
  67240. /**
  67241. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  67242. */
  67243. isAsync: boolean;
  67244. /**
  67245. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  67246. */
  67247. isReady: boolean;
  67248. /** @hidden */
  67249. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  67250. }
  67251. }
  67252. declare module BABYLON {
  67253. /**
  67254. * Class used to store gfx data (like WebGLBuffer)
  67255. */
  67256. export class DataBuffer {
  67257. /**
  67258. * Gets or sets the number of objects referencing this buffer
  67259. */
  67260. references: number;
  67261. /** Gets or sets the size of the underlying buffer */
  67262. capacity: number;
  67263. /**
  67264. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  67265. */
  67266. is32Bits: boolean;
  67267. /**
  67268. * Gets the underlying buffer
  67269. */
  67270. readonly underlyingResource: any;
  67271. }
  67272. }
  67273. declare module BABYLON {
  67274. /**
  67275. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  67276. */
  67277. export class PerformanceMonitor {
  67278. private _enabled;
  67279. private _rollingFrameTime;
  67280. private _lastFrameTimeMs;
  67281. /**
  67282. * constructor
  67283. * @param frameSampleSize The number of samples required to saturate the sliding window
  67284. */
  67285. constructor(frameSampleSize?: number);
  67286. /**
  67287. * Samples current frame
  67288. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  67289. */
  67290. sampleFrame(timeMs?: number): void;
  67291. /**
  67292. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  67293. */
  67294. readonly averageFrameTime: number;
  67295. /**
  67296. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  67297. */
  67298. readonly averageFrameTimeVariance: number;
  67299. /**
  67300. * Returns the frame time of the most recent frame
  67301. */
  67302. readonly instantaneousFrameTime: number;
  67303. /**
  67304. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  67305. */
  67306. readonly averageFPS: number;
  67307. /**
  67308. * Returns the average framerate in frames per second using the most recent frame time
  67309. */
  67310. readonly instantaneousFPS: number;
  67311. /**
  67312. * Returns true if enough samples have been taken to completely fill the sliding window
  67313. */
  67314. readonly isSaturated: boolean;
  67315. /**
  67316. * Enables contributions to the sliding window sample set
  67317. */
  67318. enable(): void;
  67319. /**
  67320. * Disables contributions to the sliding window sample set
  67321. * Samples will not be interpolated over the disabled period
  67322. */
  67323. disable(): void;
  67324. /**
  67325. * Returns true if sampling is enabled
  67326. */
  67327. readonly isEnabled: boolean;
  67328. /**
  67329. * Resets performance monitor
  67330. */
  67331. reset(): void;
  67332. }
  67333. /**
  67334. * RollingAverage
  67335. *
  67336. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  67337. */
  67338. export class RollingAverage {
  67339. /**
  67340. * Current average
  67341. */
  67342. average: number;
  67343. /**
  67344. * Current variance
  67345. */
  67346. variance: number;
  67347. protected _samples: Array<number>;
  67348. protected _sampleCount: number;
  67349. protected _pos: number;
  67350. protected _m2: number;
  67351. /**
  67352. * constructor
  67353. * @param length The number of samples required to saturate the sliding window
  67354. */
  67355. constructor(length: number);
  67356. /**
  67357. * Adds a sample to the sample set
  67358. * @param v The sample value
  67359. */
  67360. add(v: number): void;
  67361. /**
  67362. * Returns previously added values or null if outside of history or outside the sliding window domain
  67363. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  67364. * @return Value previously recorded with add() or null if outside of range
  67365. */
  67366. history(i: number): number;
  67367. /**
  67368. * Returns true if enough samples have been taken to completely fill the sliding window
  67369. * @return true if sample-set saturated
  67370. */
  67371. isSaturated(): boolean;
  67372. /**
  67373. * Resets the rolling average (equivalent to 0 samples taken so far)
  67374. */
  67375. reset(): void;
  67376. /**
  67377. * Wraps a value around the sample range boundaries
  67378. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  67379. * @return Wrapped position in sample range
  67380. */
  67381. protected _wrapPosition(i: number): number;
  67382. }
  67383. }
  67384. declare module BABYLON {
  67385. /**
  67386. * This class implement a typical dictionary using a string as key and the generic type T as value.
  67387. * The underlying implementation relies on an associative array to ensure the best performances.
  67388. * The value can be anything including 'null' but except 'undefined'
  67389. */
  67390. export class StringDictionary<T> {
  67391. /**
  67392. * This will clear this dictionary and copy the content from the 'source' one.
  67393. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  67394. * @param source the dictionary to take the content from and copy to this dictionary
  67395. */
  67396. copyFrom(source: StringDictionary<T>): void;
  67397. /**
  67398. * Get a value based from its key
  67399. * @param key the given key to get the matching value from
  67400. * @return the value if found, otherwise undefined is returned
  67401. */
  67402. get(key: string): T | undefined;
  67403. /**
  67404. * Get a value from its key or add it if it doesn't exist.
  67405. * This method will ensure you that a given key/data will be present in the dictionary.
  67406. * @param key the given key to get the matching value from
  67407. * @param factory the factory that will create the value if the key is not present in the dictionary.
  67408. * The factory will only be invoked if there's no data for the given key.
  67409. * @return the value corresponding to the key.
  67410. */
  67411. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  67412. /**
  67413. * Get a value from its key if present in the dictionary otherwise add it
  67414. * @param key the key to get the value from
  67415. * @param val if there's no such key/value pair in the dictionary add it with this value
  67416. * @return the value corresponding to the key
  67417. */
  67418. getOrAdd(key: string, val: T): T;
  67419. /**
  67420. * Check if there's a given key in the dictionary
  67421. * @param key the key to check for
  67422. * @return true if the key is present, false otherwise
  67423. */
  67424. contains(key: string): boolean;
  67425. /**
  67426. * Add a new key and its corresponding value
  67427. * @param key the key to add
  67428. * @param value the value corresponding to the key
  67429. * @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
  67430. */
  67431. add(key: string, value: T): boolean;
  67432. /**
  67433. * Update a specific value associated to a key
  67434. * @param key defines the key to use
  67435. * @param value defines the value to store
  67436. * @returns true if the value was updated (or false if the key was not found)
  67437. */
  67438. set(key: string, value: T): boolean;
  67439. /**
  67440. * Get the element of the given key and remove it from the dictionary
  67441. * @param key defines the key to search
  67442. * @returns the value associated with the key or null if not found
  67443. */
  67444. getAndRemove(key: string): Nullable<T>;
  67445. /**
  67446. * Remove a key/value from the dictionary.
  67447. * @param key the key to remove
  67448. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  67449. */
  67450. remove(key: string): boolean;
  67451. /**
  67452. * Clear the whole content of the dictionary
  67453. */
  67454. clear(): void;
  67455. /**
  67456. * Gets the current count
  67457. */
  67458. readonly count: number;
  67459. /**
  67460. * Execute a callback on each key/val of the dictionary.
  67461. * Note that you can remove any element in this dictionary in the callback implementation
  67462. * @param callback the callback to execute on a given key/value pair
  67463. */
  67464. forEach(callback: (key: string, val: T) => void): void;
  67465. /**
  67466. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  67467. * If the callback returns null or undefined the method will iterate to the next key/value pair
  67468. * Note that you can remove any element in this dictionary in the callback implementation
  67469. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  67470. * @returns the first item
  67471. */
  67472. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  67473. private _count;
  67474. private _data;
  67475. }
  67476. }
  67477. declare module BABYLON {
  67478. /**
  67479. * Helper class that provides a small promise polyfill
  67480. */
  67481. export class PromisePolyfill {
  67482. /**
  67483. * Static function used to check if the polyfill is required
  67484. * If this is the case then the function will inject the polyfill to window.Promise
  67485. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  67486. */
  67487. static Apply(force?: boolean): void;
  67488. }
  67489. }
  67490. declare module BABYLON {
  67491. /**
  67492. * Class used to store data that will be store in GPU memory
  67493. */
  67494. export class Buffer {
  67495. private _engine;
  67496. private _buffer;
  67497. /** @hidden */
  67498. _data: Nullable<DataArray>;
  67499. private _updatable;
  67500. private _instanced;
  67501. /**
  67502. * Gets the byte stride.
  67503. */
  67504. readonly byteStride: number;
  67505. /**
  67506. * Constructor
  67507. * @param engine the engine
  67508. * @param data the data to use for this buffer
  67509. * @param updatable whether the data is updatable
  67510. * @param stride the stride (optional)
  67511. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  67512. * @param instanced whether the buffer is instanced (optional)
  67513. * @param useBytes set to true if the stride in in bytes (optional)
  67514. */
  67515. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  67516. /**
  67517. * Create a new VertexBuffer based on the current buffer
  67518. * @param kind defines the vertex buffer kind (position, normal, etc.)
  67519. * @param offset defines offset in the buffer (0 by default)
  67520. * @param size defines the size in floats of attributes (position is 3 for instance)
  67521. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  67522. * @param instanced defines if the vertex buffer contains indexed data
  67523. * @param useBytes defines if the offset and stride are in bytes
  67524. * @returns the new vertex buffer
  67525. */
  67526. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  67527. /**
  67528. * Gets a boolean indicating if the Buffer is updatable?
  67529. * @returns true if the buffer is updatable
  67530. */
  67531. isUpdatable(): boolean;
  67532. /**
  67533. * Gets current buffer's data
  67534. * @returns a DataArray or null
  67535. */
  67536. getData(): Nullable<DataArray>;
  67537. /**
  67538. * Gets underlying native buffer
  67539. * @returns underlying native buffer
  67540. */
  67541. getBuffer(): Nullable<DataBuffer>;
  67542. /**
  67543. * Gets the stride in float32 units (i.e. byte stride / 4).
  67544. * May not be an integer if the byte stride is not divisible by 4.
  67545. * DEPRECATED. Use byteStride instead.
  67546. * @returns the stride in float32 units
  67547. */
  67548. getStrideSize(): number;
  67549. /**
  67550. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  67551. * @param data defines the data to store
  67552. */
  67553. create(data?: Nullable<DataArray>): void;
  67554. /** @hidden */
  67555. _rebuild(): void;
  67556. /**
  67557. * Update current buffer data
  67558. * @param data defines the data to store
  67559. */
  67560. update(data: DataArray): void;
  67561. /**
  67562. * Updates the data directly.
  67563. * @param data the new data
  67564. * @param offset the new offset
  67565. * @param vertexCount the vertex count (optional)
  67566. * @param useBytes set to true if the offset is in bytes
  67567. */
  67568. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  67569. /**
  67570. * Release all resources
  67571. */
  67572. dispose(): void;
  67573. }
  67574. /**
  67575. * Specialized buffer used to store vertex data
  67576. */
  67577. export class VertexBuffer {
  67578. /** @hidden */
  67579. _buffer: Buffer;
  67580. private _kind;
  67581. private _size;
  67582. private _ownsBuffer;
  67583. private _instanced;
  67584. private _instanceDivisor;
  67585. /**
  67586. * The byte type.
  67587. */
  67588. static readonly BYTE: number;
  67589. /**
  67590. * The unsigned byte type.
  67591. */
  67592. static readonly UNSIGNED_BYTE: number;
  67593. /**
  67594. * The short type.
  67595. */
  67596. static readonly SHORT: number;
  67597. /**
  67598. * The unsigned short type.
  67599. */
  67600. static readonly UNSIGNED_SHORT: number;
  67601. /**
  67602. * The integer type.
  67603. */
  67604. static readonly INT: number;
  67605. /**
  67606. * The unsigned integer type.
  67607. */
  67608. static readonly UNSIGNED_INT: number;
  67609. /**
  67610. * The float type.
  67611. */
  67612. static readonly FLOAT: number;
  67613. /**
  67614. * Gets or sets the instance divisor when in instanced mode
  67615. */
  67616. instanceDivisor: number;
  67617. /**
  67618. * Gets the byte stride.
  67619. */
  67620. readonly byteStride: number;
  67621. /**
  67622. * Gets the byte offset.
  67623. */
  67624. readonly byteOffset: number;
  67625. /**
  67626. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  67627. */
  67628. readonly normalized: boolean;
  67629. /**
  67630. * Gets the data type of each component in the array.
  67631. */
  67632. readonly type: number;
  67633. /**
  67634. * Constructor
  67635. * @param engine the engine
  67636. * @param data the data to use for this vertex buffer
  67637. * @param kind the vertex buffer kind
  67638. * @param updatable whether the data is updatable
  67639. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  67640. * @param stride the stride (optional)
  67641. * @param instanced whether the buffer is instanced (optional)
  67642. * @param offset the offset of the data (optional)
  67643. * @param size the number of components (optional)
  67644. * @param type the type of the component (optional)
  67645. * @param normalized whether the data contains normalized data (optional)
  67646. * @param useBytes set to true if stride and offset are in bytes (optional)
  67647. */
  67648. 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);
  67649. /** @hidden */
  67650. _rebuild(): void;
  67651. /**
  67652. * Returns the kind of the VertexBuffer (string)
  67653. * @returns a string
  67654. */
  67655. getKind(): string;
  67656. /**
  67657. * Gets a boolean indicating if the VertexBuffer is updatable?
  67658. * @returns true if the buffer is updatable
  67659. */
  67660. isUpdatable(): boolean;
  67661. /**
  67662. * Gets current buffer's data
  67663. * @returns a DataArray or null
  67664. */
  67665. getData(): Nullable<DataArray>;
  67666. /**
  67667. * Gets underlying native buffer
  67668. * @returns underlying native buffer
  67669. */
  67670. getBuffer(): Nullable<DataBuffer>;
  67671. /**
  67672. * Gets the stride in float32 units (i.e. byte stride / 4).
  67673. * May not be an integer if the byte stride is not divisible by 4.
  67674. * DEPRECATED. Use byteStride instead.
  67675. * @returns the stride in float32 units
  67676. */
  67677. getStrideSize(): number;
  67678. /**
  67679. * Returns the offset as a multiple of the type byte length.
  67680. * DEPRECATED. Use byteOffset instead.
  67681. * @returns the offset in bytes
  67682. */
  67683. getOffset(): number;
  67684. /**
  67685. * Returns the number of components per vertex attribute (integer)
  67686. * @returns the size in float
  67687. */
  67688. getSize(): number;
  67689. /**
  67690. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  67691. * @returns true if this buffer is instanced
  67692. */
  67693. getIsInstanced(): boolean;
  67694. /**
  67695. * Returns the instancing divisor, zero for non-instanced (integer).
  67696. * @returns a number
  67697. */
  67698. getInstanceDivisor(): number;
  67699. /**
  67700. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  67701. * @param data defines the data to store
  67702. */
  67703. create(data?: DataArray): void;
  67704. /**
  67705. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  67706. * This function will create a new buffer if the current one is not updatable
  67707. * @param data defines the data to store
  67708. */
  67709. update(data: DataArray): void;
  67710. /**
  67711. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  67712. * Returns the directly updated WebGLBuffer.
  67713. * @param data the new data
  67714. * @param offset the new offset
  67715. * @param useBytes set to true if the offset is in bytes
  67716. */
  67717. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  67718. /**
  67719. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  67720. */
  67721. dispose(): void;
  67722. /**
  67723. * Enumerates each value of this vertex buffer as numbers.
  67724. * @param count the number of values to enumerate
  67725. * @param callback the callback function called for each value
  67726. */
  67727. forEach(count: number, callback: (value: number, index: number) => void): void;
  67728. /**
  67729. * Positions
  67730. */
  67731. static readonly PositionKind: string;
  67732. /**
  67733. * Normals
  67734. */
  67735. static readonly NormalKind: string;
  67736. /**
  67737. * Tangents
  67738. */
  67739. static readonly TangentKind: string;
  67740. /**
  67741. * Texture coordinates
  67742. */
  67743. static readonly UVKind: string;
  67744. /**
  67745. * Texture coordinates 2
  67746. */
  67747. static readonly UV2Kind: string;
  67748. /**
  67749. * Texture coordinates 3
  67750. */
  67751. static readonly UV3Kind: string;
  67752. /**
  67753. * Texture coordinates 4
  67754. */
  67755. static readonly UV4Kind: string;
  67756. /**
  67757. * Texture coordinates 5
  67758. */
  67759. static readonly UV5Kind: string;
  67760. /**
  67761. * Texture coordinates 6
  67762. */
  67763. static readonly UV6Kind: string;
  67764. /**
  67765. * Colors
  67766. */
  67767. static readonly ColorKind: string;
  67768. /**
  67769. * Matrix indices (for bones)
  67770. */
  67771. static readonly MatricesIndicesKind: string;
  67772. /**
  67773. * Matrix weights (for bones)
  67774. */
  67775. static readonly MatricesWeightsKind: string;
  67776. /**
  67777. * Additional matrix indices (for bones)
  67778. */
  67779. static readonly MatricesIndicesExtraKind: string;
  67780. /**
  67781. * Additional matrix weights (for bones)
  67782. */
  67783. static readonly MatricesWeightsExtraKind: string;
  67784. /**
  67785. * Deduces the stride given a kind.
  67786. * @param kind The kind string to deduce
  67787. * @returns The deduced stride
  67788. */
  67789. static DeduceStride(kind: string): number;
  67790. /**
  67791. * Gets the byte length of the given type.
  67792. * @param type the type
  67793. * @returns the number of bytes
  67794. */
  67795. static GetTypeByteLength(type: number): number;
  67796. /**
  67797. * Enumerates each value of the given parameters as numbers.
  67798. * @param data the data to enumerate
  67799. * @param byteOffset the byte offset of the data
  67800. * @param byteStride the byte stride of the data
  67801. * @param componentCount the number of components per element
  67802. * @param componentType the type of the component
  67803. * @param count the total number of components
  67804. * @param normalized whether the data is normalized
  67805. * @param callback the callback function called for each value
  67806. */
  67807. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  67808. private static _GetFloatValue;
  67809. }
  67810. }
  67811. declare module BABYLON {
  67812. /**
  67813. * Class representing spherical harmonics coefficients to the 3rd degree
  67814. */
  67815. export class SphericalHarmonics {
  67816. /**
  67817. * Defines whether or not the harmonics have been prescaled for rendering.
  67818. */
  67819. preScaled: boolean;
  67820. /**
  67821. * The l0,0 coefficients of the spherical harmonics
  67822. */
  67823. l00: Vector3;
  67824. /**
  67825. * The l1,-1 coefficients of the spherical harmonics
  67826. */
  67827. l1_1: Vector3;
  67828. /**
  67829. * The l1,0 coefficients of the spherical harmonics
  67830. */
  67831. l10: Vector3;
  67832. /**
  67833. * The l1,1 coefficients of the spherical harmonics
  67834. */
  67835. l11: Vector3;
  67836. /**
  67837. * The l2,-2 coefficients of the spherical harmonics
  67838. */
  67839. l2_2: Vector3;
  67840. /**
  67841. * The l2,-1 coefficients of the spherical harmonics
  67842. */
  67843. l2_1: Vector3;
  67844. /**
  67845. * The l2,0 coefficients of the spherical harmonics
  67846. */
  67847. l20: Vector3;
  67848. /**
  67849. * The l2,1 coefficients of the spherical harmonics
  67850. */
  67851. l21: Vector3;
  67852. /**
  67853. * The l2,2 coefficients of the spherical harmonics
  67854. */
  67855. l22: Vector3;
  67856. /**
  67857. * Adds a light to the spherical harmonics
  67858. * @param direction the direction of the light
  67859. * @param color the color of the light
  67860. * @param deltaSolidAngle the delta solid angle of the light
  67861. */
  67862. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  67863. /**
  67864. * Scales the spherical harmonics by the given amount
  67865. * @param scale the amount to scale
  67866. */
  67867. scaleInPlace(scale: number): void;
  67868. /**
  67869. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  67870. *
  67871. * ```
  67872. * E_lm = A_l * L_lm
  67873. * ```
  67874. *
  67875. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  67876. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  67877. * the scaling factors are given in equation 9.
  67878. */
  67879. convertIncidentRadianceToIrradiance(): void;
  67880. /**
  67881. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  67882. *
  67883. * ```
  67884. * L = (1/pi) * E * rho
  67885. * ```
  67886. *
  67887. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  67888. */
  67889. convertIrradianceToLambertianRadiance(): void;
  67890. /**
  67891. * Integrates the reconstruction coefficients directly in to the SH preventing further
  67892. * required operations at run time.
  67893. *
  67894. * This is simply done by scaling back the SH with Ylm constants parameter.
  67895. * The trigonometric part being applied by the shader at run time.
  67896. */
  67897. preScaleForRendering(): void;
  67898. /**
  67899. * Constructs a spherical harmonics from an array.
  67900. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  67901. * @returns the spherical harmonics
  67902. */
  67903. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  67904. /**
  67905. * Gets the spherical harmonics from polynomial
  67906. * @param polynomial the spherical polynomial
  67907. * @returns the spherical harmonics
  67908. */
  67909. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  67910. }
  67911. /**
  67912. * Class representing spherical polynomial coefficients to the 3rd degree
  67913. */
  67914. export class SphericalPolynomial {
  67915. private _harmonics;
  67916. /**
  67917. * The spherical harmonics used to create the polynomials.
  67918. */
  67919. readonly preScaledHarmonics: SphericalHarmonics;
  67920. /**
  67921. * The x coefficients of the spherical polynomial
  67922. */
  67923. x: Vector3;
  67924. /**
  67925. * The y coefficients of the spherical polynomial
  67926. */
  67927. y: Vector3;
  67928. /**
  67929. * The z coefficients of the spherical polynomial
  67930. */
  67931. z: Vector3;
  67932. /**
  67933. * The xx coefficients of the spherical polynomial
  67934. */
  67935. xx: Vector3;
  67936. /**
  67937. * The yy coefficients of the spherical polynomial
  67938. */
  67939. yy: Vector3;
  67940. /**
  67941. * The zz coefficients of the spherical polynomial
  67942. */
  67943. zz: Vector3;
  67944. /**
  67945. * The xy coefficients of the spherical polynomial
  67946. */
  67947. xy: Vector3;
  67948. /**
  67949. * The yz coefficients of the spherical polynomial
  67950. */
  67951. yz: Vector3;
  67952. /**
  67953. * The zx coefficients of the spherical polynomial
  67954. */
  67955. zx: Vector3;
  67956. /**
  67957. * Adds an ambient color to the spherical polynomial
  67958. * @param color the color to add
  67959. */
  67960. addAmbient(color: Color3): void;
  67961. /**
  67962. * Scales the spherical polynomial by the given amount
  67963. * @param scale the amount to scale
  67964. */
  67965. scaleInPlace(scale: number): void;
  67966. /**
  67967. * Gets the spherical polynomial from harmonics
  67968. * @param harmonics the spherical harmonics
  67969. * @returns the spherical polynomial
  67970. */
  67971. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  67972. /**
  67973. * Constructs a spherical polynomial from an array.
  67974. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  67975. * @returns the spherical polynomial
  67976. */
  67977. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  67978. }
  67979. }
  67980. declare module BABYLON {
  67981. /**
  67982. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  67983. */
  67984. export interface CubeMapInfo {
  67985. /**
  67986. * The pixel array for the front face.
  67987. * This is stored in format, left to right, up to down format.
  67988. */
  67989. front: Nullable<ArrayBufferView>;
  67990. /**
  67991. * The pixel array for the back face.
  67992. * This is stored in format, left to right, up to down format.
  67993. */
  67994. back: Nullable<ArrayBufferView>;
  67995. /**
  67996. * The pixel array for the left face.
  67997. * This is stored in format, left to right, up to down format.
  67998. */
  67999. left: Nullable<ArrayBufferView>;
  68000. /**
  68001. * The pixel array for the right face.
  68002. * This is stored in format, left to right, up to down format.
  68003. */
  68004. right: Nullable<ArrayBufferView>;
  68005. /**
  68006. * The pixel array for the up face.
  68007. * This is stored in format, left to right, up to down format.
  68008. */
  68009. up: Nullable<ArrayBufferView>;
  68010. /**
  68011. * The pixel array for the down face.
  68012. * This is stored in format, left to right, up to down format.
  68013. */
  68014. down: Nullable<ArrayBufferView>;
  68015. /**
  68016. * The size of the cubemap stored.
  68017. *
  68018. * Each faces will be size * size pixels.
  68019. */
  68020. size: number;
  68021. /**
  68022. * The format of the texture.
  68023. *
  68024. * RGBA, RGB.
  68025. */
  68026. format: number;
  68027. /**
  68028. * The type of the texture data.
  68029. *
  68030. * UNSIGNED_INT, FLOAT.
  68031. */
  68032. type: number;
  68033. /**
  68034. * Specifies whether the texture is in gamma space.
  68035. */
  68036. gammaSpace: boolean;
  68037. }
  68038. /**
  68039. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  68040. */
  68041. export class PanoramaToCubeMapTools {
  68042. private static FACE_FRONT;
  68043. private static FACE_BACK;
  68044. private static FACE_RIGHT;
  68045. private static FACE_LEFT;
  68046. private static FACE_DOWN;
  68047. private static FACE_UP;
  68048. /**
  68049. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  68050. *
  68051. * @param float32Array The source data.
  68052. * @param inputWidth The width of the input panorama.
  68053. * @param inputHeight The height of the input panorama.
  68054. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  68055. * @return The cubemap data
  68056. */
  68057. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  68058. private static CreateCubemapTexture;
  68059. private static CalcProjectionSpherical;
  68060. }
  68061. }
  68062. declare module BABYLON {
  68063. /**
  68064. * Helper class dealing with the extraction of spherical polynomial dataArray
  68065. * from a cube map.
  68066. */
  68067. export class CubeMapToSphericalPolynomialTools {
  68068. private static FileFaces;
  68069. /**
  68070. * Converts a texture to the according Spherical Polynomial data.
  68071. * This extracts the first 3 orders only as they are the only one used in the lighting.
  68072. *
  68073. * @param texture The texture to extract the information from.
  68074. * @return The Spherical Polynomial data.
  68075. */
  68076. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  68077. /**
  68078. * Converts a cubemap to the according Spherical Polynomial data.
  68079. * This extracts the first 3 orders only as they are the only one used in the lighting.
  68080. *
  68081. * @param cubeInfo The Cube map to extract the information from.
  68082. * @return The Spherical Polynomial data.
  68083. */
  68084. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  68085. }
  68086. }
  68087. declare module BABYLON {
  68088. /**
  68089. * The engine store class is responsible to hold all the instances of Engine and Scene created
  68090. * during the life time of the application.
  68091. */
  68092. export class EngineStore {
  68093. /** Gets the list of created engines */
  68094. static Instances: Engine[];
  68095. /** @hidden */
  68096. static _LastCreatedScene: Nullable<Scene>;
  68097. /**
  68098. * Gets the latest created engine
  68099. */
  68100. static readonly LastCreatedEngine: Nullable<Engine>;
  68101. /**
  68102. * Gets the latest created scene
  68103. */
  68104. static readonly LastCreatedScene: Nullable<Scene>;
  68105. }
  68106. }
  68107. declare module BABYLON {
  68108. /**
  68109. * Define options used to create a render target texture
  68110. */
  68111. export class RenderTargetCreationOptions {
  68112. /**
  68113. * Specifies is mipmaps must be generated
  68114. */
  68115. generateMipMaps?: boolean;
  68116. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  68117. generateDepthBuffer?: boolean;
  68118. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  68119. generateStencilBuffer?: boolean;
  68120. /** Defines texture type (int by default) */
  68121. type?: number;
  68122. /** Defines sampling mode (trilinear by default) */
  68123. samplingMode?: number;
  68124. /** Defines format (RGBA by default) */
  68125. format?: number;
  68126. }
  68127. }
  68128. declare module BABYLON {
  68129. /**
  68130. * @hidden
  68131. **/
  68132. export class _AlphaState {
  68133. private _isAlphaBlendDirty;
  68134. private _isBlendFunctionParametersDirty;
  68135. private _isBlendEquationParametersDirty;
  68136. private _isBlendConstantsDirty;
  68137. private _alphaBlend;
  68138. private _blendFunctionParameters;
  68139. private _blendEquationParameters;
  68140. private _blendConstants;
  68141. /**
  68142. * Initializes the state.
  68143. */
  68144. constructor();
  68145. readonly isDirty: boolean;
  68146. alphaBlend: boolean;
  68147. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  68148. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  68149. setAlphaEquationParameters(rgb: number, alpha: number): void;
  68150. reset(): void;
  68151. apply(gl: WebGLRenderingContext): void;
  68152. }
  68153. }
  68154. declare module BABYLON {
  68155. /**
  68156. * @hidden
  68157. **/
  68158. export class _DepthCullingState {
  68159. private _isDepthTestDirty;
  68160. private _isDepthMaskDirty;
  68161. private _isDepthFuncDirty;
  68162. private _isCullFaceDirty;
  68163. private _isCullDirty;
  68164. private _isZOffsetDirty;
  68165. private _isFrontFaceDirty;
  68166. private _depthTest;
  68167. private _depthMask;
  68168. private _depthFunc;
  68169. private _cull;
  68170. private _cullFace;
  68171. private _zOffset;
  68172. private _frontFace;
  68173. /**
  68174. * Initializes the state.
  68175. */
  68176. constructor();
  68177. readonly isDirty: boolean;
  68178. zOffset: number;
  68179. cullFace: Nullable<number>;
  68180. cull: Nullable<boolean>;
  68181. depthFunc: Nullable<number>;
  68182. depthMask: boolean;
  68183. depthTest: boolean;
  68184. frontFace: Nullable<number>;
  68185. reset(): void;
  68186. apply(gl: WebGLRenderingContext): void;
  68187. }
  68188. }
  68189. declare module BABYLON {
  68190. /**
  68191. * @hidden
  68192. **/
  68193. export class _StencilState {
  68194. /** 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 */
  68195. static readonly ALWAYS: number;
  68196. /** Passed to stencilOperation to specify that stencil value must be kept */
  68197. static readonly KEEP: number;
  68198. /** Passed to stencilOperation to specify that stencil value must be replaced */
  68199. static readonly REPLACE: number;
  68200. private _isStencilTestDirty;
  68201. private _isStencilMaskDirty;
  68202. private _isStencilFuncDirty;
  68203. private _isStencilOpDirty;
  68204. private _stencilTest;
  68205. private _stencilMask;
  68206. private _stencilFunc;
  68207. private _stencilFuncRef;
  68208. private _stencilFuncMask;
  68209. private _stencilOpStencilFail;
  68210. private _stencilOpDepthFail;
  68211. private _stencilOpStencilDepthPass;
  68212. readonly isDirty: boolean;
  68213. stencilFunc: number;
  68214. stencilFuncRef: number;
  68215. stencilFuncMask: number;
  68216. stencilOpStencilFail: number;
  68217. stencilOpDepthFail: number;
  68218. stencilOpStencilDepthPass: number;
  68219. stencilMask: number;
  68220. stencilTest: boolean;
  68221. constructor();
  68222. reset(): void;
  68223. apply(gl: WebGLRenderingContext): void;
  68224. }
  68225. }
  68226. declare module BABYLON {
  68227. /**
  68228. * @hidden
  68229. **/
  68230. export class _TimeToken {
  68231. _startTimeQuery: Nullable<WebGLQuery>;
  68232. _endTimeQuery: Nullable<WebGLQuery>;
  68233. _timeElapsedQuery: Nullable<WebGLQuery>;
  68234. _timeElapsedQueryEnded: boolean;
  68235. }
  68236. }
  68237. declare module BABYLON {
  68238. /**
  68239. * Class used to store data associated with WebGL texture data for the engine
  68240. * This class should not be used directly
  68241. */
  68242. export class InternalTexture {
  68243. /** hidden */
  68244. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  68245. /**
  68246. * The source of the texture data is unknown
  68247. */
  68248. static DATASOURCE_UNKNOWN: number;
  68249. /**
  68250. * Texture data comes from an URL
  68251. */
  68252. static DATASOURCE_URL: number;
  68253. /**
  68254. * Texture data is only used for temporary storage
  68255. */
  68256. static DATASOURCE_TEMP: number;
  68257. /**
  68258. * Texture data comes from raw data (ArrayBuffer)
  68259. */
  68260. static DATASOURCE_RAW: number;
  68261. /**
  68262. * Texture content is dynamic (video or dynamic texture)
  68263. */
  68264. static DATASOURCE_DYNAMIC: number;
  68265. /**
  68266. * Texture content is generated by rendering to it
  68267. */
  68268. static DATASOURCE_RENDERTARGET: number;
  68269. /**
  68270. * Texture content is part of a multi render target process
  68271. */
  68272. static DATASOURCE_MULTIRENDERTARGET: number;
  68273. /**
  68274. * Texture data comes from a cube data file
  68275. */
  68276. static DATASOURCE_CUBE: number;
  68277. /**
  68278. * Texture data comes from a raw cube data
  68279. */
  68280. static DATASOURCE_CUBERAW: number;
  68281. /**
  68282. * Texture data come from a prefiltered cube data file
  68283. */
  68284. static DATASOURCE_CUBEPREFILTERED: number;
  68285. /**
  68286. * Texture content is raw 3D data
  68287. */
  68288. static DATASOURCE_RAW3D: number;
  68289. /**
  68290. * Texture content is a depth texture
  68291. */
  68292. static DATASOURCE_DEPTHTEXTURE: number;
  68293. /**
  68294. * Texture data comes from a raw cube data encoded with RGBD
  68295. */
  68296. static DATASOURCE_CUBERAW_RGBD: number;
  68297. /**
  68298. * Defines if the texture is ready
  68299. */
  68300. isReady: boolean;
  68301. /**
  68302. * Defines if the texture is a cube texture
  68303. */
  68304. isCube: boolean;
  68305. /**
  68306. * Defines if the texture contains 3D data
  68307. */
  68308. is3D: boolean;
  68309. /**
  68310. * Defines if the texture contains multiview data
  68311. */
  68312. isMultiview: boolean;
  68313. /**
  68314. * Gets the URL used to load this texture
  68315. */
  68316. url: string;
  68317. /**
  68318. * Gets the sampling mode of the texture
  68319. */
  68320. samplingMode: number;
  68321. /**
  68322. * Gets a boolean indicating if the texture needs mipmaps generation
  68323. */
  68324. generateMipMaps: boolean;
  68325. /**
  68326. * Gets the number of samples used by the texture (WebGL2+ only)
  68327. */
  68328. samples: number;
  68329. /**
  68330. * Gets the type of the texture (int, float...)
  68331. */
  68332. type: number;
  68333. /**
  68334. * Gets the format of the texture (RGB, RGBA...)
  68335. */
  68336. format: number;
  68337. /**
  68338. * Observable called when the texture is loaded
  68339. */
  68340. onLoadedObservable: Observable<InternalTexture>;
  68341. /**
  68342. * Gets the width of the texture
  68343. */
  68344. width: number;
  68345. /**
  68346. * Gets the height of the texture
  68347. */
  68348. height: number;
  68349. /**
  68350. * Gets the depth of the texture
  68351. */
  68352. depth: number;
  68353. /**
  68354. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  68355. */
  68356. baseWidth: number;
  68357. /**
  68358. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  68359. */
  68360. baseHeight: number;
  68361. /**
  68362. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  68363. */
  68364. baseDepth: number;
  68365. /**
  68366. * Gets a boolean indicating if the texture is inverted on Y axis
  68367. */
  68368. invertY: boolean;
  68369. /** @hidden */
  68370. _invertVScale: boolean;
  68371. /** @hidden */
  68372. _associatedChannel: number;
  68373. /** @hidden */
  68374. _dataSource: number;
  68375. /** @hidden */
  68376. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  68377. /** @hidden */
  68378. _bufferView: Nullable<ArrayBufferView>;
  68379. /** @hidden */
  68380. _bufferViewArray: Nullable<ArrayBufferView[]>;
  68381. /** @hidden */
  68382. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  68383. /** @hidden */
  68384. _size: number;
  68385. /** @hidden */
  68386. _extension: string;
  68387. /** @hidden */
  68388. _files: Nullable<string[]>;
  68389. /** @hidden */
  68390. _workingCanvas: Nullable<HTMLCanvasElement>;
  68391. /** @hidden */
  68392. _workingContext: Nullable<CanvasRenderingContext2D>;
  68393. /** @hidden */
  68394. _framebuffer: Nullable<WebGLFramebuffer>;
  68395. /** @hidden */
  68396. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  68397. /** @hidden */
  68398. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  68399. /** @hidden */
  68400. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  68401. /** @hidden */
  68402. _attachments: Nullable<number[]>;
  68403. /** @hidden */
  68404. _cachedCoordinatesMode: Nullable<number>;
  68405. /** @hidden */
  68406. _cachedWrapU: Nullable<number>;
  68407. /** @hidden */
  68408. _cachedWrapV: Nullable<number>;
  68409. /** @hidden */
  68410. _cachedWrapR: Nullable<number>;
  68411. /** @hidden */
  68412. _cachedAnisotropicFilteringLevel: Nullable<number>;
  68413. /** @hidden */
  68414. _isDisabled: boolean;
  68415. /** @hidden */
  68416. _compression: Nullable<string>;
  68417. /** @hidden */
  68418. _generateStencilBuffer: boolean;
  68419. /** @hidden */
  68420. _generateDepthBuffer: boolean;
  68421. /** @hidden */
  68422. _comparisonFunction: number;
  68423. /** @hidden */
  68424. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  68425. /** @hidden */
  68426. _lodGenerationScale: number;
  68427. /** @hidden */
  68428. _lodGenerationOffset: number;
  68429. /** @hidden */
  68430. _colorTextureArray: Nullable<WebGLTexture>;
  68431. /** @hidden */
  68432. _depthStencilTextureArray: Nullable<WebGLTexture>;
  68433. /** @hidden */
  68434. _lodTextureHigh: Nullable<BaseTexture>;
  68435. /** @hidden */
  68436. _lodTextureMid: Nullable<BaseTexture>;
  68437. /** @hidden */
  68438. _lodTextureLow: Nullable<BaseTexture>;
  68439. /** @hidden */
  68440. _isRGBD: boolean;
  68441. /** @hidden */
  68442. _webGLTexture: Nullable<WebGLTexture>;
  68443. /** @hidden */
  68444. _references: number;
  68445. private _engine;
  68446. /**
  68447. * Gets the Engine the texture belongs to.
  68448. * @returns The babylon engine
  68449. */
  68450. getEngine(): Engine;
  68451. /**
  68452. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  68453. */
  68454. readonly dataSource: number;
  68455. /**
  68456. * Creates a new InternalTexture
  68457. * @param engine defines the engine to use
  68458. * @param dataSource defines the type of data that will be used
  68459. * @param delayAllocation if the texture allocation should be delayed (default: false)
  68460. */
  68461. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  68462. /**
  68463. * Increments the number of references (ie. the number of Texture that point to it)
  68464. */
  68465. incrementReferences(): void;
  68466. /**
  68467. * Change the size of the texture (not the size of the content)
  68468. * @param width defines the new width
  68469. * @param height defines the new height
  68470. * @param depth defines the new depth (1 by default)
  68471. */
  68472. updateSize(width: int, height: int, depth?: int): void;
  68473. /** @hidden */
  68474. _rebuild(): void;
  68475. /** @hidden */
  68476. _swapAndDie(target: InternalTexture): void;
  68477. /**
  68478. * Dispose the current allocated resources
  68479. */
  68480. dispose(): void;
  68481. }
  68482. }
  68483. declare module BABYLON {
  68484. /**
  68485. * This represents the main contract an easing function should follow.
  68486. * Easing functions are used throughout the animation system.
  68487. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  68488. */
  68489. export interface IEasingFunction {
  68490. /**
  68491. * Given an input gradient between 0 and 1, this returns the corrseponding value
  68492. * of the easing function.
  68493. * The link below provides some of the most common examples of easing functions.
  68494. * @see https://easings.net/
  68495. * @param gradient Defines the value between 0 and 1 we want the easing value for
  68496. * @returns the corresponding value on the curve defined by the easing function
  68497. */
  68498. ease(gradient: number): number;
  68499. }
  68500. /**
  68501. * Base class used for every default easing function.
  68502. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  68503. */
  68504. export class EasingFunction implements IEasingFunction {
  68505. /**
  68506. * Interpolation follows the mathematical formula associated with the easing function.
  68507. */
  68508. static readonly EASINGMODE_EASEIN: number;
  68509. /**
  68510. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  68511. */
  68512. static readonly EASINGMODE_EASEOUT: number;
  68513. /**
  68514. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  68515. */
  68516. static readonly EASINGMODE_EASEINOUT: number;
  68517. private _easingMode;
  68518. /**
  68519. * Sets the easing mode of the current function.
  68520. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  68521. */
  68522. setEasingMode(easingMode: number): void;
  68523. /**
  68524. * Gets the current easing mode.
  68525. * @returns the easing mode
  68526. */
  68527. getEasingMode(): number;
  68528. /**
  68529. * @hidden
  68530. */
  68531. easeInCore(gradient: number): number;
  68532. /**
  68533. * Given an input gradient between 0 and 1, this returns the corrseponding value
  68534. * of the easing function.
  68535. * @param gradient Defines the value between 0 and 1 we want the easing value for
  68536. * @returns the corresponding value on the curve defined by the easing function
  68537. */
  68538. ease(gradient: number): number;
  68539. }
  68540. /**
  68541. * Easing function with a circle shape (see link below).
  68542. * @see https://easings.net/#easeInCirc
  68543. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  68544. */
  68545. export class CircleEase extends EasingFunction implements IEasingFunction {
  68546. /** @hidden */
  68547. easeInCore(gradient: number): number;
  68548. }
  68549. /**
  68550. * Easing function with a ease back shape (see link below).
  68551. * @see https://easings.net/#easeInBack
  68552. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  68553. */
  68554. export class BackEase extends EasingFunction implements IEasingFunction {
  68555. /** Defines the amplitude of the function */
  68556. amplitude: number;
  68557. /**
  68558. * Instantiates a back ease easing
  68559. * @see https://easings.net/#easeInBack
  68560. * @param amplitude Defines the amplitude of the function
  68561. */
  68562. constructor(
  68563. /** Defines the amplitude of the function */
  68564. amplitude?: number);
  68565. /** @hidden */
  68566. easeInCore(gradient: number): number;
  68567. }
  68568. /**
  68569. * Easing function with a bouncing shape (see link below).
  68570. * @see https://easings.net/#easeInBounce
  68571. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  68572. */
  68573. export class BounceEase extends EasingFunction implements IEasingFunction {
  68574. /** Defines the number of bounces */
  68575. bounces: number;
  68576. /** Defines the amplitude of the bounce */
  68577. bounciness: number;
  68578. /**
  68579. * Instantiates a bounce easing
  68580. * @see https://easings.net/#easeInBounce
  68581. * @param bounces Defines the number of bounces
  68582. * @param bounciness Defines the amplitude of the bounce
  68583. */
  68584. constructor(
  68585. /** Defines the number of bounces */
  68586. bounces?: number,
  68587. /** Defines the amplitude of the bounce */
  68588. bounciness?: number);
  68589. /** @hidden */
  68590. easeInCore(gradient: number): number;
  68591. }
  68592. /**
  68593. * Easing function with a power of 3 shape (see link below).
  68594. * @see https://easings.net/#easeInCubic
  68595. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  68596. */
  68597. export class CubicEase extends EasingFunction implements IEasingFunction {
  68598. /** @hidden */
  68599. easeInCore(gradient: number): number;
  68600. }
  68601. /**
  68602. * Easing function with an elastic shape (see link below).
  68603. * @see https://easings.net/#easeInElastic
  68604. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  68605. */
  68606. export class ElasticEase extends EasingFunction implements IEasingFunction {
  68607. /** Defines the number of oscillations*/
  68608. oscillations: number;
  68609. /** Defines the amplitude of the oscillations*/
  68610. springiness: number;
  68611. /**
  68612. * Instantiates an elastic easing function
  68613. * @see https://easings.net/#easeInElastic
  68614. * @param oscillations Defines the number of oscillations
  68615. * @param springiness Defines the amplitude of the oscillations
  68616. */
  68617. constructor(
  68618. /** Defines the number of oscillations*/
  68619. oscillations?: number,
  68620. /** Defines the amplitude of the oscillations*/
  68621. springiness?: number);
  68622. /** @hidden */
  68623. easeInCore(gradient: number): number;
  68624. }
  68625. /**
  68626. * Easing function with an exponential shape (see link below).
  68627. * @see https://easings.net/#easeInExpo
  68628. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  68629. */
  68630. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  68631. /** Defines the exponent of the function */
  68632. exponent: number;
  68633. /**
  68634. * Instantiates an exponential easing function
  68635. * @see https://easings.net/#easeInExpo
  68636. * @param exponent Defines the exponent of the function
  68637. */
  68638. constructor(
  68639. /** Defines the exponent of the function */
  68640. exponent?: number);
  68641. /** @hidden */
  68642. easeInCore(gradient: number): number;
  68643. }
  68644. /**
  68645. * Easing function with a power shape (see link below).
  68646. * @see https://easings.net/#easeInQuad
  68647. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  68648. */
  68649. export class PowerEase extends EasingFunction implements IEasingFunction {
  68650. /** Defines the power of the function */
  68651. power: number;
  68652. /**
  68653. * Instantiates an power base easing function
  68654. * @see https://easings.net/#easeInQuad
  68655. * @param power Defines the power of the function
  68656. */
  68657. constructor(
  68658. /** Defines the power of the function */
  68659. power?: number);
  68660. /** @hidden */
  68661. easeInCore(gradient: number): number;
  68662. }
  68663. /**
  68664. * Easing function with a power of 2 shape (see link below).
  68665. * @see https://easings.net/#easeInQuad
  68666. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  68667. */
  68668. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  68669. /** @hidden */
  68670. easeInCore(gradient: number): number;
  68671. }
  68672. /**
  68673. * Easing function with a power of 4 shape (see link below).
  68674. * @see https://easings.net/#easeInQuart
  68675. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  68676. */
  68677. export class QuarticEase extends EasingFunction implements IEasingFunction {
  68678. /** @hidden */
  68679. easeInCore(gradient: number): number;
  68680. }
  68681. /**
  68682. * Easing function with a power of 5 shape (see link below).
  68683. * @see https://easings.net/#easeInQuint
  68684. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  68685. */
  68686. export class QuinticEase extends EasingFunction implements IEasingFunction {
  68687. /** @hidden */
  68688. easeInCore(gradient: number): number;
  68689. }
  68690. /**
  68691. * Easing function with a sin shape (see link below).
  68692. * @see https://easings.net/#easeInSine
  68693. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  68694. */
  68695. export class SineEase extends EasingFunction implements IEasingFunction {
  68696. /** @hidden */
  68697. easeInCore(gradient: number): number;
  68698. }
  68699. /**
  68700. * Easing function with a bezier shape (see link below).
  68701. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  68702. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  68703. */
  68704. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  68705. /** Defines the x component of the start tangent in the bezier curve */
  68706. x1: number;
  68707. /** Defines the y component of the start tangent in the bezier curve */
  68708. y1: number;
  68709. /** Defines the x component of the end tangent in the bezier curve */
  68710. x2: number;
  68711. /** Defines the y component of the end tangent in the bezier curve */
  68712. y2: number;
  68713. /**
  68714. * Instantiates a bezier function
  68715. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  68716. * @param x1 Defines the x component of the start tangent in the bezier curve
  68717. * @param y1 Defines the y component of the start tangent in the bezier curve
  68718. * @param x2 Defines the x component of the end tangent in the bezier curve
  68719. * @param y2 Defines the y component of the end tangent in the bezier curve
  68720. */
  68721. constructor(
  68722. /** Defines the x component of the start tangent in the bezier curve */
  68723. x1?: number,
  68724. /** Defines the y component of the start tangent in the bezier curve */
  68725. y1?: number,
  68726. /** Defines the x component of the end tangent in the bezier curve */
  68727. x2?: number,
  68728. /** Defines the y component of the end tangent in the bezier curve */
  68729. y2?: number);
  68730. /** @hidden */
  68731. easeInCore(gradient: number): number;
  68732. }
  68733. }
  68734. declare module BABYLON {
  68735. /**
  68736. * Defines an interface which represents an animation key frame
  68737. */
  68738. export interface IAnimationKey {
  68739. /**
  68740. * Frame of the key frame
  68741. */
  68742. frame: number;
  68743. /**
  68744. * Value at the specifies key frame
  68745. */
  68746. value: any;
  68747. /**
  68748. * The input tangent for the cubic hermite spline
  68749. */
  68750. inTangent?: any;
  68751. /**
  68752. * The output tangent for the cubic hermite spline
  68753. */
  68754. outTangent?: any;
  68755. /**
  68756. * The animation interpolation type
  68757. */
  68758. interpolation?: AnimationKeyInterpolation;
  68759. }
  68760. /**
  68761. * Enum for the animation key frame interpolation type
  68762. */
  68763. export enum AnimationKeyInterpolation {
  68764. /**
  68765. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  68766. */
  68767. STEP = 1
  68768. }
  68769. }
  68770. declare module BABYLON {
  68771. /**
  68772. * Represents the range of an animation
  68773. */
  68774. export class AnimationRange {
  68775. /**The name of the animation range**/
  68776. name: string;
  68777. /**The starting frame of the animation */
  68778. from: number;
  68779. /**The ending frame of the animation*/
  68780. to: number;
  68781. /**
  68782. * Initializes the range of an animation
  68783. * @param name The name of the animation range
  68784. * @param from The starting frame of the animation
  68785. * @param to The ending frame of the animation
  68786. */
  68787. constructor(
  68788. /**The name of the animation range**/
  68789. name: string,
  68790. /**The starting frame of the animation */
  68791. from: number,
  68792. /**The ending frame of the animation*/
  68793. to: number);
  68794. /**
  68795. * Makes a copy of the animation range
  68796. * @returns A copy of the animation range
  68797. */
  68798. clone(): AnimationRange;
  68799. }
  68800. }
  68801. declare module BABYLON {
  68802. /**
  68803. * Composed of a frame, and an action function
  68804. */
  68805. export class AnimationEvent {
  68806. /** The frame for which the event is triggered **/
  68807. frame: number;
  68808. /** The event to perform when triggered **/
  68809. action: (currentFrame: number) => void;
  68810. /** Specifies if the event should be triggered only once**/
  68811. onlyOnce?: boolean | undefined;
  68812. /**
  68813. * Specifies if the animation event is done
  68814. */
  68815. isDone: boolean;
  68816. /**
  68817. * Initializes the animation event
  68818. * @param frame The frame for which the event is triggered
  68819. * @param action The event to perform when triggered
  68820. * @param onlyOnce Specifies if the event should be triggered only once
  68821. */
  68822. constructor(
  68823. /** The frame for which the event is triggered **/
  68824. frame: number,
  68825. /** The event to perform when triggered **/
  68826. action: (currentFrame: number) => void,
  68827. /** Specifies if the event should be triggered only once**/
  68828. onlyOnce?: boolean | undefined);
  68829. /** @hidden */
  68830. _clone(): AnimationEvent;
  68831. }
  68832. }
  68833. declare module BABYLON {
  68834. /**
  68835. * Interface used to define a behavior
  68836. */
  68837. export interface Behavior<T> {
  68838. /** gets or sets behavior's name */
  68839. name: string;
  68840. /**
  68841. * Function called when the behavior needs to be initialized (after attaching it to a target)
  68842. */
  68843. init(): void;
  68844. /**
  68845. * Called when the behavior is attached to a target
  68846. * @param target defines the target where the behavior is attached to
  68847. */
  68848. attach(target: T): void;
  68849. /**
  68850. * Called when the behavior is detached from its target
  68851. */
  68852. detach(): void;
  68853. }
  68854. /**
  68855. * Interface implemented by classes supporting behaviors
  68856. */
  68857. export interface IBehaviorAware<T> {
  68858. /**
  68859. * Attach a behavior
  68860. * @param behavior defines the behavior to attach
  68861. * @returns the current host
  68862. */
  68863. addBehavior(behavior: Behavior<T>): T;
  68864. /**
  68865. * Remove a behavior from the current object
  68866. * @param behavior defines the behavior to detach
  68867. * @returns the current host
  68868. */
  68869. removeBehavior(behavior: Behavior<T>): T;
  68870. /**
  68871. * Gets a behavior using its name to search
  68872. * @param name defines the name to search
  68873. * @returns the behavior or null if not found
  68874. */
  68875. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  68876. }
  68877. }
  68878. declare module BABYLON {
  68879. /**
  68880. * @hidden
  68881. */
  68882. export class IntersectionInfo {
  68883. bu: Nullable<number>;
  68884. bv: Nullable<number>;
  68885. distance: number;
  68886. faceId: number;
  68887. subMeshId: number;
  68888. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  68889. }
  68890. }
  68891. declare module BABYLON {
  68892. /**
  68893. * Class used to store bounding sphere information
  68894. */
  68895. export class BoundingSphere {
  68896. /**
  68897. * Gets the center of the bounding sphere in local space
  68898. */
  68899. readonly center: Vector3;
  68900. /**
  68901. * Radius of the bounding sphere in local space
  68902. */
  68903. radius: number;
  68904. /**
  68905. * Gets the center of the bounding sphere in world space
  68906. */
  68907. readonly centerWorld: Vector3;
  68908. /**
  68909. * Radius of the bounding sphere in world space
  68910. */
  68911. radiusWorld: number;
  68912. /**
  68913. * Gets the minimum vector in local space
  68914. */
  68915. readonly minimum: Vector3;
  68916. /**
  68917. * Gets the maximum vector in local space
  68918. */
  68919. readonly maximum: Vector3;
  68920. private _worldMatrix;
  68921. private static readonly TmpVector3;
  68922. /**
  68923. * Creates a new bounding sphere
  68924. * @param min defines the minimum vector (in local space)
  68925. * @param max defines the maximum vector (in local space)
  68926. * @param worldMatrix defines the new world matrix
  68927. */
  68928. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  68929. /**
  68930. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  68931. * @param min defines the new minimum vector (in local space)
  68932. * @param max defines the new maximum vector (in local space)
  68933. * @param worldMatrix defines the new world matrix
  68934. */
  68935. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  68936. /**
  68937. * Scale the current bounding sphere by applying a scale factor
  68938. * @param factor defines the scale factor to apply
  68939. * @returns the current bounding box
  68940. */
  68941. scale(factor: number): BoundingSphere;
  68942. /**
  68943. * Gets the world matrix of the bounding box
  68944. * @returns a matrix
  68945. */
  68946. getWorldMatrix(): DeepImmutable<Matrix>;
  68947. /** @hidden */
  68948. _update(worldMatrix: DeepImmutable<Matrix>): void;
  68949. /**
  68950. * Tests if the bounding sphere is intersecting the frustum planes
  68951. * @param frustumPlanes defines the frustum planes to test
  68952. * @returns true if there is an intersection
  68953. */
  68954. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  68955. /**
  68956. * Tests if the bounding sphere center is in between the frustum planes.
  68957. * Used for optimistic fast inclusion.
  68958. * @param frustumPlanes defines the frustum planes to test
  68959. * @returns true if the sphere center is in between the frustum planes
  68960. */
  68961. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  68962. /**
  68963. * Tests if a point is inside the bounding sphere
  68964. * @param point defines the point to test
  68965. * @returns true if the point is inside the bounding sphere
  68966. */
  68967. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  68968. /**
  68969. * Checks if two sphere intersct
  68970. * @param sphere0 sphere 0
  68971. * @param sphere1 sphere 1
  68972. * @returns true if the speres intersect
  68973. */
  68974. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  68975. }
  68976. }
  68977. declare module BABYLON {
  68978. /**
  68979. * Class used to store bounding box information
  68980. */
  68981. export class BoundingBox implements ICullable {
  68982. /**
  68983. * Gets the 8 vectors representing the bounding box in local space
  68984. */
  68985. readonly vectors: Vector3[];
  68986. /**
  68987. * Gets the center of the bounding box in local space
  68988. */
  68989. readonly center: Vector3;
  68990. /**
  68991. * Gets the center of the bounding box in world space
  68992. */
  68993. readonly centerWorld: Vector3;
  68994. /**
  68995. * Gets the extend size in local space
  68996. */
  68997. readonly extendSize: Vector3;
  68998. /**
  68999. * Gets the extend size in world space
  69000. */
  69001. readonly extendSizeWorld: Vector3;
  69002. /**
  69003. * Gets the OBB (object bounding box) directions
  69004. */
  69005. readonly directions: Vector3[];
  69006. /**
  69007. * Gets the 8 vectors representing the bounding box in world space
  69008. */
  69009. readonly vectorsWorld: Vector3[];
  69010. /**
  69011. * Gets the minimum vector in world space
  69012. */
  69013. readonly minimumWorld: Vector3;
  69014. /**
  69015. * Gets the maximum vector in world space
  69016. */
  69017. readonly maximumWorld: Vector3;
  69018. /**
  69019. * Gets the minimum vector in local space
  69020. */
  69021. readonly minimum: Vector3;
  69022. /**
  69023. * Gets the maximum vector in local space
  69024. */
  69025. readonly maximum: Vector3;
  69026. private _worldMatrix;
  69027. private static readonly TmpVector3;
  69028. /**
  69029. * @hidden
  69030. */
  69031. _tag: number;
  69032. /**
  69033. * Creates a new bounding box
  69034. * @param min defines the minimum vector (in local space)
  69035. * @param max defines the maximum vector (in local space)
  69036. * @param worldMatrix defines the new world matrix
  69037. */
  69038. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  69039. /**
  69040. * Recreates the entire bounding box from scratch as if we call the constructor in place
  69041. * @param min defines the new minimum vector (in local space)
  69042. * @param max defines the new maximum vector (in local space)
  69043. * @param worldMatrix defines the new world matrix
  69044. */
  69045. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  69046. /**
  69047. * Scale the current bounding box by applying a scale factor
  69048. * @param factor defines the scale factor to apply
  69049. * @returns the current bounding box
  69050. */
  69051. scale(factor: number): BoundingBox;
  69052. /**
  69053. * Gets the world matrix of the bounding box
  69054. * @returns a matrix
  69055. */
  69056. getWorldMatrix(): DeepImmutable<Matrix>;
  69057. /** @hidden */
  69058. _update(world: DeepImmutable<Matrix>): void;
  69059. /**
  69060. * Tests if the bounding box is intersecting the frustum planes
  69061. * @param frustumPlanes defines the frustum planes to test
  69062. * @returns true if there is an intersection
  69063. */
  69064. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  69065. /**
  69066. * Tests if the bounding box is entirely inside the frustum planes
  69067. * @param frustumPlanes defines the frustum planes to test
  69068. * @returns true if there is an inclusion
  69069. */
  69070. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  69071. /**
  69072. * Tests if a point is inside the bounding box
  69073. * @param point defines the point to test
  69074. * @returns true if the point is inside the bounding box
  69075. */
  69076. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  69077. /**
  69078. * Tests if the bounding box intersects with a bounding sphere
  69079. * @param sphere defines the sphere to test
  69080. * @returns true if there is an intersection
  69081. */
  69082. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  69083. /**
  69084. * Tests if the bounding box intersects with a box defined by a min and max vectors
  69085. * @param min defines the min vector to use
  69086. * @param max defines the max vector to use
  69087. * @returns true if there is an intersection
  69088. */
  69089. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  69090. /**
  69091. * Tests if two bounding boxes are intersections
  69092. * @param box0 defines the first box to test
  69093. * @param box1 defines the second box to test
  69094. * @returns true if there is an intersection
  69095. */
  69096. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  69097. /**
  69098. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  69099. * @param minPoint defines the minimum vector of the bounding box
  69100. * @param maxPoint defines the maximum vector of the bounding box
  69101. * @param sphereCenter defines the sphere center
  69102. * @param sphereRadius defines the sphere radius
  69103. * @returns true if there is an intersection
  69104. */
  69105. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  69106. /**
  69107. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  69108. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  69109. * @param frustumPlanes defines the frustum planes to test
  69110. * @return true if there is an inclusion
  69111. */
  69112. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  69113. /**
  69114. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  69115. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  69116. * @param frustumPlanes defines the frustum planes to test
  69117. * @return true if there is an intersection
  69118. */
  69119. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  69120. }
  69121. }
  69122. declare module BABYLON {
  69123. /** @hidden */
  69124. export class Collider {
  69125. /** Define if a collision was found */
  69126. collisionFound: boolean;
  69127. /**
  69128. * Define last intersection point in local space
  69129. */
  69130. intersectionPoint: Vector3;
  69131. /**
  69132. * Define last collided mesh
  69133. */
  69134. collidedMesh: Nullable<AbstractMesh>;
  69135. private _collisionPoint;
  69136. private _planeIntersectionPoint;
  69137. private _tempVector;
  69138. private _tempVector2;
  69139. private _tempVector3;
  69140. private _tempVector4;
  69141. private _edge;
  69142. private _baseToVertex;
  69143. private _destinationPoint;
  69144. private _slidePlaneNormal;
  69145. private _displacementVector;
  69146. /** @hidden */
  69147. _radius: Vector3;
  69148. /** @hidden */
  69149. _retry: number;
  69150. private _velocity;
  69151. private _basePoint;
  69152. private _epsilon;
  69153. /** @hidden */
  69154. _velocityWorldLength: number;
  69155. /** @hidden */
  69156. _basePointWorld: Vector3;
  69157. private _velocityWorld;
  69158. private _normalizedVelocity;
  69159. /** @hidden */
  69160. _initialVelocity: Vector3;
  69161. /** @hidden */
  69162. _initialPosition: Vector3;
  69163. private _nearestDistance;
  69164. private _collisionMask;
  69165. collisionMask: number;
  69166. /**
  69167. * Gets the plane normal used to compute the sliding response (in local space)
  69168. */
  69169. readonly slidePlaneNormal: Vector3;
  69170. /** @hidden */
  69171. _initialize(source: Vector3, dir: Vector3, e: number): void;
  69172. /** @hidden */
  69173. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  69174. /** @hidden */
  69175. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  69176. /** @hidden */
  69177. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  69178. /** @hidden */
  69179. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  69180. /** @hidden */
  69181. _getResponse(pos: Vector3, vel: Vector3): void;
  69182. }
  69183. }
  69184. declare module BABYLON {
  69185. /**
  69186. * Interface for cullable objects
  69187. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  69188. */
  69189. export interface ICullable {
  69190. /**
  69191. * Checks if the object or part of the object is in the frustum
  69192. * @param frustumPlanes Camera near/planes
  69193. * @returns true if the object is in frustum otherwise false
  69194. */
  69195. isInFrustum(frustumPlanes: Plane[]): boolean;
  69196. /**
  69197. * Checks if a cullable object (mesh...) is in the camera frustum
  69198. * Unlike isInFrustum this cheks the full bounding box
  69199. * @param frustumPlanes Camera near/planes
  69200. * @returns true if the object is in frustum otherwise false
  69201. */
  69202. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  69203. }
  69204. /**
  69205. * Info for a bounding data of a mesh
  69206. */
  69207. export class BoundingInfo implements ICullable {
  69208. /**
  69209. * Bounding box for the mesh
  69210. */
  69211. readonly boundingBox: BoundingBox;
  69212. /**
  69213. * Bounding sphere for the mesh
  69214. */
  69215. readonly boundingSphere: BoundingSphere;
  69216. private _isLocked;
  69217. private static readonly TmpVector3;
  69218. /**
  69219. * Constructs bounding info
  69220. * @param minimum min vector of the bounding box/sphere
  69221. * @param maximum max vector of the bounding box/sphere
  69222. * @param worldMatrix defines the new world matrix
  69223. */
  69224. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  69225. /**
  69226. * Recreates the entire bounding info from scratch as if we call the constructor in place
  69227. * @param min defines the new minimum vector (in local space)
  69228. * @param max defines the new maximum vector (in local space)
  69229. * @param worldMatrix defines the new world matrix
  69230. */
  69231. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  69232. /**
  69233. * min vector of the bounding box/sphere
  69234. */
  69235. readonly minimum: Vector3;
  69236. /**
  69237. * max vector of the bounding box/sphere
  69238. */
  69239. readonly maximum: Vector3;
  69240. /**
  69241. * If the info is locked and won't be updated to avoid perf overhead
  69242. */
  69243. isLocked: boolean;
  69244. /**
  69245. * Updates the bounding sphere and box
  69246. * @param world world matrix to be used to update
  69247. */
  69248. update(world: DeepImmutable<Matrix>): void;
  69249. /**
  69250. * Recreate the bounding info to be centered around a specific point given a specific extend.
  69251. * @param center New center of the bounding info
  69252. * @param extend New extend of the bounding info
  69253. * @returns the current bounding info
  69254. */
  69255. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  69256. /**
  69257. * Scale the current bounding info by applying a scale factor
  69258. * @param factor defines the scale factor to apply
  69259. * @returns the current bounding info
  69260. */
  69261. scale(factor: number): BoundingInfo;
  69262. /**
  69263. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  69264. * @param frustumPlanes defines the frustum to test
  69265. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  69266. * @returns true if the bounding info is in the frustum planes
  69267. */
  69268. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  69269. /**
  69270. * Gets the world distance between the min and max points of the bounding box
  69271. */
  69272. readonly diagonalLength: number;
  69273. /**
  69274. * Checks if a cullable object (mesh...) is in the camera frustum
  69275. * Unlike isInFrustum this cheks the full bounding box
  69276. * @param frustumPlanes Camera near/planes
  69277. * @returns true if the object is in frustum otherwise false
  69278. */
  69279. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  69280. /** @hidden */
  69281. _checkCollision(collider: Collider): boolean;
  69282. /**
  69283. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  69284. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  69285. * @param point the point to check intersection with
  69286. * @returns if the point intersects
  69287. */
  69288. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  69289. /**
  69290. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  69291. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  69292. * @param boundingInfo the bounding info to check intersection with
  69293. * @param precise if the intersection should be done using OBB
  69294. * @returns if the bounding info intersects
  69295. */
  69296. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  69297. }
  69298. }
  69299. declare module BABYLON {
  69300. /**
  69301. * Defines an array and its length.
  69302. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  69303. */
  69304. export interface ISmartArrayLike<T> {
  69305. /**
  69306. * The data of the array.
  69307. */
  69308. data: Array<T>;
  69309. /**
  69310. * The active length of the array.
  69311. */
  69312. length: number;
  69313. }
  69314. /**
  69315. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  69316. */
  69317. export class SmartArray<T> implements ISmartArrayLike<T> {
  69318. /**
  69319. * The full set of data from the array.
  69320. */
  69321. data: Array<T>;
  69322. /**
  69323. * The active length of the array.
  69324. */
  69325. length: number;
  69326. protected _id: number;
  69327. /**
  69328. * Instantiates a Smart Array.
  69329. * @param capacity defines the default capacity of the array.
  69330. */
  69331. constructor(capacity: number);
  69332. /**
  69333. * Pushes a value at the end of the active data.
  69334. * @param value defines the object to push in the array.
  69335. */
  69336. push(value: T): void;
  69337. /**
  69338. * Iterates over the active data and apply the lambda to them.
  69339. * @param func defines the action to apply on each value.
  69340. */
  69341. forEach(func: (content: T) => void): void;
  69342. /**
  69343. * Sorts the full sets of data.
  69344. * @param compareFn defines the comparison function to apply.
  69345. */
  69346. sort(compareFn: (a: T, b: T) => number): void;
  69347. /**
  69348. * Resets the active data to an empty array.
  69349. */
  69350. reset(): void;
  69351. /**
  69352. * Releases all the data from the array as well as the array.
  69353. */
  69354. dispose(): void;
  69355. /**
  69356. * Concats the active data with a given array.
  69357. * @param array defines the data to concatenate with.
  69358. */
  69359. concat(array: any): void;
  69360. /**
  69361. * Returns the position of a value in the active data.
  69362. * @param value defines the value to find the index for
  69363. * @returns the index if found in the active data otherwise -1
  69364. */
  69365. indexOf(value: T): number;
  69366. /**
  69367. * Returns whether an element is part of the active data.
  69368. * @param value defines the value to look for
  69369. * @returns true if found in the active data otherwise false
  69370. */
  69371. contains(value: T): boolean;
  69372. private static _GlobalId;
  69373. }
  69374. /**
  69375. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  69376. * The data in this array can only be present once
  69377. */
  69378. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  69379. private _duplicateId;
  69380. /**
  69381. * Pushes a value at the end of the active data.
  69382. * THIS DOES NOT PREVENT DUPPLICATE DATA
  69383. * @param value defines the object to push in the array.
  69384. */
  69385. push(value: T): void;
  69386. /**
  69387. * Pushes a value at the end of the active data.
  69388. * If the data is already present, it won t be added again
  69389. * @param value defines the object to push in the array.
  69390. * @returns true if added false if it was already present
  69391. */
  69392. pushNoDuplicate(value: T): boolean;
  69393. /**
  69394. * Resets the active data to an empty array.
  69395. */
  69396. reset(): void;
  69397. /**
  69398. * Concats the active data with a given array.
  69399. * This ensures no dupplicate will be present in the result.
  69400. * @param array defines the data to concatenate with.
  69401. */
  69402. concatWithNoDuplicate(array: any): void;
  69403. }
  69404. }
  69405. declare module BABYLON {
  69406. /**
  69407. * A multi-material is used to apply different materials to different parts of the same object without the need of
  69408. * separate meshes. This can be use to improve performances.
  69409. * @see http://doc.babylonjs.com/how_to/multi_materials
  69410. */
  69411. export class MultiMaterial extends Material {
  69412. private _subMaterials;
  69413. /**
  69414. * Gets or Sets the list of Materials used within the multi material.
  69415. * They need to be ordered according to the submeshes order in the associated mesh
  69416. */
  69417. subMaterials: Nullable<Material>[];
  69418. /**
  69419. * Function used to align with Node.getChildren()
  69420. * @returns the list of Materials used within the multi material
  69421. */
  69422. getChildren(): Nullable<Material>[];
  69423. /**
  69424. * Instantiates a new Multi Material
  69425. * A multi-material is used to apply different materials to different parts of the same object without the need of
  69426. * separate meshes. This can be use to improve performances.
  69427. * @see http://doc.babylonjs.com/how_to/multi_materials
  69428. * @param name Define the name in the scene
  69429. * @param scene Define the scene the material belongs to
  69430. */
  69431. constructor(name: string, scene: Scene);
  69432. private _hookArray;
  69433. /**
  69434. * Get one of the submaterial by its index in the submaterials array
  69435. * @param index The index to look the sub material at
  69436. * @returns The Material if the index has been defined
  69437. */
  69438. getSubMaterial(index: number): Nullable<Material>;
  69439. /**
  69440. * Get the list of active textures for the whole sub materials list.
  69441. * @returns All the textures that will be used during the rendering
  69442. */
  69443. getActiveTextures(): BaseTexture[];
  69444. /**
  69445. * Gets the current class name of the material e.g. "MultiMaterial"
  69446. * Mainly use in serialization.
  69447. * @returns the class name
  69448. */
  69449. getClassName(): string;
  69450. /**
  69451. * Checks if the material is ready to render the requested sub mesh
  69452. * @param mesh Define the mesh the submesh belongs to
  69453. * @param subMesh Define the sub mesh to look readyness for
  69454. * @param useInstances Define whether or not the material is used with instances
  69455. * @returns true if ready, otherwise false
  69456. */
  69457. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  69458. /**
  69459. * Clones the current material and its related sub materials
  69460. * @param name Define the name of the newly cloned material
  69461. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  69462. * @returns the cloned material
  69463. */
  69464. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  69465. /**
  69466. * Serializes the materials into a JSON representation.
  69467. * @returns the JSON representation
  69468. */
  69469. serialize(): any;
  69470. /**
  69471. * Dispose the material and release its associated resources
  69472. * @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)
  69473. * @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)
  69474. * @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)
  69475. */
  69476. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  69477. /**
  69478. * Creates a MultiMaterial from parsed MultiMaterial data.
  69479. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  69480. * @param scene defines the hosting scene
  69481. * @returns a new MultiMaterial
  69482. */
  69483. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  69484. }
  69485. }
  69486. declare module BABYLON {
  69487. /**
  69488. * Class used to represent data loading progression
  69489. */
  69490. export class SceneLoaderFlags {
  69491. private static _ForceFullSceneLoadingForIncremental;
  69492. private static _ShowLoadingScreen;
  69493. private static _CleanBoneMatrixWeights;
  69494. private static _loggingLevel;
  69495. /**
  69496. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  69497. */
  69498. static ForceFullSceneLoadingForIncremental: boolean;
  69499. /**
  69500. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  69501. */
  69502. static ShowLoadingScreen: boolean;
  69503. /**
  69504. * Defines the current logging level (while loading the scene)
  69505. * @ignorenaming
  69506. */
  69507. static loggingLevel: number;
  69508. /**
  69509. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  69510. */
  69511. static CleanBoneMatrixWeights: boolean;
  69512. }
  69513. }
  69514. declare module BABYLON {
  69515. /**
  69516. * 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.
  69517. * @see https://doc.babylonjs.com/how_to/transformnode
  69518. */
  69519. export class TransformNode extends Node {
  69520. /**
  69521. * Object will not rotate to face the camera
  69522. */
  69523. static BILLBOARDMODE_NONE: number;
  69524. /**
  69525. * Object will rotate to face the camera but only on the x axis
  69526. */
  69527. static BILLBOARDMODE_X: number;
  69528. /**
  69529. * Object will rotate to face the camera but only on the y axis
  69530. */
  69531. static BILLBOARDMODE_Y: number;
  69532. /**
  69533. * Object will rotate to face the camera but only on the z axis
  69534. */
  69535. static BILLBOARDMODE_Z: number;
  69536. /**
  69537. * Object will rotate to face the camera
  69538. */
  69539. static BILLBOARDMODE_ALL: number;
  69540. private _forward;
  69541. private _forwardInverted;
  69542. private _up;
  69543. private _right;
  69544. private _rightInverted;
  69545. private _position;
  69546. private _rotation;
  69547. private _rotationQuaternion;
  69548. protected _scaling: Vector3;
  69549. protected _isDirty: boolean;
  69550. private _transformToBoneReferal;
  69551. private _billboardMode;
  69552. /**
  69553. * Gets or sets the billboard mode. Default is 0.
  69554. *
  69555. * | Value | Type | Description |
  69556. * | --- | --- | --- |
  69557. * | 0 | BILLBOARDMODE_NONE | |
  69558. * | 1 | BILLBOARDMODE_X | |
  69559. * | 2 | BILLBOARDMODE_Y | |
  69560. * | 4 | BILLBOARDMODE_Z | |
  69561. * | 7 | BILLBOARDMODE_ALL | |
  69562. *
  69563. */
  69564. billboardMode: number;
  69565. private _preserveParentRotationForBillboard;
  69566. /**
  69567. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  69568. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  69569. */
  69570. preserveParentRotationForBillboard: boolean;
  69571. /**
  69572. * 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
  69573. */
  69574. scalingDeterminant: number;
  69575. private _infiniteDistance;
  69576. /**
  69577. * Gets or sets the distance of the object to max, often used by skybox
  69578. */
  69579. infiniteDistance: boolean;
  69580. /**
  69581. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  69582. * By default the system will update normals to compensate
  69583. */
  69584. ignoreNonUniformScaling: boolean;
  69585. /**
  69586. * 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
  69587. */
  69588. reIntegrateRotationIntoRotationQuaternion: boolean;
  69589. /** @hidden */
  69590. _poseMatrix: Nullable<Matrix>;
  69591. /** @hidden */
  69592. _localMatrix: Matrix;
  69593. private _usePivotMatrix;
  69594. private _absolutePosition;
  69595. private _pivotMatrix;
  69596. private _pivotMatrixInverse;
  69597. protected _postMultiplyPivotMatrix: boolean;
  69598. protected _isWorldMatrixFrozen: boolean;
  69599. /** @hidden */
  69600. _indexInSceneTransformNodesArray: number;
  69601. /**
  69602. * An event triggered after the world matrix is updated
  69603. */
  69604. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  69605. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  69606. /**
  69607. * Gets a string identifying the name of the class
  69608. * @returns "TransformNode" string
  69609. */
  69610. getClassName(): string;
  69611. /**
  69612. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  69613. */
  69614. position: Vector3;
  69615. /**
  69616. * 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)).
  69617. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  69618. */
  69619. rotation: Vector3;
  69620. /**
  69621. * 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)).
  69622. */
  69623. scaling: Vector3;
  69624. /**
  69625. * 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).
  69626. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  69627. */
  69628. rotationQuaternion: Nullable<Quaternion>;
  69629. /**
  69630. * The forward direction of that transform in world space.
  69631. */
  69632. readonly forward: Vector3;
  69633. /**
  69634. * The up direction of that transform in world space.
  69635. */
  69636. readonly up: Vector3;
  69637. /**
  69638. * The right direction of that transform in world space.
  69639. */
  69640. readonly right: Vector3;
  69641. /**
  69642. * Copies the parameter passed Matrix into the mesh Pose matrix.
  69643. * @param matrix the matrix to copy the pose from
  69644. * @returns this TransformNode.
  69645. */
  69646. updatePoseMatrix(matrix: Matrix): TransformNode;
  69647. /**
  69648. * Returns the mesh Pose matrix.
  69649. * @returns the pose matrix
  69650. */
  69651. getPoseMatrix(): Matrix;
  69652. /** @hidden */
  69653. _isSynchronized(): boolean;
  69654. /** @hidden */
  69655. _initCache(): void;
  69656. /**
  69657. * Flag the transform node as dirty (Forcing it to update everything)
  69658. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  69659. * @returns this transform node
  69660. */
  69661. markAsDirty(property: string): TransformNode;
  69662. /**
  69663. * Returns the current mesh absolute position.
  69664. * Returns a Vector3.
  69665. */
  69666. readonly absolutePosition: Vector3;
  69667. /**
  69668. * Sets a new matrix to apply before all other transformation
  69669. * @param matrix defines the transform matrix
  69670. * @returns the current TransformNode
  69671. */
  69672. setPreTransformMatrix(matrix: Matrix): TransformNode;
  69673. /**
  69674. * Sets a new pivot matrix to the current node
  69675. * @param matrix defines the new pivot matrix to use
  69676. * @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
  69677. * @returns the current TransformNode
  69678. */
  69679. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  69680. /**
  69681. * Returns the mesh pivot matrix.
  69682. * Default : Identity.
  69683. * @returns the matrix
  69684. */
  69685. getPivotMatrix(): Matrix;
  69686. /**
  69687. * Prevents the World matrix to be computed any longer.
  69688. * @returns the TransformNode.
  69689. */
  69690. freezeWorldMatrix(): TransformNode;
  69691. /**
  69692. * Allows back the World matrix computation.
  69693. * @returns the TransformNode.
  69694. */
  69695. unfreezeWorldMatrix(): this;
  69696. /**
  69697. * True if the World matrix has been frozen.
  69698. */
  69699. readonly isWorldMatrixFrozen: boolean;
  69700. /**
  69701. * Retuns the mesh absolute position in the World.
  69702. * @returns a Vector3.
  69703. */
  69704. getAbsolutePosition(): Vector3;
  69705. /**
  69706. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  69707. * @param absolutePosition the absolute position to set
  69708. * @returns the TransformNode.
  69709. */
  69710. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  69711. /**
  69712. * Sets the mesh position in its local space.
  69713. * @param vector3 the position to set in localspace
  69714. * @returns the TransformNode.
  69715. */
  69716. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  69717. /**
  69718. * Returns the mesh position in the local space from the current World matrix values.
  69719. * @returns a new Vector3.
  69720. */
  69721. getPositionExpressedInLocalSpace(): Vector3;
  69722. /**
  69723. * Translates the mesh along the passed Vector3 in its local space.
  69724. * @param vector3 the distance to translate in localspace
  69725. * @returns the TransformNode.
  69726. */
  69727. locallyTranslate(vector3: Vector3): TransformNode;
  69728. private static _lookAtVectorCache;
  69729. /**
  69730. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  69731. * @param targetPoint the position (must be in same space as current mesh) to look at
  69732. * @param yawCor optional yaw (y-axis) correction in radians
  69733. * @param pitchCor optional pitch (x-axis) correction in radians
  69734. * @param rollCor optional roll (z-axis) correction in radians
  69735. * @param space the choosen space of the target
  69736. * @returns the TransformNode.
  69737. */
  69738. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  69739. /**
  69740. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  69741. * This Vector3 is expressed in the World space.
  69742. * @param localAxis axis to rotate
  69743. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  69744. */
  69745. getDirection(localAxis: Vector3): Vector3;
  69746. /**
  69747. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  69748. * localAxis is expressed in the mesh local space.
  69749. * result is computed in the Wordl space from the mesh World matrix.
  69750. * @param localAxis axis to rotate
  69751. * @param result the resulting transformnode
  69752. * @returns this TransformNode.
  69753. */
  69754. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  69755. /**
  69756. * Sets this transform node rotation to the given local axis.
  69757. * @param localAxis the axis in local space
  69758. * @param yawCor optional yaw (y-axis) correction in radians
  69759. * @param pitchCor optional pitch (x-axis) correction in radians
  69760. * @param rollCor optional roll (z-axis) correction in radians
  69761. * @returns this TransformNode
  69762. */
  69763. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  69764. /**
  69765. * Sets a new pivot point to the current node
  69766. * @param point defines the new pivot point to use
  69767. * @param space defines if the point is in world or local space (local by default)
  69768. * @returns the current TransformNode
  69769. */
  69770. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  69771. /**
  69772. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  69773. * @returns the pivot point
  69774. */
  69775. getPivotPoint(): Vector3;
  69776. /**
  69777. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  69778. * @param result the vector3 to store the result
  69779. * @returns this TransformNode.
  69780. */
  69781. getPivotPointToRef(result: Vector3): TransformNode;
  69782. /**
  69783. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  69784. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  69785. */
  69786. getAbsolutePivotPoint(): Vector3;
  69787. /**
  69788. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  69789. * @param result vector3 to store the result
  69790. * @returns this TransformNode.
  69791. */
  69792. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  69793. /**
  69794. * Defines the passed node as the parent of the current node.
  69795. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  69796. * @see https://doc.babylonjs.com/how_to/parenting
  69797. * @param node the node ot set as the parent
  69798. * @returns this TransformNode.
  69799. */
  69800. setParent(node: Nullable<Node>): TransformNode;
  69801. private _nonUniformScaling;
  69802. /**
  69803. * True if the scaling property of this object is non uniform eg. (1,2,1)
  69804. */
  69805. readonly nonUniformScaling: boolean;
  69806. /** @hidden */
  69807. _updateNonUniformScalingState(value: boolean): boolean;
  69808. /**
  69809. * Attach the current TransformNode to another TransformNode associated with a bone
  69810. * @param bone Bone affecting the TransformNode
  69811. * @param affectedTransformNode TransformNode associated with the bone
  69812. * @returns this object
  69813. */
  69814. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  69815. /**
  69816. * Detach the transform node if its associated with a bone
  69817. * @returns this object
  69818. */
  69819. detachFromBone(): TransformNode;
  69820. private static _rotationAxisCache;
  69821. /**
  69822. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  69823. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  69824. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  69825. * The passed axis is also normalized.
  69826. * @param axis the axis to rotate around
  69827. * @param amount the amount to rotate in radians
  69828. * @param space Space to rotate in (Default: local)
  69829. * @returns the TransformNode.
  69830. */
  69831. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  69832. /**
  69833. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  69834. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  69835. * The passed axis is also normalized. .
  69836. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  69837. * @param point the point to rotate around
  69838. * @param axis the axis to rotate around
  69839. * @param amount the amount to rotate in radians
  69840. * @returns the TransformNode
  69841. */
  69842. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  69843. /**
  69844. * Translates the mesh along the axis vector for the passed distance in the given space.
  69845. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  69846. * @param axis the axis to translate in
  69847. * @param distance the distance to translate
  69848. * @param space Space to rotate in (Default: local)
  69849. * @returns the TransformNode.
  69850. */
  69851. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  69852. /**
  69853. * Adds a rotation step to the mesh current rotation.
  69854. * x, y, z are Euler angles expressed in radians.
  69855. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  69856. * This means this rotation is made in the mesh local space only.
  69857. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  69858. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  69859. * ```javascript
  69860. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  69861. * ```
  69862. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  69863. * 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.
  69864. * @param x Rotation to add
  69865. * @param y Rotation to add
  69866. * @param z Rotation to add
  69867. * @returns the TransformNode.
  69868. */
  69869. addRotation(x: number, y: number, z: number): TransformNode;
  69870. /**
  69871. * @hidden
  69872. */
  69873. protected _getEffectiveParent(): Nullable<Node>;
  69874. /**
  69875. * Computes the world matrix of the node
  69876. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  69877. * @returns the world matrix
  69878. */
  69879. computeWorldMatrix(force?: boolean): Matrix;
  69880. protected _afterComputeWorldMatrix(): void;
  69881. /**
  69882. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  69883. * @param func callback function to add
  69884. *
  69885. * @returns the TransformNode.
  69886. */
  69887. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  69888. /**
  69889. * Removes a registered callback function.
  69890. * @param func callback function to remove
  69891. * @returns the TransformNode.
  69892. */
  69893. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  69894. /**
  69895. * Gets the position of the current mesh in camera space
  69896. * @param camera defines the camera to use
  69897. * @returns a position
  69898. */
  69899. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  69900. /**
  69901. * Returns the distance from the mesh to the active camera
  69902. * @param camera defines the camera to use
  69903. * @returns the distance
  69904. */
  69905. getDistanceToCamera(camera?: Nullable<Camera>): number;
  69906. /**
  69907. * Clone the current transform node
  69908. * @param name Name of the new clone
  69909. * @param newParent New parent for the clone
  69910. * @param doNotCloneChildren Do not clone children hierarchy
  69911. * @returns the new transform node
  69912. */
  69913. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  69914. /**
  69915. * Serializes the objects information.
  69916. * @param currentSerializationObject defines the object to serialize in
  69917. * @returns the serialized object
  69918. */
  69919. serialize(currentSerializationObject?: any): any;
  69920. /**
  69921. * Returns a new TransformNode object parsed from the source provided.
  69922. * @param parsedTransformNode is the source.
  69923. * @param scene the scne the object belongs to
  69924. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  69925. * @returns a new TransformNode object parsed from the source provided.
  69926. */
  69927. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  69928. /**
  69929. * Get all child-transformNodes of this node
  69930. * @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
  69931. * @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
  69932. * @returns an array of TransformNode
  69933. */
  69934. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  69935. /**
  69936. * Releases resources associated with this transform node.
  69937. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  69938. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  69939. */
  69940. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  69941. }
  69942. }
  69943. declare module BABYLON {
  69944. /**
  69945. * Class used to override all child animations of a given target
  69946. */
  69947. export class AnimationPropertiesOverride {
  69948. /**
  69949. * Gets or sets a value indicating if animation blending must be used
  69950. */
  69951. enableBlending: boolean;
  69952. /**
  69953. * Gets or sets the blending speed to use when enableBlending is true
  69954. */
  69955. blendingSpeed: number;
  69956. /**
  69957. * Gets or sets the default loop mode to use
  69958. */
  69959. loopMode: number;
  69960. }
  69961. }
  69962. declare module BABYLON {
  69963. /**
  69964. * Class used to store bone information
  69965. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  69966. */
  69967. export class Bone extends Node {
  69968. /**
  69969. * defines the bone name
  69970. */
  69971. name: string;
  69972. private static _tmpVecs;
  69973. private static _tmpQuat;
  69974. private static _tmpMats;
  69975. /**
  69976. * Gets the list of child bones
  69977. */
  69978. children: Bone[];
  69979. /** Gets the animations associated with this bone */
  69980. animations: Animation[];
  69981. /**
  69982. * Gets or sets bone length
  69983. */
  69984. length: number;
  69985. /**
  69986. * @hidden Internal only
  69987. * Set this value to map this bone to a different index in the transform matrices
  69988. * Set this value to -1 to exclude the bone from the transform matrices
  69989. */
  69990. _index: Nullable<number>;
  69991. private _skeleton;
  69992. private _localMatrix;
  69993. private _restPose;
  69994. private _baseMatrix;
  69995. private _absoluteTransform;
  69996. private _invertedAbsoluteTransform;
  69997. private _parent;
  69998. private _scalingDeterminant;
  69999. private _worldTransform;
  70000. private _localScaling;
  70001. private _localRotation;
  70002. private _localPosition;
  70003. private _needToDecompose;
  70004. private _needToCompose;
  70005. /** @hidden */
  70006. _linkedTransformNode: Nullable<TransformNode>;
  70007. /** @hidden */
  70008. _waitingTransformNodeId: Nullable<string>;
  70009. /** @hidden */
  70010. /** @hidden */
  70011. _matrix: Matrix;
  70012. /**
  70013. * Create a new bone
  70014. * @param name defines the bone name
  70015. * @param skeleton defines the parent skeleton
  70016. * @param parentBone defines the parent (can be null if the bone is the root)
  70017. * @param localMatrix defines the local matrix
  70018. * @param restPose defines the rest pose matrix
  70019. * @param baseMatrix defines the base matrix
  70020. * @param index defines index of the bone in the hiearchy
  70021. */
  70022. constructor(
  70023. /**
  70024. * defines the bone name
  70025. */
  70026. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  70027. /**
  70028. * Gets the current object class name.
  70029. * @return the class name
  70030. */
  70031. getClassName(): string;
  70032. /**
  70033. * Gets the parent skeleton
  70034. * @returns a skeleton
  70035. */
  70036. getSkeleton(): Skeleton;
  70037. /**
  70038. * Gets parent bone
  70039. * @returns a bone or null if the bone is the root of the bone hierarchy
  70040. */
  70041. getParent(): Nullable<Bone>;
  70042. /**
  70043. * Returns an array containing the root bones
  70044. * @returns an array containing the root bones
  70045. */
  70046. getChildren(): Array<Bone>;
  70047. /**
  70048. * Sets the parent bone
  70049. * @param parent defines the parent (can be null if the bone is the root)
  70050. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  70051. */
  70052. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  70053. /**
  70054. * Gets the local matrix
  70055. * @returns a matrix
  70056. */
  70057. getLocalMatrix(): Matrix;
  70058. /**
  70059. * Gets the base matrix (initial matrix which remains unchanged)
  70060. * @returns a matrix
  70061. */
  70062. getBaseMatrix(): Matrix;
  70063. /**
  70064. * Gets the rest pose matrix
  70065. * @returns a matrix
  70066. */
  70067. getRestPose(): Matrix;
  70068. /**
  70069. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  70070. */
  70071. getWorldMatrix(): Matrix;
  70072. /**
  70073. * Sets the local matrix to rest pose matrix
  70074. */
  70075. returnToRest(): void;
  70076. /**
  70077. * Gets the inverse of the absolute transform matrix.
  70078. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  70079. * @returns a matrix
  70080. */
  70081. getInvertedAbsoluteTransform(): Matrix;
  70082. /**
  70083. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  70084. * @returns a matrix
  70085. */
  70086. getAbsoluteTransform(): Matrix;
  70087. /**
  70088. * Links with the given transform node.
  70089. * The local matrix of this bone is copied from the transform node every frame.
  70090. * @param transformNode defines the transform node to link to
  70091. */
  70092. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  70093. /** Gets or sets current position (in local space) */
  70094. position: Vector3;
  70095. /** Gets or sets current rotation (in local space) */
  70096. rotation: Vector3;
  70097. /** Gets or sets current rotation quaternion (in local space) */
  70098. rotationQuaternion: Quaternion;
  70099. /** Gets or sets current scaling (in local space) */
  70100. scaling: Vector3;
  70101. /**
  70102. * Gets the animation properties override
  70103. */
  70104. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  70105. private _decompose;
  70106. private _compose;
  70107. /**
  70108. * Update the base and local matrices
  70109. * @param matrix defines the new base or local matrix
  70110. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  70111. * @param updateLocalMatrix defines if the local matrix should be updated
  70112. */
  70113. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  70114. /** @hidden */
  70115. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  70116. /**
  70117. * Flag the bone as dirty (Forcing it to update everything)
  70118. */
  70119. markAsDirty(): void;
  70120. private _markAsDirtyAndCompose;
  70121. private _markAsDirtyAndDecompose;
  70122. /**
  70123. * Translate the bone in local or world space
  70124. * @param vec The amount to translate the bone
  70125. * @param space The space that the translation is in
  70126. * @param mesh The mesh that this bone is attached to. This is only used in world space
  70127. */
  70128. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  70129. /**
  70130. * Set the postion of the bone in local or world space
  70131. * @param position The position to set the bone
  70132. * @param space The space that the position is in
  70133. * @param mesh The mesh that this bone is attached to. This is only used in world space
  70134. */
  70135. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  70136. /**
  70137. * Set the absolute position of the bone (world space)
  70138. * @param position The position to set the bone
  70139. * @param mesh The mesh that this bone is attached to
  70140. */
  70141. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  70142. /**
  70143. * Scale the bone on the x, y and z axes (in local space)
  70144. * @param x The amount to scale the bone on the x axis
  70145. * @param y The amount to scale the bone on the y axis
  70146. * @param z The amount to scale the bone on the z axis
  70147. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  70148. */
  70149. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  70150. /**
  70151. * Set the bone scaling in local space
  70152. * @param scale defines the scaling vector
  70153. */
  70154. setScale(scale: Vector3): void;
  70155. /**
  70156. * Gets the current scaling in local space
  70157. * @returns the current scaling vector
  70158. */
  70159. getScale(): Vector3;
  70160. /**
  70161. * Gets the current scaling in local space and stores it in a target vector
  70162. * @param result defines the target vector
  70163. */
  70164. getScaleToRef(result: Vector3): void;
  70165. /**
  70166. * Set the yaw, pitch, and roll of the bone in local or world space
  70167. * @param yaw The rotation of the bone on the y axis
  70168. * @param pitch The rotation of the bone on the x axis
  70169. * @param roll The rotation of the bone on the z axis
  70170. * @param space The space that the axes of rotation are in
  70171. * @param mesh The mesh that this bone is attached to. This is only used in world space
  70172. */
  70173. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  70174. /**
  70175. * Add a rotation to the bone on an axis in local or world space
  70176. * @param axis The axis to rotate the bone on
  70177. * @param amount The amount to rotate the bone
  70178. * @param space The space that the axis is in
  70179. * @param mesh The mesh that this bone is attached to. This is only used in world space
  70180. */
  70181. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  70182. /**
  70183. * Set the rotation of the bone to a particular axis angle in local or world space
  70184. * @param axis The axis to rotate the bone on
  70185. * @param angle The angle that the bone should be rotated to
  70186. * @param space The space that the axis is in
  70187. * @param mesh The mesh that this bone is attached to. This is only used in world space
  70188. */
  70189. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  70190. /**
  70191. * Set the euler rotation of the bone in local of world space
  70192. * @param rotation The euler rotation that the bone should be set to
  70193. * @param space The space that the rotation is in
  70194. * @param mesh The mesh that this bone is attached to. This is only used in world space
  70195. */
  70196. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  70197. /**
  70198. * Set the quaternion rotation of the bone in local of world space
  70199. * @param quat The quaternion rotation that the bone should be set to
  70200. * @param space The space that the rotation is in
  70201. * @param mesh The mesh that this bone is attached to. This is only used in world space
  70202. */
  70203. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  70204. /**
  70205. * Set the rotation matrix of the bone in local of world space
  70206. * @param rotMat The rotation matrix that the bone should be set to
  70207. * @param space The space that the rotation is in
  70208. * @param mesh The mesh that this bone is attached to. This is only used in world space
  70209. */
  70210. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  70211. private _rotateWithMatrix;
  70212. private _getNegativeRotationToRef;
  70213. /**
  70214. * Get the position of the bone in local or world space
  70215. * @param space The space that the returned position is in
  70216. * @param mesh The mesh that this bone is attached to. This is only used in world space
  70217. * @returns The position of the bone
  70218. */
  70219. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  70220. /**
  70221. * Copy the position of the bone to a vector3 in local or world space
  70222. * @param space The space that the returned position is in
  70223. * @param mesh The mesh that this bone is attached to. This is only used in world space
  70224. * @param result The vector3 to copy the position to
  70225. */
  70226. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  70227. /**
  70228. * Get the absolute position of the bone (world space)
  70229. * @param mesh The mesh that this bone is attached to
  70230. * @returns The absolute position of the bone
  70231. */
  70232. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  70233. /**
  70234. * Copy the absolute position of the bone (world space) to the result param
  70235. * @param mesh The mesh that this bone is attached to
  70236. * @param result The vector3 to copy the absolute position to
  70237. */
  70238. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  70239. /**
  70240. * Compute the absolute transforms of this bone and its children
  70241. */
  70242. computeAbsoluteTransforms(): void;
  70243. /**
  70244. * Get the world direction from an axis that is in the local space of the bone
  70245. * @param localAxis The local direction that is used to compute the world direction
  70246. * @param mesh The mesh that this bone is attached to
  70247. * @returns The world direction
  70248. */
  70249. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  70250. /**
  70251. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  70252. * @param localAxis The local direction that is used to compute the world direction
  70253. * @param mesh The mesh that this bone is attached to
  70254. * @param result The vector3 that the world direction will be copied to
  70255. */
  70256. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  70257. /**
  70258. * Get the euler rotation of the bone in local or world space
  70259. * @param space The space that the rotation should be in
  70260. * @param mesh The mesh that this bone is attached to. This is only used in world space
  70261. * @returns The euler rotation
  70262. */
  70263. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  70264. /**
  70265. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  70266. * @param space The space that the rotation should be in
  70267. * @param mesh The mesh that this bone is attached to. This is only used in world space
  70268. * @param result The vector3 that the rotation should be copied to
  70269. */
  70270. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  70271. /**
  70272. * Get the quaternion rotation of the bone in either local or world space
  70273. * @param space The space that the rotation should be in
  70274. * @param mesh The mesh that this bone is attached to. This is only used in world space
  70275. * @returns The quaternion rotation
  70276. */
  70277. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  70278. /**
  70279. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  70280. * @param space The space that the rotation should be in
  70281. * @param mesh The mesh that this bone is attached to. This is only used in world space
  70282. * @param result The quaternion that the rotation should be copied to
  70283. */
  70284. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  70285. /**
  70286. * Get the rotation matrix of the bone in local or world space
  70287. * @param space The space that the rotation should be in
  70288. * @param mesh The mesh that this bone is attached to. This is only used in world space
  70289. * @returns The rotation matrix
  70290. */
  70291. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  70292. /**
  70293. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  70294. * @param space The space that the rotation should be in
  70295. * @param mesh The mesh that this bone is attached to. This is only used in world space
  70296. * @param result The quaternion that the rotation should be copied to
  70297. */
  70298. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  70299. /**
  70300. * Get the world position of a point that is in the local space of the bone
  70301. * @param position The local position
  70302. * @param mesh The mesh that this bone is attached to
  70303. * @returns The world position
  70304. */
  70305. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  70306. /**
  70307. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  70308. * @param position The local position
  70309. * @param mesh The mesh that this bone is attached to
  70310. * @param result The vector3 that the world position should be copied to
  70311. */
  70312. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  70313. /**
  70314. * Get the local position of a point that is in world space
  70315. * @param position The world position
  70316. * @param mesh The mesh that this bone is attached to
  70317. * @returns The local position
  70318. */
  70319. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  70320. /**
  70321. * Get the local position of a point that is in world space and copy it to the result param
  70322. * @param position The world position
  70323. * @param mesh The mesh that this bone is attached to
  70324. * @param result The vector3 that the local position should be copied to
  70325. */
  70326. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  70327. }
  70328. }
  70329. declare module BABYLON {
  70330. /**
  70331. * Enum that determines the text-wrapping mode to use.
  70332. */
  70333. export enum InspectableType {
  70334. /**
  70335. * Checkbox for booleans
  70336. */
  70337. Checkbox = 0,
  70338. /**
  70339. * Sliders for numbers
  70340. */
  70341. Slider = 1,
  70342. /**
  70343. * Vector3
  70344. */
  70345. Vector3 = 2,
  70346. /**
  70347. * Quaternions
  70348. */
  70349. Quaternion = 3,
  70350. /**
  70351. * Color3
  70352. */
  70353. Color3 = 4
  70354. }
  70355. /**
  70356. * Interface used to define custom inspectable properties.
  70357. * This interface is used by the inspector to display custom property grids
  70358. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  70359. */
  70360. export interface IInspectable {
  70361. /**
  70362. * Gets the label to display
  70363. */
  70364. label: string;
  70365. /**
  70366. * Gets the name of the property to edit
  70367. */
  70368. propertyName: string;
  70369. /**
  70370. * Gets the type of the editor to use
  70371. */
  70372. type: InspectableType;
  70373. /**
  70374. * Gets the minimum value of the property when using in "slider" mode
  70375. */
  70376. min?: number;
  70377. /**
  70378. * Gets the maximum value of the property when using in "slider" mode
  70379. */
  70380. max?: number;
  70381. /**
  70382. * Gets the setp to use when using in "slider" mode
  70383. */
  70384. step?: number;
  70385. }
  70386. }
  70387. declare module BABYLON {
  70388. /**
  70389. * This represents the required contract to create a new type of texture loader.
  70390. */
  70391. export interface IInternalTextureLoader {
  70392. /**
  70393. * Defines wether the loader supports cascade loading the different faces.
  70394. */
  70395. supportCascades: boolean;
  70396. /**
  70397. * This returns if the loader support the current file information.
  70398. * @param extension defines the file extension of the file being loaded
  70399. * @param textureFormatInUse defines the current compressed format in use iun the engine
  70400. * @param fallback defines the fallback internal texture if any
  70401. * @param isBase64 defines whether the texture is encoded as a base64
  70402. * @param isBuffer defines whether the texture data are stored as a buffer
  70403. * @returns true if the loader can load the specified file
  70404. */
  70405. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  70406. /**
  70407. * Transform the url before loading if required.
  70408. * @param rootUrl the url of the texture
  70409. * @param textureFormatInUse defines the current compressed format in use iun the engine
  70410. * @returns the transformed texture
  70411. */
  70412. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  70413. /**
  70414. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  70415. * @param rootUrl the url of the texture
  70416. * @param textureFormatInUse defines the current compressed format in use iun the engine
  70417. * @returns the fallback texture
  70418. */
  70419. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  70420. /**
  70421. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  70422. * @param data contains the texture data
  70423. * @param texture defines the BabylonJS internal texture
  70424. * @param createPolynomials will be true if polynomials have been requested
  70425. * @param onLoad defines the callback to trigger once the texture is ready
  70426. * @param onError defines the callback to trigger in case of error
  70427. */
  70428. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  70429. /**
  70430. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  70431. * @param data contains the texture data
  70432. * @param texture defines the BabylonJS internal texture
  70433. * @param callback defines the method to call once ready to upload
  70434. */
  70435. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  70436. }
  70437. }
  70438. declare module BABYLON {
  70439. interface Engine {
  70440. /**
  70441. * Creates a depth stencil cube texture.
  70442. * This is only available in WebGL 2.
  70443. * @param size The size of face edge in the cube texture.
  70444. * @param options The options defining the cube texture.
  70445. * @returns The cube texture
  70446. */
  70447. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  70448. /**
  70449. * Creates a cube texture
  70450. * @param rootUrl defines the url where the files to load is located
  70451. * @param scene defines the current scene
  70452. * @param files defines the list of files to load (1 per face)
  70453. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  70454. * @param onLoad defines an optional callback raised when the texture is loaded
  70455. * @param onError defines an optional callback raised if there is an issue to load the texture
  70456. * @param format defines the format of the data
  70457. * @param forcedExtension defines the extension to use to pick the right loader
  70458. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  70459. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  70460. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  70461. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  70462. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  70463. * @returns the cube texture as an InternalTexture
  70464. */
  70465. 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;
  70466. /**
  70467. * Creates a cube texture
  70468. * @param rootUrl defines the url where the files to load is located
  70469. * @param scene defines the current scene
  70470. * @param files defines the list of files to load (1 per face)
  70471. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  70472. * @param onLoad defines an optional callback raised when the texture is loaded
  70473. * @param onError defines an optional callback raised if there is an issue to load the texture
  70474. * @param format defines the format of the data
  70475. * @param forcedExtension defines the extension to use to pick the right loader
  70476. * @returns the cube texture as an InternalTexture
  70477. */
  70478. 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;
  70479. /**
  70480. * Creates a cube texture
  70481. * @param rootUrl defines the url where the files to load is located
  70482. * @param scene defines the current scene
  70483. * @param files defines the list of files to load (1 per face)
  70484. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  70485. * @param onLoad defines an optional callback raised when the texture is loaded
  70486. * @param onError defines an optional callback raised if there is an issue to load the texture
  70487. * @param format defines the format of the data
  70488. * @param forcedExtension defines the extension to use to pick the right loader
  70489. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  70490. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  70491. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  70492. * @returns the cube texture as an InternalTexture
  70493. */
  70494. 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;
  70495. /** @hidden */
  70496. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  70497. /** @hidden */
  70498. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  70499. /** @hidden */
  70500. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  70501. /** @hidden */
  70502. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  70503. }
  70504. }
  70505. declare module BABYLON {
  70506. /**
  70507. * Class for creating a cube texture
  70508. */
  70509. export class CubeTexture extends BaseTexture {
  70510. private _delayedOnLoad;
  70511. /**
  70512. * The url of the texture
  70513. */
  70514. url: string;
  70515. /**
  70516. * Gets or sets the center of the bounding box associated with the cube texture.
  70517. * It must define where the camera used to render the texture was set
  70518. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  70519. */
  70520. boundingBoxPosition: Vector3;
  70521. private _boundingBoxSize;
  70522. /**
  70523. * Gets or sets the size of the bounding box associated with the cube texture
  70524. * When defined, the cubemap will switch to local mode
  70525. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  70526. * @example https://www.babylonjs-playground.com/#RNASML
  70527. */
  70528. /**
  70529. * Returns the bounding box size
  70530. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  70531. */
  70532. boundingBoxSize: Vector3;
  70533. protected _rotationY: number;
  70534. /**
  70535. * Sets texture matrix rotation angle around Y axis in radians.
  70536. */
  70537. /**
  70538. * Gets texture matrix rotation angle around Y axis radians.
  70539. */
  70540. rotationY: number;
  70541. /**
  70542. * Are mip maps generated for this texture or not.
  70543. */
  70544. readonly noMipmap: boolean;
  70545. private _noMipmap;
  70546. private _files;
  70547. private _extensions;
  70548. private _textureMatrix;
  70549. private _format;
  70550. private _createPolynomials;
  70551. /** @hidden */
  70552. _prefiltered: boolean;
  70553. /**
  70554. * Creates a cube texture from an array of image urls
  70555. * @param files defines an array of image urls
  70556. * @param scene defines the hosting scene
  70557. * @param noMipmap specifies if mip maps are not used
  70558. * @returns a cube texture
  70559. */
  70560. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  70561. /**
  70562. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  70563. * @param url defines the url of the prefiltered texture
  70564. * @param scene defines the scene the texture is attached to
  70565. * @param forcedExtension defines the extension of the file if different from the url
  70566. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  70567. * @return the prefiltered texture
  70568. */
  70569. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  70570. /**
  70571. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  70572. * as prefiltered data.
  70573. * @param rootUrl defines the url of the texture or the root name of the six images
  70574. * @param scene defines the scene the texture is attached to
  70575. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  70576. * @param noMipmap defines if mipmaps should be created or not
  70577. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  70578. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  70579. * @param onError defines a callback triggered in case of error during load
  70580. * @param format defines the internal format to use for the texture once loaded
  70581. * @param prefiltered defines whether or not the texture is created from prefiltered data
  70582. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  70583. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  70584. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  70585. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  70586. * @return the cube texture
  70587. */
  70588. 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);
  70589. /**
  70590. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  70591. */
  70592. readonly isPrefiltered: boolean;
  70593. /**
  70594. * Get the current class name of the texture useful for serialization or dynamic coding.
  70595. * @returns "CubeTexture"
  70596. */
  70597. getClassName(): string;
  70598. /**
  70599. * Update the url (and optional buffer) of this texture if url was null during construction.
  70600. * @param url the url of the texture
  70601. * @param forcedExtension defines the extension to use
  70602. * @param onLoad callback called when the texture is loaded (defaults to null)
  70603. */
  70604. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  70605. /**
  70606. * Delays loading of the cube texture
  70607. * @param forcedExtension defines the extension to use
  70608. */
  70609. delayLoad(forcedExtension?: string): void;
  70610. /**
  70611. * Returns the reflection texture matrix
  70612. * @returns the reflection texture matrix
  70613. */
  70614. getReflectionTextureMatrix(): Matrix;
  70615. /**
  70616. * Sets the reflection texture matrix
  70617. * @param value Reflection texture matrix
  70618. */
  70619. setReflectionTextureMatrix(value: Matrix): void;
  70620. /**
  70621. * Parses text to create a cube texture
  70622. * @param parsedTexture define the serialized text to read from
  70623. * @param scene defines the hosting scene
  70624. * @param rootUrl defines the root url of the cube texture
  70625. * @returns a cube texture
  70626. */
  70627. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  70628. /**
  70629. * Makes a clone, or deep copy, of the cube texture
  70630. * @returns a new cube texture
  70631. */
  70632. clone(): CubeTexture;
  70633. }
  70634. }
  70635. declare module BABYLON {
  70636. /** @hidden */
  70637. export var postprocessVertexShader: {
  70638. name: string;
  70639. shader: string;
  70640. };
  70641. }
  70642. declare module BABYLON {
  70643. /**
  70644. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  70645. * This is the base of the follow, arc rotate cameras and Free camera
  70646. * @see http://doc.babylonjs.com/features/cameras
  70647. */
  70648. export class TargetCamera extends Camera {
  70649. private static _RigCamTransformMatrix;
  70650. private static _TargetTransformMatrix;
  70651. private static _TargetFocalPoint;
  70652. /**
  70653. * Define the current direction the camera is moving to
  70654. */
  70655. cameraDirection: Vector3;
  70656. /**
  70657. * Define the current rotation the camera is rotating to
  70658. */
  70659. cameraRotation: Vector2;
  70660. /**
  70661. * When set, the up vector of the camera will be updated by the rotation of the camera
  70662. */
  70663. updateUpVectorFromRotation: boolean;
  70664. private _tmpQuaternion;
  70665. /**
  70666. * Define the current rotation of the camera
  70667. */
  70668. rotation: Vector3;
  70669. /**
  70670. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  70671. */
  70672. rotationQuaternion: Quaternion;
  70673. /**
  70674. * Define the current speed of the camera
  70675. */
  70676. speed: number;
  70677. /**
  70678. * Add cconstraint to the camera to prevent it to move freely in all directions and
  70679. * around all axis.
  70680. */
  70681. noRotationConstraint: boolean;
  70682. /**
  70683. * Define the current target of the camera as an object or a position.
  70684. */
  70685. lockedTarget: any;
  70686. /** @hidden */
  70687. _currentTarget: Vector3;
  70688. /** @hidden */
  70689. _initialFocalDistance: number;
  70690. /** @hidden */
  70691. _viewMatrix: Matrix;
  70692. /** @hidden */
  70693. _camMatrix: Matrix;
  70694. /** @hidden */
  70695. _cameraTransformMatrix: Matrix;
  70696. /** @hidden */
  70697. _cameraRotationMatrix: Matrix;
  70698. /** @hidden */
  70699. _referencePoint: Vector3;
  70700. /** @hidden */
  70701. _transformedReferencePoint: Vector3;
  70702. protected _globalCurrentTarget: Vector3;
  70703. protected _globalCurrentUpVector: Vector3;
  70704. /** @hidden */
  70705. _reset: () => void;
  70706. private _defaultUp;
  70707. /**
  70708. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  70709. * This is the base of the follow, arc rotate cameras and Free camera
  70710. * @see http://doc.babylonjs.com/features/cameras
  70711. * @param name Defines the name of the camera in the scene
  70712. * @param position Defines the start position of the camera in the scene
  70713. * @param scene Defines the scene the camera belongs to
  70714. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  70715. */
  70716. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  70717. /**
  70718. * Gets the position in front of the camera at a given distance.
  70719. * @param distance The distance from the camera we want the position to be
  70720. * @returns the position
  70721. */
  70722. getFrontPosition(distance: number): Vector3;
  70723. /** @hidden */
  70724. _getLockedTargetPosition(): Nullable<Vector3>;
  70725. private _storedPosition;
  70726. private _storedRotation;
  70727. private _storedRotationQuaternion;
  70728. /**
  70729. * Store current camera state of the camera (fov, position, rotation, etc..)
  70730. * @returns the camera
  70731. */
  70732. storeState(): Camera;
  70733. /**
  70734. * Restored camera state. You must call storeState() first
  70735. * @returns whether it was successful or not
  70736. * @hidden
  70737. */
  70738. _restoreStateValues(): boolean;
  70739. /** @hidden */
  70740. _initCache(): void;
  70741. /** @hidden */
  70742. _updateCache(ignoreParentClass?: boolean): void;
  70743. /** @hidden */
  70744. _isSynchronizedViewMatrix(): boolean;
  70745. /** @hidden */
  70746. _computeLocalCameraSpeed(): number;
  70747. /**
  70748. * Defines the target the camera should look at.
  70749. * This will automatically adapt alpha beta and radius to fit within the new target.
  70750. * @param target Defines the new target as a Vector or a mesh
  70751. */
  70752. setTarget(target: Vector3): void;
  70753. /**
  70754. * Return the current target position of the camera. This value is expressed in local space.
  70755. * @returns the target position
  70756. */
  70757. getTarget(): Vector3;
  70758. /** @hidden */
  70759. _decideIfNeedsToMove(): boolean;
  70760. /** @hidden */
  70761. _updatePosition(): void;
  70762. /** @hidden */
  70763. _checkInputs(): void;
  70764. protected _updateCameraRotationMatrix(): void;
  70765. /**
  70766. * 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)
  70767. * @returns the current camera
  70768. */
  70769. private _rotateUpVectorWithCameraRotationMatrix;
  70770. private _cachedRotationZ;
  70771. private _cachedQuaternionRotationZ;
  70772. /** @hidden */
  70773. _getViewMatrix(): Matrix;
  70774. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  70775. /**
  70776. * @hidden
  70777. */
  70778. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  70779. /**
  70780. * @hidden
  70781. */
  70782. _updateRigCameras(): void;
  70783. private _getRigCamPositionAndTarget;
  70784. /**
  70785. * Gets the current object class name.
  70786. * @return the class name
  70787. */
  70788. getClassName(): string;
  70789. }
  70790. }
  70791. declare module BABYLON {
  70792. /**
  70793. * @ignore
  70794. * This is a list of all the different input types that are available in the application.
  70795. * Fo instance: ArcRotateCameraGamepadInput...
  70796. */
  70797. export var CameraInputTypes: {};
  70798. /**
  70799. * This is the contract to implement in order to create a new input class.
  70800. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  70801. */
  70802. export interface ICameraInput<TCamera extends Camera> {
  70803. /**
  70804. * Defines the camera the input is attached to.
  70805. */
  70806. camera: Nullable<TCamera>;
  70807. /**
  70808. * Gets the class name of the current intput.
  70809. * @returns the class name
  70810. */
  70811. getClassName(): string;
  70812. /**
  70813. * Get the friendly name associated with the input class.
  70814. * @returns the input friendly name
  70815. */
  70816. getSimpleName(): string;
  70817. /**
  70818. * Attach the input controls to a specific dom element to get the input from.
  70819. * @param element Defines the element the controls should be listened from
  70820. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  70821. */
  70822. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  70823. /**
  70824. * Detach the current controls from the specified dom element.
  70825. * @param element Defines the element to stop listening the inputs from
  70826. */
  70827. detachControl(element: Nullable<HTMLElement>): void;
  70828. /**
  70829. * Update the current camera state depending on the inputs that have been used this frame.
  70830. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  70831. */
  70832. checkInputs?: () => void;
  70833. }
  70834. /**
  70835. * Represents a map of input types to input instance or input index to input instance.
  70836. */
  70837. export interface CameraInputsMap<TCamera extends Camera> {
  70838. /**
  70839. * Accessor to the input by input type.
  70840. */
  70841. [name: string]: ICameraInput<TCamera>;
  70842. /**
  70843. * Accessor to the input by input index.
  70844. */
  70845. [idx: number]: ICameraInput<TCamera>;
  70846. }
  70847. /**
  70848. * This represents the input manager used within a camera.
  70849. * It helps dealing with all the different kind of input attached to a camera.
  70850. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  70851. */
  70852. export class CameraInputsManager<TCamera extends Camera> {
  70853. /**
  70854. * Defines the list of inputs attahed to the camera.
  70855. */
  70856. attached: CameraInputsMap<TCamera>;
  70857. /**
  70858. * Defines the dom element the camera is collecting inputs from.
  70859. * This is null if the controls have not been attached.
  70860. */
  70861. attachedElement: Nullable<HTMLElement>;
  70862. /**
  70863. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  70864. */
  70865. noPreventDefault: boolean;
  70866. /**
  70867. * Defined the camera the input manager belongs to.
  70868. */
  70869. camera: TCamera;
  70870. /**
  70871. * Update the current camera state depending on the inputs that have been used this frame.
  70872. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  70873. */
  70874. checkInputs: () => void;
  70875. /**
  70876. * Instantiate a new Camera Input Manager.
  70877. * @param camera Defines the camera the input manager blongs to
  70878. */
  70879. constructor(camera: TCamera);
  70880. /**
  70881. * Add an input method to a camera
  70882. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  70883. * @param input camera input method
  70884. */
  70885. add(input: ICameraInput<TCamera>): void;
  70886. /**
  70887. * Remove a specific input method from a camera
  70888. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  70889. * @param inputToRemove camera input method
  70890. */
  70891. remove(inputToRemove: ICameraInput<TCamera>): void;
  70892. /**
  70893. * Remove a specific input type from a camera
  70894. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  70895. * @param inputType the type of the input to remove
  70896. */
  70897. removeByType(inputType: string): void;
  70898. private _addCheckInputs;
  70899. /**
  70900. * Attach the input controls to the currently attached dom element to listen the events from.
  70901. * @param input Defines the input to attach
  70902. */
  70903. attachInput(input: ICameraInput<TCamera>): void;
  70904. /**
  70905. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  70906. * @param element Defines the dom element to collect the events from
  70907. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  70908. */
  70909. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  70910. /**
  70911. * Detach the current manager inputs controls from a specific dom element.
  70912. * @param element Defines the dom element to collect the events from
  70913. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  70914. */
  70915. detachElement(element: HTMLElement, disconnect?: boolean): void;
  70916. /**
  70917. * Rebuild the dynamic inputCheck function from the current list of
  70918. * defined inputs in the manager.
  70919. */
  70920. rebuildInputCheck(): void;
  70921. /**
  70922. * Remove all attached input methods from a camera
  70923. */
  70924. clear(): void;
  70925. /**
  70926. * Serialize the current input manager attached to a camera.
  70927. * This ensures than once parsed,
  70928. * the input associated to the camera will be identical to the current ones
  70929. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  70930. */
  70931. serialize(serializedCamera: any): void;
  70932. /**
  70933. * Parses an input manager serialized JSON to restore the previous list of inputs
  70934. * and states associated to a camera.
  70935. * @param parsedCamera Defines the JSON to parse
  70936. */
  70937. parse(parsedCamera: any): void;
  70938. }
  70939. }
  70940. declare module BABYLON {
  70941. /**
  70942. * Gather the list of keyboard event types as constants.
  70943. */
  70944. export class KeyboardEventTypes {
  70945. /**
  70946. * The keydown event is fired when a key becomes active (pressed).
  70947. */
  70948. static readonly KEYDOWN: number;
  70949. /**
  70950. * The keyup event is fired when a key has been released.
  70951. */
  70952. static readonly KEYUP: number;
  70953. }
  70954. /**
  70955. * This class is used to store keyboard related info for the onKeyboardObservable event.
  70956. */
  70957. export class KeyboardInfo {
  70958. /**
  70959. * Defines the type of event (KeyboardEventTypes)
  70960. */
  70961. type: number;
  70962. /**
  70963. * Defines the related dom event
  70964. */
  70965. event: KeyboardEvent;
  70966. /**
  70967. * Instantiates a new keyboard info.
  70968. * This class is used to store keyboard related info for the onKeyboardObservable event.
  70969. * @param type Defines the type of event (KeyboardEventTypes)
  70970. * @param event Defines the related dom event
  70971. */
  70972. constructor(
  70973. /**
  70974. * Defines the type of event (KeyboardEventTypes)
  70975. */
  70976. type: number,
  70977. /**
  70978. * Defines the related dom event
  70979. */
  70980. event: KeyboardEvent);
  70981. }
  70982. /**
  70983. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  70984. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  70985. */
  70986. export class KeyboardInfoPre extends KeyboardInfo {
  70987. /**
  70988. * Defines the type of event (KeyboardEventTypes)
  70989. */
  70990. type: number;
  70991. /**
  70992. * Defines the related dom event
  70993. */
  70994. event: KeyboardEvent;
  70995. /**
  70996. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  70997. */
  70998. skipOnPointerObservable: boolean;
  70999. /**
  71000. * Instantiates a new keyboard pre info.
  71001. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  71002. * @param type Defines the type of event (KeyboardEventTypes)
  71003. * @param event Defines the related dom event
  71004. */
  71005. constructor(
  71006. /**
  71007. * Defines the type of event (KeyboardEventTypes)
  71008. */
  71009. type: number,
  71010. /**
  71011. * Defines the related dom event
  71012. */
  71013. event: KeyboardEvent);
  71014. }
  71015. }
  71016. declare module BABYLON {
  71017. /**
  71018. * Manage the keyboard inputs to control the movement of a free camera.
  71019. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  71020. */
  71021. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  71022. /**
  71023. * Defines the camera the input is attached to.
  71024. */
  71025. camera: FreeCamera;
  71026. /**
  71027. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  71028. */
  71029. keysUp: number[];
  71030. /**
  71031. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  71032. */
  71033. keysDown: number[];
  71034. /**
  71035. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  71036. */
  71037. keysLeft: number[];
  71038. /**
  71039. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  71040. */
  71041. keysRight: number[];
  71042. private _keys;
  71043. private _onCanvasBlurObserver;
  71044. private _onKeyboardObserver;
  71045. private _engine;
  71046. private _scene;
  71047. /**
  71048. * Attach the input controls to a specific dom element to get the input from.
  71049. * @param element Defines the element the controls should be listened from
  71050. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  71051. */
  71052. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  71053. /**
  71054. * Detach the current controls from the specified dom element.
  71055. * @param element Defines the element to stop listening the inputs from
  71056. */
  71057. detachControl(element: Nullable<HTMLElement>): void;
  71058. /**
  71059. * Update the current camera state depending on the inputs that have been used this frame.
  71060. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  71061. */
  71062. checkInputs(): void;
  71063. /**
  71064. * Gets the class name of the current intput.
  71065. * @returns the class name
  71066. */
  71067. getClassName(): string;
  71068. /** @hidden */
  71069. _onLostFocus(): void;
  71070. /**
  71071. * Get the friendly name associated with the input class.
  71072. * @returns the input friendly name
  71073. */
  71074. getSimpleName(): string;
  71075. }
  71076. }
  71077. declare module BABYLON {
  71078. /**
  71079. * Interface describing all the common properties and methods a shadow light needs to implement.
  71080. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  71081. * as well as binding the different shadow properties to the effects.
  71082. */
  71083. export interface IShadowLight extends Light {
  71084. /**
  71085. * The light id in the scene (used in scene.findLighById for instance)
  71086. */
  71087. id: string;
  71088. /**
  71089. * The position the shdow will be casted from.
  71090. */
  71091. position: Vector3;
  71092. /**
  71093. * In 2d mode (needCube being false), the direction used to cast the shadow.
  71094. */
  71095. direction: Vector3;
  71096. /**
  71097. * The transformed position. Position of the light in world space taking parenting in account.
  71098. */
  71099. transformedPosition: Vector3;
  71100. /**
  71101. * The transformed direction. Direction of the light in world space taking parenting in account.
  71102. */
  71103. transformedDirection: Vector3;
  71104. /**
  71105. * The friendly name of the light in the scene.
  71106. */
  71107. name: string;
  71108. /**
  71109. * Defines the shadow projection clipping minimum z value.
  71110. */
  71111. shadowMinZ: number;
  71112. /**
  71113. * Defines the shadow projection clipping maximum z value.
  71114. */
  71115. shadowMaxZ: number;
  71116. /**
  71117. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  71118. * @returns true if the information has been computed, false if it does not need to (no parenting)
  71119. */
  71120. computeTransformedInformation(): boolean;
  71121. /**
  71122. * Gets the scene the light belongs to.
  71123. * @returns The scene
  71124. */
  71125. getScene(): Scene;
  71126. /**
  71127. * Callback defining a custom Projection Matrix Builder.
  71128. * This can be used to override the default projection matrix computation.
  71129. */
  71130. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  71131. /**
  71132. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  71133. * @param matrix The materix to updated with the projection information
  71134. * @param viewMatrix The transform matrix of the light
  71135. * @param renderList The list of mesh to render in the map
  71136. * @returns The current light
  71137. */
  71138. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  71139. /**
  71140. * Gets the current depth scale used in ESM.
  71141. * @returns The scale
  71142. */
  71143. getDepthScale(): number;
  71144. /**
  71145. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  71146. * @returns true if a cube texture needs to be use
  71147. */
  71148. needCube(): boolean;
  71149. /**
  71150. * Detects if the projection matrix requires to be recomputed this frame.
  71151. * @returns true if it requires to be recomputed otherwise, false.
  71152. */
  71153. needProjectionMatrixCompute(): boolean;
  71154. /**
  71155. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  71156. */
  71157. forceProjectionMatrixCompute(): void;
  71158. /**
  71159. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  71160. * @param faceIndex The index of the face we are computed the direction to generate shadow
  71161. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  71162. */
  71163. getShadowDirection(faceIndex?: number): Vector3;
  71164. /**
  71165. * Gets the minZ used for shadow according to both the scene and the light.
  71166. * @param activeCamera The camera we are returning the min for
  71167. * @returns the depth min z
  71168. */
  71169. getDepthMinZ(activeCamera: Camera): number;
  71170. /**
  71171. * Gets the maxZ used for shadow according to both the scene and the light.
  71172. * @param activeCamera The camera we are returning the max for
  71173. * @returns the depth max z
  71174. */
  71175. getDepthMaxZ(activeCamera: Camera): number;
  71176. }
  71177. /**
  71178. * Base implementation IShadowLight
  71179. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  71180. */
  71181. export abstract class ShadowLight extends Light implements IShadowLight {
  71182. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  71183. protected _position: Vector3;
  71184. protected _setPosition(value: Vector3): void;
  71185. /**
  71186. * Sets the position the shadow will be casted from. Also use as the light position for both
  71187. * point and spot lights.
  71188. */
  71189. /**
  71190. * Sets the position the shadow will be casted from. Also use as the light position for both
  71191. * point and spot lights.
  71192. */
  71193. position: Vector3;
  71194. protected _direction: Vector3;
  71195. protected _setDirection(value: Vector3): void;
  71196. /**
  71197. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  71198. * Also use as the light direction on spot and directional lights.
  71199. */
  71200. /**
  71201. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  71202. * Also use as the light direction on spot and directional lights.
  71203. */
  71204. direction: Vector3;
  71205. private _shadowMinZ;
  71206. /**
  71207. * Gets the shadow projection clipping minimum z value.
  71208. */
  71209. /**
  71210. * Sets the shadow projection clipping minimum z value.
  71211. */
  71212. shadowMinZ: number;
  71213. private _shadowMaxZ;
  71214. /**
  71215. * Sets the shadow projection clipping maximum z value.
  71216. */
  71217. /**
  71218. * Gets the shadow projection clipping maximum z value.
  71219. */
  71220. shadowMaxZ: number;
  71221. /**
  71222. * Callback defining a custom Projection Matrix Builder.
  71223. * This can be used to override the default projection matrix computation.
  71224. */
  71225. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  71226. /**
  71227. * The transformed position. Position of the light in world space taking parenting in account.
  71228. */
  71229. transformedPosition: Vector3;
  71230. /**
  71231. * The transformed direction. Direction of the light in world space taking parenting in account.
  71232. */
  71233. transformedDirection: Vector3;
  71234. private _needProjectionMatrixCompute;
  71235. /**
  71236. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  71237. * @returns true if the information has been computed, false if it does not need to (no parenting)
  71238. */
  71239. computeTransformedInformation(): boolean;
  71240. /**
  71241. * Return the depth scale used for the shadow map.
  71242. * @returns the depth scale.
  71243. */
  71244. getDepthScale(): number;
  71245. /**
  71246. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  71247. * @param faceIndex The index of the face we are computed the direction to generate shadow
  71248. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  71249. */
  71250. getShadowDirection(faceIndex?: number): Vector3;
  71251. /**
  71252. * Returns the ShadowLight absolute position in the World.
  71253. * @returns the position vector in world space
  71254. */
  71255. getAbsolutePosition(): Vector3;
  71256. /**
  71257. * Sets the ShadowLight direction toward the passed target.
  71258. * @param target The point to target in local space
  71259. * @returns the updated ShadowLight direction
  71260. */
  71261. setDirectionToTarget(target: Vector3): Vector3;
  71262. /**
  71263. * Returns the light rotation in euler definition.
  71264. * @returns the x y z rotation in local space.
  71265. */
  71266. getRotation(): Vector3;
  71267. /**
  71268. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  71269. * @returns true if a cube texture needs to be use
  71270. */
  71271. needCube(): boolean;
  71272. /**
  71273. * Detects if the projection matrix requires to be recomputed this frame.
  71274. * @returns true if it requires to be recomputed otherwise, false.
  71275. */
  71276. needProjectionMatrixCompute(): boolean;
  71277. /**
  71278. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  71279. */
  71280. forceProjectionMatrixCompute(): void;
  71281. /** @hidden */
  71282. _initCache(): void;
  71283. /** @hidden */
  71284. _isSynchronized(): boolean;
  71285. /**
  71286. * Computes the world matrix of the node
  71287. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  71288. * @returns the world matrix
  71289. */
  71290. computeWorldMatrix(force?: boolean): Matrix;
  71291. /**
  71292. * Gets the minZ used for shadow according to both the scene and the light.
  71293. * @param activeCamera The camera we are returning the min for
  71294. * @returns the depth min z
  71295. */
  71296. getDepthMinZ(activeCamera: Camera): number;
  71297. /**
  71298. * Gets the maxZ used for shadow according to both the scene and the light.
  71299. * @param activeCamera The camera we are returning the max for
  71300. * @returns the depth max z
  71301. */
  71302. getDepthMaxZ(activeCamera: Camera): number;
  71303. /**
  71304. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  71305. * @param matrix The materix to updated with the projection information
  71306. * @param viewMatrix The transform matrix of the light
  71307. * @param renderList The list of mesh to render in the map
  71308. * @returns The current light
  71309. */
  71310. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  71311. }
  71312. }
  71313. declare module BABYLON {
  71314. /**
  71315. * "Static Class" containing the most commonly used helper while dealing with material for
  71316. * rendering purpose.
  71317. *
  71318. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  71319. *
  71320. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  71321. */
  71322. export class MaterialHelper {
  71323. /**
  71324. * Bind the current view position to an effect.
  71325. * @param effect The effect to be bound
  71326. * @param scene The scene the eyes position is used from
  71327. */
  71328. static BindEyePosition(effect: Effect, scene: Scene): void;
  71329. /**
  71330. * Helps preparing the defines values about the UVs in used in the effect.
  71331. * UVs are shared as much as we can accross channels in the shaders.
  71332. * @param texture The texture we are preparing the UVs for
  71333. * @param defines The defines to update
  71334. * @param key The channel key "diffuse", "specular"... used in the shader
  71335. */
  71336. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  71337. /**
  71338. * Binds a texture matrix value to its corrsponding uniform
  71339. * @param texture The texture to bind the matrix for
  71340. * @param uniformBuffer The uniform buffer receivin the data
  71341. * @param key The channel key "diffuse", "specular"... used in the shader
  71342. */
  71343. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  71344. /**
  71345. * Gets the current status of the fog (should it be enabled?)
  71346. * @param mesh defines the mesh to evaluate for fog support
  71347. * @param scene defines the hosting scene
  71348. * @returns true if fog must be enabled
  71349. */
  71350. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  71351. /**
  71352. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  71353. * @param mesh defines the current mesh
  71354. * @param scene defines the current scene
  71355. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  71356. * @param pointsCloud defines if point cloud rendering has to be turned on
  71357. * @param fogEnabled defines if fog has to be turned on
  71358. * @param alphaTest defines if alpha testing has to be turned on
  71359. * @param defines defines the current list of defines
  71360. */
  71361. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  71362. /**
  71363. * Helper used to prepare the list of defines associated with frame values for shader compilation
  71364. * @param scene defines the current scene
  71365. * @param engine defines the current engine
  71366. * @param defines specifies the list of active defines
  71367. * @param useInstances defines if instances have to be turned on
  71368. * @param useClipPlane defines if clip plane have to be turned on
  71369. */
  71370. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  71371. /**
  71372. * Prepares the defines for bones
  71373. * @param mesh The mesh containing the geometry data we will draw
  71374. * @param defines The defines to update
  71375. */
  71376. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  71377. /**
  71378. * Prepares the defines for morph targets
  71379. * @param mesh The mesh containing the geometry data we will draw
  71380. * @param defines The defines to update
  71381. */
  71382. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  71383. /**
  71384. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  71385. * @param mesh The mesh containing the geometry data we will draw
  71386. * @param defines The defines to update
  71387. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  71388. * @param useBones Precise whether bones should be used or not (override mesh info)
  71389. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  71390. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  71391. * @returns false if defines are considered not dirty and have not been checked
  71392. */
  71393. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  71394. /**
  71395. * Prepares the defines related to multiview
  71396. * @param scene The scene we are intending to draw
  71397. * @param defines The defines to update
  71398. */
  71399. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  71400. /**
  71401. * Prepares the defines related to the light information passed in parameter
  71402. * @param scene The scene we are intending to draw
  71403. * @param mesh The mesh the effect is compiling for
  71404. * @param defines The defines to update
  71405. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  71406. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  71407. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  71408. * @returns true if normals will be required for the rest of the effect
  71409. */
  71410. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  71411. /**
  71412. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  71413. * that won t be acctive due to defines being turned off.
  71414. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  71415. * @param samplersList The samplers list
  71416. * @param defines The defines helping in the list generation
  71417. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  71418. */
  71419. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  71420. /**
  71421. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  71422. * @param defines The defines to update while falling back
  71423. * @param fallbacks The authorized effect fallbacks
  71424. * @param maxSimultaneousLights The maximum number of lights allowed
  71425. * @param rank the current rank of the Effect
  71426. * @returns The newly affected rank
  71427. */
  71428. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  71429. /**
  71430. * Prepares the list of attributes required for morph targets according to the effect defines.
  71431. * @param attribs The current list of supported attribs
  71432. * @param mesh The mesh to prepare the morph targets attributes for
  71433. * @param defines The current Defines of the effect
  71434. */
  71435. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  71436. /**
  71437. * Prepares the list of attributes required for bones according to the effect defines.
  71438. * @param attribs The current list of supported attribs
  71439. * @param mesh The mesh to prepare the bones attributes for
  71440. * @param defines The current Defines of the effect
  71441. * @param fallbacks The current efffect fallback strategy
  71442. */
  71443. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  71444. /**
  71445. * Check and prepare the list of attributes required for instances according to the effect defines.
  71446. * @param attribs The current list of supported attribs
  71447. * @param defines The current MaterialDefines of the effect
  71448. */
  71449. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  71450. /**
  71451. * Add the list of attributes required for instances to the attribs array.
  71452. * @param attribs The current list of supported attribs
  71453. */
  71454. static PushAttributesForInstances(attribs: string[]): void;
  71455. /**
  71456. * Binds the light shadow information to the effect for the given mesh.
  71457. * @param light The light containing the generator
  71458. * @param scene The scene the lights belongs to
  71459. * @param mesh The mesh we are binding the information to render
  71460. * @param lightIndex The light index in the effect used to render the mesh
  71461. * @param effect The effect we are binding the data to
  71462. */
  71463. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  71464. /**
  71465. * Binds the light information to the effect.
  71466. * @param light The light containing the generator
  71467. * @param effect The effect we are binding the data to
  71468. * @param lightIndex The light index in the effect used to render
  71469. */
  71470. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  71471. /**
  71472. * Binds the lights information from the scene to the effect for the given mesh.
  71473. * @param scene The scene the lights belongs to
  71474. * @param mesh The mesh we are binding the information to render
  71475. * @param effect The effect we are binding the data to
  71476. * @param defines The generated defines for the effect
  71477. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  71478. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  71479. */
  71480. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  71481. private static _tempFogColor;
  71482. /**
  71483. * Binds the fog information from the scene to the effect for the given mesh.
  71484. * @param scene The scene the lights belongs to
  71485. * @param mesh The mesh we are binding the information to render
  71486. * @param effect The effect we are binding the data to
  71487. * @param linearSpace Defines if the fog effect is applied in linear space
  71488. */
  71489. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  71490. /**
  71491. * Binds the bones information from the mesh to the effect.
  71492. * @param mesh The mesh we are binding the information to render
  71493. * @param effect The effect we are binding the data to
  71494. */
  71495. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  71496. /**
  71497. * Binds the morph targets information from the mesh to the effect.
  71498. * @param abstractMesh The mesh we are binding the information to render
  71499. * @param effect The effect we are binding the data to
  71500. */
  71501. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  71502. /**
  71503. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  71504. * @param defines The generated defines used in the effect
  71505. * @param effect The effect we are binding the data to
  71506. * @param scene The scene we are willing to render with logarithmic scale for
  71507. */
  71508. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  71509. /**
  71510. * Binds the clip plane information from the scene to the effect.
  71511. * @param scene The scene the clip plane information are extracted from
  71512. * @param effect The effect we are binding the data to
  71513. */
  71514. static BindClipPlane(effect: Effect, scene: Scene): void;
  71515. }
  71516. }
  71517. declare module BABYLON {
  71518. /** @hidden */
  71519. export var kernelBlurVaryingDeclaration: {
  71520. name: string;
  71521. shader: string;
  71522. };
  71523. }
  71524. declare module BABYLON {
  71525. /** @hidden */
  71526. export var kernelBlurFragment: {
  71527. name: string;
  71528. shader: string;
  71529. };
  71530. }
  71531. declare module BABYLON {
  71532. /** @hidden */
  71533. export var kernelBlurFragment2: {
  71534. name: string;
  71535. shader: string;
  71536. };
  71537. }
  71538. declare module BABYLON {
  71539. /** @hidden */
  71540. export var kernelBlurPixelShader: {
  71541. name: string;
  71542. shader: string;
  71543. };
  71544. }
  71545. declare module BABYLON {
  71546. /** @hidden */
  71547. export var kernelBlurVertex: {
  71548. name: string;
  71549. shader: string;
  71550. };
  71551. }
  71552. declare module BABYLON {
  71553. /** @hidden */
  71554. export var kernelBlurVertexShader: {
  71555. name: string;
  71556. shader: string;
  71557. };
  71558. }
  71559. declare module BABYLON {
  71560. /**
  71561. * The Blur Post Process which blurs an image based on a kernel and direction.
  71562. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  71563. */
  71564. export class BlurPostProcess extends PostProcess {
  71565. /** The direction in which to blur the image. */
  71566. direction: Vector2;
  71567. private blockCompilation;
  71568. protected _kernel: number;
  71569. protected _idealKernel: number;
  71570. protected _packedFloat: boolean;
  71571. private _staticDefines;
  71572. /**
  71573. * Sets the length in pixels of the blur sample region
  71574. */
  71575. /**
  71576. * Gets the length in pixels of the blur sample region
  71577. */
  71578. kernel: number;
  71579. /**
  71580. * Sets wether or not the blur needs to unpack/repack floats
  71581. */
  71582. /**
  71583. * Gets wether or not the blur is unpacking/repacking floats
  71584. */
  71585. packedFloat: boolean;
  71586. /**
  71587. * Creates a new instance BlurPostProcess
  71588. * @param name The name of the effect.
  71589. * @param direction The direction in which to blur the image.
  71590. * @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.
  71591. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  71592. * @param camera The camera to apply the render pass to.
  71593. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71594. * @param engine The engine which the post process will be applied. (default: current engine)
  71595. * @param reusable If the post process can be reused on the same frame. (default: false)
  71596. * @param textureType Type of textures used when performing the post process. (default: 0)
  71597. * @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)
  71598. */
  71599. constructor(name: string,
  71600. /** The direction in which to blur the image. */
  71601. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  71602. /**
  71603. * Updates the effect with the current post process compile time values and recompiles the shader.
  71604. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  71605. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  71606. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  71607. * @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
  71608. * @param onCompiled Called when the shader has been compiled.
  71609. * @param onError Called if there is an error when compiling a shader.
  71610. */
  71611. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  71612. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  71613. /**
  71614. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  71615. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  71616. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  71617. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  71618. * The gaps between physical kernels are compensated for in the weighting of the samples
  71619. * @param idealKernel Ideal blur kernel.
  71620. * @return Nearest best kernel.
  71621. */
  71622. protected _nearestBestKernel(idealKernel: number): number;
  71623. /**
  71624. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  71625. * @param x The point on the Gaussian distribution to sample.
  71626. * @return the value of the Gaussian function at x.
  71627. */
  71628. protected _gaussianWeight(x: number): number;
  71629. /**
  71630. * Generates a string that can be used as a floating point number in GLSL.
  71631. * @param x Value to print.
  71632. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  71633. * @return GLSL float string.
  71634. */
  71635. protected _glslFloat(x: number, decimalFigures?: number): string;
  71636. }
  71637. }
  71638. declare module BABYLON {
  71639. /** @hidden */
  71640. export var shadowMapPixelShader: {
  71641. name: string;
  71642. shader: string;
  71643. };
  71644. }
  71645. declare module BABYLON {
  71646. /** @hidden */
  71647. export var bonesDeclaration: {
  71648. name: string;
  71649. shader: string;
  71650. };
  71651. }
  71652. declare module BABYLON {
  71653. /** @hidden */
  71654. export var morphTargetsVertexGlobalDeclaration: {
  71655. name: string;
  71656. shader: string;
  71657. };
  71658. }
  71659. declare module BABYLON {
  71660. /** @hidden */
  71661. export var morphTargetsVertexDeclaration: {
  71662. name: string;
  71663. shader: string;
  71664. };
  71665. }
  71666. declare module BABYLON {
  71667. /** @hidden */
  71668. export var instancesDeclaration: {
  71669. name: string;
  71670. shader: string;
  71671. };
  71672. }
  71673. declare module BABYLON {
  71674. /** @hidden */
  71675. export var helperFunctions: {
  71676. name: string;
  71677. shader: string;
  71678. };
  71679. }
  71680. declare module BABYLON {
  71681. /** @hidden */
  71682. export var morphTargetsVertex: {
  71683. name: string;
  71684. shader: string;
  71685. };
  71686. }
  71687. declare module BABYLON {
  71688. /** @hidden */
  71689. export var instancesVertex: {
  71690. name: string;
  71691. shader: string;
  71692. };
  71693. }
  71694. declare module BABYLON {
  71695. /** @hidden */
  71696. export var bonesVertex: {
  71697. name: string;
  71698. shader: string;
  71699. };
  71700. }
  71701. declare module BABYLON {
  71702. /** @hidden */
  71703. export var shadowMapVertexShader: {
  71704. name: string;
  71705. shader: string;
  71706. };
  71707. }
  71708. declare module BABYLON {
  71709. /** @hidden */
  71710. export var depthBoxBlurPixelShader: {
  71711. name: string;
  71712. shader: string;
  71713. };
  71714. }
  71715. declare module BABYLON {
  71716. /**
  71717. * Defines the options associated with the creation of a custom shader for a shadow generator.
  71718. */
  71719. export interface ICustomShaderOptions {
  71720. /**
  71721. * Gets or sets the custom shader name to use
  71722. */
  71723. shaderName: string;
  71724. /**
  71725. * The list of attribute names used in the shader
  71726. */
  71727. attributes?: string[];
  71728. /**
  71729. * The list of unifrom names used in the shader
  71730. */
  71731. uniforms?: string[];
  71732. /**
  71733. * The list of sampler names used in the shader
  71734. */
  71735. samplers?: string[];
  71736. /**
  71737. * The list of defines used in the shader
  71738. */
  71739. defines?: string[];
  71740. }
  71741. /**
  71742. * Interface to implement to create a shadow generator compatible with BJS.
  71743. */
  71744. export interface IShadowGenerator {
  71745. /**
  71746. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  71747. * @returns The render target texture if present otherwise, null
  71748. */
  71749. getShadowMap(): Nullable<RenderTargetTexture>;
  71750. /**
  71751. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  71752. * @returns The render target texture if the shadow map is present otherwise, null
  71753. */
  71754. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  71755. /**
  71756. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  71757. * @param subMesh The submesh we want to render in the shadow map
  71758. * @param useInstances Defines wether will draw in the map using instances
  71759. * @returns true if ready otherwise, false
  71760. */
  71761. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  71762. /**
  71763. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  71764. * @param defines Defines of the material we want to update
  71765. * @param lightIndex Index of the light in the enabled light list of the material
  71766. */
  71767. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  71768. /**
  71769. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  71770. * defined in the generator but impacting the effect).
  71771. * It implies the unifroms available on the materials are the standard BJS ones.
  71772. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  71773. * @param effect The effect we are binfing the information for
  71774. */
  71775. bindShadowLight(lightIndex: string, effect: Effect): void;
  71776. /**
  71777. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  71778. * (eq to shadow prjection matrix * light transform matrix)
  71779. * @returns The transform matrix used to create the shadow map
  71780. */
  71781. getTransformMatrix(): Matrix;
  71782. /**
  71783. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  71784. * Cube and 2D textures for instance.
  71785. */
  71786. recreateShadowMap(): void;
  71787. /**
  71788. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  71789. * @param onCompiled Callback triggered at the and of the effects compilation
  71790. * @param options Sets of optional options forcing the compilation with different modes
  71791. */
  71792. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  71793. useInstances: boolean;
  71794. }>): void;
  71795. /**
  71796. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  71797. * @param options Sets of optional options forcing the compilation with different modes
  71798. * @returns A promise that resolves when the compilation completes
  71799. */
  71800. forceCompilationAsync(options?: Partial<{
  71801. useInstances: boolean;
  71802. }>): Promise<void>;
  71803. /**
  71804. * Serializes the shadow generator setup to a json object.
  71805. * @returns The serialized JSON object
  71806. */
  71807. serialize(): any;
  71808. /**
  71809. * Disposes the Shadow map and related Textures and effects.
  71810. */
  71811. dispose(): void;
  71812. }
  71813. /**
  71814. * Default implementation IShadowGenerator.
  71815. * This is the main object responsible of generating shadows in the framework.
  71816. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  71817. */
  71818. export class ShadowGenerator implements IShadowGenerator {
  71819. /**
  71820. * Shadow generator mode None: no filtering applied.
  71821. */
  71822. static readonly FILTER_NONE: number;
  71823. /**
  71824. * Shadow generator mode ESM: Exponential Shadow Mapping.
  71825. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  71826. */
  71827. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  71828. /**
  71829. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  71830. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  71831. */
  71832. static readonly FILTER_POISSONSAMPLING: number;
  71833. /**
  71834. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  71835. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  71836. */
  71837. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  71838. /**
  71839. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  71840. * edge artifacts on steep falloff.
  71841. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  71842. */
  71843. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  71844. /**
  71845. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  71846. * edge artifacts on steep falloff.
  71847. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  71848. */
  71849. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  71850. /**
  71851. * Shadow generator mode PCF: Percentage Closer Filtering
  71852. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  71853. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  71854. */
  71855. static readonly FILTER_PCF: number;
  71856. /**
  71857. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  71858. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  71859. * Contact Hardening
  71860. */
  71861. static readonly FILTER_PCSS: number;
  71862. /**
  71863. * Reserved for PCF and PCSS
  71864. * Highest Quality.
  71865. *
  71866. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  71867. *
  71868. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  71869. */
  71870. static readonly QUALITY_HIGH: number;
  71871. /**
  71872. * Reserved for PCF and PCSS
  71873. * Good tradeoff for quality/perf cross devices
  71874. *
  71875. * Execute PCF on a 3*3 kernel.
  71876. *
  71877. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  71878. */
  71879. static readonly QUALITY_MEDIUM: number;
  71880. /**
  71881. * Reserved for PCF and PCSS
  71882. * The lowest quality but the fastest.
  71883. *
  71884. * Execute PCF on a 1*1 kernel.
  71885. *
  71886. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  71887. */
  71888. static readonly QUALITY_LOW: number;
  71889. /** Gets or sets the custom shader name to use */
  71890. customShaderOptions: ICustomShaderOptions;
  71891. /**
  71892. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  71893. */
  71894. onBeforeShadowMapRenderObservable: Observable<Effect>;
  71895. /**
  71896. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  71897. */
  71898. onAfterShadowMapRenderObservable: Observable<Effect>;
  71899. /**
  71900. * Observable triggered before a mesh is rendered in the shadow map.
  71901. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  71902. */
  71903. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  71904. /**
  71905. * Observable triggered after a mesh is rendered in the shadow map.
  71906. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  71907. */
  71908. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  71909. private _bias;
  71910. /**
  71911. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  71912. */
  71913. /**
  71914. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  71915. */
  71916. bias: number;
  71917. private _normalBias;
  71918. /**
  71919. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  71920. */
  71921. /**
  71922. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  71923. */
  71924. normalBias: number;
  71925. private _blurBoxOffset;
  71926. /**
  71927. * Gets the blur box offset: offset applied during the blur pass.
  71928. * Only useful if useKernelBlur = false
  71929. */
  71930. /**
  71931. * Sets the blur box offset: offset applied during the blur pass.
  71932. * Only useful if useKernelBlur = false
  71933. */
  71934. blurBoxOffset: number;
  71935. private _blurScale;
  71936. /**
  71937. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  71938. * 2 means half of the size.
  71939. */
  71940. /**
  71941. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  71942. * 2 means half of the size.
  71943. */
  71944. blurScale: number;
  71945. private _blurKernel;
  71946. /**
  71947. * Gets the blur kernel: kernel size of the blur pass.
  71948. * Only useful if useKernelBlur = true
  71949. */
  71950. /**
  71951. * Sets the blur kernel: kernel size of the blur pass.
  71952. * Only useful if useKernelBlur = true
  71953. */
  71954. blurKernel: number;
  71955. private _useKernelBlur;
  71956. /**
  71957. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  71958. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  71959. */
  71960. /**
  71961. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  71962. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  71963. */
  71964. useKernelBlur: boolean;
  71965. private _depthScale;
  71966. /**
  71967. * Gets the depth scale used in ESM mode.
  71968. */
  71969. /**
  71970. * Sets the depth scale used in ESM mode.
  71971. * This can override the scale stored on the light.
  71972. */
  71973. depthScale: number;
  71974. private _filter;
  71975. /**
  71976. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  71977. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  71978. */
  71979. /**
  71980. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  71981. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  71982. */
  71983. filter: number;
  71984. /**
  71985. * Gets if the current filter is set to Poisson Sampling.
  71986. */
  71987. /**
  71988. * Sets the current filter to Poisson Sampling.
  71989. */
  71990. usePoissonSampling: boolean;
  71991. /**
  71992. * Gets if the current filter is set to ESM.
  71993. */
  71994. /**
  71995. * Sets the current filter is to ESM.
  71996. */
  71997. useExponentialShadowMap: boolean;
  71998. /**
  71999. * Gets if the current filter is set to filtered ESM.
  72000. */
  72001. /**
  72002. * Gets if the current filter is set to filtered ESM.
  72003. */
  72004. useBlurExponentialShadowMap: boolean;
  72005. /**
  72006. * Gets if the current filter is set to "close ESM" (using the inverse of the
  72007. * exponential to prevent steep falloff artifacts).
  72008. */
  72009. /**
  72010. * Sets the current filter to "close ESM" (using the inverse of the
  72011. * exponential to prevent steep falloff artifacts).
  72012. */
  72013. useCloseExponentialShadowMap: boolean;
  72014. /**
  72015. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  72016. * exponential to prevent steep falloff artifacts).
  72017. */
  72018. /**
  72019. * Sets the current filter to filtered "close ESM" (using the inverse of the
  72020. * exponential to prevent steep falloff artifacts).
  72021. */
  72022. useBlurCloseExponentialShadowMap: boolean;
  72023. /**
  72024. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  72025. */
  72026. /**
  72027. * Sets the current filter to "PCF" (percentage closer filtering).
  72028. */
  72029. usePercentageCloserFiltering: boolean;
  72030. private _filteringQuality;
  72031. /**
  72032. * Gets the PCF or PCSS Quality.
  72033. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  72034. */
  72035. /**
  72036. * Sets the PCF or PCSS Quality.
  72037. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  72038. */
  72039. filteringQuality: number;
  72040. /**
  72041. * Gets if the current filter is set to "PCSS" (contact hardening).
  72042. */
  72043. /**
  72044. * Sets the current filter to "PCSS" (contact hardening).
  72045. */
  72046. useContactHardeningShadow: boolean;
  72047. private _contactHardeningLightSizeUVRatio;
  72048. /**
  72049. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  72050. * Using a ratio helps keeping shape stability independently of the map size.
  72051. *
  72052. * It does not account for the light projection as it was having too much
  72053. * instability during the light setup or during light position changes.
  72054. *
  72055. * Only valid if useContactHardeningShadow is true.
  72056. */
  72057. /**
  72058. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  72059. * Using a ratio helps keeping shape stability independently of the map size.
  72060. *
  72061. * It does not account for the light projection as it was having too much
  72062. * instability during the light setup or during light position changes.
  72063. *
  72064. * Only valid if useContactHardeningShadow is true.
  72065. */
  72066. contactHardeningLightSizeUVRatio: number;
  72067. private _darkness;
  72068. /** Gets or sets the actual darkness of a shadow */
  72069. darkness: number;
  72070. /**
  72071. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  72072. * 0 means strongest and 1 would means no shadow.
  72073. * @returns the darkness.
  72074. */
  72075. getDarkness(): number;
  72076. /**
  72077. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  72078. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  72079. * @returns the shadow generator allowing fluent coding.
  72080. */
  72081. setDarkness(darkness: number): ShadowGenerator;
  72082. private _transparencyShadow;
  72083. /** Gets or sets the ability to have transparent shadow */
  72084. transparencyShadow: boolean;
  72085. /**
  72086. * Sets the ability to have transparent shadow (boolean).
  72087. * @param transparent True if transparent else False
  72088. * @returns the shadow generator allowing fluent coding
  72089. */
  72090. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  72091. private _shadowMap;
  72092. private _shadowMap2;
  72093. /**
  72094. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  72095. * @returns The render target texture if present otherwise, null
  72096. */
  72097. getShadowMap(): Nullable<RenderTargetTexture>;
  72098. /**
  72099. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  72100. * @returns The render target texture if the shadow map is present otherwise, null
  72101. */
  72102. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  72103. /**
  72104. * Gets the class name of that object
  72105. * @returns "ShadowGenerator"
  72106. */
  72107. getClassName(): string;
  72108. /**
  72109. * Helper function to add a mesh and its descendants to the list of shadow casters.
  72110. * @param mesh Mesh to add
  72111. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  72112. * @returns the Shadow Generator itself
  72113. */
  72114. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  72115. /**
  72116. * Helper function to remove a mesh and its descendants from the list of shadow casters
  72117. * @param mesh Mesh to remove
  72118. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  72119. * @returns the Shadow Generator itself
  72120. */
  72121. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  72122. /**
  72123. * Controls the extent to which the shadows fade out at the edge of the frustum
  72124. * Used only by directionals and spots
  72125. */
  72126. frustumEdgeFalloff: number;
  72127. private _light;
  72128. /**
  72129. * Returns the associated light object.
  72130. * @returns the light generating the shadow
  72131. */
  72132. getLight(): IShadowLight;
  72133. /**
  72134. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  72135. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  72136. * It might on the other hand introduce peter panning.
  72137. */
  72138. forceBackFacesOnly: boolean;
  72139. private _scene;
  72140. private _lightDirection;
  72141. private _effect;
  72142. private _viewMatrix;
  72143. private _projectionMatrix;
  72144. private _transformMatrix;
  72145. private _cachedPosition;
  72146. private _cachedDirection;
  72147. private _cachedDefines;
  72148. private _currentRenderID;
  72149. private _boxBlurPostprocess;
  72150. private _kernelBlurXPostprocess;
  72151. private _kernelBlurYPostprocess;
  72152. private _blurPostProcesses;
  72153. private _mapSize;
  72154. private _currentFaceIndex;
  72155. private _currentFaceIndexCache;
  72156. private _textureType;
  72157. private _defaultTextureMatrix;
  72158. /** @hidden */
  72159. static _SceneComponentInitialization: (scene: Scene) => void;
  72160. /**
  72161. * Creates a ShadowGenerator object.
  72162. * A ShadowGenerator is the required tool to use the shadows.
  72163. * Each light casting shadows needs to use its own ShadowGenerator.
  72164. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  72165. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  72166. * @param light The light object generating the shadows.
  72167. * @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.
  72168. */
  72169. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  72170. private _initializeGenerator;
  72171. private _initializeShadowMap;
  72172. private _initializeBlurRTTAndPostProcesses;
  72173. private _renderForShadowMap;
  72174. private _renderSubMeshForShadowMap;
  72175. private _applyFilterValues;
  72176. /**
  72177. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  72178. * @param onCompiled Callback triggered at the and of the effects compilation
  72179. * @param options Sets of optional options forcing the compilation with different modes
  72180. */
  72181. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  72182. useInstances: boolean;
  72183. }>): void;
  72184. /**
  72185. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  72186. * @param options Sets of optional options forcing the compilation with different modes
  72187. * @returns A promise that resolves when the compilation completes
  72188. */
  72189. forceCompilationAsync(options?: Partial<{
  72190. useInstances: boolean;
  72191. }>): Promise<void>;
  72192. /**
  72193. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  72194. * @param subMesh The submesh we want to render in the shadow map
  72195. * @param useInstances Defines wether will draw in the map using instances
  72196. * @returns true if ready otherwise, false
  72197. */
  72198. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  72199. /**
  72200. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  72201. * @param defines Defines of the material we want to update
  72202. * @param lightIndex Index of the light in the enabled light list of the material
  72203. */
  72204. prepareDefines(defines: any, lightIndex: number): void;
  72205. /**
  72206. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  72207. * defined in the generator but impacting the effect).
  72208. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  72209. * @param effect The effect we are binfing the information for
  72210. */
  72211. bindShadowLight(lightIndex: string, effect: Effect): void;
  72212. /**
  72213. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  72214. * (eq to shadow prjection matrix * light transform matrix)
  72215. * @returns The transform matrix used to create the shadow map
  72216. */
  72217. getTransformMatrix(): Matrix;
  72218. /**
  72219. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  72220. * Cube and 2D textures for instance.
  72221. */
  72222. recreateShadowMap(): void;
  72223. private _disposeBlurPostProcesses;
  72224. private _disposeRTTandPostProcesses;
  72225. /**
  72226. * Disposes the ShadowGenerator.
  72227. * Returns nothing.
  72228. */
  72229. dispose(): void;
  72230. /**
  72231. * Serializes the shadow generator setup to a json object.
  72232. * @returns The serialized JSON object
  72233. */
  72234. serialize(): any;
  72235. /**
  72236. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  72237. * @param parsedShadowGenerator The JSON object to parse
  72238. * @param scene The scene to create the shadow map for
  72239. * @returns The parsed shadow generator
  72240. */
  72241. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  72242. }
  72243. }
  72244. declare module BABYLON {
  72245. /**
  72246. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  72247. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  72248. * 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.
  72249. */
  72250. export abstract class Light extends Node {
  72251. /**
  72252. * Falloff Default: light is falling off following the material specification:
  72253. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  72254. */
  72255. static readonly FALLOFF_DEFAULT: number;
  72256. /**
  72257. * Falloff Physical: light is falling off following the inverse squared distance law.
  72258. */
  72259. static readonly FALLOFF_PHYSICAL: number;
  72260. /**
  72261. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  72262. * to enhance interoperability with other engines.
  72263. */
  72264. static readonly FALLOFF_GLTF: number;
  72265. /**
  72266. * Falloff Standard: light is falling off like in the standard material
  72267. * to enhance interoperability with other materials.
  72268. */
  72269. static readonly FALLOFF_STANDARD: number;
  72270. /**
  72271. * If every light affecting the material is in this lightmapMode,
  72272. * material.lightmapTexture adds or multiplies
  72273. * (depends on material.useLightmapAsShadowmap)
  72274. * after every other light calculations.
  72275. */
  72276. static readonly LIGHTMAP_DEFAULT: number;
  72277. /**
  72278. * material.lightmapTexture as only diffuse lighting from this light
  72279. * adds only specular lighting from this light
  72280. * adds dynamic shadows
  72281. */
  72282. static readonly LIGHTMAP_SPECULAR: number;
  72283. /**
  72284. * material.lightmapTexture as only lighting
  72285. * no light calculation from this light
  72286. * only adds dynamic shadows from this light
  72287. */
  72288. static readonly LIGHTMAP_SHADOWSONLY: number;
  72289. /**
  72290. * Each light type uses the default quantity according to its type:
  72291. * point/spot lights use luminous intensity
  72292. * directional lights use illuminance
  72293. */
  72294. static readonly INTENSITYMODE_AUTOMATIC: number;
  72295. /**
  72296. * lumen (lm)
  72297. */
  72298. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  72299. /**
  72300. * candela (lm/sr)
  72301. */
  72302. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  72303. /**
  72304. * lux (lm/m^2)
  72305. */
  72306. static readonly INTENSITYMODE_ILLUMINANCE: number;
  72307. /**
  72308. * nit (cd/m^2)
  72309. */
  72310. static readonly INTENSITYMODE_LUMINANCE: number;
  72311. /**
  72312. * Light type const id of the point light.
  72313. */
  72314. static readonly LIGHTTYPEID_POINTLIGHT: number;
  72315. /**
  72316. * Light type const id of the directional light.
  72317. */
  72318. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  72319. /**
  72320. * Light type const id of the spot light.
  72321. */
  72322. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  72323. /**
  72324. * Light type const id of the hemispheric light.
  72325. */
  72326. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  72327. /**
  72328. * Diffuse gives the basic color to an object.
  72329. */
  72330. diffuse: Color3;
  72331. /**
  72332. * Specular produces a highlight color on an object.
  72333. * Note: This is note affecting PBR materials.
  72334. */
  72335. specular: Color3;
  72336. /**
  72337. * Defines the falloff type for this light. This lets overrriding how punctual light are
  72338. * falling off base on range or angle.
  72339. * This can be set to any values in Light.FALLOFF_x.
  72340. *
  72341. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  72342. * other types of materials.
  72343. */
  72344. falloffType: number;
  72345. /**
  72346. * Strength of the light.
  72347. * Note: By default it is define in the framework own unit.
  72348. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  72349. */
  72350. intensity: number;
  72351. private _range;
  72352. protected _inverseSquaredRange: number;
  72353. /**
  72354. * Defines how far from the source the light is impacting in scene units.
  72355. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  72356. */
  72357. /**
  72358. * Defines how far from the source the light is impacting in scene units.
  72359. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  72360. */
  72361. range: number;
  72362. /**
  72363. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  72364. * of light.
  72365. */
  72366. private _photometricScale;
  72367. private _intensityMode;
  72368. /**
  72369. * Gets the photometric scale used to interpret the intensity.
  72370. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  72371. */
  72372. /**
  72373. * Sets the photometric scale used to interpret the intensity.
  72374. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  72375. */
  72376. intensityMode: number;
  72377. private _radius;
  72378. /**
  72379. * Gets the light radius used by PBR Materials to simulate soft area lights.
  72380. */
  72381. /**
  72382. * sets the light radius used by PBR Materials to simulate soft area lights.
  72383. */
  72384. radius: number;
  72385. private _renderPriority;
  72386. /**
  72387. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  72388. * exceeding the number allowed of the materials.
  72389. */
  72390. renderPriority: number;
  72391. private _shadowEnabled;
  72392. /**
  72393. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  72394. * the current shadow generator.
  72395. */
  72396. /**
  72397. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  72398. * the current shadow generator.
  72399. */
  72400. shadowEnabled: boolean;
  72401. private _includedOnlyMeshes;
  72402. /**
  72403. * Gets the only meshes impacted by this light.
  72404. */
  72405. /**
  72406. * Sets the only meshes impacted by this light.
  72407. */
  72408. includedOnlyMeshes: AbstractMesh[];
  72409. private _excludedMeshes;
  72410. /**
  72411. * Gets the meshes not impacted by this light.
  72412. */
  72413. /**
  72414. * Sets the meshes not impacted by this light.
  72415. */
  72416. excludedMeshes: AbstractMesh[];
  72417. private _excludeWithLayerMask;
  72418. /**
  72419. * Gets the layer id use to find what meshes are not impacted by the light.
  72420. * Inactive if 0
  72421. */
  72422. /**
  72423. * Sets the layer id use to find what meshes are not impacted by the light.
  72424. * Inactive if 0
  72425. */
  72426. excludeWithLayerMask: number;
  72427. private _includeOnlyWithLayerMask;
  72428. /**
  72429. * Gets the layer id use to find what meshes are impacted by the light.
  72430. * Inactive if 0
  72431. */
  72432. /**
  72433. * Sets the layer id use to find what meshes are impacted by the light.
  72434. * Inactive if 0
  72435. */
  72436. includeOnlyWithLayerMask: number;
  72437. private _lightmapMode;
  72438. /**
  72439. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  72440. */
  72441. /**
  72442. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  72443. */
  72444. lightmapMode: number;
  72445. /**
  72446. * Shadow generator associted to the light.
  72447. * @hidden Internal use only.
  72448. */
  72449. _shadowGenerator: Nullable<IShadowGenerator>;
  72450. /**
  72451. * @hidden Internal use only.
  72452. */
  72453. _excludedMeshesIds: string[];
  72454. /**
  72455. * @hidden Internal use only.
  72456. */
  72457. _includedOnlyMeshesIds: string[];
  72458. /**
  72459. * The current light unifom buffer.
  72460. * @hidden Internal use only.
  72461. */
  72462. _uniformBuffer: UniformBuffer;
  72463. /**
  72464. * Creates a Light object in the scene.
  72465. * Documentation : https://doc.babylonjs.com/babylon101/lights
  72466. * @param name The firendly name of the light
  72467. * @param scene The scene the light belongs too
  72468. */
  72469. constructor(name: string, scene: Scene);
  72470. protected abstract _buildUniformLayout(): void;
  72471. /**
  72472. * Sets the passed Effect "effect" with the Light information.
  72473. * @param effect The effect to update
  72474. * @param lightIndex The index of the light in the effect to update
  72475. * @returns The light
  72476. */
  72477. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  72478. /**
  72479. * Returns the string "Light".
  72480. * @returns the class name
  72481. */
  72482. getClassName(): string;
  72483. /** @hidden */
  72484. readonly _isLight: boolean;
  72485. /**
  72486. * Converts the light information to a readable string for debug purpose.
  72487. * @param fullDetails Supports for multiple levels of logging within scene loading
  72488. * @returns the human readable light info
  72489. */
  72490. toString(fullDetails?: boolean): string;
  72491. /** @hidden */
  72492. protected _syncParentEnabledState(): void;
  72493. /**
  72494. * Set the enabled state of this node.
  72495. * @param value - the new enabled state
  72496. */
  72497. setEnabled(value: boolean): void;
  72498. /**
  72499. * Returns the Light associated shadow generator if any.
  72500. * @return the associated shadow generator.
  72501. */
  72502. getShadowGenerator(): Nullable<IShadowGenerator>;
  72503. /**
  72504. * Returns a Vector3, the absolute light position in the World.
  72505. * @returns the world space position of the light
  72506. */
  72507. getAbsolutePosition(): Vector3;
  72508. /**
  72509. * Specifies if the light will affect the passed mesh.
  72510. * @param mesh The mesh to test against the light
  72511. * @return true the mesh is affected otherwise, false.
  72512. */
  72513. canAffectMesh(mesh: AbstractMesh): boolean;
  72514. /**
  72515. * Sort function to order lights for rendering.
  72516. * @param a First Light object to compare to second.
  72517. * @param b Second Light object to compare first.
  72518. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  72519. */
  72520. static CompareLightsPriority(a: Light, b: Light): number;
  72521. /**
  72522. * Releases resources associated with this node.
  72523. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  72524. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  72525. */
  72526. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  72527. /**
  72528. * Returns the light type ID (integer).
  72529. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  72530. */
  72531. getTypeID(): number;
  72532. /**
  72533. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  72534. * @returns the scaled intensity in intensity mode unit
  72535. */
  72536. getScaledIntensity(): number;
  72537. /**
  72538. * Returns a new Light object, named "name", from the current one.
  72539. * @param name The name of the cloned light
  72540. * @returns the new created light
  72541. */
  72542. clone(name: string): Nullable<Light>;
  72543. /**
  72544. * Serializes the current light into a Serialization object.
  72545. * @returns the serialized object.
  72546. */
  72547. serialize(): any;
  72548. /**
  72549. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  72550. * This new light is named "name" and added to the passed scene.
  72551. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  72552. * @param name The friendly name of the light
  72553. * @param scene The scene the new light will belong to
  72554. * @returns the constructor function
  72555. */
  72556. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  72557. /**
  72558. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  72559. * @param parsedLight The JSON representation of the light
  72560. * @param scene The scene to create the parsed light in
  72561. * @returns the created light after parsing
  72562. */
  72563. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  72564. private _hookArrayForExcluded;
  72565. private _hookArrayForIncludedOnly;
  72566. private _resyncMeshes;
  72567. /**
  72568. * Forces the meshes to update their light related information in their rendering used effects
  72569. * @hidden Internal Use Only
  72570. */
  72571. _markMeshesAsLightDirty(): void;
  72572. /**
  72573. * Recomputes the cached photometric scale if needed.
  72574. */
  72575. private _computePhotometricScale;
  72576. /**
  72577. * Returns the Photometric Scale according to the light type and intensity mode.
  72578. */
  72579. private _getPhotometricScale;
  72580. /**
  72581. * Reorder the light in the scene according to their defined priority.
  72582. * @hidden Internal Use Only
  72583. */
  72584. _reorderLightsInScene(): void;
  72585. /**
  72586. * Prepares the list of defines specific to the light type.
  72587. * @param defines the list of defines
  72588. * @param lightIndex defines the index of the light for the effect
  72589. */
  72590. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  72591. }
  72592. }
  72593. declare module BABYLON {
  72594. /**
  72595. * Interface used to define Action
  72596. */
  72597. export interface IAction {
  72598. /**
  72599. * Trigger for the action
  72600. */
  72601. trigger: number;
  72602. /** Options of the trigger */
  72603. triggerOptions: any;
  72604. /**
  72605. * Gets the trigger parameters
  72606. * @returns the trigger parameters
  72607. */
  72608. getTriggerParameter(): any;
  72609. /**
  72610. * Internal only - executes current action event
  72611. * @hidden
  72612. */
  72613. _executeCurrent(evt?: ActionEvent): void;
  72614. /**
  72615. * Serialize placeholder for child classes
  72616. * @param parent of child
  72617. * @returns the serialized object
  72618. */
  72619. serialize(parent: any): any;
  72620. /**
  72621. * Internal only
  72622. * @hidden
  72623. */
  72624. _prepare(): void;
  72625. /**
  72626. * Internal only - manager for action
  72627. * @hidden
  72628. */
  72629. _actionManager: AbstractActionManager;
  72630. /**
  72631. * Adds action to chain of actions, may be a DoNothingAction
  72632. * @param action defines the next action to execute
  72633. * @returns The action passed in
  72634. * @see https://www.babylonjs-playground.com/#1T30HR#0
  72635. */
  72636. then(action: IAction): IAction;
  72637. }
  72638. /**
  72639. * The action to be carried out following a trigger
  72640. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  72641. */
  72642. export class Action implements IAction {
  72643. /** the trigger, with or without parameters, for the action */
  72644. triggerOptions: any;
  72645. /**
  72646. * Trigger for the action
  72647. */
  72648. trigger: number;
  72649. /**
  72650. * Internal only - manager for action
  72651. * @hidden
  72652. */
  72653. _actionManager: ActionManager;
  72654. private _nextActiveAction;
  72655. private _child;
  72656. private _condition?;
  72657. private _triggerParameter;
  72658. /**
  72659. * An event triggered prior to action being executed.
  72660. */
  72661. onBeforeExecuteObservable: Observable<Action>;
  72662. /**
  72663. * Creates a new Action
  72664. * @param triggerOptions the trigger, with or without parameters, for the action
  72665. * @param condition an optional determinant of action
  72666. */
  72667. constructor(
  72668. /** the trigger, with or without parameters, for the action */
  72669. triggerOptions: any, condition?: Condition);
  72670. /**
  72671. * Internal only
  72672. * @hidden
  72673. */
  72674. _prepare(): void;
  72675. /**
  72676. * Gets the trigger parameters
  72677. * @returns the trigger parameters
  72678. */
  72679. getTriggerParameter(): any;
  72680. /**
  72681. * Internal only - executes current action event
  72682. * @hidden
  72683. */
  72684. _executeCurrent(evt?: ActionEvent): void;
  72685. /**
  72686. * Execute placeholder for child classes
  72687. * @param evt optional action event
  72688. */
  72689. execute(evt?: ActionEvent): void;
  72690. /**
  72691. * Skips to next active action
  72692. */
  72693. skipToNextActiveAction(): void;
  72694. /**
  72695. * Adds action to chain of actions, may be a DoNothingAction
  72696. * @param action defines the next action to execute
  72697. * @returns The action passed in
  72698. * @see https://www.babylonjs-playground.com/#1T30HR#0
  72699. */
  72700. then(action: Action): Action;
  72701. /**
  72702. * Internal only
  72703. * @hidden
  72704. */
  72705. _getProperty(propertyPath: string): string;
  72706. /**
  72707. * Internal only
  72708. * @hidden
  72709. */
  72710. _getEffectiveTarget(target: any, propertyPath: string): any;
  72711. /**
  72712. * Serialize placeholder for child classes
  72713. * @param parent of child
  72714. * @returns the serialized object
  72715. */
  72716. serialize(parent: any): any;
  72717. /**
  72718. * Internal only called by serialize
  72719. * @hidden
  72720. */
  72721. protected _serialize(serializedAction: any, parent?: any): any;
  72722. /**
  72723. * Internal only
  72724. * @hidden
  72725. */
  72726. static _SerializeValueAsString: (value: any) => string;
  72727. /**
  72728. * Internal only
  72729. * @hidden
  72730. */
  72731. static _GetTargetProperty: (target: Scene | Node) => {
  72732. name: string;
  72733. targetType: string;
  72734. value: string;
  72735. };
  72736. }
  72737. }
  72738. declare module BABYLON {
  72739. /**
  72740. * A Condition applied to an Action
  72741. */
  72742. export class Condition {
  72743. /**
  72744. * Internal only - manager for action
  72745. * @hidden
  72746. */
  72747. _actionManager: ActionManager;
  72748. /**
  72749. * Internal only
  72750. * @hidden
  72751. */
  72752. _evaluationId: number;
  72753. /**
  72754. * Internal only
  72755. * @hidden
  72756. */
  72757. _currentResult: boolean;
  72758. /**
  72759. * Creates a new Condition
  72760. * @param actionManager the manager of the action the condition is applied to
  72761. */
  72762. constructor(actionManager: ActionManager);
  72763. /**
  72764. * Check if the current condition is valid
  72765. * @returns a boolean
  72766. */
  72767. isValid(): boolean;
  72768. /**
  72769. * Internal only
  72770. * @hidden
  72771. */
  72772. _getProperty(propertyPath: string): string;
  72773. /**
  72774. * Internal only
  72775. * @hidden
  72776. */
  72777. _getEffectiveTarget(target: any, propertyPath: string): any;
  72778. /**
  72779. * Serialize placeholder for child classes
  72780. * @returns the serialized object
  72781. */
  72782. serialize(): any;
  72783. /**
  72784. * Internal only
  72785. * @hidden
  72786. */
  72787. protected _serialize(serializedCondition: any): any;
  72788. }
  72789. /**
  72790. * Defines specific conditional operators as extensions of Condition
  72791. */
  72792. export class ValueCondition extends Condition {
  72793. /** path to specify the property of the target the conditional operator uses */
  72794. propertyPath: string;
  72795. /** the value compared by the conditional operator against the current value of the property */
  72796. value: any;
  72797. /** the conditional operator, default ValueCondition.IsEqual */
  72798. operator: number;
  72799. /**
  72800. * Internal only
  72801. * @hidden
  72802. */
  72803. private static _IsEqual;
  72804. /**
  72805. * Internal only
  72806. * @hidden
  72807. */
  72808. private static _IsDifferent;
  72809. /**
  72810. * Internal only
  72811. * @hidden
  72812. */
  72813. private static _IsGreater;
  72814. /**
  72815. * Internal only
  72816. * @hidden
  72817. */
  72818. private static _IsLesser;
  72819. /**
  72820. * returns the number for IsEqual
  72821. */
  72822. static readonly IsEqual: number;
  72823. /**
  72824. * Returns the number for IsDifferent
  72825. */
  72826. static readonly IsDifferent: number;
  72827. /**
  72828. * Returns the number for IsGreater
  72829. */
  72830. static readonly IsGreater: number;
  72831. /**
  72832. * Returns the number for IsLesser
  72833. */
  72834. static readonly IsLesser: number;
  72835. /**
  72836. * Internal only The action manager for the condition
  72837. * @hidden
  72838. */
  72839. _actionManager: ActionManager;
  72840. /**
  72841. * Internal only
  72842. * @hidden
  72843. */
  72844. private _target;
  72845. /**
  72846. * Internal only
  72847. * @hidden
  72848. */
  72849. private _effectiveTarget;
  72850. /**
  72851. * Internal only
  72852. * @hidden
  72853. */
  72854. private _property;
  72855. /**
  72856. * Creates a new ValueCondition
  72857. * @param actionManager manager for the action the condition applies to
  72858. * @param target for the action
  72859. * @param propertyPath path to specify the property of the target the conditional operator uses
  72860. * @param value the value compared by the conditional operator against the current value of the property
  72861. * @param operator the conditional operator, default ValueCondition.IsEqual
  72862. */
  72863. constructor(actionManager: ActionManager, target: any,
  72864. /** path to specify the property of the target the conditional operator uses */
  72865. propertyPath: string,
  72866. /** the value compared by the conditional operator against the current value of the property */
  72867. value: any,
  72868. /** the conditional operator, default ValueCondition.IsEqual */
  72869. operator?: number);
  72870. /**
  72871. * Compares the given value with the property value for the specified conditional operator
  72872. * @returns the result of the comparison
  72873. */
  72874. isValid(): boolean;
  72875. /**
  72876. * Serialize the ValueCondition into a JSON compatible object
  72877. * @returns serialization object
  72878. */
  72879. serialize(): any;
  72880. /**
  72881. * Gets the name of the conditional operator for the ValueCondition
  72882. * @param operator the conditional operator
  72883. * @returns the name
  72884. */
  72885. static GetOperatorName(operator: number): string;
  72886. }
  72887. /**
  72888. * Defines a predicate condition as an extension of Condition
  72889. */
  72890. export class PredicateCondition extends Condition {
  72891. /** defines the predicate function used to validate the condition */
  72892. predicate: () => boolean;
  72893. /**
  72894. * Internal only - manager for action
  72895. * @hidden
  72896. */
  72897. _actionManager: ActionManager;
  72898. /**
  72899. * Creates a new PredicateCondition
  72900. * @param actionManager manager for the action the condition applies to
  72901. * @param predicate defines the predicate function used to validate the condition
  72902. */
  72903. constructor(actionManager: ActionManager,
  72904. /** defines the predicate function used to validate the condition */
  72905. predicate: () => boolean);
  72906. /**
  72907. * @returns the validity of the predicate condition
  72908. */
  72909. isValid(): boolean;
  72910. }
  72911. /**
  72912. * Defines a state condition as an extension of Condition
  72913. */
  72914. export class StateCondition extends Condition {
  72915. /** Value to compare with target state */
  72916. value: string;
  72917. /**
  72918. * Internal only - manager for action
  72919. * @hidden
  72920. */
  72921. _actionManager: ActionManager;
  72922. /**
  72923. * Internal only
  72924. * @hidden
  72925. */
  72926. private _target;
  72927. /**
  72928. * Creates a new StateCondition
  72929. * @param actionManager manager for the action the condition applies to
  72930. * @param target of the condition
  72931. * @param value to compare with target state
  72932. */
  72933. constructor(actionManager: ActionManager, target: any,
  72934. /** Value to compare with target state */
  72935. value: string);
  72936. /**
  72937. * Gets a boolean indicating if the current condition is met
  72938. * @returns the validity of the state
  72939. */
  72940. isValid(): boolean;
  72941. /**
  72942. * Serialize the StateCondition into a JSON compatible object
  72943. * @returns serialization object
  72944. */
  72945. serialize(): any;
  72946. }
  72947. }
  72948. declare module BABYLON {
  72949. /**
  72950. * This defines an action responsible to toggle a boolean once triggered.
  72951. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  72952. */
  72953. export class SwitchBooleanAction extends Action {
  72954. /**
  72955. * The path to the boolean property in the target object
  72956. */
  72957. propertyPath: string;
  72958. private _target;
  72959. private _effectiveTarget;
  72960. private _property;
  72961. /**
  72962. * Instantiate the action
  72963. * @param triggerOptions defines the trigger options
  72964. * @param target defines the object containing the boolean
  72965. * @param propertyPath defines the path to the boolean property in the target object
  72966. * @param condition defines the trigger related conditions
  72967. */
  72968. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  72969. /** @hidden */
  72970. _prepare(): void;
  72971. /**
  72972. * Execute the action toggle the boolean value.
  72973. */
  72974. execute(): void;
  72975. /**
  72976. * Serializes the actions and its related information.
  72977. * @param parent defines the object to serialize in
  72978. * @returns the serialized object
  72979. */
  72980. serialize(parent: any): any;
  72981. }
  72982. /**
  72983. * This defines an action responsible to set a the state field of the target
  72984. * to a desired value once triggered.
  72985. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  72986. */
  72987. export class SetStateAction extends Action {
  72988. /**
  72989. * The value to store in the state field.
  72990. */
  72991. value: string;
  72992. private _target;
  72993. /**
  72994. * Instantiate the action
  72995. * @param triggerOptions defines the trigger options
  72996. * @param target defines the object containing the state property
  72997. * @param value defines the value to store in the state field
  72998. * @param condition defines the trigger related conditions
  72999. */
  73000. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  73001. /**
  73002. * Execute the action and store the value on the target state property.
  73003. */
  73004. execute(): void;
  73005. /**
  73006. * Serializes the actions and its related information.
  73007. * @param parent defines the object to serialize in
  73008. * @returns the serialized object
  73009. */
  73010. serialize(parent: any): any;
  73011. }
  73012. /**
  73013. * This defines an action responsible to set a property of the target
  73014. * to a desired value once triggered.
  73015. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  73016. */
  73017. export class SetValueAction extends Action {
  73018. /**
  73019. * The path of the property to set in the target.
  73020. */
  73021. propertyPath: string;
  73022. /**
  73023. * The value to set in the property
  73024. */
  73025. value: any;
  73026. private _target;
  73027. private _effectiveTarget;
  73028. private _property;
  73029. /**
  73030. * Instantiate the action
  73031. * @param triggerOptions defines the trigger options
  73032. * @param target defines the object containing the property
  73033. * @param propertyPath defines the path of the property to set in the target
  73034. * @param value defines the value to set in the property
  73035. * @param condition defines the trigger related conditions
  73036. */
  73037. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  73038. /** @hidden */
  73039. _prepare(): void;
  73040. /**
  73041. * Execute the action and set the targetted property to the desired value.
  73042. */
  73043. execute(): void;
  73044. /**
  73045. * Serializes the actions and its related information.
  73046. * @param parent defines the object to serialize in
  73047. * @returns the serialized object
  73048. */
  73049. serialize(parent: any): any;
  73050. }
  73051. /**
  73052. * This defines an action responsible to increment the target value
  73053. * to a desired value once triggered.
  73054. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  73055. */
  73056. export class IncrementValueAction extends Action {
  73057. /**
  73058. * The path of the property to increment in the target.
  73059. */
  73060. propertyPath: string;
  73061. /**
  73062. * The value we should increment the property by.
  73063. */
  73064. value: any;
  73065. private _target;
  73066. private _effectiveTarget;
  73067. private _property;
  73068. /**
  73069. * Instantiate the action
  73070. * @param triggerOptions defines the trigger options
  73071. * @param target defines the object containing the property
  73072. * @param propertyPath defines the path of the property to increment in the target
  73073. * @param value defines the value value we should increment the property by
  73074. * @param condition defines the trigger related conditions
  73075. */
  73076. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  73077. /** @hidden */
  73078. _prepare(): void;
  73079. /**
  73080. * Execute the action and increment the target of the value amount.
  73081. */
  73082. execute(): void;
  73083. /**
  73084. * Serializes the actions and its related information.
  73085. * @param parent defines the object to serialize in
  73086. * @returns the serialized object
  73087. */
  73088. serialize(parent: any): any;
  73089. }
  73090. /**
  73091. * This defines an action responsible to start an animation once triggered.
  73092. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  73093. */
  73094. export class PlayAnimationAction extends Action {
  73095. /**
  73096. * Where the animation should start (animation frame)
  73097. */
  73098. from: number;
  73099. /**
  73100. * Where the animation should stop (animation frame)
  73101. */
  73102. to: number;
  73103. /**
  73104. * Define if the animation should loop or stop after the first play.
  73105. */
  73106. loop?: boolean;
  73107. private _target;
  73108. /**
  73109. * Instantiate the action
  73110. * @param triggerOptions defines the trigger options
  73111. * @param target defines the target animation or animation name
  73112. * @param from defines from where the animation should start (animation frame)
  73113. * @param end defines where the animation should stop (animation frame)
  73114. * @param loop defines if the animation should loop or stop after the first play
  73115. * @param condition defines the trigger related conditions
  73116. */
  73117. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  73118. /** @hidden */
  73119. _prepare(): void;
  73120. /**
  73121. * Execute the action and play the animation.
  73122. */
  73123. execute(): void;
  73124. /**
  73125. * Serializes the actions and its related information.
  73126. * @param parent defines the object to serialize in
  73127. * @returns the serialized object
  73128. */
  73129. serialize(parent: any): any;
  73130. }
  73131. /**
  73132. * This defines an action responsible to stop an animation once triggered.
  73133. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  73134. */
  73135. export class StopAnimationAction extends Action {
  73136. private _target;
  73137. /**
  73138. * Instantiate the action
  73139. * @param triggerOptions defines the trigger options
  73140. * @param target defines the target animation or animation name
  73141. * @param condition defines the trigger related conditions
  73142. */
  73143. constructor(triggerOptions: any, target: any, condition?: Condition);
  73144. /** @hidden */
  73145. _prepare(): void;
  73146. /**
  73147. * Execute the action and stop the animation.
  73148. */
  73149. execute(): void;
  73150. /**
  73151. * Serializes the actions and its related information.
  73152. * @param parent defines the object to serialize in
  73153. * @returns the serialized object
  73154. */
  73155. serialize(parent: any): any;
  73156. }
  73157. /**
  73158. * This defines an action responsible that does nothing once triggered.
  73159. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  73160. */
  73161. export class DoNothingAction extends Action {
  73162. /**
  73163. * Instantiate the action
  73164. * @param triggerOptions defines the trigger options
  73165. * @param condition defines the trigger related conditions
  73166. */
  73167. constructor(triggerOptions?: any, condition?: Condition);
  73168. /**
  73169. * Execute the action and do nothing.
  73170. */
  73171. execute(): void;
  73172. /**
  73173. * Serializes the actions and its related information.
  73174. * @param parent defines the object to serialize in
  73175. * @returns the serialized object
  73176. */
  73177. serialize(parent: any): any;
  73178. }
  73179. /**
  73180. * This defines an action responsible to trigger several actions once triggered.
  73181. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  73182. */
  73183. export class CombineAction extends Action {
  73184. /**
  73185. * The list of aggregated animations to run.
  73186. */
  73187. children: Action[];
  73188. /**
  73189. * Instantiate the action
  73190. * @param triggerOptions defines the trigger options
  73191. * @param children defines the list of aggregated animations to run
  73192. * @param condition defines the trigger related conditions
  73193. */
  73194. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  73195. /** @hidden */
  73196. _prepare(): void;
  73197. /**
  73198. * Execute the action and executes all the aggregated actions.
  73199. */
  73200. execute(evt: ActionEvent): void;
  73201. /**
  73202. * Serializes the actions and its related information.
  73203. * @param parent defines the object to serialize in
  73204. * @returns the serialized object
  73205. */
  73206. serialize(parent: any): any;
  73207. }
  73208. /**
  73209. * This defines an action responsible to run code (external event) once triggered.
  73210. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  73211. */
  73212. export class ExecuteCodeAction extends Action {
  73213. /**
  73214. * The callback function to run.
  73215. */
  73216. func: (evt: ActionEvent) => void;
  73217. /**
  73218. * Instantiate the action
  73219. * @param triggerOptions defines the trigger options
  73220. * @param func defines the callback function to run
  73221. * @param condition defines the trigger related conditions
  73222. */
  73223. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  73224. /**
  73225. * Execute the action and run the attached code.
  73226. */
  73227. execute(evt: ActionEvent): void;
  73228. }
  73229. /**
  73230. * This defines an action responsible to set the parent property of the target once triggered.
  73231. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  73232. */
  73233. export class SetParentAction extends Action {
  73234. private _parent;
  73235. private _target;
  73236. /**
  73237. * Instantiate the action
  73238. * @param triggerOptions defines the trigger options
  73239. * @param target defines the target containing the parent property
  73240. * @param parent defines from where the animation should start (animation frame)
  73241. * @param condition defines the trigger related conditions
  73242. */
  73243. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  73244. /** @hidden */
  73245. _prepare(): void;
  73246. /**
  73247. * Execute the action and set the parent property.
  73248. */
  73249. execute(): void;
  73250. /**
  73251. * Serializes the actions and its related information.
  73252. * @param parent defines the object to serialize in
  73253. * @returns the serialized object
  73254. */
  73255. serialize(parent: any): any;
  73256. }
  73257. }
  73258. declare module BABYLON {
  73259. /**
  73260. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  73261. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  73262. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  73263. */
  73264. export class ActionManager extends AbstractActionManager {
  73265. /**
  73266. * Nothing
  73267. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73268. */
  73269. static readonly NothingTrigger: number;
  73270. /**
  73271. * On pick
  73272. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73273. */
  73274. static readonly OnPickTrigger: number;
  73275. /**
  73276. * On left pick
  73277. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73278. */
  73279. static readonly OnLeftPickTrigger: number;
  73280. /**
  73281. * On right pick
  73282. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73283. */
  73284. static readonly OnRightPickTrigger: number;
  73285. /**
  73286. * On center pick
  73287. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73288. */
  73289. static readonly OnCenterPickTrigger: number;
  73290. /**
  73291. * On pick down
  73292. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73293. */
  73294. static readonly OnPickDownTrigger: number;
  73295. /**
  73296. * On double pick
  73297. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73298. */
  73299. static readonly OnDoublePickTrigger: number;
  73300. /**
  73301. * On pick up
  73302. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73303. */
  73304. static readonly OnPickUpTrigger: number;
  73305. /**
  73306. * On pick out.
  73307. * This trigger will only be raised if you also declared a OnPickDown
  73308. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73309. */
  73310. static readonly OnPickOutTrigger: number;
  73311. /**
  73312. * On long press
  73313. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73314. */
  73315. static readonly OnLongPressTrigger: number;
  73316. /**
  73317. * On pointer over
  73318. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73319. */
  73320. static readonly OnPointerOverTrigger: number;
  73321. /**
  73322. * On pointer out
  73323. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73324. */
  73325. static readonly OnPointerOutTrigger: number;
  73326. /**
  73327. * On every frame
  73328. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73329. */
  73330. static readonly OnEveryFrameTrigger: number;
  73331. /**
  73332. * On intersection enter
  73333. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73334. */
  73335. static readonly OnIntersectionEnterTrigger: number;
  73336. /**
  73337. * On intersection exit
  73338. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73339. */
  73340. static readonly OnIntersectionExitTrigger: number;
  73341. /**
  73342. * On key down
  73343. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73344. */
  73345. static readonly OnKeyDownTrigger: number;
  73346. /**
  73347. * On key up
  73348. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73349. */
  73350. static readonly OnKeyUpTrigger: number;
  73351. private _scene;
  73352. /**
  73353. * Creates a new action manager
  73354. * @param scene defines the hosting scene
  73355. */
  73356. constructor(scene: Scene);
  73357. /**
  73358. * Releases all associated resources
  73359. */
  73360. dispose(): void;
  73361. /**
  73362. * Gets hosting scene
  73363. * @returns the hosting scene
  73364. */
  73365. getScene(): Scene;
  73366. /**
  73367. * Does this action manager handles actions of any of the given triggers
  73368. * @param triggers defines the triggers to be tested
  73369. * @return a boolean indicating whether one (or more) of the triggers is handled
  73370. */
  73371. hasSpecificTriggers(triggers: number[]): boolean;
  73372. /**
  73373. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  73374. * speed.
  73375. * @param triggerA defines the trigger to be tested
  73376. * @param triggerB defines the trigger to be tested
  73377. * @return a boolean indicating whether one (or more) of the triggers is handled
  73378. */
  73379. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  73380. /**
  73381. * Does this action manager handles actions of a given trigger
  73382. * @param trigger defines the trigger to be tested
  73383. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  73384. * @return whether the trigger is handled
  73385. */
  73386. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  73387. /**
  73388. * Does this action manager has pointer triggers
  73389. */
  73390. readonly hasPointerTriggers: boolean;
  73391. /**
  73392. * Does this action manager has pick triggers
  73393. */
  73394. readonly hasPickTriggers: boolean;
  73395. /**
  73396. * Registers an action to this action manager
  73397. * @param action defines the action to be registered
  73398. * @return the action amended (prepared) after registration
  73399. */
  73400. registerAction(action: IAction): Nullable<IAction>;
  73401. /**
  73402. * Unregisters an action to this action manager
  73403. * @param action defines the action to be unregistered
  73404. * @return a boolean indicating whether the action has been unregistered
  73405. */
  73406. unregisterAction(action: IAction): Boolean;
  73407. /**
  73408. * Process a specific trigger
  73409. * @param trigger defines the trigger to process
  73410. * @param evt defines the event details to be processed
  73411. */
  73412. processTrigger(trigger: number, evt?: IActionEvent): void;
  73413. /** @hidden */
  73414. _getEffectiveTarget(target: any, propertyPath: string): any;
  73415. /** @hidden */
  73416. _getProperty(propertyPath: string): string;
  73417. /**
  73418. * Serialize this manager to a JSON object
  73419. * @param name defines the property name to store this manager
  73420. * @returns a JSON representation of this manager
  73421. */
  73422. serialize(name: string): any;
  73423. /**
  73424. * Creates a new ActionManager from a JSON data
  73425. * @param parsedActions defines the JSON data to read from
  73426. * @param object defines the hosting mesh
  73427. * @param scene defines the hosting scene
  73428. */
  73429. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  73430. /**
  73431. * Get a trigger name by index
  73432. * @param trigger defines the trigger index
  73433. * @returns a trigger name
  73434. */
  73435. static GetTriggerName(trigger: number): string;
  73436. }
  73437. }
  73438. declare module BABYLON {
  73439. /**
  73440. * Class representing a ray with position and direction
  73441. */
  73442. export class Ray {
  73443. /** origin point */
  73444. origin: Vector3;
  73445. /** direction */
  73446. direction: Vector3;
  73447. /** length of the ray */
  73448. length: number;
  73449. private static readonly TmpVector3;
  73450. private _tmpRay;
  73451. /**
  73452. * Creates a new ray
  73453. * @param origin origin point
  73454. * @param direction direction
  73455. * @param length length of the ray
  73456. */
  73457. constructor(
  73458. /** origin point */
  73459. origin: Vector3,
  73460. /** direction */
  73461. direction: Vector3,
  73462. /** length of the ray */
  73463. length?: number);
  73464. /**
  73465. * Checks if the ray intersects a box
  73466. * @param minimum bound of the box
  73467. * @param maximum bound of the box
  73468. * @param intersectionTreshold extra extend to be added to the box in all direction
  73469. * @returns if the box was hit
  73470. */
  73471. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  73472. /**
  73473. * Checks if the ray intersects a box
  73474. * @param box the bounding box to check
  73475. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  73476. * @returns if the box was hit
  73477. */
  73478. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  73479. /**
  73480. * If the ray hits a sphere
  73481. * @param sphere the bounding sphere to check
  73482. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  73483. * @returns true if it hits the sphere
  73484. */
  73485. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  73486. /**
  73487. * If the ray hits a triange
  73488. * @param vertex0 triangle vertex
  73489. * @param vertex1 triangle vertex
  73490. * @param vertex2 triangle vertex
  73491. * @returns intersection information if hit
  73492. */
  73493. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  73494. /**
  73495. * Checks if ray intersects a plane
  73496. * @param plane the plane to check
  73497. * @returns the distance away it was hit
  73498. */
  73499. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  73500. /**
  73501. * Checks if ray intersects a mesh
  73502. * @param mesh the mesh to check
  73503. * @param fastCheck if only the bounding box should checked
  73504. * @returns picking info of the intersecton
  73505. */
  73506. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  73507. /**
  73508. * Checks if ray intersects a mesh
  73509. * @param meshes the meshes to check
  73510. * @param fastCheck if only the bounding box should checked
  73511. * @param results array to store result in
  73512. * @returns Array of picking infos
  73513. */
  73514. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  73515. private _comparePickingInfo;
  73516. private static smallnum;
  73517. private static rayl;
  73518. /**
  73519. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  73520. * @param sega the first point of the segment to test the intersection against
  73521. * @param segb the second point of the segment to test the intersection against
  73522. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  73523. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  73524. */
  73525. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  73526. /**
  73527. * Update the ray from viewport position
  73528. * @param x position
  73529. * @param y y position
  73530. * @param viewportWidth viewport width
  73531. * @param viewportHeight viewport height
  73532. * @param world world matrix
  73533. * @param view view matrix
  73534. * @param projection projection matrix
  73535. * @returns this ray updated
  73536. */
  73537. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  73538. /**
  73539. * Creates a ray with origin and direction of 0,0,0
  73540. * @returns the new ray
  73541. */
  73542. static Zero(): Ray;
  73543. /**
  73544. * Creates a new ray from screen space and viewport
  73545. * @param x position
  73546. * @param y y position
  73547. * @param viewportWidth viewport width
  73548. * @param viewportHeight viewport height
  73549. * @param world world matrix
  73550. * @param view view matrix
  73551. * @param projection projection matrix
  73552. * @returns new ray
  73553. */
  73554. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  73555. /**
  73556. * 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
  73557. * transformed to the given world matrix.
  73558. * @param origin The origin point
  73559. * @param end The end point
  73560. * @param world a matrix to transform the ray to. Default is the identity matrix.
  73561. * @returns the new ray
  73562. */
  73563. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  73564. /**
  73565. * Transforms a ray by a matrix
  73566. * @param ray ray to transform
  73567. * @param matrix matrix to apply
  73568. * @returns the resulting new ray
  73569. */
  73570. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  73571. /**
  73572. * Transforms a ray by a matrix
  73573. * @param ray ray to transform
  73574. * @param matrix matrix to apply
  73575. * @param result ray to store result in
  73576. */
  73577. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  73578. /**
  73579. * Unproject a ray from screen space to object space
  73580. * @param sourceX defines the screen space x coordinate to use
  73581. * @param sourceY defines the screen space y coordinate to use
  73582. * @param viewportWidth defines the current width of the viewport
  73583. * @param viewportHeight defines the current height of the viewport
  73584. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  73585. * @param view defines the view matrix to use
  73586. * @param projection defines the projection matrix to use
  73587. */
  73588. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  73589. }
  73590. /**
  73591. * Type used to define predicate used to select faces when a mesh intersection is detected
  73592. */
  73593. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  73594. interface Scene {
  73595. /** @hidden */
  73596. _tempPickingRay: Nullable<Ray>;
  73597. /** @hidden */
  73598. _cachedRayForTransform: Ray;
  73599. /** @hidden */
  73600. _pickWithRayInverseMatrix: Matrix;
  73601. /** @hidden */
  73602. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  73603. /** @hidden */
  73604. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  73605. }
  73606. }
  73607. declare module BABYLON {
  73608. /**
  73609. * Groups all the scene component constants in one place to ease maintenance.
  73610. * @hidden
  73611. */
  73612. export class SceneComponentConstants {
  73613. static readonly NAME_EFFECTLAYER: string;
  73614. static readonly NAME_LAYER: string;
  73615. static readonly NAME_LENSFLARESYSTEM: string;
  73616. static readonly NAME_BOUNDINGBOXRENDERER: string;
  73617. static readonly NAME_PARTICLESYSTEM: string;
  73618. static readonly NAME_GAMEPAD: string;
  73619. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  73620. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  73621. static readonly NAME_DEPTHRENDERER: string;
  73622. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  73623. static readonly NAME_SPRITE: string;
  73624. static readonly NAME_OUTLINERENDERER: string;
  73625. static readonly NAME_PROCEDURALTEXTURE: string;
  73626. static readonly NAME_SHADOWGENERATOR: string;
  73627. static readonly NAME_OCTREE: string;
  73628. static readonly NAME_PHYSICSENGINE: string;
  73629. static readonly NAME_AUDIO: string;
  73630. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  73631. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  73632. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  73633. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  73634. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  73635. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  73636. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  73637. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  73638. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  73639. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  73640. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  73641. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  73642. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  73643. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  73644. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  73645. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  73646. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  73647. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  73648. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  73649. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  73650. static readonly STEP_AFTERRENDER_AUDIO: number;
  73651. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  73652. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  73653. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  73654. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  73655. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  73656. static readonly STEP_POINTERMOVE_SPRITE: number;
  73657. static readonly STEP_POINTERDOWN_SPRITE: number;
  73658. static readonly STEP_POINTERUP_SPRITE: number;
  73659. }
  73660. /**
  73661. * This represents a scene component.
  73662. *
  73663. * This is used to decouple the dependency the scene is having on the different workloads like
  73664. * layers, post processes...
  73665. */
  73666. export interface ISceneComponent {
  73667. /**
  73668. * The name of the component. Each component must have a unique name.
  73669. */
  73670. name: string;
  73671. /**
  73672. * The scene the component belongs to.
  73673. */
  73674. scene: Scene;
  73675. /**
  73676. * Register the component to one instance of a scene.
  73677. */
  73678. register(): void;
  73679. /**
  73680. * Rebuilds the elements related to this component in case of
  73681. * context lost for instance.
  73682. */
  73683. rebuild(): void;
  73684. /**
  73685. * Disposes the component and the associated ressources.
  73686. */
  73687. dispose(): void;
  73688. }
  73689. /**
  73690. * This represents a SERIALIZABLE scene component.
  73691. *
  73692. * This extends Scene Component to add Serialization methods on top.
  73693. */
  73694. export interface ISceneSerializableComponent extends ISceneComponent {
  73695. /**
  73696. * Adds all the elements from the container to the scene
  73697. * @param container the container holding the elements
  73698. */
  73699. addFromContainer(container: AbstractScene): void;
  73700. /**
  73701. * Removes all the elements in the container from the scene
  73702. * @param container contains the elements to remove
  73703. * @param dispose if the removed element should be disposed (default: false)
  73704. */
  73705. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  73706. /**
  73707. * Serializes the component data to the specified json object
  73708. * @param serializationObject The object to serialize to
  73709. */
  73710. serialize(serializationObject: any): void;
  73711. }
  73712. /**
  73713. * Strong typing of a Mesh related stage step action
  73714. */
  73715. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  73716. /**
  73717. * Strong typing of a Evaluate Sub Mesh related stage step action
  73718. */
  73719. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  73720. /**
  73721. * Strong typing of a Active Mesh related stage step action
  73722. */
  73723. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  73724. /**
  73725. * Strong typing of a Camera related stage step action
  73726. */
  73727. export type CameraStageAction = (camera: Camera) => void;
  73728. /**
  73729. * Strong typing of a Camera Frame buffer related stage step action
  73730. */
  73731. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  73732. /**
  73733. * Strong typing of a Render Target related stage step action
  73734. */
  73735. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  73736. /**
  73737. * Strong typing of a RenderingGroup related stage step action
  73738. */
  73739. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  73740. /**
  73741. * Strong typing of a Mesh Render related stage step action
  73742. */
  73743. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  73744. /**
  73745. * Strong typing of a simple stage step action
  73746. */
  73747. export type SimpleStageAction = () => void;
  73748. /**
  73749. * Strong typing of a render target action.
  73750. */
  73751. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  73752. /**
  73753. * Strong typing of a pointer move action.
  73754. */
  73755. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  73756. /**
  73757. * Strong typing of a pointer up/down action.
  73758. */
  73759. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  73760. /**
  73761. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  73762. * @hidden
  73763. */
  73764. export class Stage<T extends Function> extends Array<{
  73765. index: number;
  73766. component: ISceneComponent;
  73767. action: T;
  73768. }> {
  73769. /**
  73770. * Hide ctor from the rest of the world.
  73771. * @param items The items to add.
  73772. */
  73773. private constructor();
  73774. /**
  73775. * Creates a new Stage.
  73776. * @returns A new instance of a Stage
  73777. */
  73778. static Create<T extends Function>(): Stage<T>;
  73779. /**
  73780. * Registers a step in an ordered way in the targeted stage.
  73781. * @param index Defines the position to register the step in
  73782. * @param component Defines the component attached to the step
  73783. * @param action Defines the action to launch during the step
  73784. */
  73785. registerStep(index: number, component: ISceneComponent, action: T): void;
  73786. /**
  73787. * Clears all the steps from the stage.
  73788. */
  73789. clear(): void;
  73790. }
  73791. }
  73792. declare module BABYLON {
  73793. interface Scene {
  73794. /** @hidden */
  73795. _pointerOverSprite: Nullable<Sprite>;
  73796. /** @hidden */
  73797. _pickedDownSprite: Nullable<Sprite>;
  73798. /** @hidden */
  73799. _tempSpritePickingRay: Nullable<Ray>;
  73800. /**
  73801. * All of the sprite managers added to this scene
  73802. * @see http://doc.babylonjs.com/babylon101/sprites
  73803. */
  73804. spriteManagers: Array<ISpriteManager>;
  73805. /**
  73806. * An event triggered when sprites rendering is about to start
  73807. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  73808. */
  73809. onBeforeSpritesRenderingObservable: Observable<Scene>;
  73810. /**
  73811. * An event triggered when sprites rendering is done
  73812. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  73813. */
  73814. onAfterSpritesRenderingObservable: Observable<Scene>;
  73815. /** @hidden */
  73816. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  73817. /** Launch a ray to try to pick a sprite in the scene
  73818. * @param x position on screen
  73819. * @param y position on screen
  73820. * @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
  73821. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  73822. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  73823. * @returns a PickingInfo
  73824. */
  73825. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  73826. /** Use the given ray to pick a sprite in the scene
  73827. * @param ray The ray (in world space) to use to pick meshes
  73828. * @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
  73829. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  73830. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  73831. * @returns a PickingInfo
  73832. */
  73833. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  73834. /**
  73835. * Force the sprite under the pointer
  73836. * @param sprite defines the sprite to use
  73837. */
  73838. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  73839. /**
  73840. * Gets the sprite under the pointer
  73841. * @returns a Sprite or null if no sprite is under the pointer
  73842. */
  73843. getPointerOverSprite(): Nullable<Sprite>;
  73844. }
  73845. /**
  73846. * Defines the sprite scene component responsible to manage sprites
  73847. * in a given scene.
  73848. */
  73849. export class SpriteSceneComponent implements ISceneComponent {
  73850. /**
  73851. * The component name helpfull to identify the component in the list of scene components.
  73852. */
  73853. readonly name: string;
  73854. /**
  73855. * The scene the component belongs to.
  73856. */
  73857. scene: Scene;
  73858. /** @hidden */
  73859. private _spritePredicate;
  73860. /**
  73861. * Creates a new instance of the component for the given scene
  73862. * @param scene Defines the scene to register the component in
  73863. */
  73864. constructor(scene: Scene);
  73865. /**
  73866. * Registers the component in a given scene
  73867. */
  73868. register(): void;
  73869. /**
  73870. * Rebuilds the elements related to this component in case of
  73871. * context lost for instance.
  73872. */
  73873. rebuild(): void;
  73874. /**
  73875. * Disposes the component and the associated ressources.
  73876. */
  73877. dispose(): void;
  73878. private _pickSpriteButKeepRay;
  73879. private _pointerMove;
  73880. private _pointerDown;
  73881. private _pointerUp;
  73882. }
  73883. }
  73884. declare module BABYLON {
  73885. /** @hidden */
  73886. export var fogFragmentDeclaration: {
  73887. name: string;
  73888. shader: string;
  73889. };
  73890. }
  73891. declare module BABYLON {
  73892. /** @hidden */
  73893. export var fogFragment: {
  73894. name: string;
  73895. shader: string;
  73896. };
  73897. }
  73898. declare module BABYLON {
  73899. /** @hidden */
  73900. export var spritesPixelShader: {
  73901. name: string;
  73902. shader: string;
  73903. };
  73904. }
  73905. declare module BABYLON {
  73906. /** @hidden */
  73907. export var fogVertexDeclaration: {
  73908. name: string;
  73909. shader: string;
  73910. };
  73911. }
  73912. declare module BABYLON {
  73913. /** @hidden */
  73914. export var spritesVertexShader: {
  73915. name: string;
  73916. shader: string;
  73917. };
  73918. }
  73919. declare module BABYLON {
  73920. /**
  73921. * Defines the minimum interface to fullfil in order to be a sprite manager.
  73922. */
  73923. export interface ISpriteManager extends IDisposable {
  73924. /**
  73925. * Restricts the camera to viewing objects with the same layerMask.
  73926. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  73927. */
  73928. layerMask: number;
  73929. /**
  73930. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  73931. */
  73932. isPickable: boolean;
  73933. /**
  73934. * Specifies the rendering group id for this mesh (0 by default)
  73935. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  73936. */
  73937. renderingGroupId: number;
  73938. /**
  73939. * Defines the list of sprites managed by the manager.
  73940. */
  73941. sprites: Array<Sprite>;
  73942. /**
  73943. * Tests the intersection of a sprite with a specific ray.
  73944. * @param ray The ray we are sending to test the collision
  73945. * @param camera The camera space we are sending rays in
  73946. * @param predicate A predicate allowing excluding sprites from the list of object to test
  73947. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  73948. * @returns picking info or null.
  73949. */
  73950. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  73951. /**
  73952. * Renders the list of sprites on screen.
  73953. */
  73954. render(): void;
  73955. }
  73956. /**
  73957. * Class used to manage multiple sprites on the same spritesheet
  73958. * @see http://doc.babylonjs.com/babylon101/sprites
  73959. */
  73960. export class SpriteManager implements ISpriteManager {
  73961. /** defines the manager's name */
  73962. name: string;
  73963. /** Gets the list of sprites */
  73964. sprites: Sprite[];
  73965. /** Gets or sets the rendering group id (0 by default) */
  73966. renderingGroupId: number;
  73967. /** Gets or sets camera layer mask */
  73968. layerMask: number;
  73969. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  73970. fogEnabled: boolean;
  73971. /** Gets or sets a boolean indicating if the sprites are pickable */
  73972. isPickable: boolean;
  73973. /** Defines the default width of a cell in the spritesheet */
  73974. cellWidth: number;
  73975. /** Defines the default height of a cell in the spritesheet */
  73976. cellHeight: number;
  73977. /**
  73978. * An event triggered when the manager is disposed.
  73979. */
  73980. onDisposeObservable: Observable<SpriteManager>;
  73981. private _onDisposeObserver;
  73982. /**
  73983. * Callback called when the manager is disposed
  73984. */
  73985. onDispose: () => void;
  73986. private _capacity;
  73987. private _spriteTexture;
  73988. private _epsilon;
  73989. private _scene;
  73990. private _vertexData;
  73991. private _buffer;
  73992. private _vertexBuffers;
  73993. private _indexBuffer;
  73994. private _effectBase;
  73995. private _effectFog;
  73996. /**
  73997. * Gets or sets the spritesheet texture
  73998. */
  73999. texture: Texture;
  74000. /**
  74001. * Creates a new sprite manager
  74002. * @param name defines the manager's name
  74003. * @param imgUrl defines the sprite sheet url
  74004. * @param capacity defines the maximum allowed number of sprites
  74005. * @param cellSize defines the size of a sprite cell
  74006. * @param scene defines the hosting scene
  74007. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  74008. * @param samplingMode defines the smapling mode to use with spritesheet
  74009. */
  74010. constructor(
  74011. /** defines the manager's name */
  74012. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  74013. private _appendSpriteVertex;
  74014. /**
  74015. * Intersects the sprites with a ray
  74016. * @param ray defines the ray to intersect with
  74017. * @param camera defines the current active camera
  74018. * @param predicate defines a predicate used to select candidate sprites
  74019. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  74020. * @returns null if no hit or a PickingInfo
  74021. */
  74022. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  74023. /**
  74024. * Render all child sprites
  74025. */
  74026. render(): void;
  74027. /**
  74028. * Release associated resources
  74029. */
  74030. dispose(): void;
  74031. }
  74032. }
  74033. declare module BABYLON {
  74034. /**
  74035. * Class used to represent a sprite
  74036. * @see http://doc.babylonjs.com/babylon101/sprites
  74037. */
  74038. export class Sprite {
  74039. /** defines the name */
  74040. name: string;
  74041. /** Gets or sets the current world position */
  74042. position: Vector3;
  74043. /** Gets or sets the main color */
  74044. color: Color4;
  74045. /** Gets or sets the width */
  74046. width: number;
  74047. /** Gets or sets the height */
  74048. height: number;
  74049. /** Gets or sets rotation angle */
  74050. angle: number;
  74051. /** Gets or sets the cell index in the sprite sheet */
  74052. cellIndex: number;
  74053. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  74054. invertU: number;
  74055. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  74056. invertV: number;
  74057. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  74058. disposeWhenFinishedAnimating: boolean;
  74059. /** Gets the list of attached animations */
  74060. animations: Animation[];
  74061. /** Gets or sets a boolean indicating if the sprite can be picked */
  74062. isPickable: boolean;
  74063. /**
  74064. * Gets or sets the associated action manager
  74065. */
  74066. actionManager: Nullable<ActionManager>;
  74067. private _animationStarted;
  74068. private _loopAnimation;
  74069. private _fromIndex;
  74070. private _toIndex;
  74071. private _delay;
  74072. private _direction;
  74073. private _manager;
  74074. private _time;
  74075. private _onAnimationEnd;
  74076. /**
  74077. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  74078. */
  74079. isVisible: boolean;
  74080. /**
  74081. * Gets or sets the sprite size
  74082. */
  74083. size: number;
  74084. /**
  74085. * Creates a new Sprite
  74086. * @param name defines the name
  74087. * @param manager defines the manager
  74088. */
  74089. constructor(
  74090. /** defines the name */
  74091. name: string, manager: ISpriteManager);
  74092. /**
  74093. * Starts an animation
  74094. * @param from defines the initial key
  74095. * @param to defines the end key
  74096. * @param loop defines if the animation must loop
  74097. * @param delay defines the start delay (in ms)
  74098. * @param onAnimationEnd defines a callback to call when animation ends
  74099. */
  74100. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  74101. /** Stops current animation (if any) */
  74102. stopAnimation(): void;
  74103. /** @hidden */
  74104. _animate(deltaTime: number): void;
  74105. /** Release associated resources */
  74106. dispose(): void;
  74107. }
  74108. }
  74109. declare module BABYLON {
  74110. /**
  74111. * Information about the result of picking within a scene
  74112. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  74113. */
  74114. export class PickingInfo {
  74115. /** @hidden */
  74116. _pickingUnavailable: boolean;
  74117. /**
  74118. * If the pick collided with an object
  74119. */
  74120. hit: boolean;
  74121. /**
  74122. * Distance away where the pick collided
  74123. */
  74124. distance: number;
  74125. /**
  74126. * The location of pick collision
  74127. */
  74128. pickedPoint: Nullable<Vector3>;
  74129. /**
  74130. * The mesh corresponding the the pick collision
  74131. */
  74132. pickedMesh: Nullable<AbstractMesh>;
  74133. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  74134. bu: number;
  74135. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  74136. bv: number;
  74137. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  74138. faceId: number;
  74139. /** Id of the the submesh that was picked */
  74140. subMeshId: number;
  74141. /** If a sprite was picked, this will be the sprite the pick collided with */
  74142. pickedSprite: Nullable<Sprite>;
  74143. /**
  74144. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  74145. */
  74146. originMesh: Nullable<AbstractMesh>;
  74147. /**
  74148. * The ray that was used to perform the picking.
  74149. */
  74150. ray: Nullable<Ray>;
  74151. /**
  74152. * Gets the normal correspodning to the face the pick collided with
  74153. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  74154. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  74155. * @returns The normal correspodning to the face the pick collided with
  74156. */
  74157. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  74158. /**
  74159. * Gets the texture coordinates of where the pick occured
  74160. * @returns the vector containing the coordnates of the texture
  74161. */
  74162. getTextureCoordinates(): Nullable<Vector2>;
  74163. }
  74164. }
  74165. declare module BABYLON {
  74166. /**
  74167. * Gather the list of pointer event types as constants.
  74168. */
  74169. export class PointerEventTypes {
  74170. /**
  74171. * 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.
  74172. */
  74173. static readonly POINTERDOWN: number;
  74174. /**
  74175. * The pointerup event is fired when a pointer is no longer active.
  74176. */
  74177. static readonly POINTERUP: number;
  74178. /**
  74179. * The pointermove event is fired when a pointer changes coordinates.
  74180. */
  74181. static readonly POINTERMOVE: number;
  74182. /**
  74183. * The pointerwheel event is fired when a mouse wheel has been rotated.
  74184. */
  74185. static readonly POINTERWHEEL: number;
  74186. /**
  74187. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  74188. */
  74189. static readonly POINTERPICK: number;
  74190. /**
  74191. * The pointertap event is fired when a the object has been touched and released without drag.
  74192. */
  74193. static readonly POINTERTAP: number;
  74194. /**
  74195. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  74196. */
  74197. static readonly POINTERDOUBLETAP: number;
  74198. }
  74199. /**
  74200. * Base class of pointer info types.
  74201. */
  74202. export class PointerInfoBase {
  74203. /**
  74204. * Defines the type of event (PointerEventTypes)
  74205. */
  74206. type: number;
  74207. /**
  74208. * Defines the related dom event
  74209. */
  74210. event: PointerEvent | MouseWheelEvent;
  74211. /**
  74212. * Instantiates the base class of pointers info.
  74213. * @param type Defines the type of event (PointerEventTypes)
  74214. * @param event Defines the related dom event
  74215. */
  74216. constructor(
  74217. /**
  74218. * Defines the type of event (PointerEventTypes)
  74219. */
  74220. type: number,
  74221. /**
  74222. * Defines the related dom event
  74223. */
  74224. event: PointerEvent | MouseWheelEvent);
  74225. }
  74226. /**
  74227. * This class is used to store pointer related info for the onPrePointerObservable event.
  74228. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  74229. */
  74230. export class PointerInfoPre extends PointerInfoBase {
  74231. /**
  74232. * Ray from a pointer if availible (eg. 6dof controller)
  74233. */
  74234. ray: Nullable<Ray>;
  74235. /**
  74236. * Defines the local position of the pointer on the canvas.
  74237. */
  74238. localPosition: Vector2;
  74239. /**
  74240. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  74241. */
  74242. skipOnPointerObservable: boolean;
  74243. /**
  74244. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  74245. * @param type Defines the type of event (PointerEventTypes)
  74246. * @param event Defines the related dom event
  74247. * @param localX Defines the local x coordinates of the pointer when the event occured
  74248. * @param localY Defines the local y coordinates of the pointer when the event occured
  74249. */
  74250. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  74251. }
  74252. /**
  74253. * This type contains all the data related to a pointer event in Babylon.js.
  74254. * 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.
  74255. */
  74256. export class PointerInfo extends PointerInfoBase {
  74257. /**
  74258. * Defines the picking info associated to the info (if any)\
  74259. */
  74260. pickInfo: Nullable<PickingInfo>;
  74261. /**
  74262. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  74263. * @param type Defines the type of event (PointerEventTypes)
  74264. * @param event Defines the related dom event
  74265. * @param pickInfo Defines the picking info associated to the info (if any)\
  74266. */
  74267. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  74268. /**
  74269. * Defines the picking info associated to the info (if any)\
  74270. */
  74271. pickInfo: Nullable<PickingInfo>);
  74272. }
  74273. /**
  74274. * Data relating to a touch event on the screen.
  74275. */
  74276. export interface PointerTouch {
  74277. /**
  74278. * X coordinate of touch.
  74279. */
  74280. x: number;
  74281. /**
  74282. * Y coordinate of touch.
  74283. */
  74284. y: number;
  74285. /**
  74286. * Id of touch. Unique for each finger.
  74287. */
  74288. pointerId: number;
  74289. /**
  74290. * Event type passed from DOM.
  74291. */
  74292. type: any;
  74293. }
  74294. }
  74295. declare module BABYLON {
  74296. /**
  74297. * Manage the mouse inputs to control the movement of a free camera.
  74298. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  74299. */
  74300. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  74301. /**
  74302. * Define if touch is enabled in the mouse input
  74303. */
  74304. touchEnabled: boolean;
  74305. /**
  74306. * Defines the camera the input is attached to.
  74307. */
  74308. camera: FreeCamera;
  74309. /**
  74310. * Defines the buttons associated with the input to handle camera move.
  74311. */
  74312. buttons: number[];
  74313. /**
  74314. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  74315. */
  74316. angularSensibility: number;
  74317. private _pointerInput;
  74318. private _onMouseMove;
  74319. private _observer;
  74320. private previousPosition;
  74321. /**
  74322. * Observable for when a pointer move event occurs containing the move offset
  74323. */
  74324. onPointerMovedObservable: Observable<{
  74325. offsetX: number;
  74326. offsetY: number;
  74327. }>;
  74328. /**
  74329. * @hidden
  74330. * If the camera should be rotated automatically based on pointer movement
  74331. */
  74332. _allowCameraRotation: boolean;
  74333. /**
  74334. * Manage the mouse inputs to control the movement of a free camera.
  74335. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  74336. * @param touchEnabled Defines if touch is enabled or not
  74337. */
  74338. constructor(
  74339. /**
  74340. * Define if touch is enabled in the mouse input
  74341. */
  74342. touchEnabled?: boolean);
  74343. /**
  74344. * Attach the input controls to a specific dom element to get the input from.
  74345. * @param element Defines the element the controls should be listened from
  74346. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  74347. */
  74348. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  74349. /**
  74350. * Called on JS contextmenu event.
  74351. * Override this method to provide functionality.
  74352. */
  74353. protected onContextMenu(evt: PointerEvent): void;
  74354. /**
  74355. * Detach the current controls from the specified dom element.
  74356. * @param element Defines the element to stop listening the inputs from
  74357. */
  74358. detachControl(element: Nullable<HTMLElement>): void;
  74359. /**
  74360. * Gets the class name of the current intput.
  74361. * @returns the class name
  74362. */
  74363. getClassName(): string;
  74364. /**
  74365. * Get the friendly name associated with the input class.
  74366. * @returns the input friendly name
  74367. */
  74368. getSimpleName(): string;
  74369. }
  74370. }
  74371. declare module BABYLON {
  74372. /**
  74373. * Manage the touch inputs to control the movement of a free camera.
  74374. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  74375. */
  74376. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  74377. /**
  74378. * Defines the camera the input is attached to.
  74379. */
  74380. camera: FreeCamera;
  74381. /**
  74382. * Defines the touch sensibility for rotation.
  74383. * The higher the faster.
  74384. */
  74385. touchAngularSensibility: number;
  74386. /**
  74387. * Defines the touch sensibility for move.
  74388. * The higher the faster.
  74389. */
  74390. touchMoveSensibility: number;
  74391. private _offsetX;
  74392. private _offsetY;
  74393. private _pointerPressed;
  74394. private _pointerInput;
  74395. private _observer;
  74396. private _onLostFocus;
  74397. /**
  74398. * Attach the input controls to a specific dom element to get the input from.
  74399. * @param element Defines the element the controls should be listened from
  74400. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  74401. */
  74402. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  74403. /**
  74404. * Detach the current controls from the specified dom element.
  74405. * @param element Defines the element to stop listening the inputs from
  74406. */
  74407. detachControl(element: Nullable<HTMLElement>): void;
  74408. /**
  74409. * Update the current camera state depending on the inputs that have been used this frame.
  74410. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  74411. */
  74412. checkInputs(): void;
  74413. /**
  74414. * Gets the class name of the current intput.
  74415. * @returns the class name
  74416. */
  74417. getClassName(): string;
  74418. /**
  74419. * Get the friendly name associated with the input class.
  74420. * @returns the input friendly name
  74421. */
  74422. getSimpleName(): string;
  74423. }
  74424. }
  74425. declare module BABYLON {
  74426. /**
  74427. * Default Inputs manager for the FreeCamera.
  74428. * It groups all the default supported inputs for ease of use.
  74429. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  74430. */
  74431. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  74432. /**
  74433. * @hidden
  74434. */
  74435. _mouseInput: Nullable<FreeCameraMouseInput>;
  74436. /**
  74437. * Instantiates a new FreeCameraInputsManager.
  74438. * @param camera Defines the camera the inputs belong to
  74439. */
  74440. constructor(camera: FreeCamera);
  74441. /**
  74442. * Add keyboard input support to the input manager.
  74443. * @returns the current input manager
  74444. */
  74445. addKeyboard(): FreeCameraInputsManager;
  74446. /**
  74447. * Add mouse input support to the input manager.
  74448. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  74449. * @returns the current input manager
  74450. */
  74451. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  74452. /**
  74453. * Removes the mouse input support from the manager
  74454. * @returns the current input manager
  74455. */
  74456. removeMouse(): FreeCameraInputsManager;
  74457. /**
  74458. * Add touch input support to the input manager.
  74459. * @returns the current input manager
  74460. */
  74461. addTouch(): FreeCameraInputsManager;
  74462. /**
  74463. * Remove all attached input methods from a camera
  74464. */
  74465. clear(): void;
  74466. }
  74467. }
  74468. declare module BABYLON {
  74469. /**
  74470. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  74471. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  74472. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  74473. */
  74474. export class FreeCamera extends TargetCamera {
  74475. /**
  74476. * Define the collision ellipsoid of the camera.
  74477. * This is helpful to simulate a camera body like the player body around the camera
  74478. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  74479. */
  74480. ellipsoid: Vector3;
  74481. /**
  74482. * Define an offset for the position of the ellipsoid around the camera.
  74483. * This can be helpful to determine the center of the body near the gravity center of the body
  74484. * instead of its head.
  74485. */
  74486. ellipsoidOffset: Vector3;
  74487. /**
  74488. * Enable or disable collisions of the camera with the rest of the scene objects.
  74489. */
  74490. checkCollisions: boolean;
  74491. /**
  74492. * Enable or disable gravity on the camera.
  74493. */
  74494. applyGravity: boolean;
  74495. /**
  74496. * Define the input manager associated to the camera.
  74497. */
  74498. inputs: FreeCameraInputsManager;
  74499. /**
  74500. * Gets the input sensibility for a mouse input. (default is 2000.0)
  74501. * Higher values reduce sensitivity.
  74502. */
  74503. /**
  74504. * Sets the input sensibility for a mouse input. (default is 2000.0)
  74505. * Higher values reduce sensitivity.
  74506. */
  74507. angularSensibility: number;
  74508. /**
  74509. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  74510. */
  74511. keysUp: number[];
  74512. /**
  74513. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  74514. */
  74515. keysDown: number[];
  74516. /**
  74517. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  74518. */
  74519. keysLeft: number[];
  74520. /**
  74521. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  74522. */
  74523. keysRight: number[];
  74524. /**
  74525. * Event raised when the camera collide with a mesh in the scene.
  74526. */
  74527. onCollide: (collidedMesh: AbstractMesh) => void;
  74528. private _collider;
  74529. private _needMoveForGravity;
  74530. private _oldPosition;
  74531. private _diffPosition;
  74532. private _newPosition;
  74533. /** @hidden */
  74534. _localDirection: Vector3;
  74535. /** @hidden */
  74536. _transformedDirection: Vector3;
  74537. /**
  74538. * Instantiates a Free Camera.
  74539. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  74540. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  74541. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  74542. * @param name Define the name of the camera in the scene
  74543. * @param position Define the start position of the camera in the scene
  74544. * @param scene Define the scene the camera belongs to
  74545. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  74546. */
  74547. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  74548. /**
  74549. * Attached controls to the current camera.
  74550. * @param element Defines the element the controls should be listened from
  74551. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  74552. */
  74553. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  74554. /**
  74555. * Detach the current controls from the camera.
  74556. * The camera will stop reacting to inputs.
  74557. * @param element Defines the element to stop listening the inputs from
  74558. */
  74559. detachControl(element: HTMLElement): void;
  74560. private _collisionMask;
  74561. /**
  74562. * Define a collision mask to limit the list of object the camera can collide with
  74563. */
  74564. collisionMask: number;
  74565. /** @hidden */
  74566. _collideWithWorld(displacement: Vector3): void;
  74567. private _onCollisionPositionChange;
  74568. /** @hidden */
  74569. _checkInputs(): void;
  74570. /** @hidden */
  74571. _decideIfNeedsToMove(): boolean;
  74572. /** @hidden */
  74573. _updatePosition(): void;
  74574. /**
  74575. * Destroy the camera and release the current resources hold by it.
  74576. */
  74577. dispose(): void;
  74578. /**
  74579. * Gets the current object class name.
  74580. * @return the class name
  74581. */
  74582. getClassName(): string;
  74583. }
  74584. }
  74585. declare module BABYLON {
  74586. /**
  74587. * Represents a gamepad control stick position
  74588. */
  74589. export class StickValues {
  74590. /**
  74591. * The x component of the control stick
  74592. */
  74593. x: number;
  74594. /**
  74595. * The y component of the control stick
  74596. */
  74597. y: number;
  74598. /**
  74599. * Initializes the gamepad x and y control stick values
  74600. * @param x The x component of the gamepad control stick value
  74601. * @param y The y component of the gamepad control stick value
  74602. */
  74603. constructor(
  74604. /**
  74605. * The x component of the control stick
  74606. */
  74607. x: number,
  74608. /**
  74609. * The y component of the control stick
  74610. */
  74611. y: number);
  74612. }
  74613. /**
  74614. * An interface which manages callbacks for gamepad button changes
  74615. */
  74616. export interface GamepadButtonChanges {
  74617. /**
  74618. * Called when a gamepad has been changed
  74619. */
  74620. changed: boolean;
  74621. /**
  74622. * Called when a gamepad press event has been triggered
  74623. */
  74624. pressChanged: boolean;
  74625. /**
  74626. * Called when a touch event has been triggered
  74627. */
  74628. touchChanged: boolean;
  74629. /**
  74630. * Called when a value has changed
  74631. */
  74632. valueChanged: boolean;
  74633. }
  74634. /**
  74635. * Represents a gamepad
  74636. */
  74637. export class Gamepad {
  74638. /**
  74639. * The id of the gamepad
  74640. */
  74641. id: string;
  74642. /**
  74643. * The index of the gamepad
  74644. */
  74645. index: number;
  74646. /**
  74647. * The browser gamepad
  74648. */
  74649. browserGamepad: any;
  74650. /**
  74651. * Specifies what type of gamepad this represents
  74652. */
  74653. type: number;
  74654. private _leftStick;
  74655. private _rightStick;
  74656. /** @hidden */
  74657. _isConnected: boolean;
  74658. private _leftStickAxisX;
  74659. private _leftStickAxisY;
  74660. private _rightStickAxisX;
  74661. private _rightStickAxisY;
  74662. /**
  74663. * Triggered when the left control stick has been changed
  74664. */
  74665. private _onleftstickchanged;
  74666. /**
  74667. * Triggered when the right control stick has been changed
  74668. */
  74669. private _onrightstickchanged;
  74670. /**
  74671. * Represents a gamepad controller
  74672. */
  74673. static GAMEPAD: number;
  74674. /**
  74675. * Represents a generic controller
  74676. */
  74677. static GENERIC: number;
  74678. /**
  74679. * Represents an XBox controller
  74680. */
  74681. static XBOX: number;
  74682. /**
  74683. * Represents a pose-enabled controller
  74684. */
  74685. static POSE_ENABLED: number;
  74686. /**
  74687. * Specifies whether the left control stick should be Y-inverted
  74688. */
  74689. protected _invertLeftStickY: boolean;
  74690. /**
  74691. * Specifies if the gamepad has been connected
  74692. */
  74693. readonly isConnected: boolean;
  74694. /**
  74695. * Initializes the gamepad
  74696. * @param id The id of the gamepad
  74697. * @param index The index of the gamepad
  74698. * @param browserGamepad The browser gamepad
  74699. * @param leftStickX The x component of the left joystick
  74700. * @param leftStickY The y component of the left joystick
  74701. * @param rightStickX The x component of the right joystick
  74702. * @param rightStickY The y component of the right joystick
  74703. */
  74704. constructor(
  74705. /**
  74706. * The id of the gamepad
  74707. */
  74708. id: string,
  74709. /**
  74710. * The index of the gamepad
  74711. */
  74712. index: number,
  74713. /**
  74714. * The browser gamepad
  74715. */
  74716. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  74717. /**
  74718. * Callback triggered when the left joystick has changed
  74719. * @param callback
  74720. */
  74721. onleftstickchanged(callback: (values: StickValues) => void): void;
  74722. /**
  74723. * Callback triggered when the right joystick has changed
  74724. * @param callback
  74725. */
  74726. onrightstickchanged(callback: (values: StickValues) => void): void;
  74727. /**
  74728. * Gets the left joystick
  74729. */
  74730. /**
  74731. * Sets the left joystick values
  74732. */
  74733. leftStick: StickValues;
  74734. /**
  74735. * Gets the right joystick
  74736. */
  74737. /**
  74738. * Sets the right joystick value
  74739. */
  74740. rightStick: StickValues;
  74741. /**
  74742. * Updates the gamepad joystick positions
  74743. */
  74744. update(): void;
  74745. /**
  74746. * Disposes the gamepad
  74747. */
  74748. dispose(): void;
  74749. }
  74750. /**
  74751. * Represents a generic gamepad
  74752. */
  74753. export class GenericPad extends Gamepad {
  74754. private _buttons;
  74755. private _onbuttondown;
  74756. private _onbuttonup;
  74757. /**
  74758. * Observable triggered when a button has been pressed
  74759. */
  74760. onButtonDownObservable: Observable<number>;
  74761. /**
  74762. * Observable triggered when a button has been released
  74763. */
  74764. onButtonUpObservable: Observable<number>;
  74765. /**
  74766. * Callback triggered when a button has been pressed
  74767. * @param callback Called when a button has been pressed
  74768. */
  74769. onbuttondown(callback: (buttonPressed: number) => void): void;
  74770. /**
  74771. * Callback triggered when a button has been released
  74772. * @param callback Called when a button has been released
  74773. */
  74774. onbuttonup(callback: (buttonReleased: number) => void): void;
  74775. /**
  74776. * Initializes the generic gamepad
  74777. * @param id The id of the generic gamepad
  74778. * @param index The index of the generic gamepad
  74779. * @param browserGamepad The browser gamepad
  74780. */
  74781. constructor(id: string, index: number, browserGamepad: any);
  74782. private _setButtonValue;
  74783. /**
  74784. * Updates the generic gamepad
  74785. */
  74786. update(): void;
  74787. /**
  74788. * Disposes the generic gamepad
  74789. */
  74790. dispose(): void;
  74791. }
  74792. }
  74793. declare module BABYLON {
  74794. /**
  74795. * Defines the types of pose enabled controllers that are supported
  74796. */
  74797. export enum PoseEnabledControllerType {
  74798. /**
  74799. * HTC Vive
  74800. */
  74801. VIVE = 0,
  74802. /**
  74803. * Oculus Rift
  74804. */
  74805. OCULUS = 1,
  74806. /**
  74807. * Windows mixed reality
  74808. */
  74809. WINDOWS = 2,
  74810. /**
  74811. * Samsung gear VR
  74812. */
  74813. GEAR_VR = 3,
  74814. /**
  74815. * Google Daydream
  74816. */
  74817. DAYDREAM = 4,
  74818. /**
  74819. * Generic
  74820. */
  74821. GENERIC = 5
  74822. }
  74823. /**
  74824. * Defines the MutableGamepadButton interface for the state of a gamepad button
  74825. */
  74826. export interface MutableGamepadButton {
  74827. /**
  74828. * Value of the button/trigger
  74829. */
  74830. value: number;
  74831. /**
  74832. * If the button/trigger is currently touched
  74833. */
  74834. touched: boolean;
  74835. /**
  74836. * If the button/trigger is currently pressed
  74837. */
  74838. pressed: boolean;
  74839. }
  74840. /**
  74841. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  74842. * @hidden
  74843. */
  74844. export interface ExtendedGamepadButton extends GamepadButton {
  74845. /**
  74846. * If the button/trigger is currently pressed
  74847. */
  74848. readonly pressed: boolean;
  74849. /**
  74850. * If the button/trigger is currently touched
  74851. */
  74852. readonly touched: boolean;
  74853. /**
  74854. * Value of the button/trigger
  74855. */
  74856. readonly value: number;
  74857. }
  74858. /** @hidden */
  74859. export interface _GamePadFactory {
  74860. /**
  74861. * Returns wether or not the current gamepad can be created for this type of controller.
  74862. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  74863. * @returns true if it can be created, otherwise false
  74864. */
  74865. canCreate(gamepadInfo: any): boolean;
  74866. /**
  74867. * Creates a new instance of the Gamepad.
  74868. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  74869. * @returns the new gamepad instance
  74870. */
  74871. create(gamepadInfo: any): Gamepad;
  74872. }
  74873. /**
  74874. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  74875. */
  74876. export class PoseEnabledControllerHelper {
  74877. /** @hidden */
  74878. static _ControllerFactories: _GamePadFactory[];
  74879. /** @hidden */
  74880. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  74881. /**
  74882. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  74883. * @param vrGamepad the gamepad to initialized
  74884. * @returns a vr controller of the type the gamepad identified as
  74885. */
  74886. static InitiateController(vrGamepad: any): Gamepad;
  74887. }
  74888. /**
  74889. * Defines the PoseEnabledController object that contains state of a vr capable controller
  74890. */
  74891. export class PoseEnabledController extends Gamepad implements PoseControlled {
  74892. private _deviceRoomPosition;
  74893. private _deviceRoomRotationQuaternion;
  74894. /**
  74895. * The device position in babylon space
  74896. */
  74897. devicePosition: Vector3;
  74898. /**
  74899. * The device rotation in babylon space
  74900. */
  74901. deviceRotationQuaternion: Quaternion;
  74902. /**
  74903. * The scale factor of the device in babylon space
  74904. */
  74905. deviceScaleFactor: number;
  74906. /**
  74907. * (Likely devicePosition should be used instead) The device position in its room space
  74908. */
  74909. position: Vector3;
  74910. /**
  74911. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  74912. */
  74913. rotationQuaternion: Quaternion;
  74914. /**
  74915. * The type of controller (Eg. Windows mixed reality)
  74916. */
  74917. controllerType: PoseEnabledControllerType;
  74918. protected _calculatedPosition: Vector3;
  74919. private _calculatedRotation;
  74920. /**
  74921. * The raw pose from the device
  74922. */
  74923. rawPose: DevicePose;
  74924. private _trackPosition;
  74925. private _maxRotationDistFromHeadset;
  74926. private _draggedRoomRotation;
  74927. /**
  74928. * @hidden
  74929. */
  74930. _disableTrackPosition(fixedPosition: Vector3): void;
  74931. /**
  74932. * Internal, the mesh attached to the controller
  74933. * @hidden
  74934. */
  74935. _mesh: Nullable<AbstractMesh>;
  74936. private _poseControlledCamera;
  74937. private _leftHandSystemQuaternion;
  74938. /**
  74939. * Internal, matrix used to convert room space to babylon space
  74940. * @hidden
  74941. */
  74942. _deviceToWorld: Matrix;
  74943. /**
  74944. * Node to be used when casting a ray from the controller
  74945. * @hidden
  74946. */
  74947. _pointingPoseNode: Nullable<TransformNode>;
  74948. /**
  74949. * Name of the child mesh that can be used to cast a ray from the controller
  74950. */
  74951. static readonly POINTING_POSE: string;
  74952. /**
  74953. * Creates a new PoseEnabledController from a gamepad
  74954. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  74955. */
  74956. constructor(browserGamepad: any);
  74957. private _workingMatrix;
  74958. /**
  74959. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  74960. */
  74961. update(): void;
  74962. /**
  74963. * Updates only the pose device and mesh without doing any button event checking
  74964. */
  74965. protected _updatePoseAndMesh(): void;
  74966. /**
  74967. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  74968. * @param poseData raw pose fromthe device
  74969. */
  74970. updateFromDevice(poseData: DevicePose): void;
  74971. /**
  74972. * @hidden
  74973. */
  74974. _meshAttachedObservable: Observable<AbstractMesh>;
  74975. /**
  74976. * Attaches a mesh to the controller
  74977. * @param mesh the mesh to be attached
  74978. */
  74979. attachToMesh(mesh: AbstractMesh): void;
  74980. /**
  74981. * Attaches the controllers mesh to a camera
  74982. * @param camera the camera the mesh should be attached to
  74983. */
  74984. attachToPoseControlledCamera(camera: TargetCamera): void;
  74985. /**
  74986. * Disposes of the controller
  74987. */
  74988. dispose(): void;
  74989. /**
  74990. * The mesh that is attached to the controller
  74991. */
  74992. readonly mesh: Nullable<AbstractMesh>;
  74993. /**
  74994. * Gets the ray of the controller in the direction the controller is pointing
  74995. * @param length the length the resulting ray should be
  74996. * @returns a ray in the direction the controller is pointing
  74997. */
  74998. getForwardRay(length?: number): Ray;
  74999. }
  75000. }
  75001. declare module BABYLON {
  75002. /**
  75003. * Defines the WebVRController object that represents controllers tracked in 3D space
  75004. */
  75005. export abstract class WebVRController extends PoseEnabledController {
  75006. /**
  75007. * Internal, the default controller model for the controller
  75008. */
  75009. protected _defaultModel: AbstractMesh;
  75010. /**
  75011. * Fired when the trigger state has changed
  75012. */
  75013. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  75014. /**
  75015. * Fired when the main button state has changed
  75016. */
  75017. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  75018. /**
  75019. * Fired when the secondary button state has changed
  75020. */
  75021. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  75022. /**
  75023. * Fired when the pad state has changed
  75024. */
  75025. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  75026. /**
  75027. * Fired when controllers stick values have changed
  75028. */
  75029. onPadValuesChangedObservable: Observable<StickValues>;
  75030. /**
  75031. * Array of button availible on the controller
  75032. */
  75033. protected _buttons: Array<MutableGamepadButton>;
  75034. private _onButtonStateChange;
  75035. /**
  75036. * Fired when a controller button's state has changed
  75037. * @param callback the callback containing the button that was modified
  75038. */
  75039. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  75040. /**
  75041. * X and Y axis corrisponding to the controllers joystick
  75042. */
  75043. pad: StickValues;
  75044. /**
  75045. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  75046. */
  75047. hand: string;
  75048. /**
  75049. * The default controller model for the controller
  75050. */
  75051. readonly defaultModel: AbstractMesh;
  75052. /**
  75053. * Creates a new WebVRController from a gamepad
  75054. * @param vrGamepad the gamepad that the WebVRController should be created from
  75055. */
  75056. constructor(vrGamepad: any);
  75057. /**
  75058. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  75059. */
  75060. update(): void;
  75061. /**
  75062. * Function to be called when a button is modified
  75063. */
  75064. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  75065. /**
  75066. * Loads a mesh and attaches it to the controller
  75067. * @param scene the scene the mesh should be added to
  75068. * @param meshLoaded callback for when the mesh has been loaded
  75069. */
  75070. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  75071. private _setButtonValue;
  75072. private _changes;
  75073. private _checkChanges;
  75074. /**
  75075. * Disposes of th webVRCOntroller
  75076. */
  75077. dispose(): void;
  75078. }
  75079. }
  75080. declare module BABYLON {
  75081. /**
  75082. * The HemisphericLight simulates the ambient environment light,
  75083. * so the passed direction is the light reflection direction, not the incoming direction.
  75084. */
  75085. export class HemisphericLight extends Light {
  75086. /**
  75087. * The groundColor is the light in the opposite direction to the one specified during creation.
  75088. * 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.
  75089. */
  75090. groundColor: Color3;
  75091. /**
  75092. * The light reflection direction, not the incoming direction.
  75093. */
  75094. direction: Vector3;
  75095. /**
  75096. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  75097. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  75098. * The HemisphericLight can't cast shadows.
  75099. * Documentation : https://doc.babylonjs.com/babylon101/lights
  75100. * @param name The friendly name of the light
  75101. * @param direction The direction of the light reflection
  75102. * @param scene The scene the light belongs to
  75103. */
  75104. constructor(name: string, direction: Vector3, scene: Scene);
  75105. protected _buildUniformLayout(): void;
  75106. /**
  75107. * Returns the string "HemisphericLight".
  75108. * @return The class name
  75109. */
  75110. getClassName(): string;
  75111. /**
  75112. * Sets the HemisphericLight direction towards the passed target (Vector3).
  75113. * Returns the updated direction.
  75114. * @param target The target the direction should point to
  75115. * @return The computed direction
  75116. */
  75117. setDirectionToTarget(target: Vector3): Vector3;
  75118. /**
  75119. * Returns the shadow generator associated to the light.
  75120. * @returns Always null for hemispheric lights because it does not support shadows.
  75121. */
  75122. getShadowGenerator(): Nullable<IShadowGenerator>;
  75123. /**
  75124. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  75125. * @param effect The effect to update
  75126. * @param lightIndex The index of the light in the effect to update
  75127. * @returns The hemispheric light
  75128. */
  75129. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  75130. /**
  75131. * Computes the world matrix of the node
  75132. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  75133. * @param useWasUpdatedFlag defines a reserved property
  75134. * @returns the world matrix
  75135. */
  75136. computeWorldMatrix(): Matrix;
  75137. /**
  75138. * Returns the integer 3.
  75139. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  75140. */
  75141. getTypeID(): number;
  75142. /**
  75143. * Prepares the list of defines specific to the light type.
  75144. * @param defines the list of defines
  75145. * @param lightIndex defines the index of the light for the effect
  75146. */
  75147. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  75148. }
  75149. }
  75150. declare module BABYLON {
  75151. /** @hidden */
  75152. export var vrMultiviewToSingleviewPixelShader: {
  75153. name: string;
  75154. shader: string;
  75155. };
  75156. }
  75157. declare module BABYLON {
  75158. /**
  75159. * Renders to multiple views with a single draw call
  75160. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  75161. */
  75162. export class MultiviewRenderTarget extends RenderTargetTexture {
  75163. /**
  75164. * Creates a multiview render target
  75165. * @param scene scene used with the render target
  75166. * @param size the size of the render target (used for each view)
  75167. */
  75168. constructor(scene: Scene, size?: number | {
  75169. width: number;
  75170. height: number;
  75171. } | {
  75172. ratio: number;
  75173. });
  75174. /**
  75175. * @hidden
  75176. * @param faceIndex the face index, if its a cube texture
  75177. */
  75178. _bindFrameBuffer(faceIndex?: number): void;
  75179. /**
  75180. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  75181. * @returns the view count
  75182. */
  75183. getViewCount(): number;
  75184. }
  75185. }
  75186. declare module BABYLON {
  75187. interface Engine {
  75188. /**
  75189. * Creates a new multiview render target
  75190. * @param width defines the width of the texture
  75191. * @param height defines the height of the texture
  75192. * @returns the created multiview texture
  75193. */
  75194. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  75195. /**
  75196. * Binds a multiview framebuffer to be drawn to
  75197. * @param multiviewTexture texture to bind
  75198. */
  75199. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  75200. }
  75201. interface Camera {
  75202. /**
  75203. * @hidden
  75204. * 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)
  75205. */
  75206. _useMultiviewToSingleView: boolean;
  75207. /**
  75208. * @hidden
  75209. * 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)
  75210. */
  75211. _multiviewTexture: Nullable<RenderTargetTexture>;
  75212. /**
  75213. * @hidden
  75214. * ensures the multiview texture of the camera exists and has the specified width/height
  75215. * @param width height to set on the multiview texture
  75216. * @param height width to set on the multiview texture
  75217. */
  75218. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  75219. }
  75220. interface Scene {
  75221. /** @hidden */
  75222. _transformMatrixR: Matrix;
  75223. /** @hidden */
  75224. _multiviewSceneUbo: Nullable<UniformBuffer>;
  75225. /** @hidden */
  75226. _createMultiviewUbo(): void;
  75227. /** @hidden */
  75228. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  75229. /** @hidden */
  75230. _renderMultiviewToSingleView(camera: Camera): void;
  75231. }
  75232. }
  75233. declare module BABYLON {
  75234. /**
  75235. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  75236. * This will not be used for webXR as it supports displaying texture arrays directly
  75237. */
  75238. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  75239. /**
  75240. * Initializes a VRMultiviewToSingleview
  75241. * @param name name of the post process
  75242. * @param camera camera to be applied to
  75243. * @param scaleFactor scaling factor to the size of the output texture
  75244. */
  75245. constructor(name: string, camera: Camera, scaleFactor: number);
  75246. }
  75247. }
  75248. declare module BABYLON {
  75249. /**
  75250. * Defines the interface used by display changed events
  75251. */
  75252. interface IDisplayChangedEventArgs {
  75253. /** Gets the vrDisplay object (if any) */
  75254. vrDisplay: Nullable<any>;
  75255. /** Gets a boolean indicating if webVR is supported */
  75256. vrSupported: boolean;
  75257. }
  75258. interface Engine {
  75259. /** @hidden */
  75260. _vrDisplay: any;
  75261. /** @hidden */
  75262. _vrSupported: boolean;
  75263. /** @hidden */
  75264. _oldSize: Size;
  75265. /** @hidden */
  75266. _oldHardwareScaleFactor: number;
  75267. /** @hidden */
  75268. _vrExclusivePointerMode: boolean;
  75269. /** @hidden */
  75270. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  75271. /** @hidden */
  75272. _onVRDisplayPointerRestricted: () => void;
  75273. /** @hidden */
  75274. _onVRDisplayPointerUnrestricted: () => void;
  75275. /** @hidden */
  75276. _onVrDisplayConnect: Nullable<(display: any) => void>;
  75277. /** @hidden */
  75278. _onVrDisplayDisconnect: Nullable<() => void>;
  75279. /** @hidden */
  75280. _onVrDisplayPresentChange: Nullable<() => void>;
  75281. /**
  75282. * Observable signaled when VR display mode changes
  75283. */
  75284. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  75285. /**
  75286. * Observable signaled when VR request present is complete
  75287. */
  75288. onVRRequestPresentComplete: Observable<boolean>;
  75289. /**
  75290. * Observable signaled when VR request present starts
  75291. */
  75292. onVRRequestPresentStart: Observable<Engine>;
  75293. /**
  75294. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  75295. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  75296. */
  75297. isInVRExclusivePointerMode: boolean;
  75298. /**
  75299. * Gets a boolean indicating if a webVR device was detected
  75300. * @returns true if a webVR device was detected
  75301. */
  75302. isVRDevicePresent(): boolean;
  75303. /**
  75304. * Gets the current webVR device
  75305. * @returns the current webVR device (or null)
  75306. */
  75307. getVRDevice(): any;
  75308. /**
  75309. * Initializes a webVR display and starts listening to display change events
  75310. * The onVRDisplayChangedObservable will be notified upon these changes
  75311. * @returns A promise containing a VRDisplay and if vr is supported
  75312. */
  75313. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  75314. /** @hidden */
  75315. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  75316. /**
  75317. * Call this function to switch to webVR mode
  75318. * Will do nothing if webVR is not supported or if there is no webVR device
  75319. * @see http://doc.babylonjs.com/how_to/webvr_camera
  75320. */
  75321. enableVR(): void;
  75322. /** @hidden */
  75323. _onVRFullScreenTriggered(): void;
  75324. }
  75325. }
  75326. declare module BABYLON {
  75327. /**
  75328. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  75329. * IMPORTANT!! The data is right-hand data.
  75330. * @export
  75331. * @interface DevicePose
  75332. */
  75333. export interface DevicePose {
  75334. /**
  75335. * The position of the device, values in array are [x,y,z].
  75336. */
  75337. readonly position: Nullable<Float32Array>;
  75338. /**
  75339. * The linearVelocity of the device, values in array are [x,y,z].
  75340. */
  75341. readonly linearVelocity: Nullable<Float32Array>;
  75342. /**
  75343. * The linearAcceleration of the device, values in array are [x,y,z].
  75344. */
  75345. readonly linearAcceleration: Nullable<Float32Array>;
  75346. /**
  75347. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  75348. */
  75349. readonly orientation: Nullable<Float32Array>;
  75350. /**
  75351. * The angularVelocity of the device, values in array are [x,y,z].
  75352. */
  75353. readonly angularVelocity: Nullable<Float32Array>;
  75354. /**
  75355. * The angularAcceleration of the device, values in array are [x,y,z].
  75356. */
  75357. readonly angularAcceleration: Nullable<Float32Array>;
  75358. }
  75359. /**
  75360. * Interface representing a pose controlled object in Babylon.
  75361. * A pose controlled object has both regular pose values as well as pose values
  75362. * from an external device such as a VR head mounted display
  75363. */
  75364. export interface PoseControlled {
  75365. /**
  75366. * The position of the object in babylon space.
  75367. */
  75368. position: Vector3;
  75369. /**
  75370. * The rotation quaternion of the object in babylon space.
  75371. */
  75372. rotationQuaternion: Quaternion;
  75373. /**
  75374. * The position of the device in babylon space.
  75375. */
  75376. devicePosition?: Vector3;
  75377. /**
  75378. * The rotation quaternion of the device in babylon space.
  75379. */
  75380. deviceRotationQuaternion: Quaternion;
  75381. /**
  75382. * The raw pose coming from the device.
  75383. */
  75384. rawPose: Nullable<DevicePose>;
  75385. /**
  75386. * The scale of the device to be used when translating from device space to babylon space.
  75387. */
  75388. deviceScaleFactor: number;
  75389. /**
  75390. * Updates the poseControlled values based on the input device pose.
  75391. * @param poseData the pose data to update the object with
  75392. */
  75393. updateFromDevice(poseData: DevicePose): void;
  75394. }
  75395. /**
  75396. * Set of options to customize the webVRCamera
  75397. */
  75398. export interface WebVROptions {
  75399. /**
  75400. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  75401. */
  75402. trackPosition?: boolean;
  75403. /**
  75404. * Sets the scale of the vrDevice in babylon space. (default: 1)
  75405. */
  75406. positionScale?: number;
  75407. /**
  75408. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  75409. */
  75410. displayName?: string;
  75411. /**
  75412. * Should the native controller meshes be initialized. (default: true)
  75413. */
  75414. controllerMeshes?: boolean;
  75415. /**
  75416. * Creating a default HemiLight only on controllers. (default: true)
  75417. */
  75418. defaultLightingOnControllers?: boolean;
  75419. /**
  75420. * If you don't want to use the default VR button of the helper. (default: false)
  75421. */
  75422. useCustomVRButton?: boolean;
  75423. /**
  75424. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  75425. */
  75426. customVRButton?: HTMLButtonElement;
  75427. /**
  75428. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  75429. */
  75430. rayLength?: number;
  75431. /**
  75432. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  75433. */
  75434. defaultHeight?: number;
  75435. /**
  75436. * If multiview should be used if availible (default: false)
  75437. */
  75438. useMultiview?: boolean;
  75439. }
  75440. /**
  75441. * This represents a WebVR camera.
  75442. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  75443. * @example http://doc.babylonjs.com/how_to/webvr_camera
  75444. */
  75445. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  75446. private webVROptions;
  75447. /**
  75448. * @hidden
  75449. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  75450. */
  75451. _vrDevice: any;
  75452. /**
  75453. * The rawPose of the vrDevice.
  75454. */
  75455. rawPose: Nullable<DevicePose>;
  75456. private _onVREnabled;
  75457. private _specsVersion;
  75458. private _attached;
  75459. private _frameData;
  75460. protected _descendants: Array<Node>;
  75461. private _deviceRoomPosition;
  75462. /** @hidden */
  75463. _deviceRoomRotationQuaternion: Quaternion;
  75464. private _standingMatrix;
  75465. /**
  75466. * Represents device position in babylon space.
  75467. */
  75468. devicePosition: Vector3;
  75469. /**
  75470. * Represents device rotation in babylon space.
  75471. */
  75472. deviceRotationQuaternion: Quaternion;
  75473. /**
  75474. * The scale of the device to be used when translating from device space to babylon space.
  75475. */
  75476. deviceScaleFactor: number;
  75477. private _deviceToWorld;
  75478. private _worldToDevice;
  75479. /**
  75480. * References to the webVR controllers for the vrDevice.
  75481. */
  75482. controllers: Array<WebVRController>;
  75483. /**
  75484. * Emits an event when a controller is attached.
  75485. */
  75486. onControllersAttachedObservable: Observable<WebVRController[]>;
  75487. /**
  75488. * Emits an event when a controller's mesh has been loaded;
  75489. */
  75490. onControllerMeshLoadedObservable: Observable<WebVRController>;
  75491. /**
  75492. * Emits an event when the HMD's pose has been updated.
  75493. */
  75494. onPoseUpdatedFromDeviceObservable: Observable<any>;
  75495. private _poseSet;
  75496. /**
  75497. * If the rig cameras be used as parent instead of this camera.
  75498. */
  75499. rigParenting: boolean;
  75500. private _lightOnControllers;
  75501. private _defaultHeight?;
  75502. /**
  75503. * Instantiates a WebVRFreeCamera.
  75504. * @param name The name of the WebVRFreeCamera
  75505. * @param position The starting anchor position for the camera
  75506. * @param scene The scene the camera belongs to
  75507. * @param webVROptions a set of customizable options for the webVRCamera
  75508. */
  75509. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  75510. /**
  75511. * Gets the device distance from the ground in meters.
  75512. * @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.
  75513. */
  75514. deviceDistanceToRoomGround(): number;
  75515. /**
  75516. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  75517. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  75518. */
  75519. useStandingMatrix(callback?: (bool: boolean) => void): void;
  75520. /**
  75521. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  75522. * @returns A promise with a boolean set to if the standing matrix is supported.
  75523. */
  75524. useStandingMatrixAsync(): Promise<boolean>;
  75525. /**
  75526. * Disposes the camera
  75527. */
  75528. dispose(): void;
  75529. /**
  75530. * Gets a vrController by name.
  75531. * @param name The name of the controller to retreive
  75532. * @returns the controller matching the name specified or null if not found
  75533. */
  75534. getControllerByName(name: string): Nullable<WebVRController>;
  75535. private _leftController;
  75536. /**
  75537. * The controller corrisponding to the users left hand.
  75538. */
  75539. readonly leftController: Nullable<WebVRController>;
  75540. private _rightController;
  75541. /**
  75542. * The controller corrisponding to the users right hand.
  75543. */
  75544. readonly rightController: Nullable<WebVRController>;
  75545. /**
  75546. * Casts a ray forward from the vrCamera's gaze.
  75547. * @param length Length of the ray (default: 100)
  75548. * @returns the ray corrisponding to the gaze
  75549. */
  75550. getForwardRay(length?: number): Ray;
  75551. /**
  75552. * @hidden
  75553. * Updates the camera based on device's frame data
  75554. */
  75555. _checkInputs(): void;
  75556. /**
  75557. * Updates the poseControlled values based on the input device pose.
  75558. * @param poseData Pose coming from the device
  75559. */
  75560. updateFromDevice(poseData: DevicePose): void;
  75561. private _htmlElementAttached;
  75562. private _detachIfAttached;
  75563. /**
  75564. * WebVR's attach control will start broadcasting frames to the device.
  75565. * Note that in certain browsers (chrome for example) this function must be called
  75566. * within a user-interaction callback. Example:
  75567. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  75568. *
  75569. * @param element html element to attach the vrDevice to
  75570. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  75571. */
  75572. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  75573. /**
  75574. * Detaches the camera from the html element and disables VR
  75575. *
  75576. * @param element html element to detach from
  75577. */
  75578. detachControl(element: HTMLElement): void;
  75579. /**
  75580. * @returns the name of this class
  75581. */
  75582. getClassName(): string;
  75583. /**
  75584. * Calls resetPose on the vrDisplay
  75585. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  75586. */
  75587. resetToCurrentRotation(): void;
  75588. /**
  75589. * @hidden
  75590. * Updates the rig cameras (left and right eye)
  75591. */
  75592. _updateRigCameras(): void;
  75593. private _workingVector;
  75594. private _oneVector;
  75595. private _workingMatrix;
  75596. private updateCacheCalled;
  75597. private _correctPositionIfNotTrackPosition;
  75598. /**
  75599. * @hidden
  75600. * Updates the cached values of the camera
  75601. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  75602. */
  75603. _updateCache(ignoreParentClass?: boolean): void;
  75604. /**
  75605. * @hidden
  75606. * Get current device position in babylon world
  75607. */
  75608. _computeDevicePosition(): void;
  75609. /**
  75610. * Updates the current device position and rotation in the babylon world
  75611. */
  75612. update(): void;
  75613. /**
  75614. * @hidden
  75615. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  75616. * @returns an identity matrix
  75617. */
  75618. _getViewMatrix(): Matrix;
  75619. private _tmpMatrix;
  75620. /**
  75621. * This function is called by the two RIG cameras.
  75622. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  75623. * @hidden
  75624. */
  75625. _getWebVRViewMatrix(): Matrix;
  75626. /** @hidden */
  75627. _getWebVRProjectionMatrix(): Matrix;
  75628. private _onGamepadConnectedObserver;
  75629. private _onGamepadDisconnectedObserver;
  75630. private _updateCacheWhenTrackingDisabledObserver;
  75631. /**
  75632. * Initializes the controllers and their meshes
  75633. */
  75634. initControllers(): void;
  75635. }
  75636. }
  75637. declare module BABYLON {
  75638. /**
  75639. * Size options for a post process
  75640. */
  75641. export type PostProcessOptions = {
  75642. width: number;
  75643. height: number;
  75644. };
  75645. /**
  75646. * PostProcess can be used to apply a shader to a texture after it has been rendered
  75647. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  75648. */
  75649. export class PostProcess {
  75650. /** Name of the PostProcess. */
  75651. name: string;
  75652. /**
  75653. * Gets or sets the unique id of the post process
  75654. */
  75655. uniqueId: number;
  75656. /**
  75657. * Width of the texture to apply the post process on
  75658. */
  75659. width: number;
  75660. /**
  75661. * Height of the texture to apply the post process on
  75662. */
  75663. height: number;
  75664. /**
  75665. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  75666. * @hidden
  75667. */
  75668. _outputTexture: Nullable<InternalTexture>;
  75669. /**
  75670. * Sampling mode used by the shader
  75671. * See https://doc.babylonjs.com/classes/3.1/texture
  75672. */
  75673. renderTargetSamplingMode: number;
  75674. /**
  75675. * Clear color to use when screen clearing
  75676. */
  75677. clearColor: Color4;
  75678. /**
  75679. * If the buffer needs to be cleared before applying the post process. (default: true)
  75680. * Should be set to false if shader will overwrite all previous pixels.
  75681. */
  75682. autoClear: boolean;
  75683. /**
  75684. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  75685. */
  75686. alphaMode: number;
  75687. /**
  75688. * Sets the setAlphaBlendConstants of the babylon engine
  75689. */
  75690. alphaConstants: Color4;
  75691. /**
  75692. * Animations to be used for the post processing
  75693. */
  75694. animations: Animation[];
  75695. /**
  75696. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  75697. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  75698. */
  75699. enablePixelPerfectMode: boolean;
  75700. /**
  75701. * Force the postprocess to be applied without taking in account viewport
  75702. */
  75703. forceFullscreenViewport: boolean;
  75704. /**
  75705. * List of inspectable custom properties (used by the Inspector)
  75706. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  75707. */
  75708. inspectableCustomProperties: IInspectable[];
  75709. /**
  75710. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  75711. *
  75712. * | Value | Type | Description |
  75713. * | ----- | ----------------------------------- | ----------- |
  75714. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  75715. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  75716. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  75717. *
  75718. */
  75719. scaleMode: number;
  75720. /**
  75721. * Force textures to be a power of two (default: false)
  75722. */
  75723. alwaysForcePOT: boolean;
  75724. private _samples;
  75725. /**
  75726. * Number of sample textures (default: 1)
  75727. */
  75728. samples: number;
  75729. /**
  75730. * Modify the scale of the post process to be the same as the viewport (default: false)
  75731. */
  75732. adaptScaleToCurrentViewport: boolean;
  75733. private _camera;
  75734. private _scene;
  75735. private _engine;
  75736. private _options;
  75737. private _reusable;
  75738. private _textureType;
  75739. /**
  75740. * Smart array of input and output textures for the post process.
  75741. * @hidden
  75742. */
  75743. _textures: SmartArray<InternalTexture>;
  75744. /**
  75745. * The index in _textures that corresponds to the output texture.
  75746. * @hidden
  75747. */
  75748. _currentRenderTextureInd: number;
  75749. private _effect;
  75750. private _samplers;
  75751. private _fragmentUrl;
  75752. private _vertexUrl;
  75753. private _parameters;
  75754. private _scaleRatio;
  75755. protected _indexParameters: any;
  75756. private _shareOutputWithPostProcess;
  75757. private _texelSize;
  75758. private _forcedOutputTexture;
  75759. /**
  75760. * Returns the fragment url or shader name used in the post process.
  75761. * @returns the fragment url or name in the shader store.
  75762. */
  75763. getEffectName(): string;
  75764. /**
  75765. * An event triggered when the postprocess is activated.
  75766. */
  75767. onActivateObservable: Observable<Camera>;
  75768. private _onActivateObserver;
  75769. /**
  75770. * A function that is added to the onActivateObservable
  75771. */
  75772. onActivate: Nullable<(camera: Camera) => void>;
  75773. /**
  75774. * An event triggered when the postprocess changes its size.
  75775. */
  75776. onSizeChangedObservable: Observable<PostProcess>;
  75777. private _onSizeChangedObserver;
  75778. /**
  75779. * A function that is added to the onSizeChangedObservable
  75780. */
  75781. onSizeChanged: (postProcess: PostProcess) => void;
  75782. /**
  75783. * An event triggered when the postprocess applies its effect.
  75784. */
  75785. onApplyObservable: Observable<Effect>;
  75786. private _onApplyObserver;
  75787. /**
  75788. * A function that is added to the onApplyObservable
  75789. */
  75790. onApply: (effect: Effect) => void;
  75791. /**
  75792. * An event triggered before rendering the postprocess
  75793. */
  75794. onBeforeRenderObservable: Observable<Effect>;
  75795. private _onBeforeRenderObserver;
  75796. /**
  75797. * A function that is added to the onBeforeRenderObservable
  75798. */
  75799. onBeforeRender: (effect: Effect) => void;
  75800. /**
  75801. * An event triggered after rendering the postprocess
  75802. */
  75803. onAfterRenderObservable: Observable<Effect>;
  75804. private _onAfterRenderObserver;
  75805. /**
  75806. * A function that is added to the onAfterRenderObservable
  75807. */
  75808. onAfterRender: (efect: Effect) => void;
  75809. /**
  75810. * 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
  75811. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  75812. */
  75813. inputTexture: InternalTexture;
  75814. /**
  75815. * Gets the camera which post process is applied to.
  75816. * @returns The camera the post process is applied to.
  75817. */
  75818. getCamera(): Camera;
  75819. /**
  75820. * Gets the texel size of the postprocess.
  75821. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  75822. */
  75823. readonly texelSize: Vector2;
  75824. /**
  75825. * Creates a new instance PostProcess
  75826. * @param name The name of the PostProcess.
  75827. * @param fragmentUrl The url of the fragment shader to be used.
  75828. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  75829. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  75830. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  75831. * @param camera The camera to apply the render pass to.
  75832. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  75833. * @param engine The engine which the post process will be applied. (default: current engine)
  75834. * @param reusable If the post process can be reused on the same frame. (default: false)
  75835. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  75836. * @param textureType Type of textures used when performing the post process. (default: 0)
  75837. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  75838. * @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
  75839. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  75840. */
  75841. constructor(
  75842. /** Name of the PostProcess. */
  75843. 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);
  75844. /**
  75845. * Gets a string idenfifying the name of the class
  75846. * @returns "PostProcess" string
  75847. */
  75848. getClassName(): string;
  75849. /**
  75850. * Gets the engine which this post process belongs to.
  75851. * @returns The engine the post process was enabled with.
  75852. */
  75853. getEngine(): Engine;
  75854. /**
  75855. * The effect that is created when initializing the post process.
  75856. * @returns The created effect corrisponding the the postprocess.
  75857. */
  75858. getEffect(): Effect;
  75859. /**
  75860. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  75861. * @param postProcess The post process to share the output with.
  75862. * @returns This post process.
  75863. */
  75864. shareOutputWith(postProcess: PostProcess): PostProcess;
  75865. /**
  75866. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  75867. * This should be called if the post process that shares output with this post process is disabled/disposed.
  75868. */
  75869. useOwnOutput(): void;
  75870. /**
  75871. * Updates the effect with the current post process compile time values and recompiles the shader.
  75872. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  75873. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  75874. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  75875. * @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
  75876. * @param onCompiled Called when the shader has been compiled.
  75877. * @param onError Called if there is an error when compiling a shader.
  75878. */
  75879. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  75880. /**
  75881. * The post process is reusable if it can be used multiple times within one frame.
  75882. * @returns If the post process is reusable
  75883. */
  75884. isReusable(): boolean;
  75885. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  75886. markTextureDirty(): void;
  75887. /**
  75888. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  75889. * 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.
  75890. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  75891. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  75892. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  75893. * @returns The target texture that was bound to be written to.
  75894. */
  75895. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  75896. /**
  75897. * If the post process is supported.
  75898. */
  75899. readonly isSupported: boolean;
  75900. /**
  75901. * The aspect ratio of the output texture.
  75902. */
  75903. readonly aspectRatio: number;
  75904. /**
  75905. * Get a value indicating if the post-process is ready to be used
  75906. * @returns true if the post-process is ready (shader is compiled)
  75907. */
  75908. isReady(): boolean;
  75909. /**
  75910. * Binds all textures and uniforms to the shader, this will be run on every pass.
  75911. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  75912. */
  75913. apply(): Nullable<Effect>;
  75914. private _disposeTextures;
  75915. /**
  75916. * Disposes the post process.
  75917. * @param camera The camera to dispose the post process on.
  75918. */
  75919. dispose(camera?: Camera): void;
  75920. }
  75921. }
  75922. declare module BABYLON {
  75923. /**
  75924. * PostProcessManager is used to manage one or more post processes or post process pipelines
  75925. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  75926. */
  75927. export class PostProcessManager {
  75928. private _scene;
  75929. private _indexBuffer;
  75930. private _vertexBuffers;
  75931. /**
  75932. * Creates a new instance PostProcess
  75933. * @param scene The scene that the post process is associated with.
  75934. */
  75935. constructor(scene: Scene);
  75936. private _prepareBuffers;
  75937. private _buildIndexBuffer;
  75938. /**
  75939. * Rebuilds the vertex buffers of the manager.
  75940. * @hidden
  75941. */
  75942. _rebuild(): void;
  75943. /**
  75944. * Prepares a frame to be run through a post process.
  75945. * @param sourceTexture The input texture to the post procesess. (default: null)
  75946. * @param postProcesses An array of post processes to be run. (default: null)
  75947. * @returns True if the post processes were able to be run.
  75948. * @hidden
  75949. */
  75950. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  75951. /**
  75952. * Manually render a set of post processes to a texture.
  75953. * @param postProcesses An array of post processes to be run.
  75954. * @param targetTexture The target texture to render to.
  75955. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  75956. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  75957. * @param lodLevel defines which lod of the texture to render to
  75958. */
  75959. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  75960. /**
  75961. * Finalize the result of the output of the postprocesses.
  75962. * @param doNotPresent If true the result will not be displayed to the screen.
  75963. * @param targetTexture The target texture to render to.
  75964. * @param faceIndex The index of the face to bind the target texture to.
  75965. * @param postProcesses The array of post processes to render.
  75966. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  75967. * @hidden
  75968. */
  75969. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  75970. /**
  75971. * Disposes of the post process manager.
  75972. */
  75973. dispose(): void;
  75974. }
  75975. }
  75976. declare module BABYLON {
  75977. interface AbstractScene {
  75978. /**
  75979. * The list of procedural textures added to the scene
  75980. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  75981. */
  75982. proceduralTextures: Array<ProceduralTexture>;
  75983. }
  75984. /**
  75985. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  75986. * in a given scene.
  75987. */
  75988. export class ProceduralTextureSceneComponent implements ISceneComponent {
  75989. /**
  75990. * The component name helpfull to identify the component in the list of scene components.
  75991. */
  75992. readonly name: string;
  75993. /**
  75994. * The scene the component belongs to.
  75995. */
  75996. scene: Scene;
  75997. /**
  75998. * Creates a new instance of the component for the given scene
  75999. * @param scene Defines the scene to register the component in
  76000. */
  76001. constructor(scene: Scene);
  76002. /**
  76003. * Registers the component in a given scene
  76004. */
  76005. register(): void;
  76006. /**
  76007. * Rebuilds the elements related to this component in case of
  76008. * context lost for instance.
  76009. */
  76010. rebuild(): void;
  76011. /**
  76012. * Disposes the component and the associated ressources.
  76013. */
  76014. dispose(): void;
  76015. private _beforeClear;
  76016. }
  76017. }
  76018. declare module BABYLON {
  76019. interface Engine {
  76020. /**
  76021. * Creates a new render target cube texture
  76022. * @param size defines the size of the texture
  76023. * @param options defines the options used to create the texture
  76024. * @returns a new render target cube texture stored in an InternalTexture
  76025. */
  76026. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  76027. }
  76028. }
  76029. declare module BABYLON {
  76030. /** @hidden */
  76031. export var proceduralVertexShader: {
  76032. name: string;
  76033. shader: string;
  76034. };
  76035. }
  76036. declare module BABYLON {
  76037. /**
  76038. * 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.
  76039. * This is the base class of any Procedural texture and contains most of the shareable code.
  76040. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  76041. */
  76042. export class ProceduralTexture extends Texture {
  76043. isCube: boolean;
  76044. /**
  76045. * Define if the texture is enabled or not (disabled texture will not render)
  76046. */
  76047. isEnabled: boolean;
  76048. /**
  76049. * Define if the texture must be cleared before rendering (default is true)
  76050. */
  76051. autoClear: boolean;
  76052. /**
  76053. * Callback called when the texture is generated
  76054. */
  76055. onGenerated: () => void;
  76056. /**
  76057. * Event raised when the texture is generated
  76058. */
  76059. onGeneratedObservable: Observable<ProceduralTexture>;
  76060. /** @hidden */
  76061. _generateMipMaps: boolean;
  76062. /** @hidden **/
  76063. _effect: Effect;
  76064. /** @hidden */
  76065. _textures: {
  76066. [key: string]: Texture;
  76067. };
  76068. private _size;
  76069. private _currentRefreshId;
  76070. private _refreshRate;
  76071. private _vertexBuffers;
  76072. private _indexBuffer;
  76073. private _uniforms;
  76074. private _samplers;
  76075. private _fragment;
  76076. private _floats;
  76077. private _ints;
  76078. private _floatsArrays;
  76079. private _colors3;
  76080. private _colors4;
  76081. private _vectors2;
  76082. private _vectors3;
  76083. private _matrices;
  76084. private _fallbackTexture;
  76085. private _fallbackTextureUsed;
  76086. private _engine;
  76087. private _cachedDefines;
  76088. private _contentUpdateId;
  76089. private _contentData;
  76090. /**
  76091. * Instantiates a new procedural texture.
  76092. * 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.
  76093. * This is the base class of any Procedural texture and contains most of the shareable code.
  76094. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  76095. * @param name Define the name of the texture
  76096. * @param size Define the size of the texture to create
  76097. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  76098. * @param scene Define the scene the texture belongs to
  76099. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  76100. * @param generateMipMaps Define if the texture should creates mip maps or not
  76101. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  76102. */
  76103. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  76104. /**
  76105. * The effect that is created when initializing the post process.
  76106. * @returns The created effect corrisponding the the postprocess.
  76107. */
  76108. getEffect(): Effect;
  76109. /**
  76110. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  76111. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  76112. */
  76113. getContent(): Nullable<ArrayBufferView>;
  76114. private _createIndexBuffer;
  76115. /** @hidden */
  76116. _rebuild(): void;
  76117. /**
  76118. * Resets the texture in order to recreate its associated resources.
  76119. * This can be called in case of context loss
  76120. */
  76121. reset(): void;
  76122. protected _getDefines(): string;
  76123. /**
  76124. * Is the texture ready to be used ? (rendered at least once)
  76125. * @returns true if ready, otherwise, false.
  76126. */
  76127. isReady(): boolean;
  76128. /**
  76129. * Resets the refresh counter of the texture and start bak from scratch.
  76130. * Could be useful to regenerate the texture if it is setup to render only once.
  76131. */
  76132. resetRefreshCounter(): void;
  76133. /**
  76134. * Set the fragment shader to use in order to render the texture.
  76135. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  76136. */
  76137. setFragment(fragment: any): void;
  76138. /**
  76139. * Define the refresh rate of the texture or the rendering frequency.
  76140. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  76141. */
  76142. refreshRate: number;
  76143. /** @hidden */
  76144. _shouldRender(): boolean;
  76145. /**
  76146. * Get the size the texture is rendering at.
  76147. * @returns the size (texture is always squared)
  76148. */
  76149. getRenderSize(): number;
  76150. /**
  76151. * Resize the texture to new value.
  76152. * @param size Define the new size the texture should have
  76153. * @param generateMipMaps Define whether the new texture should create mip maps
  76154. */
  76155. resize(size: number, generateMipMaps: boolean): void;
  76156. private _checkUniform;
  76157. /**
  76158. * Set a texture in the shader program used to render.
  76159. * @param name Define the name of the uniform samplers as defined in the shader
  76160. * @param texture Define the texture to bind to this sampler
  76161. * @return the texture itself allowing "fluent" like uniform updates
  76162. */
  76163. setTexture(name: string, texture: Texture): ProceduralTexture;
  76164. /**
  76165. * Set a float in the shader.
  76166. * @param name Define the name of the uniform as defined in the shader
  76167. * @param value Define the value to give to the uniform
  76168. * @return the texture itself allowing "fluent" like uniform updates
  76169. */
  76170. setFloat(name: string, value: number): ProceduralTexture;
  76171. /**
  76172. * Set a int in the shader.
  76173. * @param name Define the name of the uniform as defined in the shader
  76174. * @param value Define the value to give to the uniform
  76175. * @return the texture itself allowing "fluent" like uniform updates
  76176. */
  76177. setInt(name: string, value: number): ProceduralTexture;
  76178. /**
  76179. * Set an array of floats in the shader.
  76180. * @param name Define the name of the uniform as defined in the shader
  76181. * @param value Define the value to give to the uniform
  76182. * @return the texture itself allowing "fluent" like uniform updates
  76183. */
  76184. setFloats(name: string, value: number[]): ProceduralTexture;
  76185. /**
  76186. * Set a vec3 in the shader from a Color3.
  76187. * @param name Define the name of the uniform as defined in the shader
  76188. * @param value Define the value to give to the uniform
  76189. * @return the texture itself allowing "fluent" like uniform updates
  76190. */
  76191. setColor3(name: string, value: Color3): ProceduralTexture;
  76192. /**
  76193. * Set a vec4 in the shader from a Color4.
  76194. * @param name Define the name of the uniform as defined in the shader
  76195. * @param value Define the value to give to the uniform
  76196. * @return the texture itself allowing "fluent" like uniform updates
  76197. */
  76198. setColor4(name: string, value: Color4): ProceduralTexture;
  76199. /**
  76200. * Set a vec2 in the shader from a Vector2.
  76201. * @param name Define the name of the uniform as defined in the shader
  76202. * @param value Define the value to give to the uniform
  76203. * @return the texture itself allowing "fluent" like uniform updates
  76204. */
  76205. setVector2(name: string, value: Vector2): ProceduralTexture;
  76206. /**
  76207. * Set a vec3 in the shader from a Vector3.
  76208. * @param name Define the name of the uniform as defined in the shader
  76209. * @param value Define the value to give to the uniform
  76210. * @return the texture itself allowing "fluent" like uniform updates
  76211. */
  76212. setVector3(name: string, value: Vector3): ProceduralTexture;
  76213. /**
  76214. * Set a mat4 in the shader from a MAtrix.
  76215. * @param name Define the name of the uniform as defined in the shader
  76216. * @param value Define the value to give to the uniform
  76217. * @return the texture itself allowing "fluent" like uniform updates
  76218. */
  76219. setMatrix(name: string, value: Matrix): ProceduralTexture;
  76220. /**
  76221. * Render the texture to its associated render target.
  76222. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  76223. */
  76224. render(useCameraPostProcess?: boolean): void;
  76225. /**
  76226. * Clone the texture.
  76227. * @returns the cloned texture
  76228. */
  76229. clone(): ProceduralTexture;
  76230. /**
  76231. * Dispose the texture and release its asoociated resources.
  76232. */
  76233. dispose(): void;
  76234. }
  76235. }
  76236. declare module BABYLON {
  76237. /**
  76238. * This represents the base class for particle system in Babylon.
  76239. * 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.
  76240. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  76241. * @example https://doc.babylonjs.com/babylon101/particles
  76242. */
  76243. export class BaseParticleSystem {
  76244. /**
  76245. * Source color is added to the destination color without alpha affecting the result
  76246. */
  76247. static BLENDMODE_ONEONE: number;
  76248. /**
  76249. * Blend current color and particle color using particle’s alpha
  76250. */
  76251. static BLENDMODE_STANDARD: number;
  76252. /**
  76253. * Add current color and particle color multiplied by particle’s alpha
  76254. */
  76255. static BLENDMODE_ADD: number;
  76256. /**
  76257. * Multiply current color with particle color
  76258. */
  76259. static BLENDMODE_MULTIPLY: number;
  76260. /**
  76261. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  76262. */
  76263. static BLENDMODE_MULTIPLYADD: number;
  76264. /**
  76265. * List of animations used by the particle system.
  76266. */
  76267. animations: Animation[];
  76268. /**
  76269. * The id of the Particle system.
  76270. */
  76271. id: string;
  76272. /**
  76273. * The friendly name of the Particle system.
  76274. */
  76275. name: string;
  76276. /**
  76277. * The rendering group used by the Particle system to chose when to render.
  76278. */
  76279. renderingGroupId: number;
  76280. /**
  76281. * The emitter represents the Mesh or position we are attaching the particle system to.
  76282. */
  76283. emitter: Nullable<AbstractMesh | Vector3>;
  76284. /**
  76285. * The maximum number of particles to emit per frame
  76286. */
  76287. emitRate: number;
  76288. /**
  76289. * If you want to launch only a few particles at once, that can be done, as well.
  76290. */
  76291. manualEmitCount: number;
  76292. /**
  76293. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  76294. */
  76295. updateSpeed: number;
  76296. /**
  76297. * The amount of time the particle system is running (depends of the overall update speed).
  76298. */
  76299. targetStopDuration: number;
  76300. /**
  76301. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  76302. */
  76303. disposeOnStop: boolean;
  76304. /**
  76305. * Minimum power of emitting particles.
  76306. */
  76307. minEmitPower: number;
  76308. /**
  76309. * Maximum power of emitting particles.
  76310. */
  76311. maxEmitPower: number;
  76312. /**
  76313. * Minimum life time of emitting particles.
  76314. */
  76315. minLifeTime: number;
  76316. /**
  76317. * Maximum life time of emitting particles.
  76318. */
  76319. maxLifeTime: number;
  76320. /**
  76321. * Minimum Size of emitting particles.
  76322. */
  76323. minSize: number;
  76324. /**
  76325. * Maximum Size of emitting particles.
  76326. */
  76327. maxSize: number;
  76328. /**
  76329. * Minimum scale of emitting particles on X axis.
  76330. */
  76331. minScaleX: number;
  76332. /**
  76333. * Maximum scale of emitting particles on X axis.
  76334. */
  76335. maxScaleX: number;
  76336. /**
  76337. * Minimum scale of emitting particles on Y axis.
  76338. */
  76339. minScaleY: number;
  76340. /**
  76341. * Maximum scale of emitting particles on Y axis.
  76342. */
  76343. maxScaleY: number;
  76344. /**
  76345. * Gets or sets the minimal initial rotation in radians.
  76346. */
  76347. minInitialRotation: number;
  76348. /**
  76349. * Gets or sets the maximal initial rotation in radians.
  76350. */
  76351. maxInitialRotation: number;
  76352. /**
  76353. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  76354. */
  76355. minAngularSpeed: number;
  76356. /**
  76357. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  76358. */
  76359. maxAngularSpeed: number;
  76360. /**
  76361. * The texture used to render each particle. (this can be a spritesheet)
  76362. */
  76363. particleTexture: Nullable<Texture>;
  76364. /**
  76365. * The layer mask we are rendering the particles through.
  76366. */
  76367. layerMask: number;
  76368. /**
  76369. * This can help using your own shader to render the particle system.
  76370. * The according effect will be created
  76371. */
  76372. customShader: any;
  76373. /**
  76374. * By default particle system starts as soon as they are created. This prevents the
  76375. * automatic start to happen and let you decide when to start emitting particles.
  76376. */
  76377. preventAutoStart: boolean;
  76378. private _noiseTexture;
  76379. /**
  76380. * Gets or sets a texture used to add random noise to particle positions
  76381. */
  76382. noiseTexture: Nullable<ProceduralTexture>;
  76383. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  76384. noiseStrength: Vector3;
  76385. /**
  76386. * Callback triggered when the particle animation is ending.
  76387. */
  76388. onAnimationEnd: Nullable<() => void>;
  76389. /**
  76390. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  76391. */
  76392. blendMode: number;
  76393. /**
  76394. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  76395. * to override the particles.
  76396. */
  76397. forceDepthWrite: boolean;
  76398. /** 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 */
  76399. preWarmCycles: number;
  76400. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  76401. preWarmStepOffset: number;
  76402. /**
  76403. * 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)
  76404. */
  76405. spriteCellChangeSpeed: number;
  76406. /**
  76407. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  76408. */
  76409. startSpriteCellID: number;
  76410. /**
  76411. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  76412. */
  76413. endSpriteCellID: number;
  76414. /**
  76415. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  76416. */
  76417. spriteCellWidth: number;
  76418. /**
  76419. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  76420. */
  76421. spriteCellHeight: number;
  76422. /**
  76423. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  76424. */
  76425. spriteRandomStartCell: boolean;
  76426. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  76427. translationPivot: Vector2;
  76428. /** @hidden */
  76429. protected _isAnimationSheetEnabled: boolean;
  76430. /**
  76431. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  76432. */
  76433. beginAnimationOnStart: boolean;
  76434. /**
  76435. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  76436. */
  76437. beginAnimationFrom: number;
  76438. /**
  76439. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  76440. */
  76441. beginAnimationTo: number;
  76442. /**
  76443. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  76444. */
  76445. beginAnimationLoop: boolean;
  76446. /**
  76447. * Gets or sets a world offset applied to all particles
  76448. */
  76449. worldOffset: Vector3;
  76450. /**
  76451. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  76452. */
  76453. isAnimationSheetEnabled: boolean;
  76454. /**
  76455. * Get hosting scene
  76456. * @returns the scene
  76457. */
  76458. getScene(): Scene;
  76459. /**
  76460. * You can use gravity if you want to give an orientation to your particles.
  76461. */
  76462. gravity: Vector3;
  76463. protected _colorGradients: Nullable<Array<ColorGradient>>;
  76464. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  76465. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  76466. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  76467. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  76468. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  76469. protected _dragGradients: Nullable<Array<FactorGradient>>;
  76470. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  76471. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  76472. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  76473. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  76474. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  76475. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  76476. /**
  76477. * Defines the delay in milliseconds before starting the system (0 by default)
  76478. */
  76479. startDelay: number;
  76480. /**
  76481. * Gets the current list of drag gradients.
  76482. * You must use addDragGradient and removeDragGradient to udpate this list
  76483. * @returns the list of drag gradients
  76484. */
  76485. getDragGradients(): Nullable<Array<FactorGradient>>;
  76486. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  76487. limitVelocityDamping: number;
  76488. /**
  76489. * Gets the current list of limit velocity gradients.
  76490. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  76491. * @returns the list of limit velocity gradients
  76492. */
  76493. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  76494. /**
  76495. * Gets the current list of color gradients.
  76496. * You must use addColorGradient and removeColorGradient to udpate this list
  76497. * @returns the list of color gradients
  76498. */
  76499. getColorGradients(): Nullable<Array<ColorGradient>>;
  76500. /**
  76501. * Gets the current list of size gradients.
  76502. * You must use addSizeGradient and removeSizeGradient to udpate this list
  76503. * @returns the list of size gradients
  76504. */
  76505. getSizeGradients(): Nullable<Array<FactorGradient>>;
  76506. /**
  76507. * Gets the current list of color remap gradients.
  76508. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  76509. * @returns the list of color remap gradients
  76510. */
  76511. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  76512. /**
  76513. * Gets the current list of alpha remap gradients.
  76514. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  76515. * @returns the list of alpha remap gradients
  76516. */
  76517. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  76518. /**
  76519. * Gets the current list of life time gradients.
  76520. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  76521. * @returns the list of life time gradients
  76522. */
  76523. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  76524. /**
  76525. * Gets the current list of angular speed gradients.
  76526. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  76527. * @returns the list of angular speed gradients
  76528. */
  76529. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  76530. /**
  76531. * Gets the current list of velocity gradients.
  76532. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  76533. * @returns the list of velocity gradients
  76534. */
  76535. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  76536. /**
  76537. * Gets the current list of start size gradients.
  76538. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  76539. * @returns the list of start size gradients
  76540. */
  76541. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  76542. /**
  76543. * Gets the current list of emit rate gradients.
  76544. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  76545. * @returns the list of emit rate gradients
  76546. */
  76547. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  76548. /**
  76549. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  76550. * This only works when particleEmitterTyps is a BoxParticleEmitter
  76551. */
  76552. direction1: Vector3;
  76553. /**
  76554. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  76555. * This only works when particleEmitterTyps is a BoxParticleEmitter
  76556. */
  76557. direction2: Vector3;
  76558. /**
  76559. * 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.
  76560. * This only works when particleEmitterTyps is a BoxParticleEmitter
  76561. */
  76562. minEmitBox: Vector3;
  76563. /**
  76564. * 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.
  76565. * This only works when particleEmitterTyps is a BoxParticleEmitter
  76566. */
  76567. maxEmitBox: Vector3;
  76568. /**
  76569. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  76570. */
  76571. color1: Color4;
  76572. /**
  76573. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  76574. */
  76575. color2: Color4;
  76576. /**
  76577. * Color the particle will have at the end of its lifetime
  76578. */
  76579. colorDead: Color4;
  76580. /**
  76581. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  76582. */
  76583. textureMask: Color4;
  76584. /**
  76585. * The particle emitter type defines the emitter used by the particle system.
  76586. * It can be for example box, sphere, or cone...
  76587. */
  76588. particleEmitterType: IParticleEmitterType;
  76589. /** @hidden */
  76590. _isSubEmitter: boolean;
  76591. /**
  76592. * Gets or sets the billboard mode to use when isBillboardBased = true.
  76593. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  76594. */
  76595. billboardMode: number;
  76596. protected _isBillboardBased: boolean;
  76597. /**
  76598. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  76599. */
  76600. isBillboardBased: boolean;
  76601. /**
  76602. * The scene the particle system belongs to.
  76603. */
  76604. protected _scene: Scene;
  76605. /**
  76606. * Local cache of defines for image processing.
  76607. */
  76608. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  76609. /**
  76610. * Default configuration related to image processing available in the standard Material.
  76611. */
  76612. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  76613. /**
  76614. * Gets the image processing configuration used either in this material.
  76615. */
  76616. /**
  76617. * Sets the Default image processing configuration used either in the this material.
  76618. *
  76619. * If sets to null, the scene one is in use.
  76620. */
  76621. imageProcessingConfiguration: ImageProcessingConfiguration;
  76622. /**
  76623. * Attaches a new image processing configuration to the Standard Material.
  76624. * @param configuration
  76625. */
  76626. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  76627. /** @hidden */
  76628. protected _reset(): void;
  76629. /** @hidden */
  76630. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  76631. /**
  76632. * Instantiates a particle system.
  76633. * 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.
  76634. * @param name The name of the particle system
  76635. */
  76636. constructor(name: string);
  76637. /**
  76638. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  76639. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  76640. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  76641. * @returns the emitter
  76642. */
  76643. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  76644. /**
  76645. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  76646. * @param radius The radius of the hemisphere to emit from
  76647. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  76648. * @returns the emitter
  76649. */
  76650. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  76651. /**
  76652. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  76653. * @param radius The radius of the sphere to emit from
  76654. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  76655. * @returns the emitter
  76656. */
  76657. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  76658. /**
  76659. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  76660. * @param radius The radius of the sphere to emit from
  76661. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  76662. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  76663. * @returns the emitter
  76664. */
  76665. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  76666. /**
  76667. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  76668. * @param radius The radius of the emission cylinder
  76669. * @param height The height of the emission cylinder
  76670. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  76671. * @param directionRandomizer How much to randomize the particle direction [0-1]
  76672. * @returns the emitter
  76673. */
  76674. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  76675. /**
  76676. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  76677. * @param radius The radius of the cylinder to emit from
  76678. * @param height The height of the emission cylinder
  76679. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  76680. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  76681. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  76682. * @returns the emitter
  76683. */
  76684. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  76685. /**
  76686. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  76687. * @param radius The radius of the cone to emit from
  76688. * @param angle The base angle of the cone
  76689. * @returns the emitter
  76690. */
  76691. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  76692. /**
  76693. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  76694. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  76695. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  76696. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  76697. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  76698. * @returns the emitter
  76699. */
  76700. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  76701. }
  76702. }
  76703. declare module BABYLON {
  76704. /**
  76705. * Type of sub emitter
  76706. */
  76707. export enum SubEmitterType {
  76708. /**
  76709. * Attached to the particle over it's lifetime
  76710. */
  76711. ATTACHED = 0,
  76712. /**
  76713. * Created when the particle dies
  76714. */
  76715. END = 1
  76716. }
  76717. /**
  76718. * Sub emitter class used to emit particles from an existing particle
  76719. */
  76720. export class SubEmitter {
  76721. /**
  76722. * the particle system to be used by the sub emitter
  76723. */
  76724. particleSystem: ParticleSystem;
  76725. /**
  76726. * Type of the submitter (Default: END)
  76727. */
  76728. type: SubEmitterType;
  76729. /**
  76730. * 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)
  76731. * Note: This only is supported when using an emitter of type Mesh
  76732. */
  76733. inheritDirection: boolean;
  76734. /**
  76735. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  76736. */
  76737. inheritedVelocityAmount: number;
  76738. /**
  76739. * Creates a sub emitter
  76740. * @param particleSystem the particle system to be used by the sub emitter
  76741. */
  76742. constructor(
  76743. /**
  76744. * the particle system to be used by the sub emitter
  76745. */
  76746. particleSystem: ParticleSystem);
  76747. /**
  76748. * Clones the sub emitter
  76749. * @returns the cloned sub emitter
  76750. */
  76751. clone(): SubEmitter;
  76752. /**
  76753. * Serialize current object to a JSON object
  76754. * @returns the serialized object
  76755. */
  76756. serialize(): any;
  76757. /** @hidden */
  76758. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  76759. /**
  76760. * Creates a new SubEmitter from a serialized JSON version
  76761. * @param serializationObject defines the JSON object to read from
  76762. * @param scene defines the hosting scene
  76763. * @param rootUrl defines the rootUrl for data loading
  76764. * @returns a new SubEmitter
  76765. */
  76766. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  76767. /** Release associated resources */
  76768. dispose(): void;
  76769. }
  76770. }
  76771. declare module BABYLON {
  76772. /** @hidden */
  76773. export var clipPlaneFragmentDeclaration: {
  76774. name: string;
  76775. shader: string;
  76776. };
  76777. }
  76778. declare module BABYLON {
  76779. /** @hidden */
  76780. export var imageProcessingDeclaration: {
  76781. name: string;
  76782. shader: string;
  76783. };
  76784. }
  76785. declare module BABYLON {
  76786. /** @hidden */
  76787. export var imageProcessingFunctions: {
  76788. name: string;
  76789. shader: string;
  76790. };
  76791. }
  76792. declare module BABYLON {
  76793. /** @hidden */
  76794. export var clipPlaneFragment: {
  76795. name: string;
  76796. shader: string;
  76797. };
  76798. }
  76799. declare module BABYLON {
  76800. /** @hidden */
  76801. export var particlesPixelShader: {
  76802. name: string;
  76803. shader: string;
  76804. };
  76805. }
  76806. declare module BABYLON {
  76807. /** @hidden */
  76808. export var clipPlaneVertexDeclaration: {
  76809. name: string;
  76810. shader: string;
  76811. };
  76812. }
  76813. declare module BABYLON {
  76814. /** @hidden */
  76815. export var clipPlaneVertex: {
  76816. name: string;
  76817. shader: string;
  76818. };
  76819. }
  76820. declare module BABYLON {
  76821. /** @hidden */
  76822. export var particlesVertexShader: {
  76823. name: string;
  76824. shader: string;
  76825. };
  76826. }
  76827. declare module BABYLON {
  76828. /**
  76829. * This represents a particle system in Babylon.
  76830. * 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.
  76831. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  76832. * @example https://doc.babylonjs.com/babylon101/particles
  76833. */
  76834. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  76835. /**
  76836. * Billboard mode will only apply to Y axis
  76837. */
  76838. static readonly BILLBOARDMODE_Y: number;
  76839. /**
  76840. * Billboard mode will apply to all axes
  76841. */
  76842. static readonly BILLBOARDMODE_ALL: number;
  76843. /**
  76844. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  76845. */
  76846. static readonly BILLBOARDMODE_STRETCHED: number;
  76847. /**
  76848. * This function can be defined to provide custom update for active particles.
  76849. * This function will be called instead of regular update (age, position, color, etc.).
  76850. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  76851. */
  76852. updateFunction: (particles: Particle[]) => void;
  76853. private _emitterWorldMatrix;
  76854. /**
  76855. * This function can be defined to specify initial direction for every new particle.
  76856. * It by default use the emitterType defined function
  76857. */
  76858. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  76859. /**
  76860. * This function can be defined to specify initial position for every new particle.
  76861. * It by default use the emitterType defined function
  76862. */
  76863. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  76864. /**
  76865. * @hidden
  76866. */
  76867. _inheritedVelocityOffset: Vector3;
  76868. /**
  76869. * An event triggered when the system is disposed
  76870. */
  76871. onDisposeObservable: Observable<ParticleSystem>;
  76872. private _onDisposeObserver;
  76873. /**
  76874. * Sets a callback that will be triggered when the system is disposed
  76875. */
  76876. onDispose: () => void;
  76877. private _particles;
  76878. private _epsilon;
  76879. private _capacity;
  76880. private _stockParticles;
  76881. private _newPartsExcess;
  76882. private _vertexData;
  76883. private _vertexBuffer;
  76884. private _vertexBuffers;
  76885. private _spriteBuffer;
  76886. private _indexBuffer;
  76887. private _effect;
  76888. private _customEffect;
  76889. private _cachedDefines;
  76890. private _scaledColorStep;
  76891. private _colorDiff;
  76892. private _scaledDirection;
  76893. private _scaledGravity;
  76894. private _currentRenderId;
  76895. private _alive;
  76896. private _useInstancing;
  76897. private _started;
  76898. private _stopped;
  76899. private _actualFrame;
  76900. private _scaledUpdateSpeed;
  76901. private _vertexBufferSize;
  76902. /** @hidden */
  76903. _currentEmitRateGradient: Nullable<FactorGradient>;
  76904. /** @hidden */
  76905. _currentEmitRate1: number;
  76906. /** @hidden */
  76907. _currentEmitRate2: number;
  76908. /** @hidden */
  76909. _currentStartSizeGradient: Nullable<FactorGradient>;
  76910. /** @hidden */
  76911. _currentStartSize1: number;
  76912. /** @hidden */
  76913. _currentStartSize2: number;
  76914. private readonly _rawTextureWidth;
  76915. private _rampGradientsTexture;
  76916. private _useRampGradients;
  76917. /** Gets or sets a boolean indicating that ramp gradients must be used
  76918. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  76919. */
  76920. useRampGradients: boolean;
  76921. /**
  76922. * 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.
  76923. * 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: [])
  76924. */
  76925. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  76926. private _subEmitters;
  76927. /**
  76928. * @hidden
  76929. * If the particle systems emitter should be disposed when the particle system is disposed
  76930. */
  76931. _disposeEmitterOnDispose: boolean;
  76932. /**
  76933. * The current active Sub-systems, this property is used by the root particle system only.
  76934. */
  76935. activeSubSystems: Array<ParticleSystem>;
  76936. private _rootParticleSystem;
  76937. /**
  76938. * Gets the current list of active particles
  76939. */
  76940. readonly particles: Particle[];
  76941. /**
  76942. * Returns the string "ParticleSystem"
  76943. * @returns a string containing the class name
  76944. */
  76945. getClassName(): string;
  76946. /**
  76947. * Instantiates a particle system.
  76948. * 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.
  76949. * @param name The name of the particle system
  76950. * @param capacity The max number of particles alive at the same time
  76951. * @param scene The scene the particle system belongs to
  76952. * @param customEffect a custom effect used to change the way particles are rendered by default
  76953. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  76954. * @param epsilon Offset used to render the particles
  76955. */
  76956. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  76957. private _addFactorGradient;
  76958. private _removeFactorGradient;
  76959. /**
  76960. * Adds a new life time gradient
  76961. * @param gradient defines the gradient to use (between 0 and 1)
  76962. * @param factor defines the life time factor to affect to the specified gradient
  76963. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  76964. * @returns the current particle system
  76965. */
  76966. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  76967. /**
  76968. * Remove a specific life time gradient
  76969. * @param gradient defines the gradient to remove
  76970. * @returns the current particle system
  76971. */
  76972. removeLifeTimeGradient(gradient: number): IParticleSystem;
  76973. /**
  76974. * Adds a new size gradient
  76975. * @param gradient defines the gradient to use (between 0 and 1)
  76976. * @param factor defines the size factor to affect to the specified gradient
  76977. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  76978. * @returns the current particle system
  76979. */
  76980. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  76981. /**
  76982. * Remove a specific size gradient
  76983. * @param gradient defines the gradient to remove
  76984. * @returns the current particle system
  76985. */
  76986. removeSizeGradient(gradient: number): IParticleSystem;
  76987. /**
  76988. * Adds a new color remap gradient
  76989. * @param gradient defines the gradient to use (between 0 and 1)
  76990. * @param min defines the color remap minimal range
  76991. * @param max defines the color remap maximal range
  76992. * @returns the current particle system
  76993. */
  76994. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  76995. /**
  76996. * Remove a specific color remap gradient
  76997. * @param gradient defines the gradient to remove
  76998. * @returns the current particle system
  76999. */
  77000. removeColorRemapGradient(gradient: number): IParticleSystem;
  77001. /**
  77002. * Adds a new alpha remap gradient
  77003. * @param gradient defines the gradient to use (between 0 and 1)
  77004. * @param min defines the alpha remap minimal range
  77005. * @param max defines the alpha remap maximal range
  77006. * @returns the current particle system
  77007. */
  77008. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  77009. /**
  77010. * Remove a specific alpha remap gradient
  77011. * @param gradient defines the gradient to remove
  77012. * @returns the current particle system
  77013. */
  77014. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  77015. /**
  77016. * Adds a new angular speed gradient
  77017. * @param gradient defines the gradient to use (between 0 and 1)
  77018. * @param factor defines the angular speed to affect to the specified gradient
  77019. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  77020. * @returns the current particle system
  77021. */
  77022. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  77023. /**
  77024. * Remove a specific angular speed gradient
  77025. * @param gradient defines the gradient to remove
  77026. * @returns the current particle system
  77027. */
  77028. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  77029. /**
  77030. * Adds a new velocity gradient
  77031. * @param gradient defines the gradient to use (between 0 and 1)
  77032. * @param factor defines the velocity to affect to the specified gradient
  77033. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  77034. * @returns the current particle system
  77035. */
  77036. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  77037. /**
  77038. * Remove a specific velocity gradient
  77039. * @param gradient defines the gradient to remove
  77040. * @returns the current particle system
  77041. */
  77042. removeVelocityGradient(gradient: number): IParticleSystem;
  77043. /**
  77044. * Adds a new limit velocity gradient
  77045. * @param gradient defines the gradient to use (between 0 and 1)
  77046. * @param factor defines the limit velocity value to affect to the specified gradient
  77047. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  77048. * @returns the current particle system
  77049. */
  77050. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  77051. /**
  77052. * Remove a specific limit velocity gradient
  77053. * @param gradient defines the gradient to remove
  77054. * @returns the current particle system
  77055. */
  77056. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  77057. /**
  77058. * Adds a new drag gradient
  77059. * @param gradient defines the gradient to use (between 0 and 1)
  77060. * @param factor defines the drag value to affect to the specified gradient
  77061. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  77062. * @returns the current particle system
  77063. */
  77064. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  77065. /**
  77066. * Remove a specific drag gradient
  77067. * @param gradient defines the gradient to remove
  77068. * @returns the current particle system
  77069. */
  77070. removeDragGradient(gradient: number): IParticleSystem;
  77071. /**
  77072. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  77073. * @param gradient defines the gradient to use (between 0 and 1)
  77074. * @param factor defines the emit rate value to affect to the specified gradient
  77075. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  77076. * @returns the current particle system
  77077. */
  77078. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  77079. /**
  77080. * Remove a specific emit rate gradient
  77081. * @param gradient defines the gradient to remove
  77082. * @returns the current particle system
  77083. */
  77084. removeEmitRateGradient(gradient: number): IParticleSystem;
  77085. /**
  77086. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  77087. * @param gradient defines the gradient to use (between 0 and 1)
  77088. * @param factor defines the start size value to affect to the specified gradient
  77089. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  77090. * @returns the current particle system
  77091. */
  77092. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  77093. /**
  77094. * Remove a specific start size gradient
  77095. * @param gradient defines the gradient to remove
  77096. * @returns the current particle system
  77097. */
  77098. removeStartSizeGradient(gradient: number): IParticleSystem;
  77099. private _createRampGradientTexture;
  77100. /**
  77101. * Gets the current list of ramp gradients.
  77102. * You must use addRampGradient and removeRampGradient to udpate this list
  77103. * @returns the list of ramp gradients
  77104. */
  77105. getRampGradients(): Nullable<Array<Color3Gradient>>;
  77106. /**
  77107. * Adds a new ramp gradient used to remap particle colors
  77108. * @param gradient defines the gradient to use (between 0 and 1)
  77109. * @param color defines the color to affect to the specified gradient
  77110. * @returns the current particle system
  77111. */
  77112. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  77113. /**
  77114. * Remove a specific ramp gradient
  77115. * @param gradient defines the gradient to remove
  77116. * @returns the current particle system
  77117. */
  77118. removeRampGradient(gradient: number): ParticleSystem;
  77119. /**
  77120. * Adds a new color gradient
  77121. * @param gradient defines the gradient to use (between 0 and 1)
  77122. * @param color1 defines the color to affect to the specified gradient
  77123. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  77124. * @returns this particle system
  77125. */
  77126. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  77127. /**
  77128. * Remove a specific color gradient
  77129. * @param gradient defines the gradient to remove
  77130. * @returns this particle system
  77131. */
  77132. removeColorGradient(gradient: number): IParticleSystem;
  77133. private _fetchR;
  77134. protected _reset(): void;
  77135. private _resetEffect;
  77136. private _createVertexBuffers;
  77137. private _createIndexBuffer;
  77138. /**
  77139. * Gets the maximum number of particles active at the same time.
  77140. * @returns The max number of active particles.
  77141. */
  77142. getCapacity(): number;
  77143. /**
  77144. * Gets whether there are still active particles in the system.
  77145. * @returns True if it is alive, otherwise false.
  77146. */
  77147. isAlive(): boolean;
  77148. /**
  77149. * Gets if the system has been started. (Note: this will still be true after stop is called)
  77150. * @returns True if it has been started, otherwise false.
  77151. */
  77152. isStarted(): boolean;
  77153. private _prepareSubEmitterInternalArray;
  77154. /**
  77155. * Starts the particle system and begins to emit
  77156. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  77157. */
  77158. start(delay?: number): void;
  77159. /**
  77160. * Stops the particle system.
  77161. * @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.
  77162. */
  77163. stop(stopSubEmitters?: boolean): void;
  77164. /**
  77165. * Remove all active particles
  77166. */
  77167. reset(): void;
  77168. /**
  77169. * @hidden (for internal use only)
  77170. */
  77171. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  77172. /**
  77173. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  77174. * Its lifetime will start back at 0.
  77175. */
  77176. recycleParticle: (particle: Particle) => void;
  77177. private _stopSubEmitters;
  77178. private _createParticle;
  77179. private _removeFromRoot;
  77180. private _emitFromParticle;
  77181. private _update;
  77182. /** @hidden */
  77183. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  77184. /** @hidden */
  77185. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  77186. /** @hidden */
  77187. private _getEffect;
  77188. /**
  77189. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  77190. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  77191. */
  77192. animate(preWarmOnly?: boolean): void;
  77193. private _appendParticleVertices;
  77194. /**
  77195. * Rebuilds the particle system.
  77196. */
  77197. rebuild(): void;
  77198. /**
  77199. * Is this system ready to be used/rendered
  77200. * @return true if the system is ready
  77201. */
  77202. isReady(): boolean;
  77203. private _render;
  77204. /**
  77205. * Renders the particle system in its current state.
  77206. * @returns the current number of particles
  77207. */
  77208. render(): number;
  77209. /**
  77210. * Disposes the particle system and free the associated resources
  77211. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  77212. */
  77213. dispose(disposeTexture?: boolean): void;
  77214. /**
  77215. * Clones the particle system.
  77216. * @param name The name of the cloned object
  77217. * @param newEmitter The new emitter to use
  77218. * @returns the cloned particle system
  77219. */
  77220. clone(name: string, newEmitter: any): ParticleSystem;
  77221. /**
  77222. * Serializes the particle system to a JSON object.
  77223. * @returns the JSON object
  77224. */
  77225. serialize(): any;
  77226. /** @hidden */
  77227. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  77228. /** @hidden */
  77229. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  77230. /**
  77231. * Parses a JSON object to create a particle system.
  77232. * @param parsedParticleSystem The JSON object to parse
  77233. * @param scene The scene to create the particle system in
  77234. * @param rootUrl The root url to use to load external dependencies like texture
  77235. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  77236. * @returns the Parsed particle system
  77237. */
  77238. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  77239. }
  77240. }
  77241. declare module BABYLON {
  77242. /**
  77243. * A particle represents one of the element emitted by a particle system.
  77244. * This is mainly define by its coordinates, direction, velocity and age.
  77245. */
  77246. export class Particle {
  77247. /**
  77248. * The particle system the particle belongs to.
  77249. */
  77250. particleSystem: ParticleSystem;
  77251. private static _Count;
  77252. /**
  77253. * Unique ID of the particle
  77254. */
  77255. id: number;
  77256. /**
  77257. * The world position of the particle in the scene.
  77258. */
  77259. position: Vector3;
  77260. /**
  77261. * The world direction of the particle in the scene.
  77262. */
  77263. direction: Vector3;
  77264. /**
  77265. * The color of the particle.
  77266. */
  77267. color: Color4;
  77268. /**
  77269. * The color change of the particle per step.
  77270. */
  77271. colorStep: Color4;
  77272. /**
  77273. * Defines how long will the life of the particle be.
  77274. */
  77275. lifeTime: number;
  77276. /**
  77277. * The current age of the particle.
  77278. */
  77279. age: number;
  77280. /**
  77281. * The current size of the particle.
  77282. */
  77283. size: number;
  77284. /**
  77285. * The current scale of the particle.
  77286. */
  77287. scale: Vector2;
  77288. /**
  77289. * The current angle of the particle.
  77290. */
  77291. angle: number;
  77292. /**
  77293. * Defines how fast is the angle changing.
  77294. */
  77295. angularSpeed: number;
  77296. /**
  77297. * Defines the cell index used by the particle to be rendered from a sprite.
  77298. */
  77299. cellIndex: number;
  77300. /**
  77301. * The information required to support color remapping
  77302. */
  77303. remapData: Vector4;
  77304. /** @hidden */
  77305. _randomCellOffset?: number;
  77306. /** @hidden */
  77307. _initialDirection: Nullable<Vector3>;
  77308. /** @hidden */
  77309. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  77310. /** @hidden */
  77311. _initialStartSpriteCellID: number;
  77312. /** @hidden */
  77313. _initialEndSpriteCellID: number;
  77314. /** @hidden */
  77315. _currentColorGradient: Nullable<ColorGradient>;
  77316. /** @hidden */
  77317. _currentColor1: Color4;
  77318. /** @hidden */
  77319. _currentColor2: Color4;
  77320. /** @hidden */
  77321. _currentSizeGradient: Nullable<FactorGradient>;
  77322. /** @hidden */
  77323. _currentSize1: number;
  77324. /** @hidden */
  77325. _currentSize2: number;
  77326. /** @hidden */
  77327. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  77328. /** @hidden */
  77329. _currentAngularSpeed1: number;
  77330. /** @hidden */
  77331. _currentAngularSpeed2: number;
  77332. /** @hidden */
  77333. _currentVelocityGradient: Nullable<FactorGradient>;
  77334. /** @hidden */
  77335. _currentVelocity1: number;
  77336. /** @hidden */
  77337. _currentVelocity2: number;
  77338. /** @hidden */
  77339. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  77340. /** @hidden */
  77341. _currentLimitVelocity1: number;
  77342. /** @hidden */
  77343. _currentLimitVelocity2: number;
  77344. /** @hidden */
  77345. _currentDragGradient: Nullable<FactorGradient>;
  77346. /** @hidden */
  77347. _currentDrag1: number;
  77348. /** @hidden */
  77349. _currentDrag2: number;
  77350. /** @hidden */
  77351. _randomNoiseCoordinates1: Vector3;
  77352. /** @hidden */
  77353. _randomNoiseCoordinates2: Vector3;
  77354. /**
  77355. * Creates a new instance Particle
  77356. * @param particleSystem the particle system the particle belongs to
  77357. */
  77358. constructor(
  77359. /**
  77360. * The particle system the particle belongs to.
  77361. */
  77362. particleSystem: ParticleSystem);
  77363. private updateCellInfoFromSystem;
  77364. /**
  77365. * Defines how the sprite cell index is updated for the particle
  77366. */
  77367. updateCellIndex(): void;
  77368. /** @hidden */
  77369. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  77370. /** @hidden */
  77371. _inheritParticleInfoToSubEmitters(): void;
  77372. /** @hidden */
  77373. _reset(): void;
  77374. /**
  77375. * Copy the properties of particle to another one.
  77376. * @param other the particle to copy the information to.
  77377. */
  77378. copyTo(other: Particle): void;
  77379. }
  77380. }
  77381. declare module BABYLON {
  77382. /**
  77383. * Particle emitter represents a volume emitting particles.
  77384. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  77385. */
  77386. export interface IParticleEmitterType {
  77387. /**
  77388. * Called by the particle System when the direction is computed for the created particle.
  77389. * @param worldMatrix is the world matrix of the particle system
  77390. * @param directionToUpdate is the direction vector to update with the result
  77391. * @param particle is the particle we are computed the direction for
  77392. */
  77393. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  77394. /**
  77395. * Called by the particle System when the position is computed for the created particle.
  77396. * @param worldMatrix is the world matrix of the particle system
  77397. * @param positionToUpdate is the position vector to update with the result
  77398. * @param particle is the particle we are computed the position for
  77399. */
  77400. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  77401. /**
  77402. * Clones the current emitter and returns a copy of it
  77403. * @returns the new emitter
  77404. */
  77405. clone(): IParticleEmitterType;
  77406. /**
  77407. * Called by the GPUParticleSystem to setup the update shader
  77408. * @param effect defines the update shader
  77409. */
  77410. applyToShader(effect: Effect): void;
  77411. /**
  77412. * Returns a string to use to update the GPU particles update shader
  77413. * @returns the effect defines string
  77414. */
  77415. getEffectDefines(): string;
  77416. /**
  77417. * Returns a string representing the class name
  77418. * @returns a string containing the class name
  77419. */
  77420. getClassName(): string;
  77421. /**
  77422. * Serializes the particle system to a JSON object.
  77423. * @returns the JSON object
  77424. */
  77425. serialize(): any;
  77426. /**
  77427. * Parse properties from a JSON object
  77428. * @param serializationObject defines the JSON object
  77429. */
  77430. parse(serializationObject: any): void;
  77431. }
  77432. }
  77433. declare module BABYLON {
  77434. /**
  77435. * Particle emitter emitting particles from the inside of a box.
  77436. * It emits the particles randomly between 2 given directions.
  77437. */
  77438. export class BoxParticleEmitter implements IParticleEmitterType {
  77439. /**
  77440. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  77441. */
  77442. direction1: Vector3;
  77443. /**
  77444. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  77445. */
  77446. direction2: Vector3;
  77447. /**
  77448. * 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.
  77449. */
  77450. minEmitBox: Vector3;
  77451. /**
  77452. * 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.
  77453. */
  77454. maxEmitBox: Vector3;
  77455. /**
  77456. * Creates a new instance BoxParticleEmitter
  77457. */
  77458. constructor();
  77459. /**
  77460. * Called by the particle System when the direction is computed for the created particle.
  77461. * @param worldMatrix is the world matrix of the particle system
  77462. * @param directionToUpdate is the direction vector to update with the result
  77463. * @param particle is the particle we are computed the direction for
  77464. */
  77465. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  77466. /**
  77467. * Called by the particle System when the position is computed for the created particle.
  77468. * @param worldMatrix is the world matrix of the particle system
  77469. * @param positionToUpdate is the position vector to update with the result
  77470. * @param particle is the particle we are computed the position for
  77471. */
  77472. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  77473. /**
  77474. * Clones the current emitter and returns a copy of it
  77475. * @returns the new emitter
  77476. */
  77477. clone(): BoxParticleEmitter;
  77478. /**
  77479. * Called by the GPUParticleSystem to setup the update shader
  77480. * @param effect defines the update shader
  77481. */
  77482. applyToShader(effect: Effect): void;
  77483. /**
  77484. * Returns a string to use to update the GPU particles update shader
  77485. * @returns a string containng the defines string
  77486. */
  77487. getEffectDefines(): string;
  77488. /**
  77489. * Returns the string "BoxParticleEmitter"
  77490. * @returns a string containing the class name
  77491. */
  77492. getClassName(): string;
  77493. /**
  77494. * Serializes the particle system to a JSON object.
  77495. * @returns the JSON object
  77496. */
  77497. serialize(): any;
  77498. /**
  77499. * Parse properties from a JSON object
  77500. * @param serializationObject defines the JSON object
  77501. */
  77502. parse(serializationObject: any): void;
  77503. }
  77504. }
  77505. declare module BABYLON {
  77506. /**
  77507. * Particle emitter emitting particles from the inside of a cone.
  77508. * It emits the particles alongside the cone volume from the base to the particle.
  77509. * The emission direction might be randomized.
  77510. */
  77511. export class ConeParticleEmitter implements IParticleEmitterType {
  77512. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  77513. directionRandomizer: number;
  77514. private _radius;
  77515. private _angle;
  77516. private _height;
  77517. /**
  77518. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  77519. */
  77520. radiusRange: number;
  77521. /**
  77522. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  77523. */
  77524. heightRange: number;
  77525. /**
  77526. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  77527. */
  77528. emitFromSpawnPointOnly: boolean;
  77529. /**
  77530. * Gets or sets the radius of the emission cone
  77531. */
  77532. radius: number;
  77533. /**
  77534. * Gets or sets the angle of the emission cone
  77535. */
  77536. angle: number;
  77537. private _buildHeight;
  77538. /**
  77539. * Creates a new instance ConeParticleEmitter
  77540. * @param radius the radius of the emission cone (1 by default)
  77541. * @param angle the cone base angle (PI by default)
  77542. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  77543. */
  77544. constructor(radius?: number, angle?: number,
  77545. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  77546. directionRandomizer?: number);
  77547. /**
  77548. * Called by the particle System when the direction is computed for the created particle.
  77549. * @param worldMatrix is the world matrix of the particle system
  77550. * @param directionToUpdate is the direction vector to update with the result
  77551. * @param particle is the particle we are computed the direction for
  77552. */
  77553. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  77554. /**
  77555. * Called by the particle System when the position is computed for the created particle.
  77556. * @param worldMatrix is the world matrix of the particle system
  77557. * @param positionToUpdate is the position vector to update with the result
  77558. * @param particle is the particle we are computed the position for
  77559. */
  77560. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  77561. /**
  77562. * Clones the current emitter and returns a copy of it
  77563. * @returns the new emitter
  77564. */
  77565. clone(): ConeParticleEmitter;
  77566. /**
  77567. * Called by the GPUParticleSystem to setup the update shader
  77568. * @param effect defines the update shader
  77569. */
  77570. applyToShader(effect: Effect): void;
  77571. /**
  77572. * Returns a string to use to update the GPU particles update shader
  77573. * @returns a string containng the defines string
  77574. */
  77575. getEffectDefines(): string;
  77576. /**
  77577. * Returns the string "ConeParticleEmitter"
  77578. * @returns a string containing the class name
  77579. */
  77580. getClassName(): string;
  77581. /**
  77582. * Serializes the particle system to a JSON object.
  77583. * @returns the JSON object
  77584. */
  77585. serialize(): any;
  77586. /**
  77587. * Parse properties from a JSON object
  77588. * @param serializationObject defines the JSON object
  77589. */
  77590. parse(serializationObject: any): void;
  77591. }
  77592. }
  77593. declare module BABYLON {
  77594. /**
  77595. * Particle emitter emitting particles from the inside of a cylinder.
  77596. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  77597. */
  77598. export class CylinderParticleEmitter implements IParticleEmitterType {
  77599. /**
  77600. * The radius of the emission cylinder.
  77601. */
  77602. radius: number;
  77603. /**
  77604. * The height of the emission cylinder.
  77605. */
  77606. height: number;
  77607. /**
  77608. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  77609. */
  77610. radiusRange: number;
  77611. /**
  77612. * How much to randomize the particle direction [0-1].
  77613. */
  77614. directionRandomizer: number;
  77615. /**
  77616. * Creates a new instance CylinderParticleEmitter
  77617. * @param radius the radius of the emission cylinder (1 by default)
  77618. * @param height the height of the emission cylinder (1 by default)
  77619. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  77620. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  77621. */
  77622. constructor(
  77623. /**
  77624. * The radius of the emission cylinder.
  77625. */
  77626. radius?: number,
  77627. /**
  77628. * The height of the emission cylinder.
  77629. */
  77630. height?: number,
  77631. /**
  77632. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  77633. */
  77634. radiusRange?: number,
  77635. /**
  77636. * How much to randomize the particle direction [0-1].
  77637. */
  77638. directionRandomizer?: number);
  77639. /**
  77640. * Called by the particle System when the direction is computed for the created particle.
  77641. * @param worldMatrix is the world matrix of the particle system
  77642. * @param directionToUpdate is the direction vector to update with the result
  77643. * @param particle is the particle we are computed the direction for
  77644. */
  77645. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  77646. /**
  77647. * Called by the particle System when the position is computed for the created particle.
  77648. * @param worldMatrix is the world matrix of the particle system
  77649. * @param positionToUpdate is the position vector to update with the result
  77650. * @param particle is the particle we are computed the position for
  77651. */
  77652. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  77653. /**
  77654. * Clones the current emitter and returns a copy of it
  77655. * @returns the new emitter
  77656. */
  77657. clone(): CylinderParticleEmitter;
  77658. /**
  77659. * Called by the GPUParticleSystem to setup the update shader
  77660. * @param effect defines the update shader
  77661. */
  77662. applyToShader(effect: Effect): void;
  77663. /**
  77664. * Returns a string to use to update the GPU particles update shader
  77665. * @returns a string containng the defines string
  77666. */
  77667. getEffectDefines(): string;
  77668. /**
  77669. * Returns the string "CylinderParticleEmitter"
  77670. * @returns a string containing the class name
  77671. */
  77672. getClassName(): string;
  77673. /**
  77674. * Serializes the particle system to a JSON object.
  77675. * @returns the JSON object
  77676. */
  77677. serialize(): any;
  77678. /**
  77679. * Parse properties from a JSON object
  77680. * @param serializationObject defines the JSON object
  77681. */
  77682. parse(serializationObject: any): void;
  77683. }
  77684. /**
  77685. * Particle emitter emitting particles from the inside of a cylinder.
  77686. * It emits the particles randomly between two vectors.
  77687. */
  77688. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  77689. /**
  77690. * The min limit of the emission direction.
  77691. */
  77692. direction1: Vector3;
  77693. /**
  77694. * The max limit of the emission direction.
  77695. */
  77696. direction2: Vector3;
  77697. /**
  77698. * Creates a new instance CylinderDirectedParticleEmitter
  77699. * @param radius the radius of the emission cylinder (1 by default)
  77700. * @param height the height of the emission cylinder (1 by default)
  77701. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  77702. * @param direction1 the min limit of the emission direction (up vector by default)
  77703. * @param direction2 the max limit of the emission direction (up vector by default)
  77704. */
  77705. constructor(radius?: number, height?: number, radiusRange?: number,
  77706. /**
  77707. * The min limit of the emission direction.
  77708. */
  77709. direction1?: Vector3,
  77710. /**
  77711. * The max limit of the emission direction.
  77712. */
  77713. direction2?: Vector3);
  77714. /**
  77715. * Called by the particle System when the direction is computed for the created particle.
  77716. * @param worldMatrix is the world matrix of the particle system
  77717. * @param directionToUpdate is the direction vector to update with the result
  77718. * @param particle is the particle we are computed the direction for
  77719. */
  77720. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  77721. /**
  77722. * Clones the current emitter and returns a copy of it
  77723. * @returns the new emitter
  77724. */
  77725. clone(): CylinderDirectedParticleEmitter;
  77726. /**
  77727. * Called by the GPUParticleSystem to setup the update shader
  77728. * @param effect defines the update shader
  77729. */
  77730. applyToShader(effect: Effect): void;
  77731. /**
  77732. * Returns a string to use to update the GPU particles update shader
  77733. * @returns a string containng the defines string
  77734. */
  77735. getEffectDefines(): string;
  77736. /**
  77737. * Returns the string "CylinderDirectedParticleEmitter"
  77738. * @returns a string containing the class name
  77739. */
  77740. getClassName(): string;
  77741. /**
  77742. * Serializes the particle system to a JSON object.
  77743. * @returns the JSON object
  77744. */
  77745. serialize(): any;
  77746. /**
  77747. * Parse properties from a JSON object
  77748. * @param serializationObject defines the JSON object
  77749. */
  77750. parse(serializationObject: any): void;
  77751. }
  77752. }
  77753. declare module BABYLON {
  77754. /**
  77755. * Particle emitter emitting particles from the inside of a hemisphere.
  77756. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  77757. */
  77758. export class HemisphericParticleEmitter implements IParticleEmitterType {
  77759. /**
  77760. * The radius of the emission hemisphere.
  77761. */
  77762. radius: number;
  77763. /**
  77764. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  77765. */
  77766. radiusRange: number;
  77767. /**
  77768. * How much to randomize the particle direction [0-1].
  77769. */
  77770. directionRandomizer: number;
  77771. /**
  77772. * Creates a new instance HemisphericParticleEmitter
  77773. * @param radius the radius of the emission hemisphere (1 by default)
  77774. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  77775. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  77776. */
  77777. constructor(
  77778. /**
  77779. * The radius of the emission hemisphere.
  77780. */
  77781. radius?: number,
  77782. /**
  77783. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  77784. */
  77785. radiusRange?: number,
  77786. /**
  77787. * How much to randomize the particle direction [0-1].
  77788. */
  77789. directionRandomizer?: number);
  77790. /**
  77791. * Called by the particle System when the direction is computed for the created particle.
  77792. * @param worldMatrix is the world matrix of the particle system
  77793. * @param directionToUpdate is the direction vector to update with the result
  77794. * @param particle is the particle we are computed the direction for
  77795. */
  77796. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  77797. /**
  77798. * Called by the particle System when the position is computed for the created particle.
  77799. * @param worldMatrix is the world matrix of the particle system
  77800. * @param positionToUpdate is the position vector to update with the result
  77801. * @param particle is the particle we are computed the position for
  77802. */
  77803. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  77804. /**
  77805. * Clones the current emitter and returns a copy of it
  77806. * @returns the new emitter
  77807. */
  77808. clone(): HemisphericParticleEmitter;
  77809. /**
  77810. * Called by the GPUParticleSystem to setup the update shader
  77811. * @param effect defines the update shader
  77812. */
  77813. applyToShader(effect: Effect): void;
  77814. /**
  77815. * Returns a string to use to update the GPU particles update shader
  77816. * @returns a string containng the defines string
  77817. */
  77818. getEffectDefines(): string;
  77819. /**
  77820. * Returns the string "HemisphericParticleEmitter"
  77821. * @returns a string containing the class name
  77822. */
  77823. getClassName(): string;
  77824. /**
  77825. * Serializes the particle system to a JSON object.
  77826. * @returns the JSON object
  77827. */
  77828. serialize(): any;
  77829. /**
  77830. * Parse properties from a JSON object
  77831. * @param serializationObject defines the JSON object
  77832. */
  77833. parse(serializationObject: any): void;
  77834. }
  77835. }
  77836. declare module BABYLON {
  77837. /**
  77838. * Particle emitter emitting particles from a point.
  77839. * It emits the particles randomly between 2 given directions.
  77840. */
  77841. export class PointParticleEmitter implements IParticleEmitterType {
  77842. /**
  77843. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  77844. */
  77845. direction1: Vector3;
  77846. /**
  77847. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  77848. */
  77849. direction2: Vector3;
  77850. /**
  77851. * Creates a new instance PointParticleEmitter
  77852. */
  77853. constructor();
  77854. /**
  77855. * Called by the particle System when the direction is computed for the created particle.
  77856. * @param worldMatrix is the world matrix of the particle system
  77857. * @param directionToUpdate is the direction vector to update with the result
  77858. * @param particle is the particle we are computed the direction for
  77859. */
  77860. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  77861. /**
  77862. * Called by the particle System when the position is computed for the created particle.
  77863. * @param worldMatrix is the world matrix of the particle system
  77864. * @param positionToUpdate is the position vector to update with the result
  77865. * @param particle is the particle we are computed the position for
  77866. */
  77867. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  77868. /**
  77869. * Clones the current emitter and returns a copy of it
  77870. * @returns the new emitter
  77871. */
  77872. clone(): PointParticleEmitter;
  77873. /**
  77874. * Called by the GPUParticleSystem to setup the update shader
  77875. * @param effect defines the update shader
  77876. */
  77877. applyToShader(effect: Effect): void;
  77878. /**
  77879. * Returns a string to use to update the GPU particles update shader
  77880. * @returns a string containng the defines string
  77881. */
  77882. getEffectDefines(): string;
  77883. /**
  77884. * Returns the string "PointParticleEmitter"
  77885. * @returns a string containing the class name
  77886. */
  77887. getClassName(): string;
  77888. /**
  77889. * Serializes the particle system to a JSON object.
  77890. * @returns the JSON object
  77891. */
  77892. serialize(): any;
  77893. /**
  77894. * Parse properties from a JSON object
  77895. * @param serializationObject defines the JSON object
  77896. */
  77897. parse(serializationObject: any): void;
  77898. }
  77899. }
  77900. declare module BABYLON {
  77901. /**
  77902. * Particle emitter emitting particles from the inside of a sphere.
  77903. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  77904. */
  77905. export class SphereParticleEmitter implements IParticleEmitterType {
  77906. /**
  77907. * The radius of the emission sphere.
  77908. */
  77909. radius: number;
  77910. /**
  77911. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  77912. */
  77913. radiusRange: number;
  77914. /**
  77915. * How much to randomize the particle direction [0-1].
  77916. */
  77917. directionRandomizer: number;
  77918. /**
  77919. * Creates a new instance SphereParticleEmitter
  77920. * @param radius the radius of the emission sphere (1 by default)
  77921. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  77922. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  77923. */
  77924. constructor(
  77925. /**
  77926. * The radius of the emission sphere.
  77927. */
  77928. radius?: number,
  77929. /**
  77930. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  77931. */
  77932. radiusRange?: number,
  77933. /**
  77934. * How much to randomize the particle direction [0-1].
  77935. */
  77936. directionRandomizer?: number);
  77937. /**
  77938. * Called by the particle System when the direction is computed for the created particle.
  77939. * @param worldMatrix is the world matrix of the particle system
  77940. * @param directionToUpdate is the direction vector to update with the result
  77941. * @param particle is the particle we are computed the direction for
  77942. */
  77943. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  77944. /**
  77945. * Called by the particle System when the position is computed for the created particle.
  77946. * @param worldMatrix is the world matrix of the particle system
  77947. * @param positionToUpdate is the position vector to update with the result
  77948. * @param particle is the particle we are computed the position for
  77949. */
  77950. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  77951. /**
  77952. * Clones the current emitter and returns a copy of it
  77953. * @returns the new emitter
  77954. */
  77955. clone(): SphereParticleEmitter;
  77956. /**
  77957. * Called by the GPUParticleSystem to setup the update shader
  77958. * @param effect defines the update shader
  77959. */
  77960. applyToShader(effect: Effect): void;
  77961. /**
  77962. * Returns a string to use to update the GPU particles update shader
  77963. * @returns a string containng the defines string
  77964. */
  77965. getEffectDefines(): string;
  77966. /**
  77967. * Returns the string "SphereParticleEmitter"
  77968. * @returns a string containing the class name
  77969. */
  77970. getClassName(): string;
  77971. /**
  77972. * Serializes the particle system to a JSON object.
  77973. * @returns the JSON object
  77974. */
  77975. serialize(): any;
  77976. /**
  77977. * Parse properties from a JSON object
  77978. * @param serializationObject defines the JSON object
  77979. */
  77980. parse(serializationObject: any): void;
  77981. }
  77982. /**
  77983. * Particle emitter emitting particles from the inside of a sphere.
  77984. * It emits the particles randomly between two vectors.
  77985. */
  77986. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  77987. /**
  77988. * The min limit of the emission direction.
  77989. */
  77990. direction1: Vector3;
  77991. /**
  77992. * The max limit of the emission direction.
  77993. */
  77994. direction2: Vector3;
  77995. /**
  77996. * Creates a new instance SphereDirectedParticleEmitter
  77997. * @param radius the radius of the emission sphere (1 by default)
  77998. * @param direction1 the min limit of the emission direction (up vector by default)
  77999. * @param direction2 the max limit of the emission direction (up vector by default)
  78000. */
  78001. constructor(radius?: number,
  78002. /**
  78003. * The min limit of the emission direction.
  78004. */
  78005. direction1?: Vector3,
  78006. /**
  78007. * The max limit of the emission direction.
  78008. */
  78009. direction2?: Vector3);
  78010. /**
  78011. * Called by the particle System when the direction is computed for the created particle.
  78012. * @param worldMatrix is the world matrix of the particle system
  78013. * @param directionToUpdate is the direction vector to update with the result
  78014. * @param particle is the particle we are computed the direction for
  78015. */
  78016. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  78017. /**
  78018. * Clones the current emitter and returns a copy of it
  78019. * @returns the new emitter
  78020. */
  78021. clone(): SphereDirectedParticleEmitter;
  78022. /**
  78023. * Called by the GPUParticleSystem to setup the update shader
  78024. * @param effect defines the update shader
  78025. */
  78026. applyToShader(effect: Effect): void;
  78027. /**
  78028. * Returns a string to use to update the GPU particles update shader
  78029. * @returns a string containng the defines string
  78030. */
  78031. getEffectDefines(): string;
  78032. /**
  78033. * Returns the string "SphereDirectedParticleEmitter"
  78034. * @returns a string containing the class name
  78035. */
  78036. getClassName(): string;
  78037. /**
  78038. * Serializes the particle system to a JSON object.
  78039. * @returns the JSON object
  78040. */
  78041. serialize(): any;
  78042. /**
  78043. * Parse properties from a JSON object
  78044. * @param serializationObject defines the JSON object
  78045. */
  78046. parse(serializationObject: any): void;
  78047. }
  78048. }
  78049. declare module BABYLON {
  78050. /**
  78051. * Interface representing a particle system in Babylon.js.
  78052. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  78053. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  78054. */
  78055. export interface IParticleSystem {
  78056. /**
  78057. * List of animations used by the particle system.
  78058. */
  78059. animations: Animation[];
  78060. /**
  78061. * The id of the Particle system.
  78062. */
  78063. id: string;
  78064. /**
  78065. * The name of the Particle system.
  78066. */
  78067. name: string;
  78068. /**
  78069. * The emitter represents the Mesh or position we are attaching the particle system to.
  78070. */
  78071. emitter: Nullable<AbstractMesh | Vector3>;
  78072. /**
  78073. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  78074. */
  78075. isBillboardBased: boolean;
  78076. /**
  78077. * The rendering group used by the Particle system to chose when to render.
  78078. */
  78079. renderingGroupId: number;
  78080. /**
  78081. * The layer mask we are rendering the particles through.
  78082. */
  78083. layerMask: number;
  78084. /**
  78085. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  78086. */
  78087. updateSpeed: number;
  78088. /**
  78089. * The amount of time the particle system is running (depends of the overall update speed).
  78090. */
  78091. targetStopDuration: number;
  78092. /**
  78093. * The texture used to render each particle. (this can be a spritesheet)
  78094. */
  78095. particleTexture: Nullable<Texture>;
  78096. /**
  78097. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  78098. */
  78099. blendMode: number;
  78100. /**
  78101. * Minimum life time of emitting particles.
  78102. */
  78103. minLifeTime: number;
  78104. /**
  78105. * Maximum life time of emitting particles.
  78106. */
  78107. maxLifeTime: number;
  78108. /**
  78109. * Minimum Size of emitting particles.
  78110. */
  78111. minSize: number;
  78112. /**
  78113. * Maximum Size of emitting particles.
  78114. */
  78115. maxSize: number;
  78116. /**
  78117. * Minimum scale of emitting particles on X axis.
  78118. */
  78119. minScaleX: number;
  78120. /**
  78121. * Maximum scale of emitting particles on X axis.
  78122. */
  78123. maxScaleX: number;
  78124. /**
  78125. * Minimum scale of emitting particles on Y axis.
  78126. */
  78127. minScaleY: number;
  78128. /**
  78129. * Maximum scale of emitting particles on Y axis.
  78130. */
  78131. maxScaleY: number;
  78132. /**
  78133. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  78134. */
  78135. color1: Color4;
  78136. /**
  78137. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  78138. */
  78139. color2: Color4;
  78140. /**
  78141. * Color the particle will have at the end of its lifetime.
  78142. */
  78143. colorDead: Color4;
  78144. /**
  78145. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  78146. */
  78147. emitRate: number;
  78148. /**
  78149. * You can use gravity if you want to give an orientation to your particles.
  78150. */
  78151. gravity: Vector3;
  78152. /**
  78153. * Minimum power of emitting particles.
  78154. */
  78155. minEmitPower: number;
  78156. /**
  78157. * Maximum power of emitting particles.
  78158. */
  78159. maxEmitPower: number;
  78160. /**
  78161. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  78162. */
  78163. minAngularSpeed: number;
  78164. /**
  78165. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  78166. */
  78167. maxAngularSpeed: number;
  78168. /**
  78169. * Gets or sets the minimal initial rotation in radians.
  78170. */
  78171. minInitialRotation: number;
  78172. /**
  78173. * Gets or sets the maximal initial rotation in radians.
  78174. */
  78175. maxInitialRotation: number;
  78176. /**
  78177. * The particle emitter type defines the emitter used by the particle system.
  78178. * It can be for example box, sphere, or cone...
  78179. */
  78180. particleEmitterType: Nullable<IParticleEmitterType>;
  78181. /**
  78182. * Defines the delay in milliseconds before starting the system (0 by default)
  78183. */
  78184. startDelay: number;
  78185. /**
  78186. * 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
  78187. */
  78188. preWarmCycles: number;
  78189. /**
  78190. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  78191. */
  78192. preWarmStepOffset: number;
  78193. /**
  78194. * 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)
  78195. */
  78196. spriteCellChangeSpeed: number;
  78197. /**
  78198. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  78199. */
  78200. startSpriteCellID: number;
  78201. /**
  78202. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  78203. */
  78204. endSpriteCellID: number;
  78205. /**
  78206. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  78207. */
  78208. spriteCellWidth: number;
  78209. /**
  78210. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  78211. */
  78212. spriteCellHeight: number;
  78213. /**
  78214. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  78215. */
  78216. spriteRandomStartCell: boolean;
  78217. /**
  78218. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  78219. */
  78220. isAnimationSheetEnabled: boolean;
  78221. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  78222. translationPivot: Vector2;
  78223. /**
  78224. * Gets or sets a texture used to add random noise to particle positions
  78225. */
  78226. noiseTexture: Nullable<BaseTexture>;
  78227. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  78228. noiseStrength: Vector3;
  78229. /**
  78230. * Gets or sets the billboard mode to use when isBillboardBased = true.
  78231. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  78232. */
  78233. billboardMode: number;
  78234. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  78235. limitVelocityDamping: number;
  78236. /**
  78237. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  78238. */
  78239. beginAnimationOnStart: boolean;
  78240. /**
  78241. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  78242. */
  78243. beginAnimationFrom: number;
  78244. /**
  78245. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  78246. */
  78247. beginAnimationTo: number;
  78248. /**
  78249. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  78250. */
  78251. beginAnimationLoop: boolean;
  78252. /**
  78253. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  78254. */
  78255. disposeOnStop: boolean;
  78256. /**
  78257. * Gets the maximum number of particles active at the same time.
  78258. * @returns The max number of active particles.
  78259. */
  78260. getCapacity(): number;
  78261. /**
  78262. * Gets if the system has been started. (Note: this will still be true after stop is called)
  78263. * @returns True if it has been started, otherwise false.
  78264. */
  78265. isStarted(): boolean;
  78266. /**
  78267. * Animates the particle system for this frame.
  78268. */
  78269. animate(): void;
  78270. /**
  78271. * Renders the particle system in its current state.
  78272. * @returns the current number of particles
  78273. */
  78274. render(): number;
  78275. /**
  78276. * Dispose the particle system and frees its associated resources.
  78277. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  78278. */
  78279. dispose(disposeTexture?: boolean): void;
  78280. /**
  78281. * Clones the particle system.
  78282. * @param name The name of the cloned object
  78283. * @param newEmitter The new emitter to use
  78284. * @returns the cloned particle system
  78285. */
  78286. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  78287. /**
  78288. * Serializes the particle system to a JSON object.
  78289. * @returns the JSON object
  78290. */
  78291. serialize(): any;
  78292. /**
  78293. * Rebuild the particle system
  78294. */
  78295. rebuild(): void;
  78296. /**
  78297. * Starts the particle system and begins to emit
  78298. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  78299. */
  78300. start(delay?: number): void;
  78301. /**
  78302. * Stops the particle system.
  78303. */
  78304. stop(): void;
  78305. /**
  78306. * Remove all active particles
  78307. */
  78308. reset(): void;
  78309. /**
  78310. * Is this system ready to be used/rendered
  78311. * @return true if the system is ready
  78312. */
  78313. isReady(): boolean;
  78314. /**
  78315. * Adds a new color gradient
  78316. * @param gradient defines the gradient to use (between 0 and 1)
  78317. * @param color1 defines the color to affect to the specified gradient
  78318. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  78319. * @returns the current particle system
  78320. */
  78321. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  78322. /**
  78323. * Remove a specific color gradient
  78324. * @param gradient defines the gradient to remove
  78325. * @returns the current particle system
  78326. */
  78327. removeColorGradient(gradient: number): IParticleSystem;
  78328. /**
  78329. * Adds a new size gradient
  78330. * @param gradient defines the gradient to use (between 0 and 1)
  78331. * @param factor defines the size factor to affect to the specified gradient
  78332. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  78333. * @returns the current particle system
  78334. */
  78335. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  78336. /**
  78337. * Remove a specific size gradient
  78338. * @param gradient defines the gradient to remove
  78339. * @returns the current particle system
  78340. */
  78341. removeSizeGradient(gradient: number): IParticleSystem;
  78342. /**
  78343. * Gets the current list of color gradients.
  78344. * You must use addColorGradient and removeColorGradient to udpate this list
  78345. * @returns the list of color gradients
  78346. */
  78347. getColorGradients(): Nullable<Array<ColorGradient>>;
  78348. /**
  78349. * Gets the current list of size gradients.
  78350. * You must use addSizeGradient and removeSizeGradient to udpate this list
  78351. * @returns the list of size gradients
  78352. */
  78353. getSizeGradients(): Nullable<Array<FactorGradient>>;
  78354. /**
  78355. * Gets the current list of angular speed gradients.
  78356. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  78357. * @returns the list of angular speed gradients
  78358. */
  78359. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  78360. /**
  78361. * Adds a new angular speed gradient
  78362. * @param gradient defines the gradient to use (between 0 and 1)
  78363. * @param factor defines the angular speed to affect to the specified gradient
  78364. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  78365. * @returns the current particle system
  78366. */
  78367. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  78368. /**
  78369. * Remove a specific angular speed gradient
  78370. * @param gradient defines the gradient to remove
  78371. * @returns the current particle system
  78372. */
  78373. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  78374. /**
  78375. * Gets the current list of velocity gradients.
  78376. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  78377. * @returns the list of velocity gradients
  78378. */
  78379. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  78380. /**
  78381. * Adds a new velocity gradient
  78382. * @param gradient defines the gradient to use (between 0 and 1)
  78383. * @param factor defines the velocity to affect to the specified gradient
  78384. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  78385. * @returns the current particle system
  78386. */
  78387. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  78388. /**
  78389. * Remove a specific velocity gradient
  78390. * @param gradient defines the gradient to remove
  78391. * @returns the current particle system
  78392. */
  78393. removeVelocityGradient(gradient: number): IParticleSystem;
  78394. /**
  78395. * Gets the current list of limit velocity gradients.
  78396. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  78397. * @returns the list of limit velocity gradients
  78398. */
  78399. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  78400. /**
  78401. * Adds a new limit velocity gradient
  78402. * @param gradient defines the gradient to use (between 0 and 1)
  78403. * @param factor defines the limit velocity to affect to the specified gradient
  78404. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  78405. * @returns the current particle system
  78406. */
  78407. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  78408. /**
  78409. * Remove a specific limit velocity gradient
  78410. * @param gradient defines the gradient to remove
  78411. * @returns the current particle system
  78412. */
  78413. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  78414. /**
  78415. * Adds a new drag gradient
  78416. * @param gradient defines the gradient to use (between 0 and 1)
  78417. * @param factor defines the drag to affect to the specified gradient
  78418. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  78419. * @returns the current particle system
  78420. */
  78421. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  78422. /**
  78423. * Remove a specific drag gradient
  78424. * @param gradient defines the gradient to remove
  78425. * @returns the current particle system
  78426. */
  78427. removeDragGradient(gradient: number): IParticleSystem;
  78428. /**
  78429. * Gets the current list of drag gradients.
  78430. * You must use addDragGradient and removeDragGradient to udpate this list
  78431. * @returns the list of drag gradients
  78432. */
  78433. getDragGradients(): Nullable<Array<FactorGradient>>;
  78434. /**
  78435. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  78436. * @param gradient defines the gradient to use (between 0 and 1)
  78437. * @param factor defines the emit rate to affect to the specified gradient
  78438. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  78439. * @returns the current particle system
  78440. */
  78441. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  78442. /**
  78443. * Remove a specific emit rate gradient
  78444. * @param gradient defines the gradient to remove
  78445. * @returns the current particle system
  78446. */
  78447. removeEmitRateGradient(gradient: number): IParticleSystem;
  78448. /**
  78449. * Gets the current list of emit rate gradients.
  78450. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  78451. * @returns the list of emit rate gradients
  78452. */
  78453. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  78454. /**
  78455. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  78456. * @param gradient defines the gradient to use (between 0 and 1)
  78457. * @param factor defines the start size to affect to the specified gradient
  78458. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  78459. * @returns the current particle system
  78460. */
  78461. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  78462. /**
  78463. * Remove a specific start size gradient
  78464. * @param gradient defines the gradient to remove
  78465. * @returns the current particle system
  78466. */
  78467. removeStartSizeGradient(gradient: number): IParticleSystem;
  78468. /**
  78469. * Gets the current list of start size gradients.
  78470. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  78471. * @returns the list of start size gradients
  78472. */
  78473. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  78474. /**
  78475. * Adds a new life time gradient
  78476. * @param gradient defines the gradient to use (between 0 and 1)
  78477. * @param factor defines the life time factor to affect to the specified gradient
  78478. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  78479. * @returns the current particle system
  78480. */
  78481. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  78482. /**
  78483. * Remove a specific life time gradient
  78484. * @param gradient defines the gradient to remove
  78485. * @returns the current particle system
  78486. */
  78487. removeLifeTimeGradient(gradient: number): IParticleSystem;
  78488. /**
  78489. * Gets the current list of life time gradients.
  78490. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  78491. * @returns the list of life time gradients
  78492. */
  78493. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  78494. /**
  78495. * Gets the current list of color gradients.
  78496. * You must use addColorGradient and removeColorGradient to udpate this list
  78497. * @returns the list of color gradients
  78498. */
  78499. getColorGradients(): Nullable<Array<ColorGradient>>;
  78500. /**
  78501. * Adds a new ramp gradient used to remap particle colors
  78502. * @param gradient defines the gradient to use (between 0 and 1)
  78503. * @param color defines the color to affect to the specified gradient
  78504. * @returns the current particle system
  78505. */
  78506. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  78507. /**
  78508. * Gets the current list of ramp gradients.
  78509. * You must use addRampGradient and removeRampGradient to udpate this list
  78510. * @returns the list of ramp gradients
  78511. */
  78512. getRampGradients(): Nullable<Array<Color3Gradient>>;
  78513. /** Gets or sets a boolean indicating that ramp gradients must be used
  78514. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  78515. */
  78516. useRampGradients: boolean;
  78517. /**
  78518. * Adds a new color remap gradient
  78519. * @param gradient defines the gradient to use (between 0 and 1)
  78520. * @param min defines the color remap minimal range
  78521. * @param max defines the color remap maximal range
  78522. * @returns the current particle system
  78523. */
  78524. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  78525. /**
  78526. * Gets the current list of color remap gradients.
  78527. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  78528. * @returns the list of color remap gradients
  78529. */
  78530. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  78531. /**
  78532. * Adds a new alpha remap gradient
  78533. * @param gradient defines the gradient to use (between 0 and 1)
  78534. * @param min defines the alpha remap minimal range
  78535. * @param max defines the alpha remap maximal range
  78536. * @returns the current particle system
  78537. */
  78538. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  78539. /**
  78540. * Gets the current list of alpha remap gradients.
  78541. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  78542. * @returns the list of alpha remap gradients
  78543. */
  78544. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  78545. /**
  78546. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  78547. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  78548. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  78549. * @returns the emitter
  78550. */
  78551. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  78552. /**
  78553. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  78554. * @param radius The radius of the hemisphere to emit from
  78555. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  78556. * @returns the emitter
  78557. */
  78558. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  78559. /**
  78560. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  78561. * @param radius The radius of the sphere to emit from
  78562. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  78563. * @returns the emitter
  78564. */
  78565. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  78566. /**
  78567. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  78568. * @param radius The radius of the sphere to emit from
  78569. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  78570. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  78571. * @returns the emitter
  78572. */
  78573. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  78574. /**
  78575. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  78576. * @param radius The radius of the emission cylinder
  78577. * @param height The height of the emission cylinder
  78578. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  78579. * @param directionRandomizer How much to randomize the particle direction [0-1]
  78580. * @returns the emitter
  78581. */
  78582. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  78583. /**
  78584. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  78585. * @param radius The radius of the cylinder to emit from
  78586. * @param height The height of the emission cylinder
  78587. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  78588. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  78589. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  78590. * @returns the emitter
  78591. */
  78592. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  78593. /**
  78594. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  78595. * @param radius The radius of the cone to emit from
  78596. * @param angle The base angle of the cone
  78597. * @returns the emitter
  78598. */
  78599. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  78600. /**
  78601. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  78602. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  78603. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  78604. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  78605. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  78606. * @returns the emitter
  78607. */
  78608. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  78609. /**
  78610. * Get hosting scene
  78611. * @returns the scene
  78612. */
  78613. getScene(): Scene;
  78614. }
  78615. }
  78616. declare module BABYLON {
  78617. /**
  78618. * Creates an instance based on a source mesh.
  78619. */
  78620. export class InstancedMesh extends AbstractMesh {
  78621. private _sourceMesh;
  78622. private _currentLOD;
  78623. /** @hidden */
  78624. _indexInSourceMeshInstanceArray: number;
  78625. constructor(name: string, source: Mesh);
  78626. /**
  78627. * Returns the string "InstancedMesh".
  78628. */
  78629. getClassName(): string;
  78630. /** Gets the list of lights affecting that mesh */
  78631. readonly lightSources: Light[];
  78632. _resyncLightSources(): void;
  78633. _resyncLighSource(light: Light): void;
  78634. _removeLightSource(light: Light): void;
  78635. /**
  78636. * If the source mesh receives shadows
  78637. */
  78638. readonly receiveShadows: boolean;
  78639. /**
  78640. * The material of the source mesh
  78641. */
  78642. readonly material: Nullable<Material>;
  78643. /**
  78644. * Visibility of the source mesh
  78645. */
  78646. readonly visibility: number;
  78647. /**
  78648. * Skeleton of the source mesh
  78649. */
  78650. readonly skeleton: Nullable<Skeleton>;
  78651. /**
  78652. * Rendering ground id of the source mesh
  78653. */
  78654. renderingGroupId: number;
  78655. /**
  78656. * Returns the total number of vertices (integer).
  78657. */
  78658. getTotalVertices(): number;
  78659. /**
  78660. * Returns a positive integer : the total number of indices in this mesh geometry.
  78661. * @returns the numner of indices or zero if the mesh has no geometry.
  78662. */
  78663. getTotalIndices(): number;
  78664. /**
  78665. * The source mesh of the instance
  78666. */
  78667. readonly sourceMesh: Mesh;
  78668. /**
  78669. * Is this node ready to be used/rendered
  78670. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  78671. * @return {boolean} is it ready
  78672. */
  78673. isReady(completeCheck?: boolean): boolean;
  78674. /**
  78675. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  78676. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  78677. * @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.
  78678. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  78679. */
  78680. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  78681. /**
  78682. * Sets the vertex data of the mesh geometry for the requested `kind`.
  78683. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  78684. * The `data` are either a numeric array either a Float32Array.
  78685. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  78686. * 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).
  78687. * Note that a new underlying VertexBuffer object is created each call.
  78688. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  78689. *
  78690. * Possible `kind` values :
  78691. * - VertexBuffer.PositionKind
  78692. * - VertexBuffer.UVKind
  78693. * - VertexBuffer.UV2Kind
  78694. * - VertexBuffer.UV3Kind
  78695. * - VertexBuffer.UV4Kind
  78696. * - VertexBuffer.UV5Kind
  78697. * - VertexBuffer.UV6Kind
  78698. * - VertexBuffer.ColorKind
  78699. * - VertexBuffer.MatricesIndicesKind
  78700. * - VertexBuffer.MatricesIndicesExtraKind
  78701. * - VertexBuffer.MatricesWeightsKind
  78702. * - VertexBuffer.MatricesWeightsExtraKind
  78703. *
  78704. * Returns the Mesh.
  78705. */
  78706. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  78707. /**
  78708. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  78709. * If the mesh has no geometry, it is simply returned as it is.
  78710. * The `data` are either a numeric array either a Float32Array.
  78711. * No new underlying VertexBuffer object is created.
  78712. * 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.
  78713. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  78714. *
  78715. * Possible `kind` values :
  78716. * - VertexBuffer.PositionKind
  78717. * - VertexBuffer.UVKind
  78718. * - VertexBuffer.UV2Kind
  78719. * - VertexBuffer.UV3Kind
  78720. * - VertexBuffer.UV4Kind
  78721. * - VertexBuffer.UV5Kind
  78722. * - VertexBuffer.UV6Kind
  78723. * - VertexBuffer.ColorKind
  78724. * - VertexBuffer.MatricesIndicesKind
  78725. * - VertexBuffer.MatricesIndicesExtraKind
  78726. * - VertexBuffer.MatricesWeightsKind
  78727. * - VertexBuffer.MatricesWeightsExtraKind
  78728. *
  78729. * Returns the Mesh.
  78730. */
  78731. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  78732. /**
  78733. * Sets the mesh indices.
  78734. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  78735. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  78736. * This method creates a new index buffer each call.
  78737. * Returns the Mesh.
  78738. */
  78739. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  78740. /**
  78741. * Boolean : True if the mesh owns the requested kind of data.
  78742. */
  78743. isVerticesDataPresent(kind: string): boolean;
  78744. /**
  78745. * Returns an array of indices (IndicesArray).
  78746. */
  78747. getIndices(): Nullable<IndicesArray>;
  78748. readonly _positions: Nullable<Vector3[]>;
  78749. /**
  78750. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  78751. * This means the mesh underlying bounding box and sphere are recomputed.
  78752. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  78753. * @returns the current mesh
  78754. */
  78755. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  78756. /** @hidden */
  78757. _preActivate(): InstancedMesh;
  78758. /** @hidden */
  78759. _activate(renderId: number, intermediateRendering: boolean): boolean;
  78760. /** @hidden */
  78761. _postActivate(): void;
  78762. getWorldMatrix(): Matrix;
  78763. readonly isAnInstance: boolean;
  78764. /**
  78765. * Returns the current associated LOD AbstractMesh.
  78766. */
  78767. getLOD(camera: Camera): AbstractMesh;
  78768. /** @hidden */
  78769. _syncSubMeshes(): InstancedMesh;
  78770. /** @hidden */
  78771. _generatePointsArray(): boolean;
  78772. /**
  78773. * Creates a new InstancedMesh from the current mesh.
  78774. * - name (string) : the cloned mesh name
  78775. * - newParent (optional Node) : the optional Node to parent the clone to.
  78776. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  78777. *
  78778. * Returns the clone.
  78779. */
  78780. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  78781. /**
  78782. * Disposes the InstancedMesh.
  78783. * Returns nothing.
  78784. */
  78785. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  78786. }
  78787. }
  78788. declare module BABYLON {
  78789. /**
  78790. * Defines the options associated with the creation of a shader material.
  78791. */
  78792. export interface IShaderMaterialOptions {
  78793. /**
  78794. * Does the material work in alpha blend mode
  78795. */
  78796. needAlphaBlending: boolean;
  78797. /**
  78798. * Does the material work in alpha test mode
  78799. */
  78800. needAlphaTesting: boolean;
  78801. /**
  78802. * The list of attribute names used in the shader
  78803. */
  78804. attributes: string[];
  78805. /**
  78806. * The list of unifrom names used in the shader
  78807. */
  78808. uniforms: string[];
  78809. /**
  78810. * The list of UBO names used in the shader
  78811. */
  78812. uniformBuffers: string[];
  78813. /**
  78814. * The list of sampler names used in the shader
  78815. */
  78816. samplers: string[];
  78817. /**
  78818. * The list of defines used in the shader
  78819. */
  78820. defines: string[];
  78821. }
  78822. /**
  78823. * 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.
  78824. *
  78825. * This returned material effects how the mesh will look based on the code in the shaders.
  78826. *
  78827. * @see http://doc.babylonjs.com/how_to/shader_material
  78828. */
  78829. export class ShaderMaterial extends Material {
  78830. private _shaderPath;
  78831. private _options;
  78832. private _textures;
  78833. private _textureArrays;
  78834. private _floats;
  78835. private _ints;
  78836. private _floatsArrays;
  78837. private _colors3;
  78838. private _colors3Arrays;
  78839. private _colors4;
  78840. private _vectors2;
  78841. private _vectors3;
  78842. private _vectors4;
  78843. private _matrices;
  78844. private _matrices3x3;
  78845. private _matrices2x2;
  78846. private _vectors2Arrays;
  78847. private _vectors3Arrays;
  78848. private _cachedWorldViewMatrix;
  78849. private _cachedWorldViewProjectionMatrix;
  78850. private _renderId;
  78851. /**
  78852. * Instantiate a new shader material.
  78853. * 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.
  78854. * This returned material effects how the mesh will look based on the code in the shaders.
  78855. * @see http://doc.babylonjs.com/how_to/shader_material
  78856. * @param name Define the name of the material in the scene
  78857. * @param scene Define the scene the material belongs to
  78858. * @param shaderPath Defines the route to the shader code in one of three ways:
  78859. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  78860. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  78861. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  78862. * @param options Define the options used to create the shader
  78863. */
  78864. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  78865. /**
  78866. * Gets the options used to compile the shader.
  78867. * They can be modified to trigger a new compilation
  78868. */
  78869. readonly options: IShaderMaterialOptions;
  78870. /**
  78871. * Gets the current class name of the material e.g. "ShaderMaterial"
  78872. * Mainly use in serialization.
  78873. * @returns the class name
  78874. */
  78875. getClassName(): string;
  78876. /**
  78877. * Specifies if the material will require alpha blending
  78878. * @returns a boolean specifying if alpha blending is needed
  78879. */
  78880. needAlphaBlending(): boolean;
  78881. /**
  78882. * Specifies if this material should be rendered in alpha test mode
  78883. * @returns a boolean specifying if an alpha test is needed.
  78884. */
  78885. needAlphaTesting(): boolean;
  78886. private _checkUniform;
  78887. /**
  78888. * Set a texture in the shader.
  78889. * @param name Define the name of the uniform samplers as defined in the shader
  78890. * @param texture Define the texture to bind to this sampler
  78891. * @return the material itself allowing "fluent" like uniform updates
  78892. */
  78893. setTexture(name: string, texture: Texture): ShaderMaterial;
  78894. /**
  78895. * Set a texture array in the shader.
  78896. * @param name Define the name of the uniform sampler array as defined in the shader
  78897. * @param textures Define the list of textures to bind to this sampler
  78898. * @return the material itself allowing "fluent" like uniform updates
  78899. */
  78900. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  78901. /**
  78902. * Set a float in the shader.
  78903. * @param name Define the name of the uniform as defined in the shader
  78904. * @param value Define the value to give to the uniform
  78905. * @return the material itself allowing "fluent" like uniform updates
  78906. */
  78907. setFloat(name: string, value: number): ShaderMaterial;
  78908. /**
  78909. * Set a int in the shader.
  78910. * @param name Define the name of the uniform as defined in the shader
  78911. * @param value Define the value to give to the uniform
  78912. * @return the material itself allowing "fluent" like uniform updates
  78913. */
  78914. setInt(name: string, value: number): ShaderMaterial;
  78915. /**
  78916. * Set an array of floats in the shader.
  78917. * @param name Define the name of the uniform as defined in the shader
  78918. * @param value Define the value to give to the uniform
  78919. * @return the material itself allowing "fluent" like uniform updates
  78920. */
  78921. setFloats(name: string, value: number[]): ShaderMaterial;
  78922. /**
  78923. * Set a vec3 in the shader from a Color3.
  78924. * @param name Define the name of the uniform as defined in the shader
  78925. * @param value Define the value to give to the uniform
  78926. * @return the material itself allowing "fluent" like uniform updates
  78927. */
  78928. setColor3(name: string, value: Color3): ShaderMaterial;
  78929. /**
  78930. * Set a vec3 array in the shader from a Color3 array.
  78931. * @param name Define the name of the uniform as defined in the shader
  78932. * @param value Define the value to give to the uniform
  78933. * @return the material itself allowing "fluent" like uniform updates
  78934. */
  78935. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  78936. /**
  78937. * Set a vec4 in the shader from a Color4.
  78938. * @param name Define the name of the uniform as defined in the shader
  78939. * @param value Define the value to give to the uniform
  78940. * @return the material itself allowing "fluent" like uniform updates
  78941. */
  78942. setColor4(name: string, value: Color4): ShaderMaterial;
  78943. /**
  78944. * Set a vec2 in the shader from a Vector2.
  78945. * @param name Define the name of the uniform as defined in the shader
  78946. * @param value Define the value to give to the uniform
  78947. * @return the material itself allowing "fluent" like uniform updates
  78948. */
  78949. setVector2(name: string, value: Vector2): ShaderMaterial;
  78950. /**
  78951. * Set a vec3 in the shader from a Vector3.
  78952. * @param name Define the name of the uniform as defined in the shader
  78953. * @param value Define the value to give to the uniform
  78954. * @return the material itself allowing "fluent" like uniform updates
  78955. */
  78956. setVector3(name: string, value: Vector3): ShaderMaterial;
  78957. /**
  78958. * Set a vec4 in the shader from a Vector4.
  78959. * @param name Define the name of the uniform as defined in the shader
  78960. * @param value Define the value to give to the uniform
  78961. * @return the material itself allowing "fluent" like uniform updates
  78962. */
  78963. setVector4(name: string, value: Vector4): ShaderMaterial;
  78964. /**
  78965. * Set a mat4 in the shader from a Matrix.
  78966. * @param name Define the name of the uniform as defined in the shader
  78967. * @param value Define the value to give to the uniform
  78968. * @return the material itself allowing "fluent" like uniform updates
  78969. */
  78970. setMatrix(name: string, value: Matrix): ShaderMaterial;
  78971. /**
  78972. * Set a mat3 in the shader from a Float32Array.
  78973. * @param name Define the name of the uniform as defined in the shader
  78974. * @param value Define the value to give to the uniform
  78975. * @return the material itself allowing "fluent" like uniform updates
  78976. */
  78977. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  78978. /**
  78979. * Set a mat2 in the shader from a Float32Array.
  78980. * @param name Define the name of the uniform as defined in the shader
  78981. * @param value Define the value to give to the uniform
  78982. * @return the material itself allowing "fluent" like uniform updates
  78983. */
  78984. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  78985. /**
  78986. * Set a vec2 array in the shader from a number array.
  78987. * @param name Define the name of the uniform as defined in the shader
  78988. * @param value Define the value to give to the uniform
  78989. * @return the material itself allowing "fluent" like uniform updates
  78990. */
  78991. setArray2(name: string, value: number[]): ShaderMaterial;
  78992. /**
  78993. * Set a vec3 array in the shader from a number array.
  78994. * @param name Define the name of the uniform as defined in the shader
  78995. * @param value Define the value to give to the uniform
  78996. * @return the material itself allowing "fluent" like uniform updates
  78997. */
  78998. setArray3(name: string, value: number[]): ShaderMaterial;
  78999. private _checkCache;
  79000. /**
  79001. * Specifies that the submesh is ready to be used
  79002. * @param mesh defines the mesh to check
  79003. * @param subMesh defines which submesh to check
  79004. * @param useInstances specifies that instances should be used
  79005. * @returns a boolean indicating that the submesh is ready or not
  79006. */
  79007. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  79008. /**
  79009. * Checks if the material is ready to render the requested mesh
  79010. * @param mesh Define the mesh to render
  79011. * @param useInstances Define whether or not the material is used with instances
  79012. * @returns true if ready, otherwise false
  79013. */
  79014. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  79015. /**
  79016. * Binds the world matrix to the material
  79017. * @param world defines the world transformation matrix
  79018. */
  79019. bindOnlyWorldMatrix(world: Matrix): void;
  79020. /**
  79021. * Binds the material to the mesh
  79022. * @param world defines the world transformation matrix
  79023. * @param mesh defines the mesh to bind the material to
  79024. */
  79025. bind(world: Matrix, mesh?: Mesh): void;
  79026. /**
  79027. * Gets the active textures from the material
  79028. * @returns an array of textures
  79029. */
  79030. getActiveTextures(): BaseTexture[];
  79031. /**
  79032. * Specifies if the material uses a texture
  79033. * @param texture defines the texture to check against the material
  79034. * @returns a boolean specifying if the material uses the texture
  79035. */
  79036. hasTexture(texture: BaseTexture): boolean;
  79037. /**
  79038. * Makes a duplicate of the material, and gives it a new name
  79039. * @param name defines the new name for the duplicated material
  79040. * @returns the cloned material
  79041. */
  79042. clone(name: string): ShaderMaterial;
  79043. /**
  79044. * Disposes the material
  79045. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  79046. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  79047. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  79048. */
  79049. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  79050. /**
  79051. * Serializes this material in a JSON representation
  79052. * @returns the serialized material object
  79053. */
  79054. serialize(): any;
  79055. /**
  79056. * Creates a shader material from parsed shader material data
  79057. * @param source defines the JSON represnetation of the material
  79058. * @param scene defines the hosting scene
  79059. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  79060. * @returns a new material
  79061. */
  79062. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  79063. }
  79064. }
  79065. declare module BABYLON {
  79066. /** @hidden */
  79067. export var colorPixelShader: {
  79068. name: string;
  79069. shader: string;
  79070. };
  79071. }
  79072. declare module BABYLON {
  79073. /** @hidden */
  79074. export var colorVertexShader: {
  79075. name: string;
  79076. shader: string;
  79077. };
  79078. }
  79079. declare module BABYLON {
  79080. /**
  79081. * Line mesh
  79082. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  79083. */
  79084. export class LinesMesh extends Mesh {
  79085. /**
  79086. * If vertex color should be applied to the mesh
  79087. */
  79088. readonly useVertexColor?: boolean | undefined;
  79089. /**
  79090. * If vertex alpha should be applied to the mesh
  79091. */
  79092. readonly useVertexAlpha?: boolean | undefined;
  79093. /**
  79094. * Color of the line (Default: White)
  79095. */
  79096. color: Color3;
  79097. /**
  79098. * Alpha of the line (Default: 1)
  79099. */
  79100. alpha: number;
  79101. /**
  79102. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  79103. * This margin is expressed in world space coordinates, so its value may vary.
  79104. * Default value is 0.1
  79105. */
  79106. intersectionThreshold: number;
  79107. private _colorShader;
  79108. private color4;
  79109. /**
  79110. * Creates a new LinesMesh
  79111. * @param name defines the name
  79112. * @param scene defines the hosting scene
  79113. * @param parent defines the parent mesh if any
  79114. * @param source defines the optional source LinesMesh used to clone data from
  79115. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  79116. * When false, achieved by calling a clone(), also passing False.
  79117. * This will make creation of children, recursive.
  79118. * @param useVertexColor defines if this LinesMesh supports vertex color
  79119. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  79120. */
  79121. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  79122. /**
  79123. * If vertex color should be applied to the mesh
  79124. */
  79125. useVertexColor?: boolean | undefined,
  79126. /**
  79127. * If vertex alpha should be applied to the mesh
  79128. */
  79129. useVertexAlpha?: boolean | undefined);
  79130. private _addClipPlaneDefine;
  79131. private _removeClipPlaneDefine;
  79132. isReady(): boolean;
  79133. /**
  79134. * Returns the string "LineMesh"
  79135. */
  79136. getClassName(): string;
  79137. /**
  79138. * @hidden
  79139. */
  79140. /**
  79141. * @hidden
  79142. */
  79143. material: Material;
  79144. /**
  79145. * @hidden
  79146. */
  79147. readonly checkCollisions: boolean;
  79148. /** @hidden */
  79149. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  79150. /** @hidden */
  79151. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  79152. /**
  79153. * Disposes of the line mesh
  79154. * @param doNotRecurse If children should be disposed
  79155. */
  79156. dispose(doNotRecurse?: boolean): void;
  79157. /**
  79158. * Returns a new LineMesh object cloned from the current one.
  79159. */
  79160. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  79161. /**
  79162. * Creates a new InstancedLinesMesh object from the mesh model.
  79163. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  79164. * @param name defines the name of the new instance
  79165. * @returns a new InstancedLinesMesh
  79166. */
  79167. createInstance(name: string): InstancedLinesMesh;
  79168. }
  79169. /**
  79170. * Creates an instance based on a source LinesMesh
  79171. */
  79172. export class InstancedLinesMesh extends InstancedMesh {
  79173. /**
  79174. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  79175. * This margin is expressed in world space coordinates, so its value may vary.
  79176. * Initilized with the intersectionThreshold value of the source LinesMesh
  79177. */
  79178. intersectionThreshold: number;
  79179. constructor(name: string, source: LinesMesh);
  79180. /**
  79181. * Returns the string "InstancedLinesMesh".
  79182. */
  79183. getClassName(): string;
  79184. }
  79185. }
  79186. declare module BABYLON {
  79187. /** @hidden */
  79188. export var linePixelShader: {
  79189. name: string;
  79190. shader: string;
  79191. };
  79192. }
  79193. declare module BABYLON {
  79194. /** @hidden */
  79195. export var lineVertexShader: {
  79196. name: string;
  79197. shader: string;
  79198. };
  79199. }
  79200. declare module BABYLON {
  79201. interface AbstractMesh {
  79202. /**
  79203. * Gets the edgesRenderer associated with the mesh
  79204. */
  79205. edgesRenderer: Nullable<EdgesRenderer>;
  79206. }
  79207. interface LinesMesh {
  79208. /**
  79209. * Enables the edge rendering mode on the mesh.
  79210. * This mode makes the mesh edges visible
  79211. * @param epsilon defines the maximal distance between two angles to detect a face
  79212. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  79213. * @returns the currentAbstractMesh
  79214. * @see https://www.babylonjs-playground.com/#19O9TU#0
  79215. */
  79216. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  79217. }
  79218. interface InstancedLinesMesh {
  79219. /**
  79220. * Enables the edge rendering mode on the mesh.
  79221. * This mode makes the mesh edges visible
  79222. * @param epsilon defines the maximal distance between two angles to detect a face
  79223. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  79224. * @returns the current InstancedLinesMesh
  79225. * @see https://www.babylonjs-playground.com/#19O9TU#0
  79226. */
  79227. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  79228. }
  79229. /**
  79230. * Defines the minimum contract an Edges renderer should follow.
  79231. */
  79232. export interface IEdgesRenderer extends IDisposable {
  79233. /**
  79234. * Gets or sets a boolean indicating if the edgesRenderer is active
  79235. */
  79236. isEnabled: boolean;
  79237. /**
  79238. * Renders the edges of the attached mesh,
  79239. */
  79240. render(): void;
  79241. /**
  79242. * Checks wether or not the edges renderer is ready to render.
  79243. * @return true if ready, otherwise false.
  79244. */
  79245. isReady(): boolean;
  79246. }
  79247. /**
  79248. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  79249. */
  79250. export class EdgesRenderer implements IEdgesRenderer {
  79251. /**
  79252. * Define the size of the edges with an orthographic camera
  79253. */
  79254. edgesWidthScalerForOrthographic: number;
  79255. /**
  79256. * Define the size of the edges with a perspective camera
  79257. */
  79258. edgesWidthScalerForPerspective: number;
  79259. protected _source: AbstractMesh;
  79260. protected _linesPositions: number[];
  79261. protected _linesNormals: number[];
  79262. protected _linesIndices: number[];
  79263. protected _epsilon: number;
  79264. protected _indicesCount: number;
  79265. protected _lineShader: ShaderMaterial;
  79266. protected _ib: DataBuffer;
  79267. protected _buffers: {
  79268. [key: string]: Nullable<VertexBuffer>;
  79269. };
  79270. protected _checkVerticesInsteadOfIndices: boolean;
  79271. private _meshRebuildObserver;
  79272. private _meshDisposeObserver;
  79273. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  79274. isEnabled: boolean;
  79275. /**
  79276. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  79277. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  79278. * @param source Mesh used to create edges
  79279. * @param epsilon sum of angles in adjacency to check for edge
  79280. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  79281. * @param generateEdgesLines - should generate Lines or only prepare resources.
  79282. */
  79283. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  79284. protected _prepareRessources(): void;
  79285. /** @hidden */
  79286. _rebuild(): void;
  79287. /**
  79288. * Releases the required resources for the edges renderer
  79289. */
  79290. dispose(): void;
  79291. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  79292. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  79293. /**
  79294. * Checks if the pair of p0 and p1 is en edge
  79295. * @param faceIndex
  79296. * @param edge
  79297. * @param faceNormals
  79298. * @param p0
  79299. * @param p1
  79300. * @private
  79301. */
  79302. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  79303. /**
  79304. * push line into the position, normal and index buffer
  79305. * @protected
  79306. */
  79307. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  79308. /**
  79309. * Generates lines edges from adjacencjes
  79310. * @private
  79311. */
  79312. _generateEdgesLines(): void;
  79313. /**
  79314. * Checks wether or not the edges renderer is ready to render.
  79315. * @return true if ready, otherwise false.
  79316. */
  79317. isReady(): boolean;
  79318. /**
  79319. * Renders the edges of the attached mesh,
  79320. */
  79321. render(): void;
  79322. }
  79323. /**
  79324. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  79325. */
  79326. export class LineEdgesRenderer extends EdgesRenderer {
  79327. /**
  79328. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  79329. * @param source LineMesh used to generate edges
  79330. * @param epsilon not important (specified angle for edge detection)
  79331. * @param checkVerticesInsteadOfIndices not important for LineMesh
  79332. */
  79333. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  79334. /**
  79335. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  79336. */
  79337. _generateEdgesLines(): void;
  79338. }
  79339. }
  79340. declare module BABYLON {
  79341. /**
  79342. * This represents the object necessary to create a rendering group.
  79343. * This is exclusively used and created by the rendering manager.
  79344. * To modify the behavior, you use the available helpers in your scene or meshes.
  79345. * @hidden
  79346. */
  79347. export class RenderingGroup {
  79348. index: number;
  79349. private static _zeroVector;
  79350. private _scene;
  79351. private _opaqueSubMeshes;
  79352. private _transparentSubMeshes;
  79353. private _alphaTestSubMeshes;
  79354. private _depthOnlySubMeshes;
  79355. private _particleSystems;
  79356. private _spriteManagers;
  79357. private _opaqueSortCompareFn;
  79358. private _alphaTestSortCompareFn;
  79359. private _transparentSortCompareFn;
  79360. private _renderOpaque;
  79361. private _renderAlphaTest;
  79362. private _renderTransparent;
  79363. /** @hidden */
  79364. _edgesRenderers: SmartArray<IEdgesRenderer>;
  79365. onBeforeTransparentRendering: () => void;
  79366. /**
  79367. * Set the opaque sort comparison function.
  79368. * If null the sub meshes will be render in the order they were created
  79369. */
  79370. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  79371. /**
  79372. * Set the alpha test sort comparison function.
  79373. * If null the sub meshes will be render in the order they were created
  79374. */
  79375. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  79376. /**
  79377. * Set the transparent sort comparison function.
  79378. * If null the sub meshes will be render in the order they were created
  79379. */
  79380. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  79381. /**
  79382. * Creates a new rendering group.
  79383. * @param index The rendering group index
  79384. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  79385. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  79386. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  79387. */
  79388. 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>);
  79389. /**
  79390. * Render all the sub meshes contained in the group.
  79391. * @param customRenderFunction Used to override the default render behaviour of the group.
  79392. * @returns true if rendered some submeshes.
  79393. */
  79394. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  79395. /**
  79396. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  79397. * @param subMeshes The submeshes to render
  79398. */
  79399. private renderOpaqueSorted;
  79400. /**
  79401. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  79402. * @param subMeshes The submeshes to render
  79403. */
  79404. private renderAlphaTestSorted;
  79405. /**
  79406. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  79407. * @param subMeshes The submeshes to render
  79408. */
  79409. private renderTransparentSorted;
  79410. /**
  79411. * Renders the submeshes in a specified order.
  79412. * @param subMeshes The submeshes to sort before render
  79413. * @param sortCompareFn The comparison function use to sort
  79414. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  79415. * @param transparent Specifies to activate blending if true
  79416. */
  79417. private static renderSorted;
  79418. /**
  79419. * Renders the submeshes in the order they were dispatched (no sort applied).
  79420. * @param subMeshes The submeshes to render
  79421. */
  79422. private static renderUnsorted;
  79423. /**
  79424. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  79425. * are rendered back to front if in the same alpha index.
  79426. *
  79427. * @param a The first submesh
  79428. * @param b The second submesh
  79429. * @returns The result of the comparison
  79430. */
  79431. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  79432. /**
  79433. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  79434. * are rendered back to front.
  79435. *
  79436. * @param a The first submesh
  79437. * @param b The second submesh
  79438. * @returns The result of the comparison
  79439. */
  79440. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  79441. /**
  79442. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  79443. * are rendered front to back (prevent overdraw).
  79444. *
  79445. * @param a The first submesh
  79446. * @param b The second submesh
  79447. * @returns The result of the comparison
  79448. */
  79449. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  79450. /**
  79451. * Resets the different lists of submeshes to prepare a new frame.
  79452. */
  79453. prepare(): void;
  79454. dispose(): void;
  79455. /**
  79456. * Inserts the submesh in its correct queue depending on its material.
  79457. * @param subMesh The submesh to dispatch
  79458. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  79459. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  79460. */
  79461. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  79462. dispatchSprites(spriteManager: ISpriteManager): void;
  79463. dispatchParticles(particleSystem: IParticleSystem): void;
  79464. private _renderParticles;
  79465. private _renderSprites;
  79466. }
  79467. }
  79468. declare module BABYLON {
  79469. /**
  79470. * Interface describing the different options available in the rendering manager
  79471. * regarding Auto Clear between groups.
  79472. */
  79473. export interface IRenderingManagerAutoClearSetup {
  79474. /**
  79475. * Defines whether or not autoclear is enable.
  79476. */
  79477. autoClear: boolean;
  79478. /**
  79479. * Defines whether or not to autoclear the depth buffer.
  79480. */
  79481. depth: boolean;
  79482. /**
  79483. * Defines whether or not to autoclear the stencil buffer.
  79484. */
  79485. stencil: boolean;
  79486. }
  79487. /**
  79488. * This class is used by the onRenderingGroupObservable
  79489. */
  79490. export class RenderingGroupInfo {
  79491. /**
  79492. * The Scene that being rendered
  79493. */
  79494. scene: Scene;
  79495. /**
  79496. * The camera currently used for the rendering pass
  79497. */
  79498. camera: Nullable<Camera>;
  79499. /**
  79500. * The ID of the renderingGroup being processed
  79501. */
  79502. renderingGroupId: number;
  79503. }
  79504. /**
  79505. * This is the manager responsible of all the rendering for meshes sprites and particles.
  79506. * It is enable to manage the different groups as well as the different necessary sort functions.
  79507. * This should not be used directly aside of the few static configurations
  79508. */
  79509. export class RenderingManager {
  79510. /**
  79511. * The max id used for rendering groups (not included)
  79512. */
  79513. static MAX_RENDERINGGROUPS: number;
  79514. /**
  79515. * The min id used for rendering groups (included)
  79516. */
  79517. static MIN_RENDERINGGROUPS: number;
  79518. /**
  79519. * Used to globally prevent autoclearing scenes.
  79520. */
  79521. static AUTOCLEAR: boolean;
  79522. /**
  79523. * @hidden
  79524. */
  79525. _useSceneAutoClearSetup: boolean;
  79526. private _scene;
  79527. private _renderingGroups;
  79528. private _depthStencilBufferAlreadyCleaned;
  79529. private _autoClearDepthStencil;
  79530. private _customOpaqueSortCompareFn;
  79531. private _customAlphaTestSortCompareFn;
  79532. private _customTransparentSortCompareFn;
  79533. private _renderingGroupInfo;
  79534. /**
  79535. * Instantiates a new rendering group for a particular scene
  79536. * @param scene Defines the scene the groups belongs to
  79537. */
  79538. constructor(scene: Scene);
  79539. private _clearDepthStencilBuffer;
  79540. /**
  79541. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  79542. * @hidden
  79543. */
  79544. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  79545. /**
  79546. * Resets the different information of the group to prepare a new frame
  79547. * @hidden
  79548. */
  79549. reset(): void;
  79550. /**
  79551. * Dispose and release the group and its associated resources.
  79552. * @hidden
  79553. */
  79554. dispose(): void;
  79555. /**
  79556. * Clear the info related to rendering groups preventing retention points during dispose.
  79557. */
  79558. freeRenderingGroups(): void;
  79559. private _prepareRenderingGroup;
  79560. /**
  79561. * Add a sprite manager to the rendering manager in order to render it this frame.
  79562. * @param spriteManager Define the sprite manager to render
  79563. */
  79564. dispatchSprites(spriteManager: ISpriteManager): void;
  79565. /**
  79566. * Add a particle system to the rendering manager in order to render it this frame.
  79567. * @param particleSystem Define the particle system to render
  79568. */
  79569. dispatchParticles(particleSystem: IParticleSystem): void;
  79570. /**
  79571. * Add a submesh to the manager in order to render it this frame
  79572. * @param subMesh The submesh to dispatch
  79573. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  79574. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  79575. */
  79576. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  79577. /**
  79578. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  79579. * This allowed control for front to back rendering or reversly depending of the special needs.
  79580. *
  79581. * @param renderingGroupId The rendering group id corresponding to its index
  79582. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  79583. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  79584. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  79585. */
  79586. 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;
  79587. /**
  79588. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  79589. *
  79590. * @param renderingGroupId The rendering group id corresponding to its index
  79591. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  79592. * @param depth Automatically clears depth between groups if true and autoClear is true.
  79593. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  79594. */
  79595. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  79596. /**
  79597. * Gets the current auto clear configuration for one rendering group of the rendering
  79598. * manager.
  79599. * @param index the rendering group index to get the information for
  79600. * @returns The auto clear setup for the requested rendering group
  79601. */
  79602. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  79603. }
  79604. }
  79605. declare module BABYLON {
  79606. /**
  79607. * This Helps creating a texture that will be created from a camera in your scene.
  79608. * It is basically a dynamic texture that could be used to create special effects for instance.
  79609. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  79610. */
  79611. export class RenderTargetTexture extends Texture {
  79612. isCube: boolean;
  79613. /**
  79614. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  79615. */
  79616. static readonly REFRESHRATE_RENDER_ONCE: number;
  79617. /**
  79618. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  79619. */
  79620. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  79621. /**
  79622. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  79623. * the central point of your effect and can save a lot of performances.
  79624. */
  79625. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  79626. /**
  79627. * Use this predicate to dynamically define the list of mesh you want to render.
  79628. * If set, the renderList property will be overwritten.
  79629. */
  79630. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  79631. private _renderList;
  79632. /**
  79633. * Use this list to define the list of mesh you want to render.
  79634. */
  79635. renderList: Nullable<Array<AbstractMesh>>;
  79636. private _hookArray;
  79637. /**
  79638. * Define if particles should be rendered in your texture.
  79639. */
  79640. renderParticles: boolean;
  79641. /**
  79642. * Define if sprites should be rendered in your texture.
  79643. */
  79644. renderSprites: boolean;
  79645. /**
  79646. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  79647. */
  79648. coordinatesMode: number;
  79649. /**
  79650. * Define the camera used to render the texture.
  79651. */
  79652. activeCamera: Nullable<Camera>;
  79653. /**
  79654. * Override the render function of the texture with your own one.
  79655. */
  79656. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  79657. /**
  79658. * Define if camera post processes should be use while rendering the texture.
  79659. */
  79660. useCameraPostProcesses: boolean;
  79661. /**
  79662. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  79663. */
  79664. ignoreCameraViewport: boolean;
  79665. private _postProcessManager;
  79666. private _postProcesses;
  79667. private _resizeObserver;
  79668. /**
  79669. * An event triggered when the texture is unbind.
  79670. */
  79671. onBeforeBindObservable: Observable<RenderTargetTexture>;
  79672. /**
  79673. * An event triggered when the texture is unbind.
  79674. */
  79675. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  79676. private _onAfterUnbindObserver;
  79677. /**
  79678. * Set a after unbind callback in the texture.
  79679. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  79680. */
  79681. onAfterUnbind: () => void;
  79682. /**
  79683. * An event triggered before rendering the texture
  79684. */
  79685. onBeforeRenderObservable: Observable<number>;
  79686. private _onBeforeRenderObserver;
  79687. /**
  79688. * Set a before render callback in the texture.
  79689. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  79690. */
  79691. onBeforeRender: (faceIndex: number) => void;
  79692. /**
  79693. * An event triggered after rendering the texture
  79694. */
  79695. onAfterRenderObservable: Observable<number>;
  79696. private _onAfterRenderObserver;
  79697. /**
  79698. * Set a after render callback in the texture.
  79699. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  79700. */
  79701. onAfterRender: (faceIndex: number) => void;
  79702. /**
  79703. * An event triggered after the texture clear
  79704. */
  79705. onClearObservable: Observable<Engine>;
  79706. private _onClearObserver;
  79707. /**
  79708. * Set a clear callback in the texture.
  79709. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  79710. */
  79711. onClear: (Engine: Engine) => void;
  79712. /**
  79713. * Define the clear color of the Render Target if it should be different from the scene.
  79714. */
  79715. clearColor: Color4;
  79716. protected _size: number | {
  79717. width: number;
  79718. height: number;
  79719. };
  79720. protected _initialSizeParameter: number | {
  79721. width: number;
  79722. height: number;
  79723. } | {
  79724. ratio: number;
  79725. };
  79726. protected _sizeRatio: Nullable<number>;
  79727. /** @hidden */
  79728. _generateMipMaps: boolean;
  79729. protected _renderingManager: RenderingManager;
  79730. /** @hidden */
  79731. _waitingRenderList: string[];
  79732. protected _doNotChangeAspectRatio: boolean;
  79733. protected _currentRefreshId: number;
  79734. protected _refreshRate: number;
  79735. protected _textureMatrix: Matrix;
  79736. protected _samples: number;
  79737. protected _renderTargetOptions: RenderTargetCreationOptions;
  79738. /**
  79739. * Gets render target creation options that were used.
  79740. */
  79741. readonly renderTargetOptions: RenderTargetCreationOptions;
  79742. protected _engine: Engine;
  79743. protected _onRatioRescale(): void;
  79744. /**
  79745. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  79746. * It must define where the camera used to render the texture is set
  79747. */
  79748. boundingBoxPosition: Vector3;
  79749. private _boundingBoxSize;
  79750. /**
  79751. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  79752. * When defined, the cubemap will switch to local mode
  79753. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  79754. * @example https://www.babylonjs-playground.com/#RNASML
  79755. */
  79756. boundingBoxSize: Vector3;
  79757. /**
  79758. * In case the RTT has been created with a depth texture, get the associated
  79759. * depth texture.
  79760. * Otherwise, return null.
  79761. */
  79762. depthStencilTexture: Nullable<InternalTexture>;
  79763. /**
  79764. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  79765. * or used a shadow, depth texture...
  79766. * @param name The friendly name of the texture
  79767. * @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)
  79768. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  79769. * @param generateMipMaps True if mip maps need to be generated after render.
  79770. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  79771. * @param type The type of the buffer in the RTT (int, half float, float...)
  79772. * @param isCube True if a cube texture needs to be created
  79773. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  79774. * @param generateDepthBuffer True to generate a depth buffer
  79775. * @param generateStencilBuffer True to generate a stencil buffer
  79776. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  79777. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  79778. * @param delayAllocation if the texture allocation should be delayed (default: false)
  79779. */
  79780. constructor(name: string, size: number | {
  79781. width: number;
  79782. height: number;
  79783. } | {
  79784. ratio: number;
  79785. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  79786. /**
  79787. * Creates a depth stencil texture.
  79788. * This is only available in WebGL 2 or with the depth texture extension available.
  79789. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  79790. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  79791. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  79792. */
  79793. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  79794. private _processSizeParameter;
  79795. /**
  79796. * Define the number of samples to use in case of MSAA.
  79797. * It defaults to one meaning no MSAA has been enabled.
  79798. */
  79799. samples: number;
  79800. /**
  79801. * Resets the refresh counter of the texture and start bak from scratch.
  79802. * Could be useful to regenerate the texture if it is setup to render only once.
  79803. */
  79804. resetRefreshCounter(): void;
  79805. /**
  79806. * Define the refresh rate of the texture or the rendering frequency.
  79807. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  79808. */
  79809. refreshRate: number;
  79810. /**
  79811. * Adds a post process to the render target rendering passes.
  79812. * @param postProcess define the post process to add
  79813. */
  79814. addPostProcess(postProcess: PostProcess): void;
  79815. /**
  79816. * Clear all the post processes attached to the render target
  79817. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  79818. */
  79819. clearPostProcesses(dispose?: boolean): void;
  79820. /**
  79821. * Remove one of the post process from the list of attached post processes to the texture
  79822. * @param postProcess define the post process to remove from the list
  79823. */
  79824. removePostProcess(postProcess: PostProcess): void;
  79825. /** @hidden */
  79826. _shouldRender(): boolean;
  79827. /**
  79828. * Gets the actual render size of the texture.
  79829. * @returns the width of the render size
  79830. */
  79831. getRenderSize(): number;
  79832. /**
  79833. * Gets the actual render width of the texture.
  79834. * @returns the width of the render size
  79835. */
  79836. getRenderWidth(): number;
  79837. /**
  79838. * Gets the actual render height of the texture.
  79839. * @returns the height of the render size
  79840. */
  79841. getRenderHeight(): number;
  79842. /**
  79843. * Get if the texture can be rescaled or not.
  79844. */
  79845. readonly canRescale: boolean;
  79846. /**
  79847. * Resize the texture using a ratio.
  79848. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  79849. */
  79850. scale(ratio: number): void;
  79851. /**
  79852. * Get the texture reflection matrix used to rotate/transform the reflection.
  79853. * @returns the reflection matrix
  79854. */
  79855. getReflectionTextureMatrix(): Matrix;
  79856. /**
  79857. * Resize the texture to a new desired size.
  79858. * Be carrefull as it will recreate all the data in the new texture.
  79859. * @param size Define the new size. It can be:
  79860. * - a number for squared texture,
  79861. * - an object containing { width: number, height: number }
  79862. * - or an object containing a ratio { ratio: number }
  79863. */
  79864. resize(size: number | {
  79865. width: number;
  79866. height: number;
  79867. } | {
  79868. ratio: number;
  79869. }): void;
  79870. /**
  79871. * Renders all the objects from the render list into the texture.
  79872. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  79873. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  79874. */
  79875. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  79876. private _bestReflectionRenderTargetDimension;
  79877. /**
  79878. * @hidden
  79879. * @param faceIndex face index to bind to if this is a cubetexture
  79880. */
  79881. _bindFrameBuffer(faceIndex?: number): void;
  79882. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  79883. private renderToTarget;
  79884. /**
  79885. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  79886. * This allowed control for front to back rendering or reversly depending of the special needs.
  79887. *
  79888. * @param renderingGroupId The rendering group id corresponding to its index
  79889. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  79890. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  79891. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  79892. */
  79893. 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;
  79894. /**
  79895. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  79896. *
  79897. * @param renderingGroupId The rendering group id corresponding to its index
  79898. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  79899. */
  79900. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  79901. /**
  79902. * Clones the texture.
  79903. * @returns the cloned texture
  79904. */
  79905. clone(): RenderTargetTexture;
  79906. /**
  79907. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  79908. * @returns The JSON representation of the texture
  79909. */
  79910. serialize(): any;
  79911. /**
  79912. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  79913. */
  79914. disposeFramebufferObjects(): void;
  79915. /**
  79916. * Dispose the texture and release its associated resources.
  79917. */
  79918. dispose(): void;
  79919. /** @hidden */
  79920. _rebuild(): void;
  79921. /**
  79922. * Clear the info related to rendering groups preventing retention point in material dispose.
  79923. */
  79924. freeRenderingGroups(): void;
  79925. /**
  79926. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  79927. * @returns the view count
  79928. */
  79929. getViewCount(): number;
  79930. }
  79931. }
  79932. declare module BABYLON {
  79933. /**
  79934. * Mirror texture can be used to simulate the view from a mirror in a scene.
  79935. * It will dynamically be rendered every frame to adapt to the camera point of view.
  79936. * You can then easily use it as a reflectionTexture on a flat surface.
  79937. * In case the surface is not a plane, please consider relying on reflection probes.
  79938. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  79939. */
  79940. export class MirrorTexture extends RenderTargetTexture {
  79941. private scene;
  79942. /**
  79943. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  79944. * 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.
  79945. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  79946. */
  79947. mirrorPlane: Plane;
  79948. /**
  79949. * Define the blur ratio used to blur the reflection if needed.
  79950. */
  79951. blurRatio: number;
  79952. /**
  79953. * Define the adaptive blur kernel used to blur the reflection if needed.
  79954. * This will autocompute the closest best match for the `blurKernel`
  79955. */
  79956. adaptiveBlurKernel: number;
  79957. /**
  79958. * Define the blur kernel used to blur the reflection if needed.
  79959. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  79960. */
  79961. blurKernel: number;
  79962. /**
  79963. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  79964. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  79965. */
  79966. blurKernelX: number;
  79967. /**
  79968. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  79969. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  79970. */
  79971. blurKernelY: number;
  79972. private _autoComputeBlurKernel;
  79973. protected _onRatioRescale(): void;
  79974. private _updateGammaSpace;
  79975. private _imageProcessingConfigChangeObserver;
  79976. private _transformMatrix;
  79977. private _mirrorMatrix;
  79978. private _savedViewMatrix;
  79979. private _blurX;
  79980. private _blurY;
  79981. private _adaptiveBlurKernel;
  79982. private _blurKernelX;
  79983. private _blurKernelY;
  79984. private _blurRatio;
  79985. /**
  79986. * Instantiates a Mirror Texture.
  79987. * Mirror texture can be used to simulate the view from a mirror in a scene.
  79988. * It will dynamically be rendered every frame to adapt to the camera point of view.
  79989. * You can then easily use it as a reflectionTexture on a flat surface.
  79990. * In case the surface is not a plane, please consider relying on reflection probes.
  79991. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  79992. * @param name
  79993. * @param size
  79994. * @param scene
  79995. * @param generateMipMaps
  79996. * @param type
  79997. * @param samplingMode
  79998. * @param generateDepthBuffer
  79999. */
  80000. constructor(name: string, size: number | {
  80001. width: number;
  80002. height: number;
  80003. } | {
  80004. ratio: number;
  80005. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  80006. private _preparePostProcesses;
  80007. /**
  80008. * Clone the mirror texture.
  80009. * @returns the cloned texture
  80010. */
  80011. clone(): MirrorTexture;
  80012. /**
  80013. * Serialize the texture to a JSON representation you could use in Parse later on
  80014. * @returns the serialized JSON representation
  80015. */
  80016. serialize(): any;
  80017. /**
  80018. * Dispose the texture and release its associated resources.
  80019. */
  80020. dispose(): void;
  80021. }
  80022. }
  80023. declare module BABYLON {
  80024. /**
  80025. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  80026. * @see http://doc.babylonjs.com/babylon101/materials#texture
  80027. */
  80028. export class Texture extends BaseTexture {
  80029. /** @hidden */
  80030. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  80031. /** @hidden */
  80032. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  80033. /** @hidden */
  80034. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  80035. /** nearest is mag = nearest and min = nearest and mip = linear */
  80036. static readonly NEAREST_SAMPLINGMODE: number;
  80037. /** nearest is mag = nearest and min = nearest and mip = linear */
  80038. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  80039. /** Bilinear is mag = linear and min = linear and mip = nearest */
  80040. static readonly BILINEAR_SAMPLINGMODE: number;
  80041. /** Bilinear is mag = linear and min = linear and mip = nearest */
  80042. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  80043. /** Trilinear is mag = linear and min = linear and mip = linear */
  80044. static readonly TRILINEAR_SAMPLINGMODE: number;
  80045. /** Trilinear is mag = linear and min = linear and mip = linear */
  80046. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  80047. /** mag = nearest and min = nearest and mip = nearest */
  80048. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  80049. /** mag = nearest and min = linear and mip = nearest */
  80050. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  80051. /** mag = nearest and min = linear and mip = linear */
  80052. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  80053. /** mag = nearest and min = linear and mip = none */
  80054. static readonly NEAREST_LINEAR: number;
  80055. /** mag = nearest and min = nearest and mip = none */
  80056. static readonly NEAREST_NEAREST: number;
  80057. /** mag = linear and min = nearest and mip = nearest */
  80058. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  80059. /** mag = linear and min = nearest and mip = linear */
  80060. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  80061. /** mag = linear and min = linear and mip = none */
  80062. static readonly LINEAR_LINEAR: number;
  80063. /** mag = linear and min = nearest and mip = none */
  80064. static readonly LINEAR_NEAREST: number;
  80065. /** Explicit coordinates mode */
  80066. static readonly EXPLICIT_MODE: number;
  80067. /** Spherical coordinates mode */
  80068. static readonly SPHERICAL_MODE: number;
  80069. /** Planar coordinates mode */
  80070. static readonly PLANAR_MODE: number;
  80071. /** Cubic coordinates mode */
  80072. static readonly CUBIC_MODE: number;
  80073. /** Projection coordinates mode */
  80074. static readonly PROJECTION_MODE: number;
  80075. /** Inverse Cubic coordinates mode */
  80076. static readonly SKYBOX_MODE: number;
  80077. /** Inverse Cubic coordinates mode */
  80078. static readonly INVCUBIC_MODE: number;
  80079. /** Equirectangular coordinates mode */
  80080. static readonly EQUIRECTANGULAR_MODE: number;
  80081. /** Equirectangular Fixed coordinates mode */
  80082. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  80083. /** Equirectangular Fixed Mirrored coordinates mode */
  80084. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  80085. /** Texture is not repeating outside of 0..1 UVs */
  80086. static readonly CLAMP_ADDRESSMODE: number;
  80087. /** Texture is repeating outside of 0..1 UVs */
  80088. static readonly WRAP_ADDRESSMODE: number;
  80089. /** Texture is repeating and mirrored */
  80090. static readonly MIRROR_ADDRESSMODE: number;
  80091. /**
  80092. * 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
  80093. */
  80094. static UseSerializedUrlIfAny: boolean;
  80095. /**
  80096. * Define the url of the texture.
  80097. */
  80098. url: Nullable<string>;
  80099. /**
  80100. * Define an offset on the texture to offset the u coordinates of the UVs
  80101. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  80102. */
  80103. uOffset: number;
  80104. /**
  80105. * Define an offset on the texture to offset the v coordinates of the UVs
  80106. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  80107. */
  80108. vOffset: number;
  80109. /**
  80110. * Define an offset on the texture to scale the u coordinates of the UVs
  80111. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  80112. */
  80113. uScale: number;
  80114. /**
  80115. * Define an offset on the texture to scale the v coordinates of the UVs
  80116. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  80117. */
  80118. vScale: number;
  80119. /**
  80120. * Define an offset on the texture to rotate around the u coordinates of the UVs
  80121. * @see http://doc.babylonjs.com/how_to/more_materials
  80122. */
  80123. uAng: number;
  80124. /**
  80125. * Define an offset on the texture to rotate around the v coordinates of the UVs
  80126. * @see http://doc.babylonjs.com/how_to/more_materials
  80127. */
  80128. vAng: number;
  80129. /**
  80130. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  80131. * @see http://doc.babylonjs.com/how_to/more_materials
  80132. */
  80133. wAng: number;
  80134. /**
  80135. * Defines the center of rotation (U)
  80136. */
  80137. uRotationCenter: number;
  80138. /**
  80139. * Defines the center of rotation (V)
  80140. */
  80141. vRotationCenter: number;
  80142. /**
  80143. * Defines the center of rotation (W)
  80144. */
  80145. wRotationCenter: number;
  80146. /**
  80147. * Are mip maps generated for this texture or not.
  80148. */
  80149. readonly noMipmap: boolean;
  80150. /**
  80151. * List of inspectable custom properties (used by the Inspector)
  80152. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  80153. */
  80154. inspectableCustomProperties: Nullable<IInspectable[]>;
  80155. private _noMipmap;
  80156. /** @hidden */
  80157. _invertY: boolean;
  80158. private _rowGenerationMatrix;
  80159. private _cachedTextureMatrix;
  80160. private _projectionModeMatrix;
  80161. private _t0;
  80162. private _t1;
  80163. private _t2;
  80164. private _cachedUOffset;
  80165. private _cachedVOffset;
  80166. private _cachedUScale;
  80167. private _cachedVScale;
  80168. private _cachedUAng;
  80169. private _cachedVAng;
  80170. private _cachedWAng;
  80171. private _cachedProjectionMatrixId;
  80172. private _cachedCoordinatesMode;
  80173. /** @hidden */
  80174. protected _initialSamplingMode: number;
  80175. /** @hidden */
  80176. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  80177. private _deleteBuffer;
  80178. protected _format: Nullable<number>;
  80179. private _delayedOnLoad;
  80180. private _delayedOnError;
  80181. /**
  80182. * Observable triggered once the texture has been loaded.
  80183. */
  80184. onLoadObservable: Observable<Texture>;
  80185. protected _isBlocking: boolean;
  80186. /**
  80187. * Is the texture preventing material to render while loading.
  80188. * If false, a default texture will be used instead of the loading one during the preparation step.
  80189. */
  80190. isBlocking: boolean;
  80191. /**
  80192. * Get the current sampling mode associated with the texture.
  80193. */
  80194. readonly samplingMode: number;
  80195. /**
  80196. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  80197. */
  80198. readonly invertY: boolean;
  80199. /**
  80200. * Instantiates a new texture.
  80201. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  80202. * @see http://doc.babylonjs.com/babylon101/materials#texture
  80203. * @param url define the url of the picture to load as a texture
  80204. * @param scene define the scene the texture will belong to
  80205. * @param noMipmap define if the texture will require mip maps or not
  80206. * @param invertY define if the texture needs to be inverted on the y axis during loading
  80207. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  80208. * @param onLoad define a callback triggered when the texture has been loaded
  80209. * @param onError define a callback triggered when an error occurred during the loading session
  80210. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  80211. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  80212. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  80213. */
  80214. constructor(url: Nullable<string>, scene: Nullable<Scene>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, deleteBuffer?: boolean, format?: number);
  80215. /**
  80216. * Update the url (and optional buffer) of this texture if url was null during construction.
  80217. * @param url the url of the texture
  80218. * @param buffer the buffer of the texture (defaults to null)
  80219. * @param onLoad callback called when the texture is loaded (defaults to null)
  80220. */
  80221. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  80222. /**
  80223. * Finish the loading sequence of a texture flagged as delayed load.
  80224. * @hidden
  80225. */
  80226. delayLoad(): void;
  80227. private _prepareRowForTextureGeneration;
  80228. /**
  80229. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  80230. * @returns the transform matrix of the texture.
  80231. */
  80232. getTextureMatrix(): Matrix;
  80233. /**
  80234. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  80235. * @returns The reflection texture transform
  80236. */
  80237. getReflectionTextureMatrix(): Matrix;
  80238. /**
  80239. * Clones the texture.
  80240. * @returns the cloned texture
  80241. */
  80242. clone(): Texture;
  80243. /**
  80244. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  80245. * @returns The JSON representation of the texture
  80246. */
  80247. serialize(): any;
  80248. /**
  80249. * Get the current class name of the texture useful for serialization or dynamic coding.
  80250. * @returns "Texture"
  80251. */
  80252. getClassName(): string;
  80253. /**
  80254. * Dispose the texture and release its associated resources.
  80255. */
  80256. dispose(): void;
  80257. /**
  80258. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  80259. * @param parsedTexture Define the JSON representation of the texture
  80260. * @param scene Define the scene the parsed texture should be instantiated in
  80261. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  80262. * @returns The parsed texture if successful
  80263. */
  80264. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  80265. /**
  80266. * Creates a texture from its base 64 representation.
  80267. * @param data Define the base64 payload without the data: prefix
  80268. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  80269. * @param scene Define the scene the texture should belong to
  80270. * @param noMipmap Forces the texture to not create mip map information if true
  80271. * @param invertY define if the texture needs to be inverted on the y axis during loading
  80272. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  80273. * @param onLoad define a callback triggered when the texture has been loaded
  80274. * @param onError define a callback triggered when an error occurred during the loading session
  80275. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  80276. * @returns the created texture
  80277. */
  80278. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  80279. /**
  80280. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  80281. * @param data Define the base64 payload without the data: prefix
  80282. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  80283. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  80284. * @param scene Define the scene the texture should belong to
  80285. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  80286. * @param noMipmap Forces the texture to not create mip map information if true
  80287. * @param invertY define if the texture needs to be inverted on the y axis during loading
  80288. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  80289. * @param onLoad define a callback triggered when the texture has been loaded
  80290. * @param onError define a callback triggered when an error occurred during the loading session
  80291. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  80292. * @returns the created texture
  80293. */
  80294. 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;
  80295. }
  80296. }
  80297. declare module BABYLON {
  80298. interface Engine {
  80299. /**
  80300. * Creates a raw texture
  80301. * @param data defines the data to store in the texture
  80302. * @param width defines the width of the texture
  80303. * @param height defines the height of the texture
  80304. * @param format defines the format of the data
  80305. * @param generateMipMaps defines if the engine should generate the mip levels
  80306. * @param invertY defines if data must be stored with Y axis inverted
  80307. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  80308. * @param compression defines the compression used (null by default)
  80309. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  80310. * @returns the raw texture inside an InternalTexture
  80311. */
  80312. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  80313. /**
  80314. * Update a raw texture
  80315. * @param texture defines the texture to update
  80316. * @param data defines the data to store in the texture
  80317. * @param format defines the format of the data
  80318. * @param invertY defines if data must be stored with Y axis inverted
  80319. */
  80320. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  80321. /**
  80322. * Update a raw texture
  80323. * @param texture defines the texture to update
  80324. * @param data defines the data to store in the texture
  80325. * @param format defines the format of the data
  80326. * @param invertY defines if data must be stored with Y axis inverted
  80327. * @param compression defines the compression used (null by default)
  80328. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  80329. */
  80330. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  80331. /**
  80332. * Creates a new raw cube texture
  80333. * @param data defines the array of data to use to create each face
  80334. * @param size defines the size of the textures
  80335. * @param format defines the format of the data
  80336. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  80337. * @param generateMipMaps defines if the engine should generate the mip levels
  80338. * @param invertY defines if data must be stored with Y axis inverted
  80339. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  80340. * @param compression defines the compression used (null by default)
  80341. * @returns the cube texture as an InternalTexture
  80342. */
  80343. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  80344. /**
  80345. * Update a raw cube texture
  80346. * @param texture defines the texture to udpdate
  80347. * @param data defines the data to store
  80348. * @param format defines the data format
  80349. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  80350. * @param invertY defines if data must be stored with Y axis inverted
  80351. */
  80352. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  80353. /**
  80354. * Update a raw cube texture
  80355. * @param texture defines the texture to udpdate
  80356. * @param data defines the data to store
  80357. * @param format defines the data format
  80358. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  80359. * @param invertY defines if data must be stored with Y axis inverted
  80360. * @param compression defines the compression used (null by default)
  80361. */
  80362. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  80363. /**
  80364. * Update a raw cube texture
  80365. * @param texture defines the texture to udpdate
  80366. * @param data defines the data to store
  80367. * @param format defines the data format
  80368. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  80369. * @param invertY defines if data must be stored with Y axis inverted
  80370. * @param compression defines the compression used (null by default)
  80371. * @param level defines which level of the texture to update
  80372. */
  80373. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  80374. /**
  80375. * Creates a new raw cube texture from a specified url
  80376. * @param url defines the url where the data is located
  80377. * @param scene defines the current scene
  80378. * @param size defines the size of the textures
  80379. * @param format defines the format of the data
  80380. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  80381. * @param noMipmap defines if the engine should avoid generating the mip levels
  80382. * @param callback defines a callback used to extract texture data from loaded data
  80383. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  80384. * @param onLoad defines a callback called when texture is loaded
  80385. * @param onError defines a callback called if there is an error
  80386. * @returns the cube texture as an InternalTexture
  80387. */
  80388. 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;
  80389. /**
  80390. * Creates a new raw cube texture from a specified url
  80391. * @param url defines the url where the data is located
  80392. * @param scene defines the current scene
  80393. * @param size defines the size of the textures
  80394. * @param format defines the format of the data
  80395. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  80396. * @param noMipmap defines if the engine should avoid generating the mip levels
  80397. * @param callback defines a callback used to extract texture data from loaded data
  80398. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  80399. * @param onLoad defines a callback called when texture is loaded
  80400. * @param onError defines a callback called if there is an error
  80401. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  80402. * @param invertY defines if data must be stored with Y axis inverted
  80403. * @returns the cube texture as an InternalTexture
  80404. */
  80405. 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;
  80406. /**
  80407. * Creates a new raw 3D texture
  80408. * @param data defines the data used to create the texture
  80409. * @param width defines the width of the texture
  80410. * @param height defines the height of the texture
  80411. * @param depth defines the depth of the texture
  80412. * @param format defines the format of the texture
  80413. * @param generateMipMaps defines if the engine must generate mip levels
  80414. * @param invertY defines if data must be stored with Y axis inverted
  80415. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  80416. * @param compression defines the compressed used (can be null)
  80417. * @param textureType defines the compressed used (can be null)
  80418. * @returns a new raw 3D texture (stored in an InternalTexture)
  80419. */
  80420. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  80421. /**
  80422. * Update a raw 3D texture
  80423. * @param texture defines the texture to update
  80424. * @param data defines the data to store
  80425. * @param format defines the data format
  80426. * @param invertY defines if data must be stored with Y axis inverted
  80427. */
  80428. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  80429. /**
  80430. * Update a raw 3D texture
  80431. * @param texture defines the texture to update
  80432. * @param data defines the data to store
  80433. * @param format defines the data format
  80434. * @param invertY defines if data must be stored with Y axis inverted
  80435. * @param compression defines the used compression (can be null)
  80436. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  80437. */
  80438. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  80439. }
  80440. }
  80441. declare module BABYLON {
  80442. /**
  80443. * Raw texture can help creating a texture directly from an array of data.
  80444. * This can be super useful if you either get the data from an uncompressed source or
  80445. * if you wish to create your texture pixel by pixel.
  80446. */
  80447. export class RawTexture extends Texture {
  80448. /**
  80449. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  80450. */
  80451. format: number;
  80452. private _engine;
  80453. /**
  80454. * Instantiates a new RawTexture.
  80455. * Raw texture can help creating a texture directly from an array of data.
  80456. * This can be super useful if you either get the data from an uncompressed source or
  80457. * if you wish to create your texture pixel by pixel.
  80458. * @param data define the array of data to use to create the texture
  80459. * @param width define the width of the texture
  80460. * @param height define the height of the texture
  80461. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  80462. * @param scene define the scene the texture belongs to
  80463. * @param generateMipMaps define whether mip maps should be generated or not
  80464. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  80465. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  80466. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  80467. */
  80468. constructor(data: ArrayBufferView, width: number, height: number,
  80469. /**
  80470. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  80471. */
  80472. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  80473. /**
  80474. * Updates the texture underlying data.
  80475. * @param data Define the new data of the texture
  80476. */
  80477. update(data: ArrayBufferView): void;
  80478. /**
  80479. * Creates a luminance texture from some data.
  80480. * @param data Define the texture data
  80481. * @param width Define the width of the texture
  80482. * @param height Define the height of the texture
  80483. * @param scene Define the scene the texture belongs to
  80484. * @param generateMipMaps Define whether or not to create mip maps for the texture
  80485. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  80486. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  80487. * @returns the luminance texture
  80488. */
  80489. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  80490. /**
  80491. * Creates a luminance alpha texture from some data.
  80492. * @param data Define the texture data
  80493. * @param width Define the width of the texture
  80494. * @param height Define the height of the texture
  80495. * @param scene Define the scene the texture belongs to
  80496. * @param generateMipMaps Define whether or not to create mip maps for the texture
  80497. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  80498. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  80499. * @returns the luminance alpha texture
  80500. */
  80501. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  80502. /**
  80503. * Creates an alpha texture from some data.
  80504. * @param data Define the texture data
  80505. * @param width Define the width of the texture
  80506. * @param height Define the height of the texture
  80507. * @param scene Define the scene the texture belongs to
  80508. * @param generateMipMaps Define whether or not to create mip maps for the texture
  80509. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  80510. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  80511. * @returns the alpha texture
  80512. */
  80513. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  80514. /**
  80515. * Creates a RGB texture from some data.
  80516. * @param data Define the texture data
  80517. * @param width Define the width of the texture
  80518. * @param height Define the height of the texture
  80519. * @param scene Define the scene the texture belongs to
  80520. * @param generateMipMaps Define whether or not to create mip maps for the texture
  80521. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  80522. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  80523. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  80524. * @returns the RGB alpha texture
  80525. */
  80526. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  80527. /**
  80528. * Creates a RGBA texture from some data.
  80529. * @param data Define the texture data
  80530. * @param width Define the width of the texture
  80531. * @param height Define the height of the texture
  80532. * @param scene Define the scene the texture belongs to
  80533. * @param generateMipMaps Define whether or not to create mip maps for the texture
  80534. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  80535. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  80536. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  80537. * @returns the RGBA texture
  80538. */
  80539. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  80540. /**
  80541. * Creates a R texture from some data.
  80542. * @param data Define the texture data
  80543. * @param width Define the width of the texture
  80544. * @param height Define the height of the texture
  80545. * @param scene Define the scene the texture belongs to
  80546. * @param generateMipMaps Define whether or not to create mip maps for the texture
  80547. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  80548. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  80549. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  80550. * @returns the R texture
  80551. */
  80552. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  80553. }
  80554. }
  80555. declare module BABYLON {
  80556. /**
  80557. * Defines a runtime animation
  80558. */
  80559. export class RuntimeAnimation {
  80560. private _events;
  80561. /**
  80562. * The current frame of the runtime animation
  80563. */
  80564. private _currentFrame;
  80565. /**
  80566. * The animation used by the runtime animation
  80567. */
  80568. private _animation;
  80569. /**
  80570. * The target of the runtime animation
  80571. */
  80572. private _target;
  80573. /**
  80574. * The initiating animatable
  80575. */
  80576. private _host;
  80577. /**
  80578. * The original value of the runtime animation
  80579. */
  80580. private _originalValue;
  80581. /**
  80582. * The original blend value of the runtime animation
  80583. */
  80584. private _originalBlendValue;
  80585. /**
  80586. * The offsets cache of the runtime animation
  80587. */
  80588. private _offsetsCache;
  80589. /**
  80590. * The high limits cache of the runtime animation
  80591. */
  80592. private _highLimitsCache;
  80593. /**
  80594. * Specifies if the runtime animation has been stopped
  80595. */
  80596. private _stopped;
  80597. /**
  80598. * The blending factor of the runtime animation
  80599. */
  80600. private _blendingFactor;
  80601. /**
  80602. * The BabylonJS scene
  80603. */
  80604. private _scene;
  80605. /**
  80606. * The current value of the runtime animation
  80607. */
  80608. private _currentValue;
  80609. /** @hidden */
  80610. _animationState: _IAnimationState;
  80611. /**
  80612. * The active target of the runtime animation
  80613. */
  80614. private _activeTargets;
  80615. private _currentActiveTarget;
  80616. private _directTarget;
  80617. /**
  80618. * The target path of the runtime animation
  80619. */
  80620. private _targetPath;
  80621. /**
  80622. * The weight of the runtime animation
  80623. */
  80624. private _weight;
  80625. /**
  80626. * The ratio offset of the runtime animation
  80627. */
  80628. private _ratioOffset;
  80629. /**
  80630. * The previous delay of the runtime animation
  80631. */
  80632. private _previousDelay;
  80633. /**
  80634. * The previous ratio of the runtime animation
  80635. */
  80636. private _previousRatio;
  80637. private _enableBlending;
  80638. private _keys;
  80639. private _minFrame;
  80640. private _maxFrame;
  80641. private _minValue;
  80642. private _maxValue;
  80643. private _targetIsArray;
  80644. /**
  80645. * Gets the current frame of the runtime animation
  80646. */
  80647. readonly currentFrame: number;
  80648. /**
  80649. * Gets the weight of the runtime animation
  80650. */
  80651. readonly weight: number;
  80652. /**
  80653. * Gets the current value of the runtime animation
  80654. */
  80655. readonly currentValue: any;
  80656. /**
  80657. * Gets the target path of the runtime animation
  80658. */
  80659. readonly targetPath: string;
  80660. /**
  80661. * Gets the actual target of the runtime animation
  80662. */
  80663. readonly target: any;
  80664. /** @hidden */
  80665. _onLoop: () => void;
  80666. /**
  80667. * Create a new RuntimeAnimation object
  80668. * @param target defines the target of the animation
  80669. * @param animation defines the source animation object
  80670. * @param scene defines the hosting scene
  80671. * @param host defines the initiating Animatable
  80672. */
  80673. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  80674. private _preparePath;
  80675. /**
  80676. * Gets the animation from the runtime animation
  80677. */
  80678. readonly animation: Animation;
  80679. /**
  80680. * Resets the runtime animation to the beginning
  80681. * @param restoreOriginal defines whether to restore the target property to the original value
  80682. */
  80683. reset(restoreOriginal?: boolean): void;
  80684. /**
  80685. * Specifies if the runtime animation is stopped
  80686. * @returns Boolean specifying if the runtime animation is stopped
  80687. */
  80688. isStopped(): boolean;
  80689. /**
  80690. * Disposes of the runtime animation
  80691. */
  80692. dispose(): void;
  80693. /**
  80694. * Apply the interpolated value to the target
  80695. * @param currentValue defines the value computed by the animation
  80696. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  80697. */
  80698. setValue(currentValue: any, weight: number): void;
  80699. private _getOriginalValues;
  80700. private _setValue;
  80701. /**
  80702. * Gets the loop pmode of the runtime animation
  80703. * @returns Loop Mode
  80704. */
  80705. private _getCorrectLoopMode;
  80706. /**
  80707. * Move the current animation to a given frame
  80708. * @param frame defines the frame to move to
  80709. */
  80710. goToFrame(frame: number): void;
  80711. /**
  80712. * @hidden Internal use only
  80713. */
  80714. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  80715. /**
  80716. * Execute the current animation
  80717. * @param delay defines the delay to add to the current frame
  80718. * @param from defines the lower bound of the animation range
  80719. * @param to defines the upper bound of the animation range
  80720. * @param loop defines if the current animation must loop
  80721. * @param speedRatio defines the current speed ratio
  80722. * @param weight defines the weight of the animation (default is -1 so no weight)
  80723. * @param onLoop optional callback called when animation loops
  80724. * @returns a boolean indicating if the animation is running
  80725. */
  80726. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  80727. }
  80728. }
  80729. declare module BABYLON {
  80730. /**
  80731. * Class used to store an actual running animation
  80732. */
  80733. export class Animatable {
  80734. /** defines the target object */
  80735. target: any;
  80736. /** defines the starting frame number (default is 0) */
  80737. fromFrame: number;
  80738. /** defines the ending frame number (default is 100) */
  80739. toFrame: number;
  80740. /** defines if the animation must loop (default is false) */
  80741. loopAnimation: boolean;
  80742. /** defines a callback to call when animation ends if it is not looping */
  80743. onAnimationEnd?: (() => void) | null | undefined;
  80744. /** defines a callback to call when animation loops */
  80745. onAnimationLoop?: (() => void) | null | undefined;
  80746. private _localDelayOffset;
  80747. private _pausedDelay;
  80748. private _runtimeAnimations;
  80749. private _paused;
  80750. private _scene;
  80751. private _speedRatio;
  80752. private _weight;
  80753. private _syncRoot;
  80754. /**
  80755. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  80756. * This will only apply for non looping animation (default is true)
  80757. */
  80758. disposeOnEnd: boolean;
  80759. /**
  80760. * Gets a boolean indicating if the animation has started
  80761. */
  80762. animationStarted: boolean;
  80763. /**
  80764. * Observer raised when the animation ends
  80765. */
  80766. onAnimationEndObservable: Observable<Animatable>;
  80767. /**
  80768. * Observer raised when the animation loops
  80769. */
  80770. onAnimationLoopObservable: Observable<Animatable>;
  80771. /**
  80772. * Gets the root Animatable used to synchronize and normalize animations
  80773. */
  80774. readonly syncRoot: Nullable<Animatable>;
  80775. /**
  80776. * Gets the current frame of the first RuntimeAnimation
  80777. * Used to synchronize Animatables
  80778. */
  80779. readonly masterFrame: number;
  80780. /**
  80781. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  80782. */
  80783. weight: number;
  80784. /**
  80785. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  80786. */
  80787. speedRatio: number;
  80788. /**
  80789. * Creates a new Animatable
  80790. * @param scene defines the hosting scene
  80791. * @param target defines the target object
  80792. * @param fromFrame defines the starting frame number (default is 0)
  80793. * @param toFrame defines the ending frame number (default is 100)
  80794. * @param loopAnimation defines if the animation must loop (default is false)
  80795. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  80796. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  80797. * @param animations defines a group of animation to add to the new Animatable
  80798. * @param onAnimationLoop defines a callback to call when animation loops
  80799. */
  80800. constructor(scene: Scene,
  80801. /** defines the target object */
  80802. target: any,
  80803. /** defines the starting frame number (default is 0) */
  80804. fromFrame?: number,
  80805. /** defines the ending frame number (default is 100) */
  80806. toFrame?: number,
  80807. /** defines if the animation must loop (default is false) */
  80808. loopAnimation?: boolean, speedRatio?: number,
  80809. /** defines a callback to call when animation ends if it is not looping */
  80810. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  80811. /** defines a callback to call when animation loops */
  80812. onAnimationLoop?: (() => void) | null | undefined);
  80813. /**
  80814. * Synchronize and normalize current Animatable with a source Animatable
  80815. * This is useful when using animation weights and when animations are not of the same length
  80816. * @param root defines the root Animatable to synchronize with
  80817. * @returns the current Animatable
  80818. */
  80819. syncWith(root: Animatable): Animatable;
  80820. /**
  80821. * Gets the list of runtime animations
  80822. * @returns an array of RuntimeAnimation
  80823. */
  80824. getAnimations(): RuntimeAnimation[];
  80825. /**
  80826. * Adds more animations to the current animatable
  80827. * @param target defines the target of the animations
  80828. * @param animations defines the new animations to add
  80829. */
  80830. appendAnimations(target: any, animations: Animation[]): void;
  80831. /**
  80832. * Gets the source animation for a specific property
  80833. * @param property defines the propertyu to look for
  80834. * @returns null or the source animation for the given property
  80835. */
  80836. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  80837. /**
  80838. * Gets the runtime animation for a specific property
  80839. * @param property defines the propertyu to look for
  80840. * @returns null or the runtime animation for the given property
  80841. */
  80842. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  80843. /**
  80844. * Resets the animatable to its original state
  80845. */
  80846. reset(): void;
  80847. /**
  80848. * Allows the animatable to blend with current running animations
  80849. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  80850. * @param blendingSpeed defines the blending speed to use
  80851. */
  80852. enableBlending(blendingSpeed: number): void;
  80853. /**
  80854. * Disable animation blending
  80855. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  80856. */
  80857. disableBlending(): void;
  80858. /**
  80859. * Jump directly to a given frame
  80860. * @param frame defines the frame to jump to
  80861. */
  80862. goToFrame(frame: number): void;
  80863. /**
  80864. * Pause the animation
  80865. */
  80866. pause(): void;
  80867. /**
  80868. * Restart the animation
  80869. */
  80870. restart(): void;
  80871. private _raiseOnAnimationEnd;
  80872. /**
  80873. * Stop and delete the current animation
  80874. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  80875. * @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)
  80876. */
  80877. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  80878. /**
  80879. * Wait asynchronously for the animation to end
  80880. * @returns a promise which will be fullfilled when the animation ends
  80881. */
  80882. waitAsync(): Promise<Animatable>;
  80883. /** @hidden */
  80884. _animate(delay: number): boolean;
  80885. }
  80886. interface Scene {
  80887. /** @hidden */
  80888. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  80889. /** @hidden */
  80890. _processLateAnimationBindingsForMatrices(holder: {
  80891. totalWeight: number;
  80892. animations: RuntimeAnimation[];
  80893. originalValue: Matrix;
  80894. }): any;
  80895. /** @hidden */
  80896. _processLateAnimationBindingsForQuaternions(holder: {
  80897. totalWeight: number;
  80898. animations: RuntimeAnimation[];
  80899. originalValue: Quaternion;
  80900. }, refQuaternion: Quaternion): Quaternion;
  80901. /** @hidden */
  80902. _processLateAnimationBindings(): void;
  80903. /**
  80904. * Will start the animation sequence of a given target
  80905. * @param target defines the target
  80906. * @param from defines from which frame should animation start
  80907. * @param to defines until which frame should animation run.
  80908. * @param weight defines the weight to apply to the animation (1.0 by default)
  80909. * @param loop defines if the animation loops
  80910. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  80911. * @param onAnimationEnd defines the function to be executed when the animation ends
  80912. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  80913. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  80914. * @param onAnimationLoop defines the callback to call when an animation loops
  80915. * @returns the animatable object created for this animation
  80916. */
  80917. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  80918. /**
  80919. * Will start the animation sequence of a given target
  80920. * @param target defines the target
  80921. * @param from defines from which frame should animation start
  80922. * @param to defines until which frame should animation run.
  80923. * @param loop defines if the animation loops
  80924. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  80925. * @param onAnimationEnd defines the function to be executed when the animation ends
  80926. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  80927. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  80928. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  80929. * @param onAnimationLoop defines the callback to call when an animation loops
  80930. * @returns the animatable object created for this animation
  80931. */
  80932. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  80933. /**
  80934. * Will start the animation sequence of a given target and its hierarchy
  80935. * @param target defines the target
  80936. * @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.
  80937. * @param from defines from which frame should animation start
  80938. * @param to defines until which frame should animation run.
  80939. * @param loop defines if the animation loops
  80940. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  80941. * @param onAnimationEnd defines the function to be executed when the animation ends
  80942. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  80943. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  80944. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  80945. * @param onAnimationLoop defines the callback to call when an animation loops
  80946. * @returns the list of created animatables
  80947. */
  80948. 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[];
  80949. /**
  80950. * Begin a new animation on a given node
  80951. * @param target defines the target where the animation will take place
  80952. * @param animations defines the list of animations to start
  80953. * @param from defines the initial value
  80954. * @param to defines the final value
  80955. * @param loop defines if you want animation to loop (off by default)
  80956. * @param speedRatio defines the speed ratio to apply to all animations
  80957. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  80958. * @param onAnimationLoop defines the callback to call when an animation loops
  80959. * @returns the list of created animatables
  80960. */
  80961. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  80962. /**
  80963. * Begin a new animation on a given node and its hierarchy
  80964. * @param target defines the root node where the animation will take place
  80965. * @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.
  80966. * @param animations defines the list of animations to start
  80967. * @param from defines the initial value
  80968. * @param to defines the final value
  80969. * @param loop defines if you want animation to loop (off by default)
  80970. * @param speedRatio defines the speed ratio to apply to all animations
  80971. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  80972. * @param onAnimationLoop defines the callback to call when an animation loops
  80973. * @returns the list of animatables created for all nodes
  80974. */
  80975. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  80976. /**
  80977. * Gets the animatable associated with a specific target
  80978. * @param target defines the target of the animatable
  80979. * @returns the required animatable if found
  80980. */
  80981. getAnimatableByTarget(target: any): Nullable<Animatable>;
  80982. /**
  80983. * Gets all animatables associated with a given target
  80984. * @param target defines the target to look animatables for
  80985. * @returns an array of Animatables
  80986. */
  80987. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  80988. /**
  80989. * Stops and removes all animations that have been applied to the scene
  80990. */
  80991. stopAllAnimations(): void;
  80992. }
  80993. interface Bone {
  80994. /**
  80995. * Copy an animation range from another bone
  80996. * @param source defines the source bone
  80997. * @param rangeName defines the range name to copy
  80998. * @param frameOffset defines the frame offset
  80999. * @param rescaleAsRequired defines if rescaling must be applied if required
  81000. * @param skelDimensionsRatio defines the scaling ratio
  81001. * @returns true if operation was successful
  81002. */
  81003. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  81004. }
  81005. }
  81006. declare module BABYLON {
  81007. /**
  81008. * Class used to handle skinning animations
  81009. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  81010. */
  81011. export class Skeleton implements IAnimatable {
  81012. /** defines the skeleton name */
  81013. name: string;
  81014. /** defines the skeleton Id */
  81015. id: string;
  81016. /**
  81017. * Defines the list of child bones
  81018. */
  81019. bones: Bone[];
  81020. /**
  81021. * Defines an estimate of the dimension of the skeleton at rest
  81022. */
  81023. dimensionsAtRest: Vector3;
  81024. /**
  81025. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  81026. */
  81027. needInitialSkinMatrix: boolean;
  81028. /**
  81029. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  81030. */
  81031. overrideMesh: Nullable<AbstractMesh>;
  81032. /**
  81033. * Gets the list of animations attached to this skeleton
  81034. */
  81035. animations: Array<Animation>;
  81036. private _scene;
  81037. private _isDirty;
  81038. private _transformMatrices;
  81039. private _transformMatrixTexture;
  81040. private _meshesWithPoseMatrix;
  81041. private _animatables;
  81042. private _identity;
  81043. private _synchronizedWithMesh;
  81044. private _ranges;
  81045. private _lastAbsoluteTransformsUpdateId;
  81046. private _canUseTextureForBones;
  81047. private _uniqueId;
  81048. /** @hidden */
  81049. _numBonesWithLinkedTransformNode: number;
  81050. /** @hidden */
  81051. _hasWaitingData: Nullable<boolean>;
  81052. /**
  81053. * Specifies if the skeleton should be serialized
  81054. */
  81055. doNotSerialize: boolean;
  81056. private _useTextureToStoreBoneMatrices;
  81057. /**
  81058. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  81059. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  81060. */
  81061. useTextureToStoreBoneMatrices: boolean;
  81062. private _animationPropertiesOverride;
  81063. /**
  81064. * Gets or sets the animation properties override
  81065. */
  81066. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  81067. /**
  81068. * List of inspectable custom properties (used by the Inspector)
  81069. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  81070. */
  81071. inspectableCustomProperties: IInspectable[];
  81072. /**
  81073. * An observable triggered before computing the skeleton's matrices
  81074. */
  81075. onBeforeComputeObservable: Observable<Skeleton>;
  81076. /**
  81077. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  81078. */
  81079. readonly isUsingTextureForMatrices: boolean;
  81080. /**
  81081. * Gets the unique ID of this skeleton
  81082. */
  81083. readonly uniqueId: number;
  81084. /**
  81085. * Creates a new skeleton
  81086. * @param name defines the skeleton name
  81087. * @param id defines the skeleton Id
  81088. * @param scene defines the hosting scene
  81089. */
  81090. constructor(
  81091. /** defines the skeleton name */
  81092. name: string,
  81093. /** defines the skeleton Id */
  81094. id: string, scene: Scene);
  81095. /**
  81096. * Gets the current object class name.
  81097. * @return the class name
  81098. */
  81099. getClassName(): string;
  81100. /**
  81101. * Returns an array containing the root bones
  81102. * @returns an array containing the root bones
  81103. */
  81104. getChildren(): Array<Bone>;
  81105. /**
  81106. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  81107. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  81108. * @returns a Float32Array containing matrices data
  81109. */
  81110. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  81111. /**
  81112. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  81113. * @returns a raw texture containing the data
  81114. */
  81115. getTransformMatrixTexture(): Nullable<RawTexture>;
  81116. /**
  81117. * Gets the current hosting scene
  81118. * @returns a scene object
  81119. */
  81120. getScene(): Scene;
  81121. /**
  81122. * Gets a string representing the current skeleton data
  81123. * @param fullDetails defines a boolean indicating if we want a verbose version
  81124. * @returns a string representing the current skeleton data
  81125. */
  81126. toString(fullDetails?: boolean): string;
  81127. /**
  81128. * Get bone's index searching by name
  81129. * @param name defines bone's name to search for
  81130. * @return the indice of the bone. Returns -1 if not found
  81131. */
  81132. getBoneIndexByName(name: string): number;
  81133. /**
  81134. * Creater a new animation range
  81135. * @param name defines the name of the range
  81136. * @param from defines the start key
  81137. * @param to defines the end key
  81138. */
  81139. createAnimationRange(name: string, from: number, to: number): void;
  81140. /**
  81141. * Delete a specific animation range
  81142. * @param name defines the name of the range
  81143. * @param deleteFrames defines if frames must be removed as well
  81144. */
  81145. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  81146. /**
  81147. * Gets a specific animation range
  81148. * @param name defines the name of the range to look for
  81149. * @returns the requested animation range or null if not found
  81150. */
  81151. getAnimationRange(name: string): Nullable<AnimationRange>;
  81152. /**
  81153. * Gets the list of all animation ranges defined on this skeleton
  81154. * @returns an array
  81155. */
  81156. getAnimationRanges(): Nullable<AnimationRange>[];
  81157. /**
  81158. * Copy animation range from a source skeleton.
  81159. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  81160. * @param source defines the source skeleton
  81161. * @param name defines the name of the range to copy
  81162. * @param rescaleAsRequired defines if rescaling must be applied if required
  81163. * @returns true if operation was successful
  81164. */
  81165. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  81166. /**
  81167. * Forces the skeleton to go to rest pose
  81168. */
  81169. returnToRest(): void;
  81170. private _getHighestAnimationFrame;
  81171. /**
  81172. * Begin a specific animation range
  81173. * @param name defines the name of the range to start
  81174. * @param loop defines if looping must be turned on (false by default)
  81175. * @param speedRatio defines the speed ratio to apply (1 by default)
  81176. * @param onAnimationEnd defines a callback which will be called when animation will end
  81177. * @returns a new animatable
  81178. */
  81179. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  81180. /** @hidden */
  81181. _markAsDirty(): void;
  81182. /** @hidden */
  81183. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  81184. /** @hidden */
  81185. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  81186. private _computeTransformMatrices;
  81187. /**
  81188. * Build all resources required to render a skeleton
  81189. */
  81190. prepare(): void;
  81191. /**
  81192. * Gets the list of animatables currently running for this skeleton
  81193. * @returns an array of animatables
  81194. */
  81195. getAnimatables(): IAnimatable[];
  81196. /**
  81197. * Clone the current skeleton
  81198. * @param name defines the name of the new skeleton
  81199. * @param id defines the id of the new skeleton
  81200. * @returns the new skeleton
  81201. */
  81202. clone(name: string, id: string): Skeleton;
  81203. /**
  81204. * Enable animation blending for this skeleton
  81205. * @param blendingSpeed defines the blending speed to apply
  81206. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  81207. */
  81208. enableBlending(blendingSpeed?: number): void;
  81209. /**
  81210. * Releases all resources associated with the current skeleton
  81211. */
  81212. dispose(): void;
  81213. /**
  81214. * Serialize the skeleton in a JSON object
  81215. * @returns a JSON object
  81216. */
  81217. serialize(): any;
  81218. /**
  81219. * Creates a new skeleton from serialized data
  81220. * @param parsedSkeleton defines the serialized data
  81221. * @param scene defines the hosting scene
  81222. * @returns a new skeleton
  81223. */
  81224. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  81225. /**
  81226. * Compute all node absolute transforms
  81227. * @param forceUpdate defines if computation must be done even if cache is up to date
  81228. */
  81229. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  81230. /**
  81231. * Gets the root pose matrix
  81232. * @returns a matrix
  81233. */
  81234. getPoseMatrix(): Nullable<Matrix>;
  81235. /**
  81236. * Sorts bones per internal index
  81237. */
  81238. sortBones(): void;
  81239. private _sortBones;
  81240. }
  81241. }
  81242. declare module BABYLON {
  81243. /**
  81244. * Defines a target to use with MorphTargetManager
  81245. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  81246. */
  81247. export class MorphTarget implements IAnimatable {
  81248. /** defines the name of the target */
  81249. name: string;
  81250. /**
  81251. * Gets or sets the list of animations
  81252. */
  81253. animations: Animation[];
  81254. private _scene;
  81255. private _positions;
  81256. private _normals;
  81257. private _tangents;
  81258. private _influence;
  81259. /**
  81260. * Observable raised when the influence changes
  81261. */
  81262. onInfluenceChanged: Observable<boolean>;
  81263. /** @hidden */
  81264. _onDataLayoutChanged: Observable<void>;
  81265. /**
  81266. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  81267. */
  81268. influence: number;
  81269. /**
  81270. * Gets or sets the id of the morph Target
  81271. */
  81272. id: string;
  81273. private _animationPropertiesOverride;
  81274. /**
  81275. * Gets or sets the animation properties override
  81276. */
  81277. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  81278. /**
  81279. * Creates a new MorphTarget
  81280. * @param name defines the name of the target
  81281. * @param influence defines the influence to use
  81282. * @param scene defines the scene the morphtarget belongs to
  81283. */
  81284. constructor(
  81285. /** defines the name of the target */
  81286. name: string, influence?: number, scene?: Nullable<Scene>);
  81287. /**
  81288. * Gets a boolean defining if the target contains position data
  81289. */
  81290. readonly hasPositions: boolean;
  81291. /**
  81292. * Gets a boolean defining if the target contains normal data
  81293. */
  81294. readonly hasNormals: boolean;
  81295. /**
  81296. * Gets a boolean defining if the target contains tangent data
  81297. */
  81298. readonly hasTangents: boolean;
  81299. /**
  81300. * Affects position data to this target
  81301. * @param data defines the position data to use
  81302. */
  81303. setPositions(data: Nullable<FloatArray>): void;
  81304. /**
  81305. * Gets the position data stored in this target
  81306. * @returns a FloatArray containing the position data (or null if not present)
  81307. */
  81308. getPositions(): Nullable<FloatArray>;
  81309. /**
  81310. * Affects normal data to this target
  81311. * @param data defines the normal data to use
  81312. */
  81313. setNormals(data: Nullable<FloatArray>): void;
  81314. /**
  81315. * Gets the normal data stored in this target
  81316. * @returns a FloatArray containing the normal data (or null if not present)
  81317. */
  81318. getNormals(): Nullable<FloatArray>;
  81319. /**
  81320. * Affects tangent data to this target
  81321. * @param data defines the tangent data to use
  81322. */
  81323. setTangents(data: Nullable<FloatArray>): void;
  81324. /**
  81325. * Gets the tangent data stored in this target
  81326. * @returns a FloatArray containing the tangent data (or null if not present)
  81327. */
  81328. getTangents(): Nullable<FloatArray>;
  81329. /**
  81330. * Serializes the current target into a Serialization object
  81331. * @returns the serialized object
  81332. */
  81333. serialize(): any;
  81334. /**
  81335. * Returns the string "MorphTarget"
  81336. * @returns "MorphTarget"
  81337. */
  81338. getClassName(): string;
  81339. /**
  81340. * Creates a new target from serialized data
  81341. * @param serializationObject defines the serialized data to use
  81342. * @returns a new MorphTarget
  81343. */
  81344. static Parse(serializationObject: any): MorphTarget;
  81345. /**
  81346. * Creates a MorphTarget from mesh data
  81347. * @param mesh defines the source mesh
  81348. * @param name defines the name to use for the new target
  81349. * @param influence defines the influence to attach to the target
  81350. * @returns a new MorphTarget
  81351. */
  81352. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  81353. }
  81354. }
  81355. declare module BABYLON {
  81356. /**
  81357. * This class is used to deform meshes using morphing between different targets
  81358. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  81359. */
  81360. export class MorphTargetManager {
  81361. private _targets;
  81362. private _targetInfluenceChangedObservers;
  81363. private _targetDataLayoutChangedObservers;
  81364. private _activeTargets;
  81365. private _scene;
  81366. private _influences;
  81367. private _supportsNormals;
  81368. private _supportsTangents;
  81369. private _vertexCount;
  81370. private _uniqueId;
  81371. private _tempInfluences;
  81372. /**
  81373. * Creates a new MorphTargetManager
  81374. * @param scene defines the current scene
  81375. */
  81376. constructor(scene?: Nullable<Scene>);
  81377. /**
  81378. * Gets the unique ID of this manager
  81379. */
  81380. readonly uniqueId: number;
  81381. /**
  81382. * Gets the number of vertices handled by this manager
  81383. */
  81384. readonly vertexCount: number;
  81385. /**
  81386. * Gets a boolean indicating if this manager supports morphing of normals
  81387. */
  81388. readonly supportsNormals: boolean;
  81389. /**
  81390. * Gets a boolean indicating if this manager supports morphing of tangents
  81391. */
  81392. readonly supportsTangents: boolean;
  81393. /**
  81394. * Gets the number of targets stored in this manager
  81395. */
  81396. readonly numTargets: number;
  81397. /**
  81398. * Gets the number of influencers (ie. the number of targets with influences > 0)
  81399. */
  81400. readonly numInfluencers: number;
  81401. /**
  81402. * Gets the list of influences (one per target)
  81403. */
  81404. readonly influences: Float32Array;
  81405. /**
  81406. * Gets the active target at specified index. An active target is a target with an influence > 0
  81407. * @param index defines the index to check
  81408. * @returns the requested target
  81409. */
  81410. getActiveTarget(index: number): MorphTarget;
  81411. /**
  81412. * Gets the target at specified index
  81413. * @param index defines the index to check
  81414. * @returns the requested target
  81415. */
  81416. getTarget(index: number): MorphTarget;
  81417. /**
  81418. * Add a new target to this manager
  81419. * @param target defines the target to add
  81420. */
  81421. addTarget(target: MorphTarget): void;
  81422. /**
  81423. * Removes a target from the manager
  81424. * @param target defines the target to remove
  81425. */
  81426. removeTarget(target: MorphTarget): void;
  81427. /**
  81428. * Serializes the current manager into a Serialization object
  81429. * @returns the serialized object
  81430. */
  81431. serialize(): any;
  81432. private _syncActiveTargets;
  81433. /**
  81434. * Syncrhonize the targets with all the meshes using this morph target manager
  81435. */
  81436. synchronize(): void;
  81437. /**
  81438. * Creates a new MorphTargetManager from serialized data
  81439. * @param serializationObject defines the serialized data
  81440. * @param scene defines the hosting scene
  81441. * @returns the new MorphTargetManager
  81442. */
  81443. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  81444. }
  81445. }
  81446. declare module BABYLON {
  81447. /**
  81448. * Class used to represent a specific level of detail of a mesh
  81449. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  81450. */
  81451. export class MeshLODLevel {
  81452. /** Defines the distance where this level should star being displayed */
  81453. distance: number;
  81454. /** Defines the mesh to use to render this level */
  81455. mesh: Nullable<Mesh>;
  81456. /**
  81457. * Creates a new LOD level
  81458. * @param distance defines the distance where this level should star being displayed
  81459. * @param mesh defines the mesh to use to render this level
  81460. */
  81461. constructor(
  81462. /** Defines the distance where this level should star being displayed */
  81463. distance: number,
  81464. /** Defines the mesh to use to render this level */
  81465. mesh: Nullable<Mesh>);
  81466. }
  81467. }
  81468. declare module BABYLON {
  81469. /**
  81470. * Mesh representing the gorund
  81471. */
  81472. export class GroundMesh extends Mesh {
  81473. /** If octree should be generated */
  81474. generateOctree: boolean;
  81475. private _heightQuads;
  81476. /** @hidden */
  81477. _subdivisionsX: number;
  81478. /** @hidden */
  81479. _subdivisionsY: number;
  81480. /** @hidden */
  81481. _width: number;
  81482. /** @hidden */
  81483. _height: number;
  81484. /** @hidden */
  81485. _minX: number;
  81486. /** @hidden */
  81487. _maxX: number;
  81488. /** @hidden */
  81489. _minZ: number;
  81490. /** @hidden */
  81491. _maxZ: number;
  81492. constructor(name: string, scene: Scene);
  81493. /**
  81494. * "GroundMesh"
  81495. * @returns "GroundMesh"
  81496. */
  81497. getClassName(): string;
  81498. /**
  81499. * The minimum of x and y subdivisions
  81500. */
  81501. readonly subdivisions: number;
  81502. /**
  81503. * X subdivisions
  81504. */
  81505. readonly subdivisionsX: number;
  81506. /**
  81507. * Y subdivisions
  81508. */
  81509. readonly subdivisionsY: number;
  81510. /**
  81511. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  81512. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  81513. * @param chunksCount the number of subdivisions for x and y
  81514. * @param octreeBlocksSize (Default: 32)
  81515. */
  81516. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  81517. /**
  81518. * Returns a height (y) value in the Worl system :
  81519. * the ground altitude at the coordinates (x, z) expressed in the World system.
  81520. * @param x x coordinate
  81521. * @param z z coordinate
  81522. * @returns the ground y position if (x, z) are outside the ground surface.
  81523. */
  81524. getHeightAtCoordinates(x: number, z: number): number;
  81525. /**
  81526. * Returns a normalized vector (Vector3) orthogonal to the ground
  81527. * at the ground coordinates (x, z) expressed in the World system.
  81528. * @param x x coordinate
  81529. * @param z z coordinate
  81530. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  81531. */
  81532. getNormalAtCoordinates(x: number, z: number): Vector3;
  81533. /**
  81534. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  81535. * at the ground coordinates (x, z) expressed in the World system.
  81536. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  81537. * @param x x coordinate
  81538. * @param z z coordinate
  81539. * @param ref vector to store the result
  81540. * @returns the GroundMesh.
  81541. */
  81542. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  81543. /**
  81544. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  81545. * if the ground has been updated.
  81546. * This can be used in the render loop.
  81547. * @returns the GroundMesh.
  81548. */
  81549. updateCoordinateHeights(): GroundMesh;
  81550. private _getFacetAt;
  81551. private _initHeightQuads;
  81552. private _computeHeightQuads;
  81553. /**
  81554. * Serializes this ground mesh
  81555. * @param serializationObject object to write serialization to
  81556. */
  81557. serialize(serializationObject: any): void;
  81558. /**
  81559. * Parses a serialized ground mesh
  81560. * @param parsedMesh the serialized mesh
  81561. * @param scene the scene to create the ground mesh in
  81562. * @returns the created ground mesh
  81563. */
  81564. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  81565. }
  81566. }
  81567. declare module BABYLON {
  81568. /**
  81569. * Interface for Physics-Joint data
  81570. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  81571. */
  81572. export interface PhysicsJointData {
  81573. /**
  81574. * The main pivot of the joint
  81575. */
  81576. mainPivot?: Vector3;
  81577. /**
  81578. * The connected pivot of the joint
  81579. */
  81580. connectedPivot?: Vector3;
  81581. /**
  81582. * The main axis of the joint
  81583. */
  81584. mainAxis?: Vector3;
  81585. /**
  81586. * The connected axis of the joint
  81587. */
  81588. connectedAxis?: Vector3;
  81589. /**
  81590. * The collision of the joint
  81591. */
  81592. collision?: boolean;
  81593. /**
  81594. * Native Oimo/Cannon/Energy data
  81595. */
  81596. nativeParams?: any;
  81597. }
  81598. /**
  81599. * This is a holder class for the physics joint created by the physics plugin
  81600. * It holds a set of functions to control the underlying joint
  81601. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  81602. */
  81603. export class PhysicsJoint {
  81604. /**
  81605. * The type of the physics joint
  81606. */
  81607. type: number;
  81608. /**
  81609. * The data for the physics joint
  81610. */
  81611. jointData: PhysicsJointData;
  81612. private _physicsJoint;
  81613. protected _physicsPlugin: IPhysicsEnginePlugin;
  81614. /**
  81615. * Initializes the physics joint
  81616. * @param type The type of the physics joint
  81617. * @param jointData The data for the physics joint
  81618. */
  81619. constructor(
  81620. /**
  81621. * The type of the physics joint
  81622. */
  81623. type: number,
  81624. /**
  81625. * The data for the physics joint
  81626. */
  81627. jointData: PhysicsJointData);
  81628. /**
  81629. * Gets the physics joint
  81630. */
  81631. /**
  81632. * Sets the physics joint
  81633. */
  81634. physicsJoint: any;
  81635. /**
  81636. * Sets the physics plugin
  81637. */
  81638. physicsPlugin: IPhysicsEnginePlugin;
  81639. /**
  81640. * Execute a function that is physics-plugin specific.
  81641. * @param {Function} func the function that will be executed.
  81642. * It accepts two parameters: the physics world and the physics joint
  81643. */
  81644. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  81645. /**
  81646. * Distance-Joint type
  81647. */
  81648. static DistanceJoint: number;
  81649. /**
  81650. * Hinge-Joint type
  81651. */
  81652. static HingeJoint: number;
  81653. /**
  81654. * Ball-and-Socket joint type
  81655. */
  81656. static BallAndSocketJoint: number;
  81657. /**
  81658. * Wheel-Joint type
  81659. */
  81660. static WheelJoint: number;
  81661. /**
  81662. * Slider-Joint type
  81663. */
  81664. static SliderJoint: number;
  81665. /**
  81666. * Prismatic-Joint type
  81667. */
  81668. static PrismaticJoint: number;
  81669. /**
  81670. * Universal-Joint type
  81671. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  81672. */
  81673. static UniversalJoint: number;
  81674. /**
  81675. * Hinge-Joint 2 type
  81676. */
  81677. static Hinge2Joint: number;
  81678. /**
  81679. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  81680. */
  81681. static PointToPointJoint: number;
  81682. /**
  81683. * Spring-Joint type
  81684. */
  81685. static SpringJoint: number;
  81686. /**
  81687. * Lock-Joint type
  81688. */
  81689. static LockJoint: number;
  81690. }
  81691. /**
  81692. * A class representing a physics distance joint
  81693. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  81694. */
  81695. export class DistanceJoint extends PhysicsJoint {
  81696. /**
  81697. *
  81698. * @param jointData The data for the Distance-Joint
  81699. */
  81700. constructor(jointData: DistanceJointData);
  81701. /**
  81702. * Update the predefined distance.
  81703. * @param maxDistance The maximum preferred distance
  81704. * @param minDistance The minimum preferred distance
  81705. */
  81706. updateDistance(maxDistance: number, minDistance?: number): void;
  81707. }
  81708. /**
  81709. * Represents a Motor-Enabled Joint
  81710. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  81711. */
  81712. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  81713. /**
  81714. * Initializes the Motor-Enabled Joint
  81715. * @param type The type of the joint
  81716. * @param jointData The physica joint data for the joint
  81717. */
  81718. constructor(type: number, jointData: PhysicsJointData);
  81719. /**
  81720. * Set the motor values.
  81721. * Attention, this function is plugin specific. Engines won't react 100% the same.
  81722. * @param force the force to apply
  81723. * @param maxForce max force for this motor.
  81724. */
  81725. setMotor(force?: number, maxForce?: number): void;
  81726. /**
  81727. * Set the motor's limits.
  81728. * Attention, this function is plugin specific. Engines won't react 100% the same.
  81729. * @param upperLimit The upper limit of the motor
  81730. * @param lowerLimit The lower limit of the motor
  81731. */
  81732. setLimit(upperLimit: number, lowerLimit?: number): void;
  81733. }
  81734. /**
  81735. * This class represents a single physics Hinge-Joint
  81736. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  81737. */
  81738. export class HingeJoint extends MotorEnabledJoint {
  81739. /**
  81740. * Initializes the Hinge-Joint
  81741. * @param jointData The joint data for the Hinge-Joint
  81742. */
  81743. constructor(jointData: PhysicsJointData);
  81744. /**
  81745. * Set the motor values.
  81746. * Attention, this function is plugin specific. Engines won't react 100% the same.
  81747. * @param {number} force the force to apply
  81748. * @param {number} maxForce max force for this motor.
  81749. */
  81750. setMotor(force?: number, maxForce?: number): void;
  81751. /**
  81752. * Set the motor's limits.
  81753. * Attention, this function is plugin specific. Engines won't react 100% the same.
  81754. * @param upperLimit The upper limit of the motor
  81755. * @param lowerLimit The lower limit of the motor
  81756. */
  81757. setLimit(upperLimit: number, lowerLimit?: number): void;
  81758. }
  81759. /**
  81760. * This class represents a dual hinge physics joint (same as wheel joint)
  81761. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  81762. */
  81763. export class Hinge2Joint extends MotorEnabledJoint {
  81764. /**
  81765. * Initializes the Hinge2-Joint
  81766. * @param jointData The joint data for the Hinge2-Joint
  81767. */
  81768. constructor(jointData: PhysicsJointData);
  81769. /**
  81770. * Set the motor values.
  81771. * Attention, this function is plugin specific. Engines won't react 100% the same.
  81772. * @param {number} targetSpeed the speed the motor is to reach
  81773. * @param {number} maxForce max force for this motor.
  81774. * @param {motorIndex} the motor's index, 0 or 1.
  81775. */
  81776. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  81777. /**
  81778. * Set the motor limits.
  81779. * Attention, this function is plugin specific. Engines won't react 100% the same.
  81780. * @param {number} upperLimit the upper limit
  81781. * @param {number} lowerLimit lower limit
  81782. * @param {motorIndex} the motor's index, 0 or 1.
  81783. */
  81784. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  81785. }
  81786. /**
  81787. * Interface for a motor enabled joint
  81788. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  81789. */
  81790. export interface IMotorEnabledJoint {
  81791. /**
  81792. * Physics joint
  81793. */
  81794. physicsJoint: any;
  81795. /**
  81796. * Sets the motor of the motor-enabled joint
  81797. * @param force The force of the motor
  81798. * @param maxForce The maximum force of the motor
  81799. * @param motorIndex The index of the motor
  81800. */
  81801. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  81802. /**
  81803. * Sets the limit of the motor
  81804. * @param upperLimit The upper limit of the motor
  81805. * @param lowerLimit The lower limit of the motor
  81806. * @param motorIndex The index of the motor
  81807. */
  81808. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  81809. }
  81810. /**
  81811. * Joint data for a Distance-Joint
  81812. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  81813. */
  81814. export interface DistanceJointData extends PhysicsJointData {
  81815. /**
  81816. * Max distance the 2 joint objects can be apart
  81817. */
  81818. maxDistance: number;
  81819. }
  81820. /**
  81821. * Joint data from a spring joint
  81822. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  81823. */
  81824. export interface SpringJointData extends PhysicsJointData {
  81825. /**
  81826. * Length of the spring
  81827. */
  81828. length: number;
  81829. /**
  81830. * Stiffness of the spring
  81831. */
  81832. stiffness: number;
  81833. /**
  81834. * Damping of the spring
  81835. */
  81836. damping: number;
  81837. /** this callback will be called when applying the force to the impostors. */
  81838. forceApplicationCallback: () => void;
  81839. }
  81840. }
  81841. declare module BABYLON {
  81842. /**
  81843. * Holds the data for the raycast result
  81844. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  81845. */
  81846. export class PhysicsRaycastResult {
  81847. private _hasHit;
  81848. private _hitDistance;
  81849. private _hitNormalWorld;
  81850. private _hitPointWorld;
  81851. private _rayFromWorld;
  81852. private _rayToWorld;
  81853. /**
  81854. * Gets if there was a hit
  81855. */
  81856. readonly hasHit: boolean;
  81857. /**
  81858. * Gets the distance from the hit
  81859. */
  81860. readonly hitDistance: number;
  81861. /**
  81862. * Gets the hit normal/direction in the world
  81863. */
  81864. readonly hitNormalWorld: Vector3;
  81865. /**
  81866. * Gets the hit point in the world
  81867. */
  81868. readonly hitPointWorld: Vector3;
  81869. /**
  81870. * Gets the ray "start point" of the ray in the world
  81871. */
  81872. readonly rayFromWorld: Vector3;
  81873. /**
  81874. * Gets the ray "end point" of the ray in the world
  81875. */
  81876. readonly rayToWorld: Vector3;
  81877. /**
  81878. * Sets the hit data (normal & point in world space)
  81879. * @param hitNormalWorld defines the normal in world space
  81880. * @param hitPointWorld defines the point in world space
  81881. */
  81882. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  81883. /**
  81884. * Sets the distance from the start point to the hit point
  81885. * @param distance
  81886. */
  81887. setHitDistance(distance: number): void;
  81888. /**
  81889. * Calculates the distance manually
  81890. */
  81891. calculateHitDistance(): void;
  81892. /**
  81893. * Resets all the values to default
  81894. * @param from The from point on world space
  81895. * @param to The to point on world space
  81896. */
  81897. reset(from?: Vector3, to?: Vector3): void;
  81898. }
  81899. /**
  81900. * Interface for the size containing width and height
  81901. */
  81902. interface IXYZ {
  81903. /**
  81904. * X
  81905. */
  81906. x: number;
  81907. /**
  81908. * Y
  81909. */
  81910. y: number;
  81911. /**
  81912. * Z
  81913. */
  81914. z: number;
  81915. }
  81916. }
  81917. declare module BABYLON {
  81918. /**
  81919. * Interface used to describe a physics joint
  81920. */
  81921. export interface PhysicsImpostorJoint {
  81922. /** Defines the main impostor to which the joint is linked */
  81923. mainImpostor: PhysicsImpostor;
  81924. /** Defines the impostor that is connected to the main impostor using this joint */
  81925. connectedImpostor: PhysicsImpostor;
  81926. /** Defines the joint itself */
  81927. joint: PhysicsJoint;
  81928. }
  81929. /** @hidden */
  81930. export interface IPhysicsEnginePlugin {
  81931. world: any;
  81932. name: string;
  81933. setGravity(gravity: Vector3): void;
  81934. setTimeStep(timeStep: number): void;
  81935. getTimeStep(): number;
  81936. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  81937. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  81938. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  81939. generatePhysicsBody(impostor: PhysicsImpostor): void;
  81940. removePhysicsBody(impostor: PhysicsImpostor): void;
  81941. generateJoint(joint: PhysicsImpostorJoint): void;
  81942. removeJoint(joint: PhysicsImpostorJoint): void;
  81943. isSupported(): boolean;
  81944. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  81945. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  81946. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  81947. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  81948. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  81949. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  81950. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  81951. getBodyMass(impostor: PhysicsImpostor): number;
  81952. getBodyFriction(impostor: PhysicsImpostor): number;
  81953. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  81954. getBodyRestitution(impostor: PhysicsImpostor): number;
  81955. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  81956. getBodyPressure?(impostor: PhysicsImpostor): number;
  81957. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  81958. getBodyStiffness?(impostor: PhysicsImpostor): number;
  81959. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  81960. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  81961. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  81962. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  81963. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  81964. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  81965. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  81966. sleepBody(impostor: PhysicsImpostor): void;
  81967. wakeUpBody(impostor: PhysicsImpostor): void;
  81968. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  81969. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  81970. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  81971. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  81972. getRadius(impostor: PhysicsImpostor): number;
  81973. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  81974. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  81975. dispose(): void;
  81976. }
  81977. /**
  81978. * Interface used to define a physics engine
  81979. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  81980. */
  81981. export interface IPhysicsEngine {
  81982. /**
  81983. * Gets the gravity vector used by the simulation
  81984. */
  81985. gravity: Vector3;
  81986. /**
  81987. * Sets the gravity vector used by the simulation
  81988. * @param gravity defines the gravity vector to use
  81989. */
  81990. setGravity(gravity: Vector3): void;
  81991. /**
  81992. * Set the time step of the physics engine.
  81993. * Default is 1/60.
  81994. * To slow it down, enter 1/600 for example.
  81995. * To speed it up, 1/30
  81996. * @param newTimeStep the new timestep to apply to this world.
  81997. */
  81998. setTimeStep(newTimeStep: number): void;
  81999. /**
  82000. * Get the time step of the physics engine.
  82001. * @returns the current time step
  82002. */
  82003. getTimeStep(): number;
  82004. /**
  82005. * Release all resources
  82006. */
  82007. dispose(): void;
  82008. /**
  82009. * Gets the name of the current physics plugin
  82010. * @returns the name of the plugin
  82011. */
  82012. getPhysicsPluginName(): string;
  82013. /**
  82014. * Adding a new impostor for the impostor tracking.
  82015. * This will be done by the impostor itself.
  82016. * @param impostor the impostor to add
  82017. */
  82018. addImpostor(impostor: PhysicsImpostor): void;
  82019. /**
  82020. * Remove an impostor from the engine.
  82021. * This impostor and its mesh will not longer be updated by the physics engine.
  82022. * @param impostor the impostor to remove
  82023. */
  82024. removeImpostor(impostor: PhysicsImpostor): void;
  82025. /**
  82026. * Add a joint to the physics engine
  82027. * @param mainImpostor defines the main impostor to which the joint is added.
  82028. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  82029. * @param joint defines the joint that will connect both impostors.
  82030. */
  82031. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  82032. /**
  82033. * Removes a joint from the simulation
  82034. * @param mainImpostor defines the impostor used with the joint
  82035. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  82036. * @param joint defines the joint to remove
  82037. */
  82038. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  82039. /**
  82040. * Gets the current plugin used to run the simulation
  82041. * @returns current plugin
  82042. */
  82043. getPhysicsPlugin(): IPhysicsEnginePlugin;
  82044. /**
  82045. * Gets the list of physic impostors
  82046. * @returns an array of PhysicsImpostor
  82047. */
  82048. getImpostors(): Array<PhysicsImpostor>;
  82049. /**
  82050. * Gets the impostor for a physics enabled object
  82051. * @param object defines the object impersonated by the impostor
  82052. * @returns the PhysicsImpostor or null if not found
  82053. */
  82054. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  82055. /**
  82056. * Gets the impostor for a physics body object
  82057. * @param body defines physics body used by the impostor
  82058. * @returns the PhysicsImpostor or null if not found
  82059. */
  82060. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  82061. /**
  82062. * Does a raycast in the physics world
  82063. * @param from when should the ray start?
  82064. * @param to when should the ray end?
  82065. * @returns PhysicsRaycastResult
  82066. */
  82067. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  82068. /**
  82069. * Called by the scene. No need to call it.
  82070. * @param delta defines the timespam between frames
  82071. */
  82072. _step(delta: number): void;
  82073. }
  82074. }
  82075. declare module BABYLON {
  82076. /**
  82077. * The interface for the physics imposter parameters
  82078. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  82079. */
  82080. export interface PhysicsImpostorParameters {
  82081. /**
  82082. * The mass of the physics imposter
  82083. */
  82084. mass: number;
  82085. /**
  82086. * The friction of the physics imposter
  82087. */
  82088. friction?: number;
  82089. /**
  82090. * The coefficient of restitution of the physics imposter
  82091. */
  82092. restitution?: number;
  82093. /**
  82094. * The native options of the physics imposter
  82095. */
  82096. nativeOptions?: any;
  82097. /**
  82098. * Specifies if the parent should be ignored
  82099. */
  82100. ignoreParent?: boolean;
  82101. /**
  82102. * Specifies if bi-directional transformations should be disabled
  82103. */
  82104. disableBidirectionalTransformation?: boolean;
  82105. /**
  82106. * The pressure inside the physics imposter, soft object only
  82107. */
  82108. pressure?: number;
  82109. /**
  82110. * The stiffness the physics imposter, soft object only
  82111. */
  82112. stiffness?: number;
  82113. /**
  82114. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  82115. */
  82116. velocityIterations?: number;
  82117. /**
  82118. * The number of iterations used in maintaining consistent vertex positions, soft object only
  82119. */
  82120. positionIterations?: number;
  82121. /**
  82122. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  82123. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  82124. * Add to fix multiple points
  82125. */
  82126. fixedPoints?: number;
  82127. /**
  82128. * The collision margin around a soft object
  82129. */
  82130. margin?: number;
  82131. /**
  82132. * The collision margin around a soft object
  82133. */
  82134. damping?: number;
  82135. /**
  82136. * The path for a rope based on an extrusion
  82137. */
  82138. path?: any;
  82139. /**
  82140. * The shape of an extrusion used for a rope based on an extrusion
  82141. */
  82142. shape?: any;
  82143. }
  82144. /**
  82145. * Interface for a physics-enabled object
  82146. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  82147. */
  82148. export interface IPhysicsEnabledObject {
  82149. /**
  82150. * The position of the physics-enabled object
  82151. */
  82152. position: Vector3;
  82153. /**
  82154. * The rotation of the physics-enabled object
  82155. */
  82156. rotationQuaternion: Nullable<Quaternion>;
  82157. /**
  82158. * The scale of the physics-enabled object
  82159. */
  82160. scaling: Vector3;
  82161. /**
  82162. * The rotation of the physics-enabled object
  82163. */
  82164. rotation?: Vector3;
  82165. /**
  82166. * The parent of the physics-enabled object
  82167. */
  82168. parent?: any;
  82169. /**
  82170. * The bounding info of the physics-enabled object
  82171. * @returns The bounding info of the physics-enabled object
  82172. */
  82173. getBoundingInfo(): BoundingInfo;
  82174. /**
  82175. * Computes the world matrix
  82176. * @param force Specifies if the world matrix should be computed by force
  82177. * @returns A world matrix
  82178. */
  82179. computeWorldMatrix(force: boolean): Matrix;
  82180. /**
  82181. * Gets the world matrix
  82182. * @returns A world matrix
  82183. */
  82184. getWorldMatrix?(): Matrix;
  82185. /**
  82186. * Gets the child meshes
  82187. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  82188. * @returns An array of abstract meshes
  82189. */
  82190. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  82191. /**
  82192. * Gets the vertex data
  82193. * @param kind The type of vertex data
  82194. * @returns A nullable array of numbers, or a float32 array
  82195. */
  82196. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  82197. /**
  82198. * Gets the indices from the mesh
  82199. * @returns A nullable array of index arrays
  82200. */
  82201. getIndices?(): Nullable<IndicesArray>;
  82202. /**
  82203. * Gets the scene from the mesh
  82204. * @returns the indices array or null
  82205. */
  82206. getScene?(): Scene;
  82207. /**
  82208. * Gets the absolute position from the mesh
  82209. * @returns the absolute position
  82210. */
  82211. getAbsolutePosition(): Vector3;
  82212. /**
  82213. * Gets the absolute pivot point from the mesh
  82214. * @returns the absolute pivot point
  82215. */
  82216. getAbsolutePivotPoint(): Vector3;
  82217. /**
  82218. * Rotates the mesh
  82219. * @param axis The axis of rotation
  82220. * @param amount The amount of rotation
  82221. * @param space The space of the rotation
  82222. * @returns The rotation transform node
  82223. */
  82224. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  82225. /**
  82226. * Translates the mesh
  82227. * @param axis The axis of translation
  82228. * @param distance The distance of translation
  82229. * @param space The space of the translation
  82230. * @returns The transform node
  82231. */
  82232. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  82233. /**
  82234. * Sets the absolute position of the mesh
  82235. * @param absolutePosition The absolute position of the mesh
  82236. * @returns The transform node
  82237. */
  82238. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  82239. /**
  82240. * Gets the class name of the mesh
  82241. * @returns The class name
  82242. */
  82243. getClassName(): string;
  82244. }
  82245. /**
  82246. * Represents a physics imposter
  82247. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  82248. */
  82249. export class PhysicsImpostor {
  82250. /**
  82251. * The physics-enabled object used as the physics imposter
  82252. */
  82253. object: IPhysicsEnabledObject;
  82254. /**
  82255. * The type of the physics imposter
  82256. */
  82257. type: number;
  82258. private _options;
  82259. private _scene?;
  82260. /**
  82261. * The default object size of the imposter
  82262. */
  82263. static DEFAULT_OBJECT_SIZE: Vector3;
  82264. /**
  82265. * The identity quaternion of the imposter
  82266. */
  82267. static IDENTITY_QUATERNION: Quaternion;
  82268. /** @hidden */
  82269. _pluginData: any;
  82270. private _physicsEngine;
  82271. private _physicsBody;
  82272. private _bodyUpdateRequired;
  82273. private _onBeforePhysicsStepCallbacks;
  82274. private _onAfterPhysicsStepCallbacks;
  82275. /** @hidden */
  82276. _onPhysicsCollideCallbacks: Array<{
  82277. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  82278. otherImpostors: Array<PhysicsImpostor>;
  82279. }>;
  82280. private _deltaPosition;
  82281. private _deltaRotation;
  82282. private _deltaRotationConjugated;
  82283. /** hidden */
  82284. _isFromLine: boolean;
  82285. private _parent;
  82286. private _isDisposed;
  82287. private static _tmpVecs;
  82288. private static _tmpQuat;
  82289. /**
  82290. * Specifies if the physics imposter is disposed
  82291. */
  82292. readonly isDisposed: boolean;
  82293. /**
  82294. * Gets the mass of the physics imposter
  82295. */
  82296. mass: number;
  82297. /**
  82298. * Gets the coefficient of friction
  82299. */
  82300. /**
  82301. * Sets the coefficient of friction
  82302. */
  82303. friction: number;
  82304. /**
  82305. * Gets the coefficient of restitution
  82306. */
  82307. /**
  82308. * Sets the coefficient of restitution
  82309. */
  82310. restitution: number;
  82311. /**
  82312. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  82313. */
  82314. /**
  82315. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  82316. */
  82317. pressure: number;
  82318. /**
  82319. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  82320. */
  82321. /**
  82322. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  82323. */
  82324. stiffness: number;
  82325. /**
  82326. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  82327. */
  82328. /**
  82329. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  82330. */
  82331. velocityIterations: number;
  82332. /**
  82333. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  82334. */
  82335. /**
  82336. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  82337. */
  82338. positionIterations: number;
  82339. /**
  82340. * The unique id of the physics imposter
  82341. * set by the physics engine when adding this impostor to the array
  82342. */
  82343. uniqueId: number;
  82344. /**
  82345. * @hidden
  82346. */
  82347. soft: boolean;
  82348. /**
  82349. * @hidden
  82350. */
  82351. segments: number;
  82352. private _joints;
  82353. /**
  82354. * Initializes the physics imposter
  82355. * @param object The physics-enabled object used as the physics imposter
  82356. * @param type The type of the physics imposter
  82357. * @param _options The options for the physics imposter
  82358. * @param _scene The Babylon scene
  82359. */
  82360. constructor(
  82361. /**
  82362. * The physics-enabled object used as the physics imposter
  82363. */
  82364. object: IPhysicsEnabledObject,
  82365. /**
  82366. * The type of the physics imposter
  82367. */
  82368. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  82369. /**
  82370. * This function will completly initialize this impostor.
  82371. * It will create a new body - but only if this mesh has no parent.
  82372. * If it has, this impostor will not be used other than to define the impostor
  82373. * of the child mesh.
  82374. * @hidden
  82375. */
  82376. _init(): void;
  82377. private _getPhysicsParent;
  82378. /**
  82379. * Should a new body be generated.
  82380. * @returns boolean specifying if body initialization is required
  82381. */
  82382. isBodyInitRequired(): boolean;
  82383. /**
  82384. * Sets the updated scaling
  82385. * @param updated Specifies if the scaling is updated
  82386. */
  82387. setScalingUpdated(): void;
  82388. /**
  82389. * Force a regeneration of this or the parent's impostor's body.
  82390. * Use under cautious - This will remove all joints already implemented.
  82391. */
  82392. forceUpdate(): void;
  82393. /**
  82394. * Gets the body that holds this impostor. Either its own, or its parent.
  82395. */
  82396. /**
  82397. * Set the physics body. Used mainly by the physics engine/plugin
  82398. */
  82399. physicsBody: any;
  82400. /**
  82401. * Get the parent of the physics imposter
  82402. * @returns Physics imposter or null
  82403. */
  82404. /**
  82405. * Sets the parent of the physics imposter
  82406. */
  82407. parent: Nullable<PhysicsImpostor>;
  82408. /**
  82409. * Resets the update flags
  82410. */
  82411. resetUpdateFlags(): void;
  82412. /**
  82413. * Gets the object extend size
  82414. * @returns the object extend size
  82415. */
  82416. getObjectExtendSize(): Vector3;
  82417. /**
  82418. * Gets the object center
  82419. * @returns The object center
  82420. */
  82421. getObjectCenter(): Vector3;
  82422. /**
  82423. * Get a specific parametes from the options parameter
  82424. * @param paramName The object parameter name
  82425. * @returns The object parameter
  82426. */
  82427. getParam(paramName: string): any;
  82428. /**
  82429. * Sets a specific parameter in the options given to the physics plugin
  82430. * @param paramName The parameter name
  82431. * @param value The value of the parameter
  82432. */
  82433. setParam(paramName: string, value: number): void;
  82434. /**
  82435. * Specifically change the body's mass option. Won't recreate the physics body object
  82436. * @param mass The mass of the physics imposter
  82437. */
  82438. setMass(mass: number): void;
  82439. /**
  82440. * Gets the linear velocity
  82441. * @returns linear velocity or null
  82442. */
  82443. getLinearVelocity(): Nullable<Vector3>;
  82444. /**
  82445. * Sets the linear velocity
  82446. * @param velocity linear velocity or null
  82447. */
  82448. setLinearVelocity(velocity: Nullable<Vector3>): void;
  82449. /**
  82450. * Gets the angular velocity
  82451. * @returns angular velocity or null
  82452. */
  82453. getAngularVelocity(): Nullable<Vector3>;
  82454. /**
  82455. * Sets the angular velocity
  82456. * @param velocity The velocity or null
  82457. */
  82458. setAngularVelocity(velocity: Nullable<Vector3>): void;
  82459. /**
  82460. * Execute a function with the physics plugin native code
  82461. * Provide a function the will have two variables - the world object and the physics body object
  82462. * @param func The function to execute with the physics plugin native code
  82463. */
  82464. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  82465. /**
  82466. * Register a function that will be executed before the physics world is stepping forward
  82467. * @param func The function to execute before the physics world is stepped forward
  82468. */
  82469. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  82470. /**
  82471. * Unregister a function that will be executed before the physics world is stepping forward
  82472. * @param func The function to execute before the physics world is stepped forward
  82473. */
  82474. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  82475. /**
  82476. * Register a function that will be executed after the physics step
  82477. * @param func The function to execute after physics step
  82478. */
  82479. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  82480. /**
  82481. * Unregisters a function that will be executed after the physics step
  82482. * @param func The function to execute after physics step
  82483. */
  82484. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  82485. /**
  82486. * register a function that will be executed when this impostor collides against a different body
  82487. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  82488. * @param func Callback that is executed on collision
  82489. */
  82490. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  82491. /**
  82492. * Unregisters the physics imposter on contact
  82493. * @param collideAgainst The physics object to collide against
  82494. * @param func Callback to execute on collision
  82495. */
  82496. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  82497. private _tmpQuat;
  82498. private _tmpQuat2;
  82499. /**
  82500. * Get the parent rotation
  82501. * @returns The parent rotation
  82502. */
  82503. getParentsRotation(): Quaternion;
  82504. /**
  82505. * this function is executed by the physics engine.
  82506. */
  82507. beforeStep: () => void;
  82508. /**
  82509. * this function is executed by the physics engine
  82510. */
  82511. afterStep: () => void;
  82512. /**
  82513. * Legacy collision detection event support
  82514. */
  82515. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  82516. /**
  82517. * event and body object due to cannon's event-based architecture.
  82518. */
  82519. onCollide: (e: {
  82520. body: any;
  82521. }) => void;
  82522. /**
  82523. * Apply a force
  82524. * @param force The force to apply
  82525. * @param contactPoint The contact point for the force
  82526. * @returns The physics imposter
  82527. */
  82528. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  82529. /**
  82530. * Apply an impulse
  82531. * @param force The impulse force
  82532. * @param contactPoint The contact point for the impulse force
  82533. * @returns The physics imposter
  82534. */
  82535. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  82536. /**
  82537. * A help function to create a joint
  82538. * @param otherImpostor A physics imposter used to create a joint
  82539. * @param jointType The type of joint
  82540. * @param jointData The data for the joint
  82541. * @returns The physics imposter
  82542. */
  82543. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  82544. /**
  82545. * Add a joint to this impostor with a different impostor
  82546. * @param otherImpostor A physics imposter used to add a joint
  82547. * @param joint The joint to add
  82548. * @returns The physics imposter
  82549. */
  82550. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  82551. /**
  82552. * Add an anchor to a cloth impostor
  82553. * @param otherImpostor rigid impostor to anchor to
  82554. * @param width ratio across width from 0 to 1
  82555. * @param height ratio up height from 0 to 1
  82556. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  82557. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  82558. * @returns impostor the soft imposter
  82559. */
  82560. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  82561. /**
  82562. * Add a hook to a rope impostor
  82563. * @param otherImpostor rigid impostor to anchor to
  82564. * @param length ratio across rope from 0 to 1
  82565. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  82566. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  82567. * @returns impostor the rope imposter
  82568. */
  82569. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  82570. /**
  82571. * Will keep this body still, in a sleep mode.
  82572. * @returns the physics imposter
  82573. */
  82574. sleep(): PhysicsImpostor;
  82575. /**
  82576. * Wake the body up.
  82577. * @returns The physics imposter
  82578. */
  82579. wakeUp(): PhysicsImpostor;
  82580. /**
  82581. * Clones the physics imposter
  82582. * @param newObject The physics imposter clones to this physics-enabled object
  82583. * @returns A nullable physics imposter
  82584. */
  82585. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  82586. /**
  82587. * Disposes the physics imposter
  82588. */
  82589. dispose(): void;
  82590. /**
  82591. * Sets the delta position
  82592. * @param position The delta position amount
  82593. */
  82594. setDeltaPosition(position: Vector3): void;
  82595. /**
  82596. * Sets the delta rotation
  82597. * @param rotation The delta rotation amount
  82598. */
  82599. setDeltaRotation(rotation: Quaternion): void;
  82600. /**
  82601. * Gets the box size of the physics imposter and stores the result in the input parameter
  82602. * @param result Stores the box size
  82603. * @returns The physics imposter
  82604. */
  82605. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  82606. /**
  82607. * Gets the radius of the physics imposter
  82608. * @returns Radius of the physics imposter
  82609. */
  82610. getRadius(): number;
  82611. /**
  82612. * Sync a bone with this impostor
  82613. * @param bone The bone to sync to the impostor.
  82614. * @param boneMesh The mesh that the bone is influencing.
  82615. * @param jointPivot The pivot of the joint / bone in local space.
  82616. * @param distToJoint Optional distance from the impostor to the joint.
  82617. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  82618. */
  82619. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  82620. /**
  82621. * Sync impostor to a bone
  82622. * @param bone The bone that the impostor will be synced to.
  82623. * @param boneMesh The mesh that the bone is influencing.
  82624. * @param jointPivot The pivot of the joint / bone in local space.
  82625. * @param distToJoint Optional distance from the impostor to the joint.
  82626. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  82627. * @param boneAxis Optional vector3 axis the bone is aligned with
  82628. */
  82629. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  82630. /**
  82631. * No-Imposter type
  82632. */
  82633. static NoImpostor: number;
  82634. /**
  82635. * Sphere-Imposter type
  82636. */
  82637. static SphereImpostor: number;
  82638. /**
  82639. * Box-Imposter type
  82640. */
  82641. static BoxImpostor: number;
  82642. /**
  82643. * Plane-Imposter type
  82644. */
  82645. static PlaneImpostor: number;
  82646. /**
  82647. * Mesh-imposter type
  82648. */
  82649. static MeshImpostor: number;
  82650. /**
  82651. * Cylinder-Imposter type
  82652. */
  82653. static CylinderImpostor: number;
  82654. /**
  82655. * Particle-Imposter type
  82656. */
  82657. static ParticleImpostor: number;
  82658. /**
  82659. * Heightmap-Imposter type
  82660. */
  82661. static HeightmapImpostor: number;
  82662. /**
  82663. * ConvexHull-Impostor type (Ammo.js plugin only)
  82664. */
  82665. static ConvexHullImpostor: number;
  82666. /**
  82667. * Rope-Imposter type
  82668. */
  82669. static RopeImpostor: number;
  82670. /**
  82671. * Cloth-Imposter type
  82672. */
  82673. static ClothImpostor: number;
  82674. /**
  82675. * Softbody-Imposter type
  82676. */
  82677. static SoftbodyImpostor: number;
  82678. }
  82679. }
  82680. declare module BABYLON {
  82681. /**
  82682. * @hidden
  82683. **/
  82684. export class _CreationDataStorage {
  82685. closePath?: boolean;
  82686. closeArray?: boolean;
  82687. idx: number[];
  82688. dashSize: number;
  82689. gapSize: number;
  82690. path3D: Path3D;
  82691. pathArray: Vector3[][];
  82692. arc: number;
  82693. radius: number;
  82694. cap: number;
  82695. tessellation: number;
  82696. }
  82697. /**
  82698. * @hidden
  82699. **/
  82700. class _InstanceDataStorage {
  82701. visibleInstances: any;
  82702. batchCache: _InstancesBatch;
  82703. instancesBufferSize: number;
  82704. instancesBuffer: Nullable<Buffer>;
  82705. instancesData: Float32Array;
  82706. overridenInstanceCount: number;
  82707. isFrozen: boolean;
  82708. previousBatch: _InstancesBatch;
  82709. hardwareInstancedRendering: boolean;
  82710. sideOrientation: number;
  82711. }
  82712. /**
  82713. * @hidden
  82714. **/
  82715. export class _InstancesBatch {
  82716. mustReturn: boolean;
  82717. visibleInstances: Nullable<InstancedMesh[]>[];
  82718. renderSelf: boolean[];
  82719. hardwareInstancedRendering: boolean[];
  82720. }
  82721. /**
  82722. * Class used to represent renderable models
  82723. */
  82724. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  82725. /**
  82726. * Mesh side orientation : usually the external or front surface
  82727. */
  82728. static readonly FRONTSIDE: number;
  82729. /**
  82730. * Mesh side orientation : usually the internal or back surface
  82731. */
  82732. static readonly BACKSIDE: number;
  82733. /**
  82734. * Mesh side orientation : both internal and external or front and back surfaces
  82735. */
  82736. static readonly DOUBLESIDE: number;
  82737. /**
  82738. * Mesh side orientation : by default, `FRONTSIDE`
  82739. */
  82740. static readonly DEFAULTSIDE: number;
  82741. /**
  82742. * Mesh cap setting : no cap
  82743. */
  82744. static readonly NO_CAP: number;
  82745. /**
  82746. * Mesh cap setting : one cap at the beginning of the mesh
  82747. */
  82748. static readonly CAP_START: number;
  82749. /**
  82750. * Mesh cap setting : one cap at the end of the mesh
  82751. */
  82752. static readonly CAP_END: number;
  82753. /**
  82754. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  82755. */
  82756. static readonly CAP_ALL: number;
  82757. /**
  82758. * Mesh pattern setting : no flip or rotate
  82759. */
  82760. static readonly NO_FLIP: number;
  82761. /**
  82762. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  82763. */
  82764. static readonly FLIP_TILE: number;
  82765. /**
  82766. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  82767. */
  82768. static readonly ROTATE_TILE: number;
  82769. /**
  82770. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  82771. */
  82772. static readonly FLIP_ROW: number;
  82773. /**
  82774. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  82775. */
  82776. static readonly ROTATE_ROW: number;
  82777. /**
  82778. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  82779. */
  82780. static readonly FLIP_N_ROTATE_TILE: number;
  82781. /**
  82782. * Mesh pattern setting : rotate pattern and rotate
  82783. */
  82784. static readonly FLIP_N_ROTATE_ROW: number;
  82785. /**
  82786. * Mesh tile positioning : part tiles same on left/right or top/bottom
  82787. */
  82788. static readonly CENTER: number;
  82789. /**
  82790. * Mesh tile positioning : part tiles on left
  82791. */
  82792. static readonly LEFT: number;
  82793. /**
  82794. * Mesh tile positioning : part tiles on right
  82795. */
  82796. static readonly RIGHT: number;
  82797. /**
  82798. * Mesh tile positioning : part tiles on top
  82799. */
  82800. static readonly TOP: number;
  82801. /**
  82802. * Mesh tile positioning : part tiles on bottom
  82803. */
  82804. static readonly BOTTOM: number;
  82805. /**
  82806. * Gets the default side orientation.
  82807. * @param orientation the orientation to value to attempt to get
  82808. * @returns the default orientation
  82809. * @hidden
  82810. */
  82811. static _GetDefaultSideOrientation(orientation?: number): number;
  82812. private _internalMeshDataInfo;
  82813. /**
  82814. * An event triggered before rendering the mesh
  82815. */
  82816. readonly onBeforeRenderObservable: Observable<Mesh>;
  82817. /**
  82818. * An event triggered before binding the mesh
  82819. */
  82820. readonly onBeforeBindObservable: Observable<Mesh>;
  82821. /**
  82822. * An event triggered after rendering the mesh
  82823. */
  82824. readonly onAfterRenderObservable: Observable<Mesh>;
  82825. /**
  82826. * An event triggered before drawing the mesh
  82827. */
  82828. readonly onBeforeDrawObservable: Observable<Mesh>;
  82829. private _onBeforeDrawObserver;
  82830. /**
  82831. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  82832. */
  82833. onBeforeDraw: () => void;
  82834. /**
  82835. * Gets the delay loading state of the mesh (when delay loading is turned on)
  82836. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  82837. */
  82838. delayLoadState: number;
  82839. /**
  82840. * Gets the list of instances created from this mesh
  82841. * it is not supposed to be modified manually.
  82842. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  82843. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  82844. */
  82845. instances: InstancedMesh[];
  82846. /**
  82847. * Gets the file containing delay loading data for this mesh
  82848. */
  82849. delayLoadingFile: string;
  82850. /** @hidden */
  82851. _binaryInfo: any;
  82852. /**
  82853. * User defined function used to change how LOD level selection is done
  82854. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  82855. */
  82856. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  82857. /**
  82858. * Gets or sets the morph target manager
  82859. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  82860. */
  82861. morphTargetManager: Nullable<MorphTargetManager>;
  82862. /** @hidden */
  82863. _creationDataStorage: Nullable<_CreationDataStorage>;
  82864. /** @hidden */
  82865. _geometry: Nullable<Geometry>;
  82866. /** @hidden */
  82867. _delayInfo: Array<string>;
  82868. /** @hidden */
  82869. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  82870. /** @hidden */
  82871. _instanceDataStorage: _InstanceDataStorage;
  82872. private _effectiveMaterial;
  82873. /** @hidden */
  82874. _shouldGenerateFlatShading: boolean;
  82875. /** @hidden */
  82876. _originalBuilderSideOrientation: number;
  82877. /**
  82878. * Use this property to change the original side orientation defined at construction time
  82879. */
  82880. overrideMaterialSideOrientation: Nullable<number>;
  82881. /**
  82882. * Gets the source mesh (the one used to clone this one from)
  82883. */
  82884. readonly source: Nullable<Mesh>;
  82885. /**
  82886. * Gets or sets a boolean indicating that this mesh does not use index buffer
  82887. */
  82888. isUnIndexed: boolean;
  82889. /**
  82890. * @constructor
  82891. * @param name The value used by scene.getMeshByName() to do a lookup.
  82892. * @param scene The scene to add this mesh to.
  82893. * @param parent The parent of this mesh, if it has one
  82894. * @param source An optional Mesh from which geometry is shared, cloned.
  82895. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  82896. * When false, achieved by calling a clone(), also passing False.
  82897. * This will make creation of children, recursive.
  82898. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  82899. */
  82900. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  82901. /**
  82902. * Gets the class name
  82903. * @returns the string "Mesh".
  82904. */
  82905. getClassName(): string;
  82906. /** @hidden */
  82907. readonly _isMesh: boolean;
  82908. /**
  82909. * Returns a description of this mesh
  82910. * @param fullDetails define if full details about this mesh must be used
  82911. * @returns a descriptive string representing this mesh
  82912. */
  82913. toString(fullDetails?: boolean): string;
  82914. /** @hidden */
  82915. _unBindEffect(): void;
  82916. /**
  82917. * Gets a boolean indicating if this mesh has LOD
  82918. */
  82919. readonly hasLODLevels: boolean;
  82920. /**
  82921. * Gets the list of MeshLODLevel associated with the current mesh
  82922. * @returns an array of MeshLODLevel
  82923. */
  82924. getLODLevels(): MeshLODLevel[];
  82925. private _sortLODLevels;
  82926. /**
  82927. * Add a mesh as LOD level triggered at the given distance.
  82928. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  82929. * @param distance The distance from the center of the object to show this level
  82930. * @param mesh The mesh to be added as LOD level (can be null)
  82931. * @return This mesh (for chaining)
  82932. */
  82933. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  82934. /**
  82935. * Returns the LOD level mesh at the passed distance or null if not found.
  82936. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  82937. * @param distance The distance from the center of the object to show this level
  82938. * @returns a Mesh or `null`
  82939. */
  82940. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  82941. /**
  82942. * Remove a mesh from the LOD array
  82943. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  82944. * @param mesh defines the mesh to be removed
  82945. * @return This mesh (for chaining)
  82946. */
  82947. removeLODLevel(mesh: Mesh): Mesh;
  82948. /**
  82949. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  82950. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  82951. * @param camera defines the camera to use to compute distance
  82952. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  82953. * @return This mesh (for chaining)
  82954. */
  82955. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  82956. /**
  82957. * Gets the mesh internal Geometry object
  82958. */
  82959. readonly geometry: Nullable<Geometry>;
  82960. /**
  82961. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  82962. * @returns the total number of vertices
  82963. */
  82964. getTotalVertices(): number;
  82965. /**
  82966. * Returns the content of an associated vertex buffer
  82967. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  82968. * - VertexBuffer.PositionKind
  82969. * - VertexBuffer.UVKind
  82970. * - VertexBuffer.UV2Kind
  82971. * - VertexBuffer.UV3Kind
  82972. * - VertexBuffer.UV4Kind
  82973. * - VertexBuffer.UV5Kind
  82974. * - VertexBuffer.UV6Kind
  82975. * - VertexBuffer.ColorKind
  82976. * - VertexBuffer.MatricesIndicesKind
  82977. * - VertexBuffer.MatricesIndicesExtraKind
  82978. * - VertexBuffer.MatricesWeightsKind
  82979. * - VertexBuffer.MatricesWeightsExtraKind
  82980. * @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
  82981. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  82982. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  82983. */
  82984. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  82985. /**
  82986. * Returns the mesh VertexBuffer object from the requested `kind`
  82987. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  82988. * - VertexBuffer.PositionKind
  82989. * - VertexBuffer.NormalKind
  82990. * - VertexBuffer.UVKind
  82991. * - VertexBuffer.UV2Kind
  82992. * - VertexBuffer.UV3Kind
  82993. * - VertexBuffer.UV4Kind
  82994. * - VertexBuffer.UV5Kind
  82995. * - VertexBuffer.UV6Kind
  82996. * - VertexBuffer.ColorKind
  82997. * - VertexBuffer.MatricesIndicesKind
  82998. * - VertexBuffer.MatricesIndicesExtraKind
  82999. * - VertexBuffer.MatricesWeightsKind
  83000. * - VertexBuffer.MatricesWeightsExtraKind
  83001. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  83002. */
  83003. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  83004. /**
  83005. * Tests if a specific vertex buffer is associated with this mesh
  83006. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  83007. * - VertexBuffer.PositionKind
  83008. * - VertexBuffer.NormalKind
  83009. * - VertexBuffer.UVKind
  83010. * - VertexBuffer.UV2Kind
  83011. * - VertexBuffer.UV3Kind
  83012. * - VertexBuffer.UV4Kind
  83013. * - VertexBuffer.UV5Kind
  83014. * - VertexBuffer.UV6Kind
  83015. * - VertexBuffer.ColorKind
  83016. * - VertexBuffer.MatricesIndicesKind
  83017. * - VertexBuffer.MatricesIndicesExtraKind
  83018. * - VertexBuffer.MatricesWeightsKind
  83019. * - VertexBuffer.MatricesWeightsExtraKind
  83020. * @returns a boolean
  83021. */
  83022. isVerticesDataPresent(kind: string): boolean;
  83023. /**
  83024. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  83025. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  83026. * - VertexBuffer.PositionKind
  83027. * - VertexBuffer.UVKind
  83028. * - VertexBuffer.UV2Kind
  83029. * - VertexBuffer.UV3Kind
  83030. * - VertexBuffer.UV4Kind
  83031. * - VertexBuffer.UV5Kind
  83032. * - VertexBuffer.UV6Kind
  83033. * - VertexBuffer.ColorKind
  83034. * - VertexBuffer.MatricesIndicesKind
  83035. * - VertexBuffer.MatricesIndicesExtraKind
  83036. * - VertexBuffer.MatricesWeightsKind
  83037. * - VertexBuffer.MatricesWeightsExtraKind
  83038. * @returns a boolean
  83039. */
  83040. isVertexBufferUpdatable(kind: string): boolean;
  83041. /**
  83042. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  83043. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  83044. * - VertexBuffer.PositionKind
  83045. * - VertexBuffer.NormalKind
  83046. * - VertexBuffer.UVKind
  83047. * - VertexBuffer.UV2Kind
  83048. * - VertexBuffer.UV3Kind
  83049. * - VertexBuffer.UV4Kind
  83050. * - VertexBuffer.UV5Kind
  83051. * - VertexBuffer.UV6Kind
  83052. * - VertexBuffer.ColorKind
  83053. * - VertexBuffer.MatricesIndicesKind
  83054. * - VertexBuffer.MatricesIndicesExtraKind
  83055. * - VertexBuffer.MatricesWeightsKind
  83056. * - VertexBuffer.MatricesWeightsExtraKind
  83057. * @returns an array of strings
  83058. */
  83059. getVerticesDataKinds(): string[];
  83060. /**
  83061. * Returns a positive integer : the total number of indices in this mesh geometry.
  83062. * @returns the numner of indices or zero if the mesh has no geometry.
  83063. */
  83064. getTotalIndices(): number;
  83065. /**
  83066. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  83067. * @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.
  83068. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  83069. * @returns the indices array or an empty array if the mesh has no geometry
  83070. */
  83071. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  83072. readonly isBlocked: boolean;
  83073. /**
  83074. * Determine if the current mesh is ready to be rendered
  83075. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  83076. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  83077. * @returns true if all associated assets are ready (material, textures, shaders)
  83078. */
  83079. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  83080. /**
  83081. * 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.
  83082. */
  83083. readonly areNormalsFrozen: boolean;
  83084. /**
  83085. * 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.
  83086. * @returns the current mesh
  83087. */
  83088. freezeNormals(): Mesh;
  83089. /**
  83090. * 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
  83091. * @returns the current mesh
  83092. */
  83093. unfreezeNormals(): Mesh;
  83094. /**
  83095. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  83096. */
  83097. overridenInstanceCount: number;
  83098. /** @hidden */
  83099. _preActivate(): Mesh;
  83100. /** @hidden */
  83101. _preActivateForIntermediateRendering(renderId: number): Mesh;
  83102. /** @hidden */
  83103. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  83104. /**
  83105. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  83106. * This means the mesh underlying bounding box and sphere are recomputed.
  83107. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  83108. * @returns the current mesh
  83109. */
  83110. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  83111. /** @hidden */
  83112. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  83113. /**
  83114. * This function will subdivide the mesh into multiple submeshes
  83115. * @param count defines the expected number of submeshes
  83116. */
  83117. subdivide(count: number): void;
  83118. /**
  83119. * Copy a FloatArray into a specific associated vertex buffer
  83120. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  83121. * - VertexBuffer.PositionKind
  83122. * - VertexBuffer.UVKind
  83123. * - VertexBuffer.UV2Kind
  83124. * - VertexBuffer.UV3Kind
  83125. * - VertexBuffer.UV4Kind
  83126. * - VertexBuffer.UV5Kind
  83127. * - VertexBuffer.UV6Kind
  83128. * - VertexBuffer.ColorKind
  83129. * - VertexBuffer.MatricesIndicesKind
  83130. * - VertexBuffer.MatricesIndicesExtraKind
  83131. * - VertexBuffer.MatricesWeightsKind
  83132. * - VertexBuffer.MatricesWeightsExtraKind
  83133. * @param data defines the data source
  83134. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  83135. * @param stride defines the data stride size (can be null)
  83136. * @returns the current mesh
  83137. */
  83138. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  83139. /**
  83140. * Flags an associated vertex buffer as updatable
  83141. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  83142. * - VertexBuffer.PositionKind
  83143. * - VertexBuffer.UVKind
  83144. * - VertexBuffer.UV2Kind
  83145. * - VertexBuffer.UV3Kind
  83146. * - VertexBuffer.UV4Kind
  83147. * - VertexBuffer.UV5Kind
  83148. * - VertexBuffer.UV6Kind
  83149. * - VertexBuffer.ColorKind
  83150. * - VertexBuffer.MatricesIndicesKind
  83151. * - VertexBuffer.MatricesIndicesExtraKind
  83152. * - VertexBuffer.MatricesWeightsKind
  83153. * - VertexBuffer.MatricesWeightsExtraKind
  83154. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  83155. */
  83156. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  83157. /**
  83158. * Sets the mesh global Vertex Buffer
  83159. * @param buffer defines the buffer to use
  83160. * @returns the current mesh
  83161. */
  83162. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  83163. /**
  83164. * Update a specific associated vertex buffer
  83165. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  83166. * - VertexBuffer.PositionKind
  83167. * - VertexBuffer.UVKind
  83168. * - VertexBuffer.UV2Kind
  83169. * - VertexBuffer.UV3Kind
  83170. * - VertexBuffer.UV4Kind
  83171. * - VertexBuffer.UV5Kind
  83172. * - VertexBuffer.UV6Kind
  83173. * - VertexBuffer.ColorKind
  83174. * - VertexBuffer.MatricesIndicesKind
  83175. * - VertexBuffer.MatricesIndicesExtraKind
  83176. * - VertexBuffer.MatricesWeightsKind
  83177. * - VertexBuffer.MatricesWeightsExtraKind
  83178. * @param data defines the data source
  83179. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  83180. * @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)
  83181. * @returns the current mesh
  83182. */
  83183. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  83184. /**
  83185. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  83186. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  83187. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  83188. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  83189. * @returns the current mesh
  83190. */
  83191. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  83192. /**
  83193. * Creates a un-shared specific occurence of the geometry for the mesh.
  83194. * @returns the current mesh
  83195. */
  83196. makeGeometryUnique(): Mesh;
  83197. /**
  83198. * Set the index buffer of this mesh
  83199. * @param indices defines the source data
  83200. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  83201. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  83202. * @returns the current mesh
  83203. */
  83204. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  83205. /**
  83206. * Update the current index buffer
  83207. * @param indices defines the source data
  83208. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  83209. * @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)
  83210. * @returns the current mesh
  83211. */
  83212. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  83213. /**
  83214. * Invert the geometry to move from a right handed system to a left handed one.
  83215. * @returns the current mesh
  83216. */
  83217. toLeftHanded(): Mesh;
  83218. /** @hidden */
  83219. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  83220. /** @hidden */
  83221. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  83222. /**
  83223. * Registers for this mesh a javascript function called just before the rendering process
  83224. * @param func defines the function to call before rendering this mesh
  83225. * @returns the current mesh
  83226. */
  83227. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  83228. /**
  83229. * Disposes a previously registered javascript function called before the rendering
  83230. * @param func defines the function to remove
  83231. * @returns the current mesh
  83232. */
  83233. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  83234. /**
  83235. * Registers for this mesh a javascript function called just after the rendering is complete
  83236. * @param func defines the function to call after rendering this mesh
  83237. * @returns the current mesh
  83238. */
  83239. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  83240. /**
  83241. * Disposes a previously registered javascript function called after the rendering.
  83242. * @param func defines the function to remove
  83243. * @returns the current mesh
  83244. */
  83245. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  83246. /** @hidden */
  83247. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  83248. /** @hidden */
  83249. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  83250. /** @hidden */
  83251. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  83252. /** @hidden */
  83253. _freeze(): void;
  83254. /** @hidden */
  83255. _unFreeze(): void;
  83256. /**
  83257. * 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
  83258. * @param subMesh defines the subMesh to render
  83259. * @param enableAlphaMode defines if alpha mode can be changed
  83260. * @returns the current mesh
  83261. */
  83262. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  83263. private _onBeforeDraw;
  83264. /**
  83265. * Renormalize the mesh and patch it up if there are no weights
  83266. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  83267. * However in the case of zero weights then we set just a single influence to 1.
  83268. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  83269. */
  83270. cleanMatrixWeights(): void;
  83271. private normalizeSkinFourWeights;
  83272. private normalizeSkinWeightsAndExtra;
  83273. /**
  83274. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  83275. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  83276. * the user know there was an issue with importing the mesh
  83277. * @returns a validation object with skinned, valid and report string
  83278. */
  83279. validateSkinning(): {
  83280. skinned: boolean;
  83281. valid: boolean;
  83282. report: string;
  83283. };
  83284. /** @hidden */
  83285. _checkDelayState(): Mesh;
  83286. private _queueLoad;
  83287. /**
  83288. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  83289. * A mesh is in the frustum if its bounding box intersects the frustum
  83290. * @param frustumPlanes defines the frustum to test
  83291. * @returns true if the mesh is in the frustum planes
  83292. */
  83293. isInFrustum(frustumPlanes: Plane[]): boolean;
  83294. /**
  83295. * Sets the mesh material by the material or multiMaterial `id` property
  83296. * @param id is a string identifying the material or the multiMaterial
  83297. * @returns the current mesh
  83298. */
  83299. setMaterialByID(id: string): Mesh;
  83300. /**
  83301. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  83302. * @returns an array of IAnimatable
  83303. */
  83304. getAnimatables(): IAnimatable[];
  83305. /**
  83306. * Modifies the mesh geometry according to the passed transformation matrix.
  83307. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  83308. * The mesh normals are modified using the same transformation.
  83309. * Note that, under the hood, this method sets a new VertexBuffer each call.
  83310. * @param transform defines the transform matrix to use
  83311. * @see http://doc.babylonjs.com/resources/baking_transformations
  83312. * @returns the current mesh
  83313. */
  83314. bakeTransformIntoVertices(transform: Matrix): Mesh;
  83315. /**
  83316. * Modifies the mesh geometry according to its own current World Matrix.
  83317. * The mesh World Matrix is then reset.
  83318. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  83319. * Note that, under the hood, this method sets a new VertexBuffer each call.
  83320. * @see http://doc.babylonjs.com/resources/baking_transformations
  83321. * @returns the current mesh
  83322. */
  83323. bakeCurrentTransformIntoVertices(): Mesh;
  83324. /** @hidden */
  83325. readonly _positions: Nullable<Vector3[]>;
  83326. /** @hidden */
  83327. _resetPointsArrayCache(): Mesh;
  83328. /** @hidden */
  83329. _generatePointsArray(): boolean;
  83330. /**
  83331. * Returns a new Mesh object generated from the current mesh properties.
  83332. * This method must not get confused with createInstance()
  83333. * @param name is a string, the name given to the new mesh
  83334. * @param newParent can be any Node object (default `null`)
  83335. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  83336. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  83337. * @returns a new mesh
  83338. */
  83339. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  83340. /**
  83341. * Releases resources associated with this mesh.
  83342. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  83343. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  83344. */
  83345. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  83346. /**
  83347. * Modifies the mesh geometry according to a displacement map.
  83348. * 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.
  83349. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  83350. * @param url is a string, the URL from the image file is to be downloaded.
  83351. * @param minHeight is the lower limit of the displacement.
  83352. * @param maxHeight is the upper limit of the displacement.
  83353. * @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.
  83354. * @param uvOffset is an optional vector2 used to offset UV.
  83355. * @param uvScale is an optional vector2 used to scale UV.
  83356. * @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.
  83357. * @returns the Mesh.
  83358. */
  83359. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  83360. /**
  83361. * Modifies the mesh geometry according to a displacementMap buffer.
  83362. * 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.
  83363. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  83364. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  83365. * @param heightMapWidth is the width of the buffer image.
  83366. * @param heightMapHeight is the height of the buffer image.
  83367. * @param minHeight is the lower limit of the displacement.
  83368. * @param maxHeight is the upper limit of the displacement.
  83369. * @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.
  83370. * @param uvOffset is an optional vector2 used to offset UV.
  83371. * @param uvScale is an optional vector2 used to scale UV.
  83372. * @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.
  83373. * @returns the Mesh.
  83374. */
  83375. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  83376. /**
  83377. * Modify the mesh to get a flat shading rendering.
  83378. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  83379. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  83380. * @returns current mesh
  83381. */
  83382. convertToFlatShadedMesh(): Mesh;
  83383. /**
  83384. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  83385. * In other words, more vertices, no more indices and a single bigger VBO.
  83386. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  83387. * @returns current mesh
  83388. */
  83389. convertToUnIndexedMesh(): Mesh;
  83390. /**
  83391. * Inverses facet orientations.
  83392. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  83393. * @param flipNormals will also inverts the normals
  83394. * @returns current mesh
  83395. */
  83396. flipFaces(flipNormals?: boolean): Mesh;
  83397. /**
  83398. * Increase the number of facets and hence vertices in a mesh
  83399. * Vertex normals are interpolated from existing vertex normals
  83400. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  83401. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  83402. */
  83403. increaseVertices(numberPerEdge: number): void;
  83404. /**
  83405. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  83406. * This will undo any application of covertToFlatShadedMesh
  83407. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  83408. */
  83409. forceSharedVertices(): void;
  83410. /** @hidden */
  83411. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  83412. /** @hidden */
  83413. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  83414. /**
  83415. * Creates a new InstancedMesh object from the mesh model.
  83416. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  83417. * @param name defines the name of the new instance
  83418. * @returns a new InstancedMesh
  83419. */
  83420. createInstance(name: string): InstancedMesh;
  83421. /**
  83422. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  83423. * After this call, all the mesh instances have the same submeshes than the current mesh.
  83424. * @returns the current mesh
  83425. */
  83426. synchronizeInstances(): Mesh;
  83427. /**
  83428. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  83429. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  83430. * This should be used together with the simplification to avoid disappearing triangles.
  83431. * @param successCallback an optional success callback to be called after the optimization finished.
  83432. * @returns the current mesh
  83433. */
  83434. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  83435. /**
  83436. * Serialize current mesh
  83437. * @param serializationObject defines the object which will receive the serialization data
  83438. */
  83439. serialize(serializationObject: any): void;
  83440. /** @hidden */
  83441. _syncGeometryWithMorphTargetManager(): void;
  83442. /** @hidden */
  83443. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  83444. /**
  83445. * Returns a new Mesh object parsed from the source provided.
  83446. * @param parsedMesh is the source
  83447. * @param scene defines the hosting scene
  83448. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  83449. * @returns a new Mesh
  83450. */
  83451. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  83452. /**
  83453. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  83454. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  83455. * @param name defines the name of the mesh to create
  83456. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  83457. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  83458. * @param closePath creates a seam between the first and the last points of each path of the path array
  83459. * @param offset is taken in account only if the `pathArray` is containing a single path
  83460. * @param scene defines the hosting scene
  83461. * @param updatable defines if the mesh must be flagged as updatable
  83462. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  83463. * @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)
  83464. * @returns a new Mesh
  83465. */
  83466. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  83467. /**
  83468. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  83469. * @param name defines the name of the mesh to create
  83470. * @param radius sets the radius size (float) of the polygon (default 0.5)
  83471. * @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
  83472. * @param scene defines the hosting scene
  83473. * @param updatable defines if the mesh must be flagged as updatable
  83474. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  83475. * @returns a new Mesh
  83476. */
  83477. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  83478. /**
  83479. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  83480. * @param name defines the name of the mesh to create
  83481. * @param size sets the size (float) of each box side (default 1)
  83482. * @param scene defines the hosting scene
  83483. * @param updatable defines if the mesh must be flagged as updatable
  83484. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  83485. * @returns a new Mesh
  83486. */
  83487. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  83488. /**
  83489. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  83490. * @param name defines the name of the mesh to create
  83491. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  83492. * @param diameter sets the diameter size (float) of the sphere (default 1)
  83493. * @param scene defines the hosting scene
  83494. * @param updatable defines if the mesh must be flagged as updatable
  83495. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  83496. * @returns a new Mesh
  83497. */
  83498. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  83499. /**
  83500. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  83501. * @param name defines the name of the mesh to create
  83502. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  83503. * @param diameter sets the diameter size (float) of the sphere (default 1)
  83504. * @param scene defines the hosting scene
  83505. * @returns a new Mesh
  83506. */
  83507. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  83508. /**
  83509. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  83510. * @param name defines the name of the mesh to create
  83511. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  83512. * @param diameterTop set the top cap diameter (floats, default 1)
  83513. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  83514. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  83515. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  83516. * @param scene defines the hosting scene
  83517. * @param updatable defines if the mesh must be flagged as updatable
  83518. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  83519. * @returns a new Mesh
  83520. */
  83521. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  83522. /**
  83523. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  83524. * @param name defines the name of the mesh to create
  83525. * @param diameter sets the diameter size (float) of the torus (default 1)
  83526. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  83527. * @param tessellation sets the number of torus sides (postive integer, default 16)
  83528. * @param scene defines the hosting scene
  83529. * @param updatable defines if the mesh must be flagged as updatable
  83530. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  83531. * @returns a new Mesh
  83532. */
  83533. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  83534. /**
  83535. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  83536. * @param name defines the name of the mesh to create
  83537. * @param radius sets the global radius size (float) of the torus knot (default 2)
  83538. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  83539. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  83540. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  83541. * @param p the number of windings on X axis (positive integers, default 2)
  83542. * @param q the number of windings on Y axis (positive integers, default 3)
  83543. * @param scene defines the hosting scene
  83544. * @param updatable defines if the mesh must be flagged as updatable
  83545. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  83546. * @returns a new Mesh
  83547. */
  83548. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  83549. /**
  83550. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  83551. * @param name defines the name of the mesh to create
  83552. * @param points is an array successive Vector3
  83553. * @param scene defines the hosting scene
  83554. * @param updatable defines if the mesh must be flagged as updatable
  83555. * @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).
  83556. * @returns a new Mesh
  83557. */
  83558. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  83559. /**
  83560. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  83561. * @param name defines the name of the mesh to create
  83562. * @param points is an array successive Vector3
  83563. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  83564. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  83565. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  83566. * @param scene defines the hosting scene
  83567. * @param updatable defines if the mesh must be flagged as updatable
  83568. * @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)
  83569. * @returns a new Mesh
  83570. */
  83571. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  83572. /**
  83573. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  83574. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  83575. * 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.
  83576. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  83577. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  83578. * Remember you can only change the shape positions, not their number when updating a polygon.
  83579. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  83580. * @param name defines the name of the mesh to create
  83581. * @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
  83582. * @param scene defines the hosting scene
  83583. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  83584. * @param updatable defines if the mesh must be flagged as updatable
  83585. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  83586. * @param earcutInjection can be used to inject your own earcut reference
  83587. * @returns a new Mesh
  83588. */
  83589. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  83590. /**
  83591. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  83592. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  83593. * @param name defines the name of the mesh to create
  83594. * @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
  83595. * @param depth defines the height of extrusion
  83596. * @param scene defines the hosting scene
  83597. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  83598. * @param updatable defines if the mesh must be flagged as updatable
  83599. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  83600. * @param earcutInjection can be used to inject your own earcut reference
  83601. * @returns a new Mesh
  83602. */
  83603. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  83604. /**
  83605. * Creates an extruded shape mesh.
  83606. * 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
  83607. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  83608. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  83609. * @param name defines the name of the mesh to create
  83610. * @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
  83611. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  83612. * @param scale is the value to scale the shape
  83613. * @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
  83614. * @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
  83615. * @param scene defines the hosting scene
  83616. * @param updatable defines if the mesh must be flagged as updatable
  83617. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  83618. * @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)
  83619. * @returns a new Mesh
  83620. */
  83621. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  83622. /**
  83623. * Creates an custom extruded shape mesh.
  83624. * The custom extrusion is a parametric shape.
  83625. * It has no predefined shape. Its final shape will depend on the input parameters.
  83626. * Please consider using the same method from the MeshBuilder class instead
  83627. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  83628. * @param name defines the name of the mesh to create
  83629. * @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
  83630. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  83631. * @param scaleFunction is a custom Javascript function called on each path point
  83632. * @param rotationFunction is a custom Javascript function called on each path point
  83633. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  83634. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  83635. * @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
  83636. * @param scene defines the hosting scene
  83637. * @param updatable defines if the mesh must be flagged as updatable
  83638. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  83639. * @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)
  83640. * @returns a new Mesh
  83641. */
  83642. 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;
  83643. /**
  83644. * Creates lathe mesh.
  83645. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  83646. * Please consider using the same method from the MeshBuilder class instead
  83647. * @param name defines the name of the mesh to create
  83648. * @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
  83649. * @param radius is the radius value of the lathe
  83650. * @param tessellation is the side number of the lathe.
  83651. * @param scene defines the hosting scene
  83652. * @param updatable defines if the mesh must be flagged as updatable
  83653. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  83654. * @returns a new Mesh
  83655. */
  83656. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  83657. /**
  83658. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  83659. * @param name defines the name of the mesh to create
  83660. * @param size sets the size (float) of both sides of the plane at once (default 1)
  83661. * @param scene defines the hosting scene
  83662. * @param updatable defines if the mesh must be flagged as updatable
  83663. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  83664. * @returns a new Mesh
  83665. */
  83666. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  83667. /**
  83668. * Creates a ground mesh.
  83669. * Please consider using the same method from the MeshBuilder class instead
  83670. * @param name defines the name of the mesh to create
  83671. * @param width set the width of the ground
  83672. * @param height set the height of the ground
  83673. * @param subdivisions sets the number of subdivisions per side
  83674. * @param scene defines the hosting scene
  83675. * @param updatable defines if the mesh must be flagged as updatable
  83676. * @returns a new Mesh
  83677. */
  83678. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  83679. /**
  83680. * Creates a tiled ground mesh.
  83681. * Please consider using the same method from the MeshBuilder class instead
  83682. * @param name defines the name of the mesh to create
  83683. * @param xmin set the ground minimum X coordinate
  83684. * @param zmin set the ground minimum Y coordinate
  83685. * @param xmax set the ground maximum X coordinate
  83686. * @param zmax set the ground maximum Z coordinate
  83687. * @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
  83688. * @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
  83689. * @param scene defines the hosting scene
  83690. * @param updatable defines if the mesh must be flagged as updatable
  83691. * @returns a new Mesh
  83692. */
  83693. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  83694. w: number;
  83695. h: number;
  83696. }, precision: {
  83697. w: number;
  83698. h: number;
  83699. }, scene: Scene, updatable?: boolean): Mesh;
  83700. /**
  83701. * Creates a ground mesh from a height map.
  83702. * Please consider using the same method from the MeshBuilder class instead
  83703. * @see http://doc.babylonjs.com/babylon101/height_map
  83704. * @param name defines the name of the mesh to create
  83705. * @param url sets the URL of the height map image resource
  83706. * @param width set the ground width size
  83707. * @param height set the ground height size
  83708. * @param subdivisions sets the number of subdivision per side
  83709. * @param minHeight is the minimum altitude on the ground
  83710. * @param maxHeight is the maximum altitude on the ground
  83711. * @param scene defines the hosting scene
  83712. * @param updatable defines if the mesh must be flagged as updatable
  83713. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  83714. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  83715. * @returns a new Mesh
  83716. */
  83717. 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;
  83718. /**
  83719. * Creates a tube mesh.
  83720. * The tube is a parametric shape.
  83721. * It has no predefined shape. Its final shape will depend on the input parameters.
  83722. * Please consider using the same method from the MeshBuilder class instead
  83723. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  83724. * @param name defines the name of the mesh to create
  83725. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  83726. * @param radius sets the tube radius size
  83727. * @param tessellation is the number of sides on the tubular surface
  83728. * @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
  83729. * @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
  83730. * @param scene defines the hosting scene
  83731. * @param updatable defines if the mesh must be flagged as updatable
  83732. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  83733. * @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)
  83734. * @returns a new Mesh
  83735. */
  83736. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  83737. (i: number, distance: number): number;
  83738. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  83739. /**
  83740. * Creates a polyhedron mesh.
  83741. * Please consider using the same method from the MeshBuilder class instead.
  83742. * * 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
  83743. * * The parameter `size` (positive float, default 1) sets the polygon size
  83744. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  83745. * * 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`
  83746. * * 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
  83747. * * 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)`)
  83748. * * 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
  83749. * * 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
  83750. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  83751. * * If you create a double-sided mesh, you can choose what parts of 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
  83752. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  83753. * @param name defines the name of the mesh to create
  83754. * @param options defines the options used to create the mesh
  83755. * @param scene defines the hosting scene
  83756. * @returns a new Mesh
  83757. */
  83758. static CreatePolyhedron(name: string, options: {
  83759. type?: number;
  83760. size?: number;
  83761. sizeX?: number;
  83762. sizeY?: number;
  83763. sizeZ?: number;
  83764. custom?: any;
  83765. faceUV?: Vector4[];
  83766. faceColors?: Color4[];
  83767. updatable?: boolean;
  83768. sideOrientation?: number;
  83769. }, scene: Scene): Mesh;
  83770. /**
  83771. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  83772. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  83773. * * 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`)
  83774. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  83775. * * 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
  83776. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  83777. * * If you create a double-sided mesh, you can choose what parts of 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
  83778. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  83779. * @param name defines the name of the mesh
  83780. * @param options defines the options used to create the mesh
  83781. * @param scene defines the hosting scene
  83782. * @returns a new Mesh
  83783. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  83784. */
  83785. static CreateIcoSphere(name: string, options: {
  83786. radius?: number;
  83787. flat?: boolean;
  83788. subdivisions?: number;
  83789. sideOrientation?: number;
  83790. updatable?: boolean;
  83791. }, scene: Scene): Mesh;
  83792. /**
  83793. * Creates a decal mesh.
  83794. * Please consider using the same method from the MeshBuilder class instead.
  83795. * A decal is a mesh usually applied as a model onto the surface of another mesh
  83796. * @param name defines the name of the mesh
  83797. * @param sourceMesh defines the mesh receiving the decal
  83798. * @param position sets the position of the decal in world coordinates
  83799. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  83800. * @param size sets the decal scaling
  83801. * @param angle sets the angle to rotate the decal
  83802. * @returns a new Mesh
  83803. */
  83804. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  83805. /**
  83806. * Prepare internal position array for software CPU skinning
  83807. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  83808. */
  83809. setPositionsForCPUSkinning(): Float32Array;
  83810. /**
  83811. * Prepare internal normal array for software CPU skinning
  83812. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  83813. */
  83814. setNormalsForCPUSkinning(): Float32Array;
  83815. /**
  83816. * Updates the vertex buffer by applying transformation from the bones
  83817. * @param skeleton defines the skeleton to apply to current mesh
  83818. * @returns the current mesh
  83819. */
  83820. applySkeleton(skeleton: Skeleton): Mesh;
  83821. /**
  83822. * 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
  83823. * @param meshes defines the list of meshes to scan
  83824. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  83825. */
  83826. static MinMax(meshes: AbstractMesh[]): {
  83827. min: Vector3;
  83828. max: Vector3;
  83829. };
  83830. /**
  83831. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  83832. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  83833. * @returns a vector3
  83834. */
  83835. static Center(meshesOrMinMaxVector: {
  83836. min: Vector3;
  83837. max: Vector3;
  83838. } | AbstractMesh[]): Vector3;
  83839. /**
  83840. * Merge the array of meshes into a single mesh for performance reasons.
  83841. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  83842. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  83843. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  83844. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  83845. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  83846. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  83847. * @returns a new mesh
  83848. */
  83849. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  83850. /** @hidden */
  83851. addInstance(instance: InstancedMesh): void;
  83852. /** @hidden */
  83853. removeInstance(instance: InstancedMesh): void;
  83854. }
  83855. }
  83856. declare module BABYLON {
  83857. /**
  83858. * Base class for the main features of a material in Babylon.js
  83859. */
  83860. export class Material implements IAnimatable {
  83861. /**
  83862. * Returns the triangle fill mode
  83863. */
  83864. static readonly TriangleFillMode: number;
  83865. /**
  83866. * Returns the wireframe mode
  83867. */
  83868. static readonly WireFrameFillMode: number;
  83869. /**
  83870. * Returns the point fill mode
  83871. */
  83872. static readonly PointFillMode: number;
  83873. /**
  83874. * Returns the point list draw mode
  83875. */
  83876. static readonly PointListDrawMode: number;
  83877. /**
  83878. * Returns the line list draw mode
  83879. */
  83880. static readonly LineListDrawMode: number;
  83881. /**
  83882. * Returns the line loop draw mode
  83883. */
  83884. static readonly LineLoopDrawMode: number;
  83885. /**
  83886. * Returns the line strip draw mode
  83887. */
  83888. static readonly LineStripDrawMode: number;
  83889. /**
  83890. * Returns the triangle strip draw mode
  83891. */
  83892. static readonly TriangleStripDrawMode: number;
  83893. /**
  83894. * Returns the triangle fan draw mode
  83895. */
  83896. static readonly TriangleFanDrawMode: number;
  83897. /**
  83898. * Stores the clock-wise side orientation
  83899. */
  83900. static readonly ClockWiseSideOrientation: number;
  83901. /**
  83902. * Stores the counter clock-wise side orientation
  83903. */
  83904. static readonly CounterClockWiseSideOrientation: number;
  83905. /**
  83906. * The dirty texture flag value
  83907. */
  83908. static readonly TextureDirtyFlag: number;
  83909. /**
  83910. * The dirty light flag value
  83911. */
  83912. static readonly LightDirtyFlag: number;
  83913. /**
  83914. * The dirty fresnel flag value
  83915. */
  83916. static readonly FresnelDirtyFlag: number;
  83917. /**
  83918. * The dirty attribute flag value
  83919. */
  83920. static readonly AttributesDirtyFlag: number;
  83921. /**
  83922. * The dirty misc flag value
  83923. */
  83924. static readonly MiscDirtyFlag: number;
  83925. /**
  83926. * The all dirty flag value
  83927. */
  83928. static readonly AllDirtyFlag: number;
  83929. /**
  83930. * The ID of the material
  83931. */
  83932. id: string;
  83933. /**
  83934. * Gets or sets the unique id of the material
  83935. */
  83936. uniqueId: number;
  83937. /**
  83938. * The name of the material
  83939. */
  83940. name: string;
  83941. /**
  83942. * Gets or sets user defined metadata
  83943. */
  83944. metadata: any;
  83945. /**
  83946. * For internal use only. Please do not use.
  83947. */
  83948. reservedDataStore: any;
  83949. /**
  83950. * Specifies if the ready state should be checked on each call
  83951. */
  83952. checkReadyOnEveryCall: boolean;
  83953. /**
  83954. * Specifies if the ready state should be checked once
  83955. */
  83956. checkReadyOnlyOnce: boolean;
  83957. /**
  83958. * The state of the material
  83959. */
  83960. state: string;
  83961. /**
  83962. * The alpha value of the material
  83963. */
  83964. protected _alpha: number;
  83965. /**
  83966. * List of inspectable custom properties (used by the Inspector)
  83967. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  83968. */
  83969. inspectableCustomProperties: IInspectable[];
  83970. /**
  83971. * Sets the alpha value of the material
  83972. */
  83973. /**
  83974. * Gets the alpha value of the material
  83975. */
  83976. alpha: number;
  83977. /**
  83978. * Specifies if back face culling is enabled
  83979. */
  83980. protected _backFaceCulling: boolean;
  83981. /**
  83982. * Sets the back-face culling state
  83983. */
  83984. /**
  83985. * Gets the back-face culling state
  83986. */
  83987. backFaceCulling: boolean;
  83988. /**
  83989. * Stores the value for side orientation
  83990. */
  83991. sideOrientation: number;
  83992. /**
  83993. * Callback triggered when the material is compiled
  83994. */
  83995. onCompiled: Nullable<(effect: Effect) => void>;
  83996. /**
  83997. * Callback triggered when an error occurs
  83998. */
  83999. onError: Nullable<(effect: Effect, errors: string) => void>;
  84000. /**
  84001. * Callback triggered to get the render target textures
  84002. */
  84003. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  84004. /**
  84005. * Gets a boolean indicating that current material needs to register RTT
  84006. */
  84007. readonly hasRenderTargetTextures: boolean;
  84008. /**
  84009. * Specifies if the material should be serialized
  84010. */
  84011. doNotSerialize: boolean;
  84012. /**
  84013. * @hidden
  84014. */
  84015. _storeEffectOnSubMeshes: boolean;
  84016. /**
  84017. * Stores the animations for the material
  84018. */
  84019. animations: Nullable<Array<Animation>>;
  84020. /**
  84021. * An event triggered when the material is disposed
  84022. */
  84023. onDisposeObservable: Observable<Material>;
  84024. /**
  84025. * An observer which watches for dispose events
  84026. */
  84027. private _onDisposeObserver;
  84028. private _onUnBindObservable;
  84029. /**
  84030. * Called during a dispose event
  84031. */
  84032. onDispose: () => void;
  84033. private _onBindObservable;
  84034. /**
  84035. * An event triggered when the material is bound
  84036. */
  84037. readonly onBindObservable: Observable<AbstractMesh>;
  84038. /**
  84039. * An observer which watches for bind events
  84040. */
  84041. private _onBindObserver;
  84042. /**
  84043. * Called during a bind event
  84044. */
  84045. onBind: (Mesh: AbstractMesh) => void;
  84046. /**
  84047. * An event triggered when the material is unbound
  84048. */
  84049. readonly onUnBindObservable: Observable<Material>;
  84050. /**
  84051. * Stores the value of the alpha mode
  84052. */
  84053. private _alphaMode;
  84054. /**
  84055. * Sets the value of the alpha mode.
  84056. *
  84057. * | Value | Type | Description |
  84058. * | --- | --- | --- |
  84059. * | 0 | ALPHA_DISABLE | |
  84060. * | 1 | ALPHA_ADD | |
  84061. * | 2 | ALPHA_COMBINE | |
  84062. * | 3 | ALPHA_SUBTRACT | |
  84063. * | 4 | ALPHA_MULTIPLY | |
  84064. * | 5 | ALPHA_MAXIMIZED | |
  84065. * | 6 | ALPHA_ONEONE | |
  84066. * | 7 | ALPHA_PREMULTIPLIED | |
  84067. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  84068. * | 9 | ALPHA_INTERPOLATE | |
  84069. * | 10 | ALPHA_SCREENMODE | |
  84070. *
  84071. */
  84072. /**
  84073. * Gets the value of the alpha mode
  84074. */
  84075. alphaMode: number;
  84076. /**
  84077. * Stores the state of the need depth pre-pass value
  84078. */
  84079. private _needDepthPrePass;
  84080. /**
  84081. * Sets the need depth pre-pass value
  84082. */
  84083. /**
  84084. * Gets the depth pre-pass value
  84085. */
  84086. needDepthPrePass: boolean;
  84087. /**
  84088. * Specifies if depth writing should be disabled
  84089. */
  84090. disableDepthWrite: boolean;
  84091. /**
  84092. * Specifies if depth writing should be forced
  84093. */
  84094. forceDepthWrite: boolean;
  84095. /**
  84096. * Specifies if there should be a separate pass for culling
  84097. */
  84098. separateCullingPass: boolean;
  84099. /**
  84100. * Stores the state specifing if fog should be enabled
  84101. */
  84102. private _fogEnabled;
  84103. /**
  84104. * Sets the state for enabling fog
  84105. */
  84106. /**
  84107. * Gets the value of the fog enabled state
  84108. */
  84109. fogEnabled: boolean;
  84110. /**
  84111. * Stores the size of points
  84112. */
  84113. pointSize: number;
  84114. /**
  84115. * Stores the z offset value
  84116. */
  84117. zOffset: number;
  84118. /**
  84119. * Gets a value specifying if wireframe mode is enabled
  84120. */
  84121. /**
  84122. * Sets the state of wireframe mode
  84123. */
  84124. wireframe: boolean;
  84125. /**
  84126. * Gets the value specifying if point clouds are enabled
  84127. */
  84128. /**
  84129. * Sets the state of point cloud mode
  84130. */
  84131. pointsCloud: boolean;
  84132. /**
  84133. * Gets the material fill mode
  84134. */
  84135. /**
  84136. * Sets the material fill mode
  84137. */
  84138. fillMode: number;
  84139. /**
  84140. * @hidden
  84141. * Stores the effects for the material
  84142. */
  84143. _effect: Nullable<Effect>;
  84144. /**
  84145. * @hidden
  84146. * Specifies if the material was previously ready
  84147. */
  84148. _wasPreviouslyReady: boolean;
  84149. /**
  84150. * Specifies if uniform buffers should be used
  84151. */
  84152. private _useUBO;
  84153. /**
  84154. * Stores a reference to the scene
  84155. */
  84156. private _scene;
  84157. /**
  84158. * Stores the fill mode state
  84159. */
  84160. private _fillMode;
  84161. /**
  84162. * Specifies if the depth write state should be cached
  84163. */
  84164. private _cachedDepthWriteState;
  84165. /**
  84166. * Stores the uniform buffer
  84167. */
  84168. protected _uniformBuffer: UniformBuffer;
  84169. /** @hidden */
  84170. _indexInSceneMaterialArray: number;
  84171. /** @hidden */
  84172. meshMap: Nullable<{
  84173. [id: string]: AbstractMesh | undefined;
  84174. }>;
  84175. /**
  84176. * Creates a material instance
  84177. * @param name defines the name of the material
  84178. * @param scene defines the scene to reference
  84179. * @param doNotAdd specifies if the material should be added to the scene
  84180. */
  84181. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  84182. /**
  84183. * Returns a string representation of the current material
  84184. * @param fullDetails defines a boolean indicating which levels of logging is desired
  84185. * @returns a string with material information
  84186. */
  84187. toString(fullDetails?: boolean): string;
  84188. /**
  84189. * Gets the class name of the material
  84190. * @returns a string with the class name of the material
  84191. */
  84192. getClassName(): string;
  84193. /**
  84194. * Specifies if updates for the material been locked
  84195. */
  84196. readonly isFrozen: boolean;
  84197. /**
  84198. * Locks updates for the material
  84199. */
  84200. freeze(): void;
  84201. /**
  84202. * Unlocks updates for the material
  84203. */
  84204. unfreeze(): void;
  84205. /**
  84206. * Specifies if the material is ready to be used
  84207. * @param mesh defines the mesh to check
  84208. * @param useInstances specifies if instances should be used
  84209. * @returns a boolean indicating if the material is ready to be used
  84210. */
  84211. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  84212. /**
  84213. * Specifies that the submesh is ready to be used
  84214. * @param mesh defines the mesh to check
  84215. * @param subMesh defines which submesh to check
  84216. * @param useInstances specifies that instances should be used
  84217. * @returns a boolean indicating that the submesh is ready or not
  84218. */
  84219. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  84220. /**
  84221. * Returns the material effect
  84222. * @returns the effect associated with the material
  84223. */
  84224. getEffect(): Nullable<Effect>;
  84225. /**
  84226. * Returns the current scene
  84227. * @returns a Scene
  84228. */
  84229. getScene(): Scene;
  84230. /**
  84231. * Specifies if the material will require alpha blending
  84232. * @returns a boolean specifying if alpha blending is needed
  84233. */
  84234. needAlphaBlending(): boolean;
  84235. /**
  84236. * Specifies if the mesh will require alpha blending
  84237. * @param mesh defines the mesh to check
  84238. * @returns a boolean specifying if alpha blending is needed for the mesh
  84239. */
  84240. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  84241. /**
  84242. * Specifies if this material should be rendered in alpha test mode
  84243. * @returns a boolean specifying if an alpha test is needed.
  84244. */
  84245. needAlphaTesting(): boolean;
  84246. /**
  84247. * Gets the texture used for the alpha test
  84248. * @returns the texture to use for alpha testing
  84249. */
  84250. getAlphaTestTexture(): Nullable<BaseTexture>;
  84251. /**
  84252. * Marks the material to indicate that it needs to be re-calculated
  84253. */
  84254. markDirty(): void;
  84255. /** @hidden */
  84256. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  84257. /**
  84258. * Binds the material to the mesh
  84259. * @param world defines the world transformation matrix
  84260. * @param mesh defines the mesh to bind the material to
  84261. */
  84262. bind(world: Matrix, mesh?: Mesh): void;
  84263. /**
  84264. * Binds the submesh to the material
  84265. * @param world defines the world transformation matrix
  84266. * @param mesh defines the mesh containing the submesh
  84267. * @param subMesh defines the submesh to bind the material to
  84268. */
  84269. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  84270. /**
  84271. * Binds the world matrix to the material
  84272. * @param world defines the world transformation matrix
  84273. */
  84274. bindOnlyWorldMatrix(world: Matrix): void;
  84275. /**
  84276. * Binds the scene's uniform buffer to the effect.
  84277. * @param effect defines the effect to bind to the scene uniform buffer
  84278. * @param sceneUbo defines the uniform buffer storing scene data
  84279. */
  84280. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  84281. /**
  84282. * Binds the view matrix to the effect
  84283. * @param effect defines the effect to bind the view matrix to
  84284. */
  84285. bindView(effect: Effect): void;
  84286. /**
  84287. * Binds the view projection matrix to the effect
  84288. * @param effect defines the effect to bind the view projection matrix to
  84289. */
  84290. bindViewProjection(effect: Effect): void;
  84291. /**
  84292. * Specifies if material alpha testing should be turned on for the mesh
  84293. * @param mesh defines the mesh to check
  84294. */
  84295. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  84296. /**
  84297. * Processes to execute after binding the material to a mesh
  84298. * @param mesh defines the rendered mesh
  84299. */
  84300. protected _afterBind(mesh?: Mesh): void;
  84301. /**
  84302. * Unbinds the material from the mesh
  84303. */
  84304. unbind(): void;
  84305. /**
  84306. * Gets the active textures from the material
  84307. * @returns an array of textures
  84308. */
  84309. getActiveTextures(): BaseTexture[];
  84310. /**
  84311. * Specifies if the material uses a texture
  84312. * @param texture defines the texture to check against the material
  84313. * @returns a boolean specifying if the material uses the texture
  84314. */
  84315. hasTexture(texture: BaseTexture): boolean;
  84316. /**
  84317. * Makes a duplicate of the material, and gives it a new name
  84318. * @param name defines the new name for the duplicated material
  84319. * @returns the cloned material
  84320. */
  84321. clone(name: string): Nullable<Material>;
  84322. /**
  84323. * Gets the meshes bound to the material
  84324. * @returns an array of meshes bound to the material
  84325. */
  84326. getBindedMeshes(): AbstractMesh[];
  84327. /**
  84328. * Force shader compilation
  84329. * @param mesh defines the mesh associated with this material
  84330. * @param onCompiled defines a function to execute once the material is compiled
  84331. * @param options defines the options to configure the compilation
  84332. */
  84333. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  84334. clipPlane: boolean;
  84335. }>): void;
  84336. /**
  84337. * Force shader compilation
  84338. * @param mesh defines the mesh that will use this material
  84339. * @param options defines additional options for compiling the shaders
  84340. * @returns a promise that resolves when the compilation completes
  84341. */
  84342. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  84343. clipPlane: boolean;
  84344. }>): Promise<void>;
  84345. private static readonly _AllDirtyCallBack;
  84346. private static readonly _ImageProcessingDirtyCallBack;
  84347. private static readonly _TextureDirtyCallBack;
  84348. private static readonly _FresnelDirtyCallBack;
  84349. private static readonly _MiscDirtyCallBack;
  84350. private static readonly _LightsDirtyCallBack;
  84351. private static readonly _AttributeDirtyCallBack;
  84352. private static _FresnelAndMiscDirtyCallBack;
  84353. private static _TextureAndMiscDirtyCallBack;
  84354. private static readonly _DirtyCallbackArray;
  84355. private static readonly _RunDirtyCallBacks;
  84356. /**
  84357. * Marks a define in the material to indicate that it needs to be re-computed
  84358. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  84359. */
  84360. markAsDirty(flag: number): void;
  84361. /**
  84362. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  84363. * @param func defines a function which checks material defines against the submeshes
  84364. */
  84365. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  84366. /**
  84367. * Indicates that we need to re-calculated for all submeshes
  84368. */
  84369. protected _markAllSubMeshesAsAllDirty(): void;
  84370. /**
  84371. * Indicates that image processing needs to be re-calculated for all submeshes
  84372. */
  84373. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  84374. /**
  84375. * Indicates that textures need to be re-calculated for all submeshes
  84376. */
  84377. protected _markAllSubMeshesAsTexturesDirty(): void;
  84378. /**
  84379. * Indicates that fresnel needs to be re-calculated for all submeshes
  84380. */
  84381. protected _markAllSubMeshesAsFresnelDirty(): void;
  84382. /**
  84383. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  84384. */
  84385. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  84386. /**
  84387. * Indicates that lights need to be re-calculated for all submeshes
  84388. */
  84389. protected _markAllSubMeshesAsLightsDirty(): void;
  84390. /**
  84391. * Indicates that attributes need to be re-calculated for all submeshes
  84392. */
  84393. protected _markAllSubMeshesAsAttributesDirty(): void;
  84394. /**
  84395. * Indicates that misc needs to be re-calculated for all submeshes
  84396. */
  84397. protected _markAllSubMeshesAsMiscDirty(): void;
  84398. /**
  84399. * Indicates that textures and misc need to be re-calculated for all submeshes
  84400. */
  84401. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  84402. /**
  84403. * Disposes the material
  84404. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  84405. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  84406. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  84407. */
  84408. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  84409. /** @hidden */
  84410. private releaseVertexArrayObject;
  84411. /**
  84412. * Serializes this material
  84413. * @returns the serialized material object
  84414. */
  84415. serialize(): any;
  84416. /**
  84417. * Creates a material from parsed material data
  84418. * @param parsedMaterial defines parsed material data
  84419. * @param scene defines the hosting scene
  84420. * @param rootUrl defines the root URL to use to load textures
  84421. * @returns a new material
  84422. */
  84423. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  84424. }
  84425. }
  84426. declare module BABYLON {
  84427. /**
  84428. * Base class for submeshes
  84429. */
  84430. export class BaseSubMesh {
  84431. /** @hidden */
  84432. _materialDefines: Nullable<MaterialDefines>;
  84433. /** @hidden */
  84434. _materialEffect: Nullable<Effect>;
  84435. /**
  84436. * Gets associated effect
  84437. */
  84438. readonly effect: Nullable<Effect>;
  84439. /**
  84440. * Sets associated effect (effect used to render this submesh)
  84441. * @param effect defines the effect to associate with
  84442. * @param defines defines the set of defines used to compile this effect
  84443. */
  84444. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  84445. }
  84446. /**
  84447. * Defines a subdivision inside a mesh
  84448. */
  84449. export class SubMesh extends BaseSubMesh implements ICullable {
  84450. /** the material index to use */
  84451. materialIndex: number;
  84452. /** vertex index start */
  84453. verticesStart: number;
  84454. /** vertices count */
  84455. verticesCount: number;
  84456. /** index start */
  84457. indexStart: number;
  84458. /** indices count */
  84459. indexCount: number;
  84460. /** @hidden */
  84461. _linesIndexCount: number;
  84462. private _mesh;
  84463. private _renderingMesh;
  84464. private _boundingInfo;
  84465. private _linesIndexBuffer;
  84466. /** @hidden */
  84467. _lastColliderWorldVertices: Nullable<Vector3[]>;
  84468. /** @hidden */
  84469. _trianglePlanes: Plane[];
  84470. /** @hidden */
  84471. _lastColliderTransformMatrix: Nullable<Matrix>;
  84472. /** @hidden */
  84473. _renderId: number;
  84474. /** @hidden */
  84475. _alphaIndex: number;
  84476. /** @hidden */
  84477. _distanceToCamera: number;
  84478. /** @hidden */
  84479. _id: number;
  84480. private _currentMaterial;
  84481. /**
  84482. * Add a new submesh to a mesh
  84483. * @param materialIndex defines the material index to use
  84484. * @param verticesStart defines vertex index start
  84485. * @param verticesCount defines vertices count
  84486. * @param indexStart defines index start
  84487. * @param indexCount defines indices count
  84488. * @param mesh defines the parent mesh
  84489. * @param renderingMesh defines an optional rendering mesh
  84490. * @param createBoundingBox defines if bounding box should be created for this submesh
  84491. * @returns the new submesh
  84492. */
  84493. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  84494. /**
  84495. * Creates a new submesh
  84496. * @param materialIndex defines the material index to use
  84497. * @param verticesStart defines vertex index start
  84498. * @param verticesCount defines vertices count
  84499. * @param indexStart defines index start
  84500. * @param indexCount defines indices count
  84501. * @param mesh defines the parent mesh
  84502. * @param renderingMesh defines an optional rendering mesh
  84503. * @param createBoundingBox defines if bounding box should be created for this submesh
  84504. */
  84505. constructor(
  84506. /** the material index to use */
  84507. materialIndex: number,
  84508. /** vertex index start */
  84509. verticesStart: number,
  84510. /** vertices count */
  84511. verticesCount: number,
  84512. /** index start */
  84513. indexStart: number,
  84514. /** indices count */
  84515. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  84516. /**
  84517. * Returns true if this submesh covers the entire parent mesh
  84518. * @ignorenaming
  84519. */
  84520. readonly IsGlobal: boolean;
  84521. /**
  84522. * Returns the submesh BoudingInfo object
  84523. * @returns current bounding info (or mesh's one if the submesh is global)
  84524. */
  84525. getBoundingInfo(): BoundingInfo;
  84526. /**
  84527. * Sets the submesh BoundingInfo
  84528. * @param boundingInfo defines the new bounding info to use
  84529. * @returns the SubMesh
  84530. */
  84531. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  84532. /**
  84533. * Returns the mesh of the current submesh
  84534. * @return the parent mesh
  84535. */
  84536. getMesh(): AbstractMesh;
  84537. /**
  84538. * Returns the rendering mesh of the submesh
  84539. * @returns the rendering mesh (could be different from parent mesh)
  84540. */
  84541. getRenderingMesh(): Mesh;
  84542. /**
  84543. * Returns the submesh material
  84544. * @returns null or the current material
  84545. */
  84546. getMaterial(): Nullable<Material>;
  84547. /**
  84548. * Sets a new updated BoundingInfo object to the submesh
  84549. * @param data defines an optional position array to use to determine the bounding info
  84550. * @returns the SubMesh
  84551. */
  84552. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  84553. /** @hidden */
  84554. _checkCollision(collider: Collider): boolean;
  84555. /**
  84556. * Updates the submesh BoundingInfo
  84557. * @param world defines the world matrix to use to update the bounding info
  84558. * @returns the submesh
  84559. */
  84560. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  84561. /**
  84562. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  84563. * @param frustumPlanes defines the frustum planes
  84564. * @returns true if the submesh is intersecting with the frustum
  84565. */
  84566. isInFrustum(frustumPlanes: Plane[]): boolean;
  84567. /**
  84568. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  84569. * @param frustumPlanes defines the frustum planes
  84570. * @returns true if the submesh is inside the frustum
  84571. */
  84572. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  84573. /**
  84574. * Renders the submesh
  84575. * @param enableAlphaMode defines if alpha needs to be used
  84576. * @returns the submesh
  84577. */
  84578. render(enableAlphaMode: boolean): SubMesh;
  84579. /**
  84580. * @hidden
  84581. */
  84582. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  84583. /**
  84584. * Checks if the submesh intersects with a ray
  84585. * @param ray defines the ray to test
  84586. * @returns true is the passed ray intersects the submesh bounding box
  84587. */
  84588. canIntersects(ray: Ray): boolean;
  84589. /**
  84590. * Intersects current submesh with a ray
  84591. * @param ray defines the ray to test
  84592. * @param positions defines mesh's positions array
  84593. * @param indices defines mesh's indices array
  84594. * @param fastCheck defines if only bounding info should be used
  84595. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  84596. * @returns intersection info or null if no intersection
  84597. */
  84598. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  84599. /** @hidden */
  84600. private _intersectLines;
  84601. /** @hidden */
  84602. private _intersectUnIndexedLines;
  84603. /** @hidden */
  84604. private _intersectTriangles;
  84605. /** @hidden */
  84606. private _intersectUnIndexedTriangles;
  84607. /** @hidden */
  84608. _rebuild(): void;
  84609. /**
  84610. * Creates a new submesh from the passed mesh
  84611. * @param newMesh defines the new hosting mesh
  84612. * @param newRenderingMesh defines an optional rendering mesh
  84613. * @returns the new submesh
  84614. */
  84615. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  84616. /**
  84617. * Release associated resources
  84618. */
  84619. dispose(): void;
  84620. /**
  84621. * Gets the class name
  84622. * @returns the string "SubMesh".
  84623. */
  84624. getClassName(): string;
  84625. /**
  84626. * Creates a new submesh from indices data
  84627. * @param materialIndex the index of the main mesh material
  84628. * @param startIndex the index where to start the copy in the mesh indices array
  84629. * @param indexCount the number of indices to copy then from the startIndex
  84630. * @param mesh the main mesh to create the submesh from
  84631. * @param renderingMesh the optional rendering mesh
  84632. * @returns a new submesh
  84633. */
  84634. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  84635. }
  84636. }
  84637. declare module BABYLON {
  84638. /**
  84639. * Class used to store geometry data (vertex buffers + index buffer)
  84640. */
  84641. export class Geometry implements IGetSetVerticesData {
  84642. /**
  84643. * Gets or sets the ID of the geometry
  84644. */
  84645. id: string;
  84646. /**
  84647. * Gets or sets the unique ID of the geometry
  84648. */
  84649. uniqueId: number;
  84650. /**
  84651. * Gets the delay loading state of the geometry (none by default which means not delayed)
  84652. */
  84653. delayLoadState: number;
  84654. /**
  84655. * Gets the file containing the data to load when running in delay load state
  84656. */
  84657. delayLoadingFile: Nullable<string>;
  84658. /**
  84659. * Callback called when the geometry is updated
  84660. */
  84661. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  84662. private _scene;
  84663. private _engine;
  84664. private _meshes;
  84665. private _totalVertices;
  84666. /** @hidden */
  84667. _indices: IndicesArray;
  84668. /** @hidden */
  84669. _vertexBuffers: {
  84670. [key: string]: VertexBuffer;
  84671. };
  84672. private _isDisposed;
  84673. private _extend;
  84674. private _boundingBias;
  84675. /** @hidden */
  84676. _delayInfo: Array<string>;
  84677. private _indexBuffer;
  84678. private _indexBufferIsUpdatable;
  84679. /** @hidden */
  84680. _boundingInfo: Nullable<BoundingInfo>;
  84681. /** @hidden */
  84682. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  84683. /** @hidden */
  84684. _softwareSkinningFrameId: number;
  84685. private _vertexArrayObjects;
  84686. private _updatable;
  84687. /** @hidden */
  84688. _positions: Nullable<Vector3[]>;
  84689. /**
  84690. * 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
  84691. */
  84692. /**
  84693. * 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
  84694. */
  84695. boundingBias: Vector2;
  84696. /**
  84697. * Static function used to attach a new empty geometry to a mesh
  84698. * @param mesh defines the mesh to attach the geometry to
  84699. * @returns the new Geometry
  84700. */
  84701. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  84702. /**
  84703. * Creates a new geometry
  84704. * @param id defines the unique ID
  84705. * @param scene defines the hosting scene
  84706. * @param vertexData defines the VertexData used to get geometry data
  84707. * @param updatable defines if geometry must be updatable (false by default)
  84708. * @param mesh defines the mesh that will be associated with the geometry
  84709. */
  84710. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  84711. /**
  84712. * Gets the current extend of the geometry
  84713. */
  84714. readonly extend: {
  84715. minimum: Vector3;
  84716. maximum: Vector3;
  84717. };
  84718. /**
  84719. * Gets the hosting scene
  84720. * @returns the hosting Scene
  84721. */
  84722. getScene(): Scene;
  84723. /**
  84724. * Gets the hosting engine
  84725. * @returns the hosting Engine
  84726. */
  84727. getEngine(): Engine;
  84728. /**
  84729. * Defines if the geometry is ready to use
  84730. * @returns true if the geometry is ready to be used
  84731. */
  84732. isReady(): boolean;
  84733. /**
  84734. * Gets a value indicating that the geometry should not be serialized
  84735. */
  84736. readonly doNotSerialize: boolean;
  84737. /** @hidden */
  84738. _rebuild(): void;
  84739. /**
  84740. * Affects all geometry data in one call
  84741. * @param vertexData defines the geometry data
  84742. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  84743. */
  84744. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  84745. /**
  84746. * Set specific vertex data
  84747. * @param kind defines the data kind (Position, normal, etc...)
  84748. * @param data defines the vertex data to use
  84749. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  84750. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  84751. */
  84752. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  84753. /**
  84754. * Removes a specific vertex data
  84755. * @param kind defines the data kind (Position, normal, etc...)
  84756. */
  84757. removeVerticesData(kind: string): void;
  84758. /**
  84759. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  84760. * @param buffer defines the vertex buffer to use
  84761. * @param totalVertices defines the total number of vertices for position kind (could be null)
  84762. */
  84763. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  84764. /**
  84765. * Update a specific vertex buffer
  84766. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  84767. * It will do nothing if the buffer is not updatable
  84768. * @param kind defines the data kind (Position, normal, etc...)
  84769. * @param data defines the data to use
  84770. * @param offset defines the offset in the target buffer where to store the data
  84771. * @param useBytes set to true if the offset is in bytes
  84772. */
  84773. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  84774. /**
  84775. * Update a specific vertex buffer
  84776. * This function will create a new buffer if the current one is not updatable
  84777. * @param kind defines the data kind (Position, normal, etc...)
  84778. * @param data defines the data to use
  84779. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  84780. */
  84781. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  84782. private _updateBoundingInfo;
  84783. /** @hidden */
  84784. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  84785. /**
  84786. * Gets total number of vertices
  84787. * @returns the total number of vertices
  84788. */
  84789. getTotalVertices(): number;
  84790. /**
  84791. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  84792. * @param kind defines the data kind (Position, normal, etc...)
  84793. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  84794. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  84795. * @returns a float array containing vertex data
  84796. */
  84797. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  84798. /**
  84799. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  84800. * @param kind defines the data kind (Position, normal, etc...)
  84801. * @returns true if the vertex buffer with the specified kind is updatable
  84802. */
  84803. isVertexBufferUpdatable(kind: string): boolean;
  84804. /**
  84805. * Gets a specific vertex buffer
  84806. * @param kind defines the data kind (Position, normal, etc...)
  84807. * @returns a VertexBuffer
  84808. */
  84809. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  84810. /**
  84811. * Returns all vertex buffers
  84812. * @return an object holding all vertex buffers indexed by kind
  84813. */
  84814. getVertexBuffers(): Nullable<{
  84815. [key: string]: VertexBuffer;
  84816. }>;
  84817. /**
  84818. * Gets a boolean indicating if specific vertex buffer is present
  84819. * @param kind defines the data kind (Position, normal, etc...)
  84820. * @returns true if data is present
  84821. */
  84822. isVerticesDataPresent(kind: string): boolean;
  84823. /**
  84824. * Gets a list of all attached data kinds (Position, normal, etc...)
  84825. * @returns a list of string containing all kinds
  84826. */
  84827. getVerticesDataKinds(): string[];
  84828. /**
  84829. * Update index buffer
  84830. * @param indices defines the indices to store in the index buffer
  84831. * @param offset defines the offset in the target buffer where to store the data
  84832. * @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)
  84833. */
  84834. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  84835. /**
  84836. * Creates a new index buffer
  84837. * @param indices defines the indices to store in the index buffer
  84838. * @param totalVertices defines the total number of vertices (could be null)
  84839. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  84840. */
  84841. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  84842. /**
  84843. * Return the total number of indices
  84844. * @returns the total number of indices
  84845. */
  84846. getTotalIndices(): number;
  84847. /**
  84848. * Gets the index buffer array
  84849. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  84850. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  84851. * @returns the index buffer array
  84852. */
  84853. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  84854. /**
  84855. * Gets the index buffer
  84856. * @return the index buffer
  84857. */
  84858. getIndexBuffer(): Nullable<DataBuffer>;
  84859. /** @hidden */
  84860. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  84861. /**
  84862. * Release the associated resources for a specific mesh
  84863. * @param mesh defines the source mesh
  84864. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  84865. */
  84866. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  84867. /**
  84868. * Apply current geometry to a given mesh
  84869. * @param mesh defines the mesh to apply geometry to
  84870. */
  84871. applyToMesh(mesh: Mesh): void;
  84872. private _updateExtend;
  84873. private _applyToMesh;
  84874. private notifyUpdate;
  84875. /**
  84876. * Load the geometry if it was flagged as delay loaded
  84877. * @param scene defines the hosting scene
  84878. * @param onLoaded defines a callback called when the geometry is loaded
  84879. */
  84880. load(scene: Scene, onLoaded?: () => void): void;
  84881. private _queueLoad;
  84882. /**
  84883. * Invert the geometry to move from a right handed system to a left handed one.
  84884. */
  84885. toLeftHanded(): void;
  84886. /** @hidden */
  84887. _resetPointsArrayCache(): void;
  84888. /** @hidden */
  84889. _generatePointsArray(): boolean;
  84890. /**
  84891. * Gets a value indicating if the geometry is disposed
  84892. * @returns true if the geometry was disposed
  84893. */
  84894. isDisposed(): boolean;
  84895. private _disposeVertexArrayObjects;
  84896. /**
  84897. * Free all associated resources
  84898. */
  84899. dispose(): void;
  84900. /**
  84901. * Clone the current geometry into a new geometry
  84902. * @param id defines the unique ID of the new geometry
  84903. * @returns a new geometry object
  84904. */
  84905. copy(id: string): Geometry;
  84906. /**
  84907. * Serialize the current geometry info (and not the vertices data) into a JSON object
  84908. * @return a JSON representation of the current geometry data (without the vertices data)
  84909. */
  84910. serialize(): any;
  84911. private toNumberArray;
  84912. /**
  84913. * Serialize all vertices data into a JSON oject
  84914. * @returns a JSON representation of the current geometry data
  84915. */
  84916. serializeVerticeData(): any;
  84917. /**
  84918. * Extracts a clone of a mesh geometry
  84919. * @param mesh defines the source mesh
  84920. * @param id defines the unique ID of the new geometry object
  84921. * @returns the new geometry object
  84922. */
  84923. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  84924. /**
  84925. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  84926. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  84927. * Be aware Math.random() could cause collisions, but:
  84928. * "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"
  84929. * @returns a string containing a new GUID
  84930. */
  84931. static RandomId(): string;
  84932. /** @hidden */
  84933. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  84934. private static _CleanMatricesWeights;
  84935. /**
  84936. * Create a new geometry from persisted data (Using .babylon file format)
  84937. * @param parsedVertexData defines the persisted data
  84938. * @param scene defines the hosting scene
  84939. * @param rootUrl defines the root url to use to load assets (like delayed data)
  84940. * @returns the new geometry object
  84941. */
  84942. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  84943. }
  84944. }
  84945. declare module BABYLON {
  84946. /**
  84947. * Define an interface for all classes that will get and set the data on vertices
  84948. */
  84949. export interface IGetSetVerticesData {
  84950. /**
  84951. * Gets a boolean indicating if specific vertex data is present
  84952. * @param kind defines the vertex data kind to use
  84953. * @returns true is data kind is present
  84954. */
  84955. isVerticesDataPresent(kind: string): boolean;
  84956. /**
  84957. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  84958. * @param kind defines the data kind (Position, normal, etc...)
  84959. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  84960. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  84961. * @returns a float array containing vertex data
  84962. */
  84963. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  84964. /**
  84965. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  84966. * @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.
  84967. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  84968. * @returns the indices array or an empty array if the mesh has no geometry
  84969. */
  84970. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  84971. /**
  84972. * Set specific vertex data
  84973. * @param kind defines the data kind (Position, normal, etc...)
  84974. * @param data defines the vertex data to use
  84975. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  84976. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  84977. */
  84978. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  84979. /**
  84980. * Update a specific associated vertex buffer
  84981. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  84982. * - VertexBuffer.PositionKind
  84983. * - VertexBuffer.UVKind
  84984. * - VertexBuffer.UV2Kind
  84985. * - VertexBuffer.UV3Kind
  84986. * - VertexBuffer.UV4Kind
  84987. * - VertexBuffer.UV5Kind
  84988. * - VertexBuffer.UV6Kind
  84989. * - VertexBuffer.ColorKind
  84990. * - VertexBuffer.MatricesIndicesKind
  84991. * - VertexBuffer.MatricesIndicesExtraKind
  84992. * - VertexBuffer.MatricesWeightsKind
  84993. * - VertexBuffer.MatricesWeightsExtraKind
  84994. * @param data defines the data source
  84995. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  84996. * @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)
  84997. */
  84998. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  84999. /**
  85000. * Creates a new index buffer
  85001. * @param indices defines the indices to store in the index buffer
  85002. * @param totalVertices defines the total number of vertices (could be null)
  85003. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  85004. */
  85005. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  85006. }
  85007. /**
  85008. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  85009. */
  85010. export class VertexData {
  85011. /**
  85012. * Mesh side orientation : usually the external or front surface
  85013. */
  85014. static readonly FRONTSIDE: number;
  85015. /**
  85016. * Mesh side orientation : usually the internal or back surface
  85017. */
  85018. static readonly BACKSIDE: number;
  85019. /**
  85020. * Mesh side orientation : both internal and external or front and back surfaces
  85021. */
  85022. static readonly DOUBLESIDE: number;
  85023. /**
  85024. * Mesh side orientation : by default, `FRONTSIDE`
  85025. */
  85026. static readonly DEFAULTSIDE: number;
  85027. /**
  85028. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  85029. */
  85030. positions: Nullable<FloatArray>;
  85031. /**
  85032. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  85033. */
  85034. normals: Nullable<FloatArray>;
  85035. /**
  85036. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  85037. */
  85038. tangents: Nullable<FloatArray>;
  85039. /**
  85040. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  85041. */
  85042. uvs: Nullable<FloatArray>;
  85043. /**
  85044. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  85045. */
  85046. uvs2: Nullable<FloatArray>;
  85047. /**
  85048. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  85049. */
  85050. uvs3: Nullable<FloatArray>;
  85051. /**
  85052. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  85053. */
  85054. uvs4: Nullable<FloatArray>;
  85055. /**
  85056. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  85057. */
  85058. uvs5: Nullable<FloatArray>;
  85059. /**
  85060. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  85061. */
  85062. uvs6: Nullable<FloatArray>;
  85063. /**
  85064. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  85065. */
  85066. colors: Nullable<FloatArray>;
  85067. /**
  85068. * 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).
  85069. */
  85070. matricesIndices: Nullable<FloatArray>;
  85071. /**
  85072. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  85073. */
  85074. matricesWeights: Nullable<FloatArray>;
  85075. /**
  85076. * An array extending the number of possible indices
  85077. */
  85078. matricesIndicesExtra: Nullable<FloatArray>;
  85079. /**
  85080. * An array extending the number of possible weights when the number of indices is extended
  85081. */
  85082. matricesWeightsExtra: Nullable<FloatArray>;
  85083. /**
  85084. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  85085. */
  85086. indices: Nullable<IndicesArray>;
  85087. /**
  85088. * Uses the passed data array to set the set the values for the specified kind of data
  85089. * @param data a linear array of floating numbers
  85090. * @param kind the type of data that is being set, eg positions, colors etc
  85091. */
  85092. set(data: FloatArray, kind: string): void;
  85093. /**
  85094. * Associates the vertexData to the passed Mesh.
  85095. * Sets it as updatable or not (default `false`)
  85096. * @param mesh the mesh the vertexData is applied to
  85097. * @param updatable when used and having the value true allows new data to update the vertexData
  85098. * @returns the VertexData
  85099. */
  85100. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  85101. /**
  85102. * Associates the vertexData to the passed Geometry.
  85103. * Sets it as updatable or not (default `false`)
  85104. * @param geometry the geometry the vertexData is applied to
  85105. * @param updatable when used and having the value true allows new data to update the vertexData
  85106. * @returns VertexData
  85107. */
  85108. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  85109. /**
  85110. * Updates the associated mesh
  85111. * @param mesh the mesh to be updated
  85112. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  85113. * @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
  85114. * @returns VertexData
  85115. */
  85116. updateMesh(mesh: Mesh): VertexData;
  85117. /**
  85118. * Updates the associated geometry
  85119. * @param geometry the geometry to be updated
  85120. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  85121. * @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
  85122. * @returns VertexData.
  85123. */
  85124. updateGeometry(geometry: Geometry): VertexData;
  85125. private _applyTo;
  85126. private _update;
  85127. /**
  85128. * Transforms each position and each normal of the vertexData according to the passed Matrix
  85129. * @param matrix the transforming matrix
  85130. * @returns the VertexData
  85131. */
  85132. transform(matrix: Matrix): VertexData;
  85133. /**
  85134. * Merges the passed VertexData into the current one
  85135. * @param other the VertexData to be merged into the current one
  85136. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  85137. * @returns the modified VertexData
  85138. */
  85139. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  85140. private _mergeElement;
  85141. private _validate;
  85142. /**
  85143. * Serializes the VertexData
  85144. * @returns a serialized object
  85145. */
  85146. serialize(): any;
  85147. /**
  85148. * Extracts the vertexData from a mesh
  85149. * @param mesh the mesh from which to extract the VertexData
  85150. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  85151. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  85152. * @returns the object VertexData associated to the passed mesh
  85153. */
  85154. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  85155. /**
  85156. * Extracts the vertexData from the geometry
  85157. * @param geometry the geometry from which to extract the VertexData
  85158. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  85159. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  85160. * @returns the object VertexData associated to the passed mesh
  85161. */
  85162. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  85163. private static _ExtractFrom;
  85164. /**
  85165. * Creates the VertexData for a Ribbon
  85166. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  85167. * * pathArray array of paths, each of which an array of successive Vector3
  85168. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  85169. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  85170. * * 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
  85171. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85172. * * 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)
  85173. * * 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)
  85174. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  85175. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  85176. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  85177. * @returns the VertexData of the ribbon
  85178. */
  85179. static CreateRibbon(options: {
  85180. pathArray: Vector3[][];
  85181. closeArray?: boolean;
  85182. closePath?: boolean;
  85183. offset?: number;
  85184. sideOrientation?: number;
  85185. frontUVs?: Vector4;
  85186. backUVs?: Vector4;
  85187. invertUV?: boolean;
  85188. uvs?: Vector2[];
  85189. colors?: Color4[];
  85190. }): VertexData;
  85191. /**
  85192. * Creates the VertexData for a box
  85193. * @param options an object used to set the following optional parameters for the box, required but can be empty
  85194. * * size sets the width, height and depth of the box to the value of size, optional default 1
  85195. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  85196. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  85197. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  85198. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  85199. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  85200. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85201. * * 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)
  85202. * * 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)
  85203. * @returns the VertexData of the box
  85204. */
  85205. static CreateBox(options: {
  85206. size?: number;
  85207. width?: number;
  85208. height?: number;
  85209. depth?: number;
  85210. faceUV?: Vector4[];
  85211. faceColors?: Color4[];
  85212. sideOrientation?: number;
  85213. frontUVs?: Vector4;
  85214. backUVs?: Vector4;
  85215. }): VertexData;
  85216. /**
  85217. * Creates the VertexData for a tiled box
  85218. * @param options an object used to set the following optional parameters for the box, required but can be empty
  85219. * * faceTiles sets the pattern, tile size and number of tiles for a face
  85220. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  85221. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  85222. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85223. * @returns the VertexData of the box
  85224. */
  85225. static CreateTiledBox(options: {
  85226. pattern?: number;
  85227. width?: number;
  85228. height?: number;
  85229. depth?: number;
  85230. tileSize?: number;
  85231. tileWidth?: number;
  85232. tileHeight?: number;
  85233. alignHorizontal?: number;
  85234. alignVertical?: number;
  85235. faceUV?: Vector4[];
  85236. faceColors?: Color4[];
  85237. sideOrientation?: number;
  85238. }): VertexData;
  85239. /**
  85240. * Creates the VertexData for a tiled plane
  85241. * @param options an object used to set the following optional parameters for the box, required but can be empty
  85242. * * pattern a limited pattern arrangement depending on the number
  85243. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  85244. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  85245. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  85246. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85247. * * 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)
  85248. * * 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)
  85249. * @returns the VertexData of the tiled plane
  85250. */
  85251. static CreateTiledPlane(options: {
  85252. pattern?: number;
  85253. tileSize?: number;
  85254. tileWidth?: number;
  85255. tileHeight?: number;
  85256. size?: number;
  85257. width?: number;
  85258. height?: number;
  85259. alignHorizontal?: number;
  85260. alignVertical?: number;
  85261. sideOrientation?: number;
  85262. frontUVs?: Vector4;
  85263. backUVs?: Vector4;
  85264. }): VertexData;
  85265. /**
  85266. * Creates the VertexData for an ellipsoid, defaults to a sphere
  85267. * @param options an object used to set the following optional parameters for the box, required but can be empty
  85268. * * segments sets the number of horizontal strips optional, default 32
  85269. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  85270. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  85271. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  85272. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  85273. * * 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
  85274. * * 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
  85275. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85276. * * 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)
  85277. * * 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)
  85278. * @returns the VertexData of the ellipsoid
  85279. */
  85280. static CreateSphere(options: {
  85281. segments?: number;
  85282. diameter?: number;
  85283. diameterX?: number;
  85284. diameterY?: number;
  85285. diameterZ?: number;
  85286. arc?: number;
  85287. slice?: number;
  85288. sideOrientation?: number;
  85289. frontUVs?: Vector4;
  85290. backUVs?: Vector4;
  85291. }): VertexData;
  85292. /**
  85293. * Creates the VertexData for a cylinder, cone or prism
  85294. * @param options an object used to set the following optional parameters for the box, required but can be empty
  85295. * * height sets the height (y direction) of the cylinder, optional, default 2
  85296. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  85297. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  85298. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  85299. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  85300. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  85301. * * 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
  85302. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  85303. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  85304. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  85305. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  85306. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85307. * * 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)
  85308. * * 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)
  85309. * @returns the VertexData of the cylinder, cone or prism
  85310. */
  85311. static CreateCylinder(options: {
  85312. height?: number;
  85313. diameterTop?: number;
  85314. diameterBottom?: number;
  85315. diameter?: number;
  85316. tessellation?: number;
  85317. subdivisions?: number;
  85318. arc?: number;
  85319. faceColors?: Color4[];
  85320. faceUV?: Vector4[];
  85321. hasRings?: boolean;
  85322. enclose?: boolean;
  85323. sideOrientation?: number;
  85324. frontUVs?: Vector4;
  85325. backUVs?: Vector4;
  85326. }): VertexData;
  85327. /**
  85328. * Creates the VertexData for a torus
  85329. * @param options an object used to set the following optional parameters for the box, required but can be empty
  85330. * * diameter the diameter of the torus, optional default 1
  85331. * * thickness the diameter of the tube forming the torus, optional default 0.5
  85332. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  85333. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85334. * * 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)
  85335. * * 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)
  85336. * @returns the VertexData of the torus
  85337. */
  85338. static CreateTorus(options: {
  85339. diameter?: number;
  85340. thickness?: number;
  85341. tessellation?: number;
  85342. sideOrientation?: number;
  85343. frontUVs?: Vector4;
  85344. backUVs?: Vector4;
  85345. }): VertexData;
  85346. /**
  85347. * Creates the VertexData of the LineSystem
  85348. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  85349. * - lines an array of lines, each line being an array of successive Vector3
  85350. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  85351. * @returns the VertexData of the LineSystem
  85352. */
  85353. static CreateLineSystem(options: {
  85354. lines: Vector3[][];
  85355. colors?: Nullable<Color4[][]>;
  85356. }): VertexData;
  85357. /**
  85358. * Create the VertexData for a DashedLines
  85359. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  85360. * - points an array successive Vector3
  85361. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  85362. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  85363. * - dashNb the intended total number of dashes, optional, default 200
  85364. * @returns the VertexData for the DashedLines
  85365. */
  85366. static CreateDashedLines(options: {
  85367. points: Vector3[];
  85368. dashSize?: number;
  85369. gapSize?: number;
  85370. dashNb?: number;
  85371. }): VertexData;
  85372. /**
  85373. * Creates the VertexData for a Ground
  85374. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  85375. * - width the width (x direction) of the ground, optional, default 1
  85376. * - height the height (z direction) of the ground, optional, default 1
  85377. * - subdivisions the number of subdivisions per side, optional, default 1
  85378. * @returns the VertexData of the Ground
  85379. */
  85380. static CreateGround(options: {
  85381. width?: number;
  85382. height?: number;
  85383. subdivisions?: number;
  85384. subdivisionsX?: number;
  85385. subdivisionsY?: number;
  85386. }): VertexData;
  85387. /**
  85388. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  85389. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  85390. * * xmin the ground minimum X coordinate, optional, default -1
  85391. * * zmin the ground minimum Z coordinate, optional, default -1
  85392. * * xmax the ground maximum X coordinate, optional, default 1
  85393. * * zmax the ground maximum Z coordinate, optional, default 1
  85394. * * 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}
  85395. * * 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}
  85396. * @returns the VertexData of the TiledGround
  85397. */
  85398. static CreateTiledGround(options: {
  85399. xmin: number;
  85400. zmin: number;
  85401. xmax: number;
  85402. zmax: number;
  85403. subdivisions?: {
  85404. w: number;
  85405. h: number;
  85406. };
  85407. precision?: {
  85408. w: number;
  85409. h: number;
  85410. };
  85411. }): VertexData;
  85412. /**
  85413. * Creates the VertexData of the Ground designed from a heightmap
  85414. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  85415. * * width the width (x direction) of the ground
  85416. * * height the height (z direction) of the ground
  85417. * * subdivisions the number of subdivisions per side
  85418. * * minHeight the minimum altitude on the ground, optional, default 0
  85419. * * maxHeight the maximum altitude on the ground, optional default 1
  85420. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  85421. * * buffer the array holding the image color data
  85422. * * bufferWidth the width of image
  85423. * * bufferHeight the height of image
  85424. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  85425. * @returns the VertexData of the Ground designed from a heightmap
  85426. */
  85427. static CreateGroundFromHeightMap(options: {
  85428. width: number;
  85429. height: number;
  85430. subdivisions: number;
  85431. minHeight: number;
  85432. maxHeight: number;
  85433. colorFilter: Color3;
  85434. buffer: Uint8Array;
  85435. bufferWidth: number;
  85436. bufferHeight: number;
  85437. alphaFilter: number;
  85438. }): VertexData;
  85439. /**
  85440. * Creates the VertexData for a Plane
  85441. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  85442. * * size sets the width and height of the plane to the value of size, optional default 1
  85443. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  85444. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  85445. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85446. * * 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)
  85447. * * 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)
  85448. * @returns the VertexData of the box
  85449. */
  85450. static CreatePlane(options: {
  85451. size?: number;
  85452. width?: number;
  85453. height?: number;
  85454. sideOrientation?: number;
  85455. frontUVs?: Vector4;
  85456. backUVs?: Vector4;
  85457. }): VertexData;
  85458. /**
  85459. * Creates the VertexData of the Disc or regular Polygon
  85460. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  85461. * * radius the radius of the disc, optional default 0.5
  85462. * * tessellation the number of polygon sides, optional, default 64
  85463. * * 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
  85464. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85465. * * 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)
  85466. * * 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)
  85467. * @returns the VertexData of the box
  85468. */
  85469. static CreateDisc(options: {
  85470. radius?: number;
  85471. tessellation?: number;
  85472. arc?: number;
  85473. sideOrientation?: number;
  85474. frontUVs?: Vector4;
  85475. backUVs?: Vector4;
  85476. }): VertexData;
  85477. /**
  85478. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  85479. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  85480. * @param polygon a mesh built from polygonTriangulation.build()
  85481. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85482. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  85483. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  85484. * @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)
  85485. * @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)
  85486. * @returns the VertexData of the Polygon
  85487. */
  85488. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  85489. /**
  85490. * Creates the VertexData of the IcoSphere
  85491. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  85492. * * radius the radius of the IcoSphere, optional default 1
  85493. * * radiusX allows stretching in the x direction, optional, default radius
  85494. * * radiusY allows stretching in the y direction, optional, default radius
  85495. * * radiusZ allows stretching in the z direction, optional, default radius
  85496. * * flat when true creates a flat shaded mesh, optional, default true
  85497. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  85498. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85499. * * 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)
  85500. * * 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)
  85501. * @returns the VertexData of the IcoSphere
  85502. */
  85503. static CreateIcoSphere(options: {
  85504. radius?: number;
  85505. radiusX?: number;
  85506. radiusY?: number;
  85507. radiusZ?: number;
  85508. flat?: boolean;
  85509. subdivisions?: number;
  85510. sideOrientation?: number;
  85511. frontUVs?: Vector4;
  85512. backUVs?: Vector4;
  85513. }): VertexData;
  85514. /**
  85515. * Creates the VertexData for a Polyhedron
  85516. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  85517. * * type provided types are:
  85518. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  85519. * * 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)
  85520. * * size the size of the IcoSphere, optional default 1
  85521. * * sizeX allows stretching in the x direction, optional, default size
  85522. * * sizeY allows stretching in the y direction, optional, default size
  85523. * * sizeZ allows stretching in the z direction, optional, default size
  85524. * * 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
  85525. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  85526. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  85527. * * flat when true creates a flat shaded mesh, optional, default true
  85528. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  85529. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85530. * * 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)
  85531. * * 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)
  85532. * @returns the VertexData of the Polyhedron
  85533. */
  85534. static CreatePolyhedron(options: {
  85535. type?: number;
  85536. size?: number;
  85537. sizeX?: number;
  85538. sizeY?: number;
  85539. sizeZ?: number;
  85540. custom?: any;
  85541. faceUV?: Vector4[];
  85542. faceColors?: Color4[];
  85543. flat?: boolean;
  85544. sideOrientation?: number;
  85545. frontUVs?: Vector4;
  85546. backUVs?: Vector4;
  85547. }): VertexData;
  85548. /**
  85549. * Creates the VertexData for a TorusKnot
  85550. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  85551. * * radius the radius of the torus knot, optional, default 2
  85552. * * tube the thickness of the tube, optional, default 0.5
  85553. * * radialSegments the number of sides on each tube segments, optional, default 32
  85554. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  85555. * * p the number of windings around the z axis, optional, default 2
  85556. * * q the number of windings around the x axis, optional, default 3
  85557. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85558. * * 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)
  85559. * * 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)
  85560. * @returns the VertexData of the Torus Knot
  85561. */
  85562. static CreateTorusKnot(options: {
  85563. radius?: number;
  85564. tube?: number;
  85565. radialSegments?: number;
  85566. tubularSegments?: number;
  85567. p?: number;
  85568. q?: number;
  85569. sideOrientation?: number;
  85570. frontUVs?: Vector4;
  85571. backUVs?: Vector4;
  85572. }): VertexData;
  85573. /**
  85574. * Compute normals for given positions and indices
  85575. * @param positions an array of vertex positions, [...., x, y, z, ......]
  85576. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  85577. * @param normals an array of vertex normals, [...., x, y, z, ......]
  85578. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  85579. * * facetNormals : optional array of facet normals (vector3)
  85580. * * facetPositions : optional array of facet positions (vector3)
  85581. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  85582. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  85583. * * bInfo : optional bounding info, required for facetPartitioning computation
  85584. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  85585. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  85586. * * useRightHandedSystem: optional boolean to for right handed system computation
  85587. * * depthSort : optional boolean to enable the facet depth sort computation
  85588. * * distanceTo : optional Vector3 to compute the facet depth from this location
  85589. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  85590. */
  85591. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  85592. facetNormals?: any;
  85593. facetPositions?: any;
  85594. facetPartitioning?: any;
  85595. ratio?: number;
  85596. bInfo?: any;
  85597. bbSize?: Vector3;
  85598. subDiv?: any;
  85599. useRightHandedSystem?: boolean;
  85600. depthSort?: boolean;
  85601. distanceTo?: Vector3;
  85602. depthSortedFacets?: any;
  85603. }): void;
  85604. /** @hidden */
  85605. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  85606. /**
  85607. * Applies VertexData created from the imported parameters to the geometry
  85608. * @param parsedVertexData the parsed data from an imported file
  85609. * @param geometry the geometry to apply the VertexData to
  85610. */
  85611. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  85612. }
  85613. }
  85614. declare module BABYLON {
  85615. /**
  85616. * Class containing static functions to help procedurally build meshes
  85617. */
  85618. export class DiscBuilder {
  85619. /**
  85620. * Creates a plane polygonal mesh. By default, this is a disc
  85621. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  85622. * * 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
  85623. * * 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
  85624. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  85625. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  85626. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  85627. * @param name defines the name of the mesh
  85628. * @param options defines the options used to create the mesh
  85629. * @param scene defines the hosting scene
  85630. * @returns the plane polygonal mesh
  85631. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  85632. */
  85633. static CreateDisc(name: string, options: {
  85634. radius?: number;
  85635. tessellation?: number;
  85636. arc?: number;
  85637. updatable?: boolean;
  85638. sideOrientation?: number;
  85639. frontUVs?: Vector4;
  85640. backUVs?: Vector4;
  85641. }, scene?: Nullable<Scene>): Mesh;
  85642. }
  85643. }
  85644. declare module BABYLON {
  85645. /**
  85646. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  85647. *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.
  85648. * The SPS is also a particle system. It provides some methods to manage the particles.
  85649. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  85650. *
  85651. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  85652. */
  85653. export class SolidParticleSystem implements IDisposable {
  85654. /**
  85655. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  85656. * Example : var p = SPS.particles[i];
  85657. */
  85658. particles: SolidParticle[];
  85659. /**
  85660. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  85661. */
  85662. nbParticles: number;
  85663. /**
  85664. * If the particles must ever face the camera (default false). Useful for planar particles.
  85665. */
  85666. billboard: boolean;
  85667. /**
  85668. * Recompute normals when adding a shape
  85669. */
  85670. recomputeNormals: boolean;
  85671. /**
  85672. * This a counter ofr your own usage. It's not set by any SPS functions.
  85673. */
  85674. counter: number;
  85675. /**
  85676. * The SPS name. This name is also given to the underlying mesh.
  85677. */
  85678. name: string;
  85679. /**
  85680. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  85681. */
  85682. mesh: Mesh;
  85683. /**
  85684. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  85685. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  85686. */
  85687. vars: any;
  85688. /**
  85689. * This array is populated when the SPS is set as 'pickable'.
  85690. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  85691. * Each element of this array is an object `{idx: int, faceId: int}`.
  85692. * `idx` is the picked particle index in the `SPS.particles` array
  85693. * `faceId` is the picked face index counted within this particle.
  85694. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  85695. */
  85696. pickedParticles: {
  85697. idx: number;
  85698. faceId: number;
  85699. }[];
  85700. /**
  85701. * This array is populated when `enableDepthSort` is set to true.
  85702. * Each element of this array is an instance of the class DepthSortedParticle.
  85703. */
  85704. depthSortedParticles: DepthSortedParticle[];
  85705. /**
  85706. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  85707. * @hidden
  85708. */
  85709. _bSphereOnly: boolean;
  85710. /**
  85711. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  85712. * @hidden
  85713. */
  85714. _bSphereRadiusFactor: number;
  85715. private _scene;
  85716. private _positions;
  85717. private _indices;
  85718. private _normals;
  85719. private _colors;
  85720. private _uvs;
  85721. private _indices32;
  85722. private _positions32;
  85723. private _normals32;
  85724. private _fixedNormal32;
  85725. private _colors32;
  85726. private _uvs32;
  85727. private _index;
  85728. private _updatable;
  85729. private _pickable;
  85730. private _isVisibilityBoxLocked;
  85731. private _alwaysVisible;
  85732. private _depthSort;
  85733. private _shapeCounter;
  85734. private _copy;
  85735. private _color;
  85736. private _computeParticleColor;
  85737. private _computeParticleTexture;
  85738. private _computeParticleRotation;
  85739. private _computeParticleVertex;
  85740. private _computeBoundingBox;
  85741. private _depthSortParticles;
  85742. private _camera;
  85743. private _mustUnrotateFixedNormals;
  85744. private _particlesIntersect;
  85745. private _needs32Bits;
  85746. /**
  85747. * Creates a SPS (Solid Particle System) object.
  85748. * @param name (String) is the SPS name, this will be the underlying mesh name.
  85749. * @param scene (Scene) is the scene in which the SPS is added.
  85750. * @param options defines the options of the sps e.g.
  85751. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  85752. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  85753. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  85754. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  85755. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  85756. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  85757. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  85758. */
  85759. constructor(name: string, scene: Scene, options?: {
  85760. updatable?: boolean;
  85761. isPickable?: boolean;
  85762. enableDepthSort?: boolean;
  85763. particleIntersection?: boolean;
  85764. boundingSphereOnly?: boolean;
  85765. bSphereRadiusFactor?: number;
  85766. });
  85767. /**
  85768. * Builds the SPS underlying mesh. Returns a standard Mesh.
  85769. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  85770. * @returns the created mesh
  85771. */
  85772. buildMesh(): Mesh;
  85773. /**
  85774. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  85775. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  85776. * Thus the particles generated from `digest()` have their property `position` set yet.
  85777. * @param mesh ( Mesh ) is the mesh to be digested
  85778. * @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
  85779. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  85780. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  85781. * @returns the current SPS
  85782. */
  85783. digest(mesh: Mesh, options?: {
  85784. facetNb?: number;
  85785. number?: number;
  85786. delta?: number;
  85787. }): SolidParticleSystem;
  85788. private _unrotateFixedNormals;
  85789. private _resetCopy;
  85790. private _meshBuilder;
  85791. private _posToShape;
  85792. private _uvsToShapeUV;
  85793. private _addParticle;
  85794. /**
  85795. * Adds some particles to the SPS from the model shape. Returns the shape id.
  85796. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  85797. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  85798. * @param nb (positive integer) the number of particles to be created from this model
  85799. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  85800. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  85801. * @returns the number of shapes in the system
  85802. */
  85803. addShape(mesh: Mesh, nb: number, options?: {
  85804. positionFunction?: any;
  85805. vertexFunction?: any;
  85806. }): number;
  85807. private _rebuildParticle;
  85808. /**
  85809. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  85810. * @returns the SPS.
  85811. */
  85812. rebuildMesh(): SolidParticleSystem;
  85813. /**
  85814. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  85815. * This method calls `updateParticle()` for each particle of the SPS.
  85816. * For an animated SPS, it is usually called within the render loop.
  85817. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  85818. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  85819. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  85820. * @returns the SPS.
  85821. */
  85822. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  85823. /**
  85824. * Disposes the SPS.
  85825. */
  85826. dispose(): void;
  85827. /**
  85828. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  85829. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  85830. * @returns the SPS.
  85831. */
  85832. refreshVisibleSize(): SolidParticleSystem;
  85833. /**
  85834. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  85835. * @param size the size (float) of the visibility box
  85836. * note : this doesn't lock the SPS mesh bounding box.
  85837. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  85838. */
  85839. setVisibilityBox(size: number): void;
  85840. /**
  85841. * Gets whether the SPS as always visible or not
  85842. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  85843. */
  85844. /**
  85845. * Sets the SPS as always visible or not
  85846. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  85847. */
  85848. isAlwaysVisible: boolean;
  85849. /**
  85850. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  85851. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  85852. */
  85853. /**
  85854. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  85855. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  85856. */
  85857. isVisibilityBoxLocked: boolean;
  85858. /**
  85859. * Tells to `setParticles()` to compute the particle rotations or not.
  85860. * Default value : true. The SPS is faster when it's set to false.
  85861. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  85862. */
  85863. /**
  85864. * Gets if `setParticles()` computes the particle rotations or not.
  85865. * Default value : true. The SPS is faster when it's set to false.
  85866. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  85867. */
  85868. computeParticleRotation: boolean;
  85869. /**
  85870. * Tells to `setParticles()` to compute the particle colors or not.
  85871. * Default value : true. The SPS is faster when it's set to false.
  85872. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  85873. */
  85874. /**
  85875. * Gets if `setParticles()` computes the particle colors or not.
  85876. * Default value : true. The SPS is faster when it's set to false.
  85877. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  85878. */
  85879. computeParticleColor: boolean;
  85880. /**
  85881. * Gets if `setParticles()` computes the particle textures or not.
  85882. * Default value : true. The SPS is faster when it's set to false.
  85883. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  85884. */
  85885. computeParticleTexture: boolean;
  85886. /**
  85887. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  85888. * Default value : false. The SPS is faster when it's set to false.
  85889. * Note : the particle custom vertex positions aren't stored values.
  85890. */
  85891. /**
  85892. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  85893. * Default value : false. The SPS is faster when it's set to false.
  85894. * Note : the particle custom vertex positions aren't stored values.
  85895. */
  85896. computeParticleVertex: boolean;
  85897. /**
  85898. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  85899. */
  85900. /**
  85901. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  85902. */
  85903. computeBoundingBox: boolean;
  85904. /**
  85905. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  85906. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  85907. * Default : `true`
  85908. */
  85909. /**
  85910. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  85911. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  85912. * Default : `true`
  85913. */
  85914. depthSortParticles: boolean;
  85915. /**
  85916. * This function does nothing. It may be overwritten to set all the particle first values.
  85917. * The SPS doesn't call this function, you may have to call it by your own.
  85918. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  85919. */
  85920. initParticles(): void;
  85921. /**
  85922. * This function does nothing. It may be overwritten to recycle a particle.
  85923. * The SPS doesn't call this function, you may have to call it by your own.
  85924. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  85925. * @param particle The particle to recycle
  85926. * @returns the recycled particle
  85927. */
  85928. recycleParticle(particle: SolidParticle): SolidParticle;
  85929. /**
  85930. * Updates a particle : this function should be overwritten by the user.
  85931. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  85932. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  85933. * @example : just set a particle position or velocity and recycle conditions
  85934. * @param particle The particle to update
  85935. * @returns the updated particle
  85936. */
  85937. updateParticle(particle: SolidParticle): SolidParticle;
  85938. /**
  85939. * Updates a vertex of a particle : it can be overwritten by the user.
  85940. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  85941. * @param particle the current particle
  85942. * @param vertex the current index of the current particle
  85943. * @param pt the index of the current vertex in the particle shape
  85944. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  85945. * @example : just set a vertex particle position
  85946. * @returns the updated vertex
  85947. */
  85948. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  85949. /**
  85950. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  85951. * This does nothing and may be overwritten by the user.
  85952. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  85953. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  85954. * @param update the boolean update value actually passed to setParticles()
  85955. */
  85956. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  85957. /**
  85958. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  85959. * This will be passed three parameters.
  85960. * This does nothing and may be overwritten by the user.
  85961. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  85962. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  85963. * @param update the boolean update value actually passed to setParticles()
  85964. */
  85965. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  85966. }
  85967. }
  85968. declare module BABYLON {
  85969. /**
  85970. * Represents one particle of a solid particle system.
  85971. */
  85972. export class SolidParticle {
  85973. /**
  85974. * particle global index
  85975. */
  85976. idx: number;
  85977. /**
  85978. * The color of the particle
  85979. */
  85980. color: Nullable<Color4>;
  85981. /**
  85982. * The world space position of the particle.
  85983. */
  85984. position: Vector3;
  85985. /**
  85986. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  85987. */
  85988. rotation: Vector3;
  85989. /**
  85990. * The world space rotation quaternion of the particle.
  85991. */
  85992. rotationQuaternion: Nullable<Quaternion>;
  85993. /**
  85994. * The scaling of the particle.
  85995. */
  85996. scaling: Vector3;
  85997. /**
  85998. * The uvs of the particle.
  85999. */
  86000. uvs: Vector4;
  86001. /**
  86002. * The current speed of the particle.
  86003. */
  86004. velocity: Vector3;
  86005. /**
  86006. * The pivot point in the particle local space.
  86007. */
  86008. pivot: Vector3;
  86009. /**
  86010. * Must the particle be translated from its pivot point in its local space ?
  86011. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  86012. * Default : false
  86013. */
  86014. translateFromPivot: boolean;
  86015. /**
  86016. * Is the particle active or not ?
  86017. */
  86018. alive: boolean;
  86019. /**
  86020. * Is the particle visible or not ?
  86021. */
  86022. isVisible: boolean;
  86023. /**
  86024. * Index of this particle in the global "positions" array (Internal use)
  86025. * @hidden
  86026. */
  86027. _pos: number;
  86028. /**
  86029. * @hidden Index of this particle in the global "indices" array (Internal use)
  86030. */
  86031. _ind: number;
  86032. /**
  86033. * @hidden ModelShape of this particle (Internal use)
  86034. */
  86035. _model: ModelShape;
  86036. /**
  86037. * ModelShape id of this particle
  86038. */
  86039. shapeId: number;
  86040. /**
  86041. * Index of the particle in its shape id (Internal use)
  86042. */
  86043. idxInShape: number;
  86044. /**
  86045. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  86046. */
  86047. _modelBoundingInfo: BoundingInfo;
  86048. /**
  86049. * @hidden Particle BoundingInfo object (Internal use)
  86050. */
  86051. _boundingInfo: BoundingInfo;
  86052. /**
  86053. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  86054. */
  86055. _sps: SolidParticleSystem;
  86056. /**
  86057. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  86058. */
  86059. _stillInvisible: boolean;
  86060. /**
  86061. * @hidden Last computed particle rotation matrix
  86062. */
  86063. _rotationMatrix: number[];
  86064. /**
  86065. * Parent particle Id, if any.
  86066. * Default null.
  86067. */
  86068. parentId: Nullable<number>;
  86069. /**
  86070. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  86071. * The possible values are :
  86072. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  86073. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  86074. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  86075. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  86076. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  86077. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  86078. * */
  86079. cullingStrategy: number;
  86080. /**
  86081. * @hidden Internal global position in the SPS.
  86082. */
  86083. _globalPosition: Vector3;
  86084. /**
  86085. * Creates a Solid Particle object.
  86086. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  86087. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  86088. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  86089. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  86090. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  86091. * @param shapeId (integer) is the model shape identifier in the SPS.
  86092. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  86093. * @param sps defines the sps it is associated to
  86094. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  86095. */
  86096. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  86097. /**
  86098. * Legacy support, changed scale to scaling
  86099. */
  86100. /**
  86101. * Legacy support, changed scale to scaling
  86102. */
  86103. scale: Vector3;
  86104. /**
  86105. * Legacy support, changed quaternion to rotationQuaternion
  86106. */
  86107. /**
  86108. * Legacy support, changed quaternion to rotationQuaternion
  86109. */
  86110. quaternion: Nullable<Quaternion>;
  86111. /**
  86112. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  86113. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  86114. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  86115. * @returns true if it intersects
  86116. */
  86117. intersectsMesh(target: Mesh | SolidParticle): boolean;
  86118. /**
  86119. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  86120. * A particle is in the frustum if its bounding box intersects the frustum
  86121. * @param frustumPlanes defines the frustum to test
  86122. * @returns true if the particle is in the frustum planes
  86123. */
  86124. isInFrustum(frustumPlanes: Plane[]): boolean;
  86125. /**
  86126. * get the rotation matrix of the particle
  86127. * @hidden
  86128. */
  86129. getRotationMatrix(m: Matrix): void;
  86130. }
  86131. /**
  86132. * Represents the shape of the model used by one particle of a solid particle system.
  86133. * SPS internal tool, don't use it manually.
  86134. */
  86135. export class ModelShape {
  86136. /**
  86137. * The shape id
  86138. * @hidden
  86139. */
  86140. shapeID: number;
  86141. /**
  86142. * flat array of model positions (internal use)
  86143. * @hidden
  86144. */
  86145. _shape: Vector3[];
  86146. /**
  86147. * flat array of model UVs (internal use)
  86148. * @hidden
  86149. */
  86150. _shapeUV: number[];
  86151. /**
  86152. * length of the shape in the model indices array (internal use)
  86153. * @hidden
  86154. */
  86155. _indicesLength: number;
  86156. /**
  86157. * Custom position function (internal use)
  86158. * @hidden
  86159. */
  86160. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  86161. /**
  86162. * Custom vertex function (internal use)
  86163. * @hidden
  86164. */
  86165. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  86166. /**
  86167. * 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.
  86168. * SPS internal tool, don't use it manually.
  86169. * @hidden
  86170. */
  86171. 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>);
  86172. }
  86173. /**
  86174. * Represents a Depth Sorted Particle in the solid particle system.
  86175. */
  86176. export class DepthSortedParticle {
  86177. /**
  86178. * Index of the particle in the "indices" array
  86179. */
  86180. ind: number;
  86181. /**
  86182. * Length of the particle shape in the "indices" array
  86183. */
  86184. indicesLength: number;
  86185. /**
  86186. * Squared distance from the particle to the camera
  86187. */
  86188. sqDistance: number;
  86189. }
  86190. }
  86191. declare module BABYLON {
  86192. /**
  86193. * @hidden
  86194. */
  86195. export class _MeshCollisionData {
  86196. _checkCollisions: boolean;
  86197. _collisionMask: number;
  86198. _collisionGroup: number;
  86199. _collider: Nullable<Collider>;
  86200. _oldPositionForCollisions: Vector3;
  86201. _diffPositionForCollisions: Vector3;
  86202. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  86203. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  86204. }
  86205. }
  86206. declare module BABYLON {
  86207. /** @hidden */
  86208. class _FacetDataStorage {
  86209. facetPositions: Vector3[];
  86210. facetNormals: Vector3[];
  86211. facetPartitioning: number[][];
  86212. facetNb: number;
  86213. partitioningSubdivisions: number;
  86214. partitioningBBoxRatio: number;
  86215. facetDataEnabled: boolean;
  86216. facetParameters: any;
  86217. bbSize: Vector3;
  86218. subDiv: {
  86219. max: number;
  86220. X: number;
  86221. Y: number;
  86222. Z: number;
  86223. };
  86224. facetDepthSort: boolean;
  86225. facetDepthSortEnabled: boolean;
  86226. depthSortedIndices: IndicesArray;
  86227. depthSortedFacets: {
  86228. ind: number;
  86229. sqDistance: number;
  86230. }[];
  86231. facetDepthSortFunction: (f1: {
  86232. ind: number;
  86233. sqDistance: number;
  86234. }, f2: {
  86235. ind: number;
  86236. sqDistance: number;
  86237. }) => number;
  86238. facetDepthSortFrom: Vector3;
  86239. facetDepthSortOrigin: Vector3;
  86240. invertedMatrix: Matrix;
  86241. }
  86242. /**
  86243. * @hidden
  86244. **/
  86245. class _InternalAbstractMeshDataInfo {
  86246. _hasVertexAlpha: boolean;
  86247. _useVertexColors: boolean;
  86248. _numBoneInfluencers: number;
  86249. _applyFog: boolean;
  86250. _receiveShadows: boolean;
  86251. _facetData: _FacetDataStorage;
  86252. _visibility: number;
  86253. _skeleton: Nullable<Skeleton>;
  86254. _layerMask: number;
  86255. _computeBonesUsingShaders: boolean;
  86256. _isActive: boolean;
  86257. _onlyForInstances: boolean;
  86258. _isActiveIntermediate: boolean;
  86259. _onlyForInstancesIntermediate: boolean;
  86260. }
  86261. /**
  86262. * Class used to store all common mesh properties
  86263. */
  86264. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  86265. /** No occlusion */
  86266. static OCCLUSION_TYPE_NONE: number;
  86267. /** Occlusion set to optimisitic */
  86268. static OCCLUSION_TYPE_OPTIMISTIC: number;
  86269. /** Occlusion set to strict */
  86270. static OCCLUSION_TYPE_STRICT: number;
  86271. /** Use an accurante occlusion algorithm */
  86272. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  86273. /** Use a conservative occlusion algorithm */
  86274. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  86275. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  86276. * Test order :
  86277. * Is the bounding sphere outside the frustum ?
  86278. * If not, are the bounding box vertices outside the frustum ?
  86279. * It not, then the cullable object is in the frustum.
  86280. */
  86281. static readonly CULLINGSTRATEGY_STANDARD: number;
  86282. /** Culling strategy : Bounding Sphere Only.
  86283. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  86284. * It's also less accurate than the standard because some not visible objects can still be selected.
  86285. * Test : is the bounding sphere outside the frustum ?
  86286. * If not, then the cullable object is in the frustum.
  86287. */
  86288. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  86289. /** Culling strategy : Optimistic Inclusion.
  86290. * This in an inclusion test first, then the standard exclusion test.
  86291. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  86292. * 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.
  86293. * Anyway, it's as accurate as the standard strategy.
  86294. * Test :
  86295. * Is the cullable object bounding sphere center in the frustum ?
  86296. * If not, apply the default culling strategy.
  86297. */
  86298. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  86299. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  86300. * This in an inclusion test first, then the bounding sphere only exclusion test.
  86301. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  86302. * 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.
  86303. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  86304. * Test :
  86305. * Is the cullable object bounding sphere center in the frustum ?
  86306. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  86307. */
  86308. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  86309. /**
  86310. * No billboard
  86311. */
  86312. static readonly BILLBOARDMODE_NONE: number;
  86313. /** Billboard on X axis */
  86314. static readonly BILLBOARDMODE_X: number;
  86315. /** Billboard on Y axis */
  86316. static readonly BILLBOARDMODE_Y: number;
  86317. /** Billboard on Z axis */
  86318. static readonly BILLBOARDMODE_Z: number;
  86319. /** Billboard on all axes */
  86320. static readonly BILLBOARDMODE_ALL: number;
  86321. /** @hidden */
  86322. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  86323. /**
  86324. * The culling strategy to use to check whether the mesh must be rendered or not.
  86325. * This value can be changed at any time and will be used on the next render mesh selection.
  86326. * The possible values are :
  86327. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  86328. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  86329. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  86330. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  86331. * Please read each static variable documentation to get details about the culling process.
  86332. * */
  86333. cullingStrategy: number;
  86334. /**
  86335. * Gets the number of facets in the mesh
  86336. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  86337. */
  86338. readonly facetNb: number;
  86339. /**
  86340. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  86341. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  86342. */
  86343. partitioningSubdivisions: number;
  86344. /**
  86345. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  86346. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  86347. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  86348. */
  86349. partitioningBBoxRatio: number;
  86350. /**
  86351. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  86352. * Works only for updatable meshes.
  86353. * Doesn't work with multi-materials
  86354. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  86355. */
  86356. mustDepthSortFacets: boolean;
  86357. /**
  86358. * The location (Vector3) where the facet depth sort must be computed from.
  86359. * By default, the active camera position.
  86360. * Used only when facet depth sort is enabled
  86361. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  86362. */
  86363. facetDepthSortFrom: Vector3;
  86364. /**
  86365. * gets a boolean indicating if facetData is enabled
  86366. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  86367. */
  86368. readonly isFacetDataEnabled: boolean;
  86369. /** @hidden */
  86370. _updateNonUniformScalingState(value: boolean): boolean;
  86371. /**
  86372. * An event triggered when this mesh collides with another one
  86373. */
  86374. onCollideObservable: Observable<AbstractMesh>;
  86375. /** Set a function to call when this mesh collides with another one */
  86376. onCollide: () => void;
  86377. /**
  86378. * An event triggered when the collision's position changes
  86379. */
  86380. onCollisionPositionChangeObservable: Observable<Vector3>;
  86381. /** Set a function to call when the collision's position changes */
  86382. onCollisionPositionChange: () => void;
  86383. /**
  86384. * An event triggered when material is changed
  86385. */
  86386. onMaterialChangedObservable: Observable<AbstractMesh>;
  86387. /**
  86388. * Gets or sets the orientation for POV movement & rotation
  86389. */
  86390. definedFacingForward: boolean;
  86391. /** @hidden */
  86392. _occlusionQuery: Nullable<WebGLQuery>;
  86393. /** @hidden */
  86394. _renderingGroup: Nullable<RenderingGroup>;
  86395. /**
  86396. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  86397. */
  86398. /**
  86399. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  86400. */
  86401. visibility: number;
  86402. /** Gets or sets the alpha index used to sort transparent meshes
  86403. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  86404. */
  86405. alphaIndex: number;
  86406. /**
  86407. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  86408. */
  86409. isVisible: boolean;
  86410. /**
  86411. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  86412. */
  86413. isPickable: boolean;
  86414. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  86415. showSubMeshesBoundingBox: boolean;
  86416. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  86417. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  86418. */
  86419. isBlocker: boolean;
  86420. /**
  86421. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  86422. */
  86423. enablePointerMoveEvents: boolean;
  86424. /**
  86425. * Specifies the rendering group id for this mesh (0 by default)
  86426. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  86427. */
  86428. renderingGroupId: number;
  86429. private _material;
  86430. /** Gets or sets current material */
  86431. material: Nullable<Material>;
  86432. /**
  86433. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  86434. * @see http://doc.babylonjs.com/babylon101/shadows
  86435. */
  86436. receiveShadows: boolean;
  86437. /** Defines color to use when rendering outline */
  86438. outlineColor: Color3;
  86439. /** Define width to use when rendering outline */
  86440. outlineWidth: number;
  86441. /** Defines color to use when rendering overlay */
  86442. overlayColor: Color3;
  86443. /** Defines alpha to use when rendering overlay */
  86444. overlayAlpha: number;
  86445. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  86446. hasVertexAlpha: boolean;
  86447. /** 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) */
  86448. useVertexColors: boolean;
  86449. /**
  86450. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  86451. */
  86452. computeBonesUsingShaders: boolean;
  86453. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  86454. numBoneInfluencers: number;
  86455. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  86456. applyFog: boolean;
  86457. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  86458. useOctreeForRenderingSelection: boolean;
  86459. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  86460. useOctreeForPicking: boolean;
  86461. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  86462. useOctreeForCollisions: boolean;
  86463. /**
  86464. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  86465. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  86466. */
  86467. layerMask: number;
  86468. /**
  86469. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  86470. */
  86471. alwaysSelectAsActiveMesh: boolean;
  86472. /**
  86473. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  86474. */
  86475. doNotSyncBoundingInfo: boolean;
  86476. /**
  86477. * Gets or sets the current action manager
  86478. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  86479. */
  86480. actionManager: Nullable<AbstractActionManager>;
  86481. private _meshCollisionData;
  86482. /**
  86483. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  86484. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  86485. */
  86486. ellipsoid: Vector3;
  86487. /**
  86488. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  86489. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  86490. */
  86491. ellipsoidOffset: Vector3;
  86492. /**
  86493. * Gets or sets a collision mask used to mask collisions (default is -1).
  86494. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  86495. */
  86496. collisionMask: number;
  86497. /**
  86498. * Gets or sets the current collision group mask (-1 by default).
  86499. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  86500. */
  86501. collisionGroup: number;
  86502. /**
  86503. * Defines edge width used when edgesRenderer is enabled
  86504. * @see https://www.babylonjs-playground.com/#10OJSG#13
  86505. */
  86506. edgesWidth: number;
  86507. /**
  86508. * Defines edge color used when edgesRenderer is enabled
  86509. * @see https://www.babylonjs-playground.com/#10OJSG#13
  86510. */
  86511. edgesColor: Color4;
  86512. /** @hidden */
  86513. _edgesRenderer: Nullable<IEdgesRenderer>;
  86514. /** @hidden */
  86515. _masterMesh: Nullable<AbstractMesh>;
  86516. /** @hidden */
  86517. _boundingInfo: Nullable<BoundingInfo>;
  86518. /** @hidden */
  86519. _renderId: number;
  86520. /**
  86521. * Gets or sets the list of subMeshes
  86522. * @see http://doc.babylonjs.com/how_to/multi_materials
  86523. */
  86524. subMeshes: SubMesh[];
  86525. /** @hidden */
  86526. _intersectionsInProgress: AbstractMesh[];
  86527. /** @hidden */
  86528. _unIndexed: boolean;
  86529. /** @hidden */
  86530. _lightSources: Light[];
  86531. /** Gets the list of lights affecting that mesh */
  86532. readonly lightSources: Light[];
  86533. /** @hidden */
  86534. readonly _positions: Nullable<Vector3[]>;
  86535. /** @hidden */
  86536. _waitingData: {
  86537. lods: Nullable<any>;
  86538. actions: Nullable<any>;
  86539. freezeWorldMatrix: Nullable<boolean>;
  86540. };
  86541. /** @hidden */
  86542. _bonesTransformMatrices: Nullable<Float32Array>;
  86543. /**
  86544. * Gets or sets a skeleton to apply skining transformations
  86545. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  86546. */
  86547. skeleton: Nullable<Skeleton>;
  86548. /**
  86549. * An event triggered when the mesh is rebuilt.
  86550. */
  86551. onRebuildObservable: Observable<AbstractMesh>;
  86552. /**
  86553. * Creates a new AbstractMesh
  86554. * @param name defines the name of the mesh
  86555. * @param scene defines the hosting scene
  86556. */
  86557. constructor(name: string, scene?: Nullable<Scene>);
  86558. /**
  86559. * Returns the string "AbstractMesh"
  86560. * @returns "AbstractMesh"
  86561. */
  86562. getClassName(): string;
  86563. /**
  86564. * Gets a string representation of the current mesh
  86565. * @param fullDetails defines a boolean indicating if full details must be included
  86566. * @returns a string representation of the current mesh
  86567. */
  86568. toString(fullDetails?: boolean): string;
  86569. /**
  86570. * @hidden
  86571. */
  86572. protected _getEffectiveParent(): Nullable<Node>;
  86573. /** @hidden */
  86574. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  86575. /** @hidden */
  86576. _rebuild(): void;
  86577. /** @hidden */
  86578. _resyncLightSources(): void;
  86579. /** @hidden */
  86580. _resyncLighSource(light: Light): void;
  86581. /** @hidden */
  86582. _unBindEffect(): void;
  86583. /** @hidden */
  86584. _removeLightSource(light: Light): void;
  86585. private _markSubMeshesAsDirty;
  86586. /** @hidden */
  86587. _markSubMeshesAsLightDirty(): void;
  86588. /** @hidden */
  86589. _markSubMeshesAsAttributesDirty(): void;
  86590. /** @hidden */
  86591. _markSubMeshesAsMiscDirty(): void;
  86592. /**
  86593. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  86594. */
  86595. scaling: Vector3;
  86596. /**
  86597. * Returns true if the mesh is blocked. Implemented by child classes
  86598. */
  86599. readonly isBlocked: boolean;
  86600. /**
  86601. * Returns the mesh itself by default. Implemented by child classes
  86602. * @param camera defines the camera to use to pick the right LOD level
  86603. * @returns the currentAbstractMesh
  86604. */
  86605. getLOD(camera: Camera): Nullable<AbstractMesh>;
  86606. /**
  86607. * Returns 0 by default. Implemented by child classes
  86608. * @returns an integer
  86609. */
  86610. getTotalVertices(): number;
  86611. /**
  86612. * Returns a positive integer : the total number of indices in this mesh geometry.
  86613. * @returns the numner of indices or zero if the mesh has no geometry.
  86614. */
  86615. getTotalIndices(): number;
  86616. /**
  86617. * Returns null by default. Implemented by child classes
  86618. * @returns null
  86619. */
  86620. getIndices(): Nullable<IndicesArray>;
  86621. /**
  86622. * Returns the array of the requested vertex data kind. Implemented by child classes
  86623. * @param kind defines the vertex data kind to use
  86624. * @returns null
  86625. */
  86626. getVerticesData(kind: string): Nullable<FloatArray>;
  86627. /**
  86628. * Sets the vertex data of the mesh geometry for the requested `kind`.
  86629. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  86630. * Note that a new underlying VertexBuffer object is created each call.
  86631. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  86632. * @param kind defines vertex data kind:
  86633. * * VertexBuffer.PositionKind
  86634. * * VertexBuffer.UVKind
  86635. * * VertexBuffer.UV2Kind
  86636. * * VertexBuffer.UV3Kind
  86637. * * VertexBuffer.UV4Kind
  86638. * * VertexBuffer.UV5Kind
  86639. * * VertexBuffer.UV6Kind
  86640. * * VertexBuffer.ColorKind
  86641. * * VertexBuffer.MatricesIndicesKind
  86642. * * VertexBuffer.MatricesIndicesExtraKind
  86643. * * VertexBuffer.MatricesWeightsKind
  86644. * * VertexBuffer.MatricesWeightsExtraKind
  86645. * @param data defines the data source
  86646. * @param updatable defines if the data must be flagged as updatable (or static)
  86647. * @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
  86648. * @returns the current mesh
  86649. */
  86650. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  86651. /**
  86652. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  86653. * If the mesh has no geometry, it is simply returned as it is.
  86654. * @param kind defines vertex data kind:
  86655. * * VertexBuffer.PositionKind
  86656. * * VertexBuffer.UVKind
  86657. * * VertexBuffer.UV2Kind
  86658. * * VertexBuffer.UV3Kind
  86659. * * VertexBuffer.UV4Kind
  86660. * * VertexBuffer.UV5Kind
  86661. * * VertexBuffer.UV6Kind
  86662. * * VertexBuffer.ColorKind
  86663. * * VertexBuffer.MatricesIndicesKind
  86664. * * VertexBuffer.MatricesIndicesExtraKind
  86665. * * VertexBuffer.MatricesWeightsKind
  86666. * * VertexBuffer.MatricesWeightsExtraKind
  86667. * @param data defines the data source
  86668. * @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
  86669. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  86670. * @returns the current mesh
  86671. */
  86672. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  86673. /**
  86674. * Sets the mesh indices,
  86675. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  86676. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  86677. * @param totalVertices Defines the total number of vertices
  86678. * @returns the current mesh
  86679. */
  86680. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  86681. /**
  86682. * Gets a boolean indicating if specific vertex data is present
  86683. * @param kind defines the vertex data kind to use
  86684. * @returns true is data kind is present
  86685. */
  86686. isVerticesDataPresent(kind: string): boolean;
  86687. /**
  86688. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  86689. * @returns a BoundingInfo
  86690. */
  86691. getBoundingInfo(): BoundingInfo;
  86692. /**
  86693. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  86694. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  86695. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  86696. * @returns the current mesh
  86697. */
  86698. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean): AbstractMesh;
  86699. /**
  86700. * Overwrite the current bounding info
  86701. * @param boundingInfo defines the new bounding info
  86702. * @returns the current mesh
  86703. */
  86704. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  86705. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  86706. readonly useBones: boolean;
  86707. /** @hidden */
  86708. _preActivate(): void;
  86709. /** @hidden */
  86710. _preActivateForIntermediateRendering(renderId: number): void;
  86711. /** @hidden */
  86712. _activate(renderId: number, intermediateRendering: boolean): boolean;
  86713. /** @hidden */
  86714. _postActivate(): void;
  86715. /** @hidden */
  86716. _freeze(): void;
  86717. /** @hidden */
  86718. _unFreeze(): void;
  86719. /**
  86720. * Gets the current world matrix
  86721. * @returns a Matrix
  86722. */
  86723. getWorldMatrix(): Matrix;
  86724. /** @hidden */
  86725. _getWorldMatrixDeterminant(): number;
  86726. /**
  86727. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  86728. */
  86729. readonly isAnInstance: boolean;
  86730. /**
  86731. * Perform relative position change from the point of view of behind the front of the mesh.
  86732. * This is performed taking into account the meshes current rotation, so you do not have to care.
  86733. * Supports definition of mesh facing forward or backward
  86734. * @param amountRight defines the distance on the right axis
  86735. * @param amountUp defines the distance on the up axis
  86736. * @param amountForward defines the distance on the forward axis
  86737. * @returns the current mesh
  86738. */
  86739. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  86740. /**
  86741. * Calculate relative position change from the point of view of behind the front of the mesh.
  86742. * This is performed taking into account the meshes current rotation, so you do not have to care.
  86743. * Supports definition of mesh facing forward or backward
  86744. * @param amountRight defines the distance on the right axis
  86745. * @param amountUp defines the distance on the up axis
  86746. * @param amountForward defines the distance on the forward axis
  86747. * @returns the new displacement vector
  86748. */
  86749. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  86750. /**
  86751. * Perform relative rotation change from the point of view of behind the front of the mesh.
  86752. * Supports definition of mesh facing forward or backward
  86753. * @param flipBack defines the flip
  86754. * @param twirlClockwise defines the twirl
  86755. * @param tiltRight defines the tilt
  86756. * @returns the current mesh
  86757. */
  86758. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  86759. /**
  86760. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  86761. * Supports definition of mesh facing forward or backward.
  86762. * @param flipBack defines the flip
  86763. * @param twirlClockwise defines the twirl
  86764. * @param tiltRight defines the tilt
  86765. * @returns the new rotation vector
  86766. */
  86767. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  86768. /**
  86769. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  86770. * This means the mesh underlying bounding box and sphere are recomputed.
  86771. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  86772. * @returns the current mesh
  86773. */
  86774. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  86775. /** @hidden */
  86776. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  86777. /** @hidden */
  86778. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  86779. /** @hidden */
  86780. _updateBoundingInfo(): AbstractMesh;
  86781. /** @hidden */
  86782. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  86783. /** @hidden */
  86784. protected _afterComputeWorldMatrix(): void;
  86785. /** @hidden */
  86786. readonly _effectiveMesh: AbstractMesh;
  86787. /**
  86788. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  86789. * A mesh is in the frustum if its bounding box intersects the frustum
  86790. * @param frustumPlanes defines the frustum to test
  86791. * @returns true if the mesh is in the frustum planes
  86792. */
  86793. isInFrustum(frustumPlanes: Plane[]): boolean;
  86794. /**
  86795. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  86796. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  86797. * @param frustumPlanes defines the frustum to test
  86798. * @returns true if the mesh is completely in the frustum planes
  86799. */
  86800. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  86801. /**
  86802. * True if the mesh intersects another mesh or a SolidParticle object
  86803. * @param mesh defines a target mesh or SolidParticle to test
  86804. * @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)
  86805. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  86806. * @returns true if there is an intersection
  86807. */
  86808. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  86809. /**
  86810. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  86811. * @param point defines the point to test
  86812. * @returns true if there is an intersection
  86813. */
  86814. intersectsPoint(point: Vector3): boolean;
  86815. /**
  86816. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  86817. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  86818. */
  86819. checkCollisions: boolean;
  86820. /**
  86821. * Gets Collider object used to compute collisions (not physics)
  86822. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  86823. */
  86824. readonly collider: Nullable<Collider>;
  86825. /**
  86826. * Move the mesh using collision engine
  86827. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  86828. * @param displacement defines the requested displacement vector
  86829. * @returns the current mesh
  86830. */
  86831. moveWithCollisions(displacement: Vector3): AbstractMesh;
  86832. private _onCollisionPositionChange;
  86833. /** @hidden */
  86834. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  86835. /** @hidden */
  86836. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  86837. /** @hidden */
  86838. _checkCollision(collider: Collider): AbstractMesh;
  86839. /** @hidden */
  86840. _generatePointsArray(): boolean;
  86841. /**
  86842. * Checks if the passed Ray intersects with the mesh
  86843. * @param ray defines the ray to use
  86844. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  86845. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  86846. * @returns the picking info
  86847. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  86848. */
  86849. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  86850. /**
  86851. * Clones the current mesh
  86852. * @param name defines the mesh name
  86853. * @param newParent defines the new mesh parent
  86854. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  86855. * @returns the new mesh
  86856. */
  86857. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  86858. /**
  86859. * Disposes all the submeshes of the current meshnp
  86860. * @returns the current mesh
  86861. */
  86862. releaseSubMeshes(): AbstractMesh;
  86863. /**
  86864. * Releases resources associated with this abstract mesh.
  86865. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  86866. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  86867. */
  86868. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  86869. /**
  86870. * Adds the passed mesh as a child to the current mesh
  86871. * @param mesh defines the child mesh
  86872. * @returns the current mesh
  86873. */
  86874. addChild(mesh: AbstractMesh): AbstractMesh;
  86875. /**
  86876. * Removes the passed mesh from the current mesh children list
  86877. * @param mesh defines the child mesh
  86878. * @returns the current mesh
  86879. */
  86880. removeChild(mesh: AbstractMesh): AbstractMesh;
  86881. /** @hidden */
  86882. private _initFacetData;
  86883. /**
  86884. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  86885. * This method can be called within the render loop.
  86886. * 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
  86887. * @returns the current mesh
  86888. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  86889. */
  86890. updateFacetData(): AbstractMesh;
  86891. /**
  86892. * Returns the facetLocalNormals array.
  86893. * The normals are expressed in the mesh local spac
  86894. * @returns an array of Vector3
  86895. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  86896. */
  86897. getFacetLocalNormals(): Vector3[];
  86898. /**
  86899. * Returns the facetLocalPositions array.
  86900. * The facet positions are expressed in the mesh local space
  86901. * @returns an array of Vector3
  86902. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  86903. */
  86904. getFacetLocalPositions(): Vector3[];
  86905. /**
  86906. * Returns the facetLocalPartioning array
  86907. * @returns an array of array of numbers
  86908. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  86909. */
  86910. getFacetLocalPartitioning(): number[][];
  86911. /**
  86912. * Returns the i-th facet position in the world system.
  86913. * This method allocates a new Vector3 per call
  86914. * @param i defines the facet index
  86915. * @returns a new Vector3
  86916. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  86917. */
  86918. getFacetPosition(i: number): Vector3;
  86919. /**
  86920. * Sets the reference Vector3 with the i-th facet position in the world system
  86921. * @param i defines the facet index
  86922. * @param ref defines the target vector
  86923. * @returns the current mesh
  86924. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  86925. */
  86926. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  86927. /**
  86928. * Returns the i-th facet normal in the world system.
  86929. * This method allocates a new Vector3 per call
  86930. * @param i defines the facet index
  86931. * @returns a new Vector3
  86932. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  86933. */
  86934. getFacetNormal(i: number): Vector3;
  86935. /**
  86936. * Sets the reference Vector3 with the i-th facet normal in the world system
  86937. * @param i defines the facet index
  86938. * @param ref defines the target vector
  86939. * @returns the current mesh
  86940. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  86941. */
  86942. getFacetNormalToRef(i: number, ref: Vector3): this;
  86943. /**
  86944. * 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)
  86945. * @param x defines x coordinate
  86946. * @param y defines y coordinate
  86947. * @param z defines z coordinate
  86948. * @returns the array of facet indexes
  86949. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  86950. */
  86951. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  86952. /**
  86953. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  86954. * @param projected sets as the (x,y,z) world projection on the facet
  86955. * @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
  86956. * @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
  86957. * @param x defines x coordinate
  86958. * @param y defines y coordinate
  86959. * @param z defines z coordinate
  86960. * @returns the face index if found (or null instead)
  86961. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  86962. */
  86963. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  86964. /**
  86965. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  86966. * @param projected sets as the (x,y,z) local projection on the facet
  86967. * @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
  86968. * @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
  86969. * @param x defines x coordinate
  86970. * @param y defines y coordinate
  86971. * @param z defines z coordinate
  86972. * @returns the face index if found (or null instead)
  86973. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  86974. */
  86975. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  86976. /**
  86977. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  86978. * @returns the parameters
  86979. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  86980. */
  86981. getFacetDataParameters(): any;
  86982. /**
  86983. * Disables the feature FacetData and frees the related memory
  86984. * @returns the current mesh
  86985. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  86986. */
  86987. disableFacetData(): AbstractMesh;
  86988. /**
  86989. * Updates the AbstractMesh indices array
  86990. * @param indices defines the data source
  86991. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  86992. * @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)
  86993. * @returns the current mesh
  86994. */
  86995. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  86996. /**
  86997. * Creates new normals data for the mesh
  86998. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  86999. * @returns the current mesh
  87000. */
  87001. createNormals(updatable: boolean): AbstractMesh;
  87002. /**
  87003. * Align the mesh with a normal
  87004. * @param normal defines the normal to use
  87005. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  87006. * @returns the current mesh
  87007. */
  87008. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  87009. /** @hidden */
  87010. _checkOcclusionQuery(): boolean;
  87011. /**
  87012. * Disables the mesh edge rendering mode
  87013. * @returns the currentAbstractMesh
  87014. */
  87015. disableEdgesRendering(): AbstractMesh;
  87016. /**
  87017. * Enables the edge rendering mode on the mesh.
  87018. * This mode makes the mesh edges visible
  87019. * @param epsilon defines the maximal distance between two angles to detect a face
  87020. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  87021. * @returns the currentAbstractMesh
  87022. * @see https://www.babylonjs-playground.com/#19O9TU#0
  87023. */
  87024. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  87025. }
  87026. }
  87027. declare module BABYLON {
  87028. /**
  87029. * Interface used to define ActionEvent
  87030. */
  87031. export interface IActionEvent {
  87032. /** The mesh or sprite that triggered the action */
  87033. source: any;
  87034. /** The X mouse cursor position at the time of the event */
  87035. pointerX: number;
  87036. /** The Y mouse cursor position at the time of the event */
  87037. pointerY: number;
  87038. /** The mesh that is currently pointed at (can be null) */
  87039. meshUnderPointer: Nullable<AbstractMesh>;
  87040. /** the original (browser) event that triggered the ActionEvent */
  87041. sourceEvent?: any;
  87042. /** additional data for the event */
  87043. additionalData?: any;
  87044. }
  87045. /**
  87046. * ActionEvent is the event being sent when an action is triggered.
  87047. */
  87048. export class ActionEvent implements IActionEvent {
  87049. /** The mesh or sprite that triggered the action */
  87050. source: any;
  87051. /** The X mouse cursor position at the time of the event */
  87052. pointerX: number;
  87053. /** The Y mouse cursor position at the time of the event */
  87054. pointerY: number;
  87055. /** The mesh that is currently pointed at (can be null) */
  87056. meshUnderPointer: Nullable<AbstractMesh>;
  87057. /** the original (browser) event that triggered the ActionEvent */
  87058. sourceEvent?: any;
  87059. /** additional data for the event */
  87060. additionalData?: any;
  87061. /**
  87062. * Creates a new ActionEvent
  87063. * @param source The mesh or sprite that triggered the action
  87064. * @param pointerX The X mouse cursor position at the time of the event
  87065. * @param pointerY The Y mouse cursor position at the time of the event
  87066. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  87067. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  87068. * @param additionalData additional data for the event
  87069. */
  87070. constructor(
  87071. /** The mesh or sprite that triggered the action */
  87072. source: any,
  87073. /** The X mouse cursor position at the time of the event */
  87074. pointerX: number,
  87075. /** The Y mouse cursor position at the time of the event */
  87076. pointerY: number,
  87077. /** The mesh that is currently pointed at (can be null) */
  87078. meshUnderPointer: Nullable<AbstractMesh>,
  87079. /** the original (browser) event that triggered the ActionEvent */
  87080. sourceEvent?: any,
  87081. /** additional data for the event */
  87082. additionalData?: any);
  87083. /**
  87084. * Helper function to auto-create an ActionEvent from a source mesh.
  87085. * @param source The source mesh that triggered the event
  87086. * @param evt The original (browser) event
  87087. * @param additionalData additional data for the event
  87088. * @returns the new ActionEvent
  87089. */
  87090. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  87091. /**
  87092. * Helper function to auto-create an ActionEvent from a source sprite
  87093. * @param source The source sprite that triggered the event
  87094. * @param scene Scene associated with the sprite
  87095. * @param evt The original (browser) event
  87096. * @param additionalData additional data for the event
  87097. * @returns the new ActionEvent
  87098. */
  87099. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  87100. /**
  87101. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  87102. * @param scene the scene where the event occurred
  87103. * @param evt The original (browser) event
  87104. * @returns the new ActionEvent
  87105. */
  87106. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  87107. /**
  87108. * Helper function to auto-create an ActionEvent from a primitive
  87109. * @param prim defines the target primitive
  87110. * @param pointerPos defines the pointer position
  87111. * @param evt The original (browser) event
  87112. * @param additionalData additional data for the event
  87113. * @returns the new ActionEvent
  87114. */
  87115. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  87116. }
  87117. }
  87118. declare module BABYLON {
  87119. /**
  87120. * Abstract class used to decouple action Manager from scene and meshes.
  87121. * Do not instantiate.
  87122. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  87123. */
  87124. export abstract class AbstractActionManager implements IDisposable {
  87125. /** Gets the list of active triggers */
  87126. static Triggers: {
  87127. [key: string]: number;
  87128. };
  87129. /** Gets the cursor to use when hovering items */
  87130. hoverCursor: string;
  87131. /** Gets the list of actions */
  87132. actions: IAction[];
  87133. /**
  87134. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  87135. */
  87136. isRecursive: boolean;
  87137. /**
  87138. * Releases all associated resources
  87139. */
  87140. abstract dispose(): void;
  87141. /**
  87142. * Does this action manager has pointer triggers
  87143. */
  87144. abstract readonly hasPointerTriggers: boolean;
  87145. /**
  87146. * Does this action manager has pick triggers
  87147. */
  87148. abstract readonly hasPickTriggers: boolean;
  87149. /**
  87150. * Process a specific trigger
  87151. * @param trigger defines the trigger to process
  87152. * @param evt defines the event details to be processed
  87153. */
  87154. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  87155. /**
  87156. * Does this action manager handles actions of any of the given triggers
  87157. * @param triggers defines the triggers to be tested
  87158. * @return a boolean indicating whether one (or more) of the triggers is handled
  87159. */
  87160. abstract hasSpecificTriggers(triggers: number[]): boolean;
  87161. /**
  87162. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  87163. * speed.
  87164. * @param triggerA defines the trigger to be tested
  87165. * @param triggerB defines the trigger to be tested
  87166. * @return a boolean indicating whether one (or more) of the triggers is handled
  87167. */
  87168. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  87169. /**
  87170. * Does this action manager handles actions of a given trigger
  87171. * @param trigger defines the trigger to be tested
  87172. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  87173. * @return whether the trigger is handled
  87174. */
  87175. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  87176. /**
  87177. * Serialize this manager to a JSON object
  87178. * @param name defines the property name to store this manager
  87179. * @returns a JSON representation of this manager
  87180. */
  87181. abstract serialize(name: string): any;
  87182. /**
  87183. * Registers an action to this action manager
  87184. * @param action defines the action to be registered
  87185. * @return the action amended (prepared) after registration
  87186. */
  87187. abstract registerAction(action: IAction): Nullable<IAction>;
  87188. /**
  87189. * Unregisters an action to this action manager
  87190. * @param action defines the action to be unregistered
  87191. * @return a boolean indicating whether the action has been unregistered
  87192. */
  87193. abstract unregisterAction(action: IAction): Boolean;
  87194. /**
  87195. * Does exist one action manager with at least one trigger
  87196. **/
  87197. static readonly HasTriggers: boolean;
  87198. /**
  87199. * Does exist one action manager with at least one pick trigger
  87200. **/
  87201. static readonly HasPickTriggers: boolean;
  87202. /**
  87203. * Does exist one action manager that handles actions of a given trigger
  87204. * @param trigger defines the trigger to be tested
  87205. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  87206. **/
  87207. static HasSpecificTrigger(trigger: number): boolean;
  87208. }
  87209. }
  87210. declare module BABYLON {
  87211. /**
  87212. * Defines how a node can be built from a string name.
  87213. */
  87214. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  87215. /**
  87216. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  87217. */
  87218. export class Node implements IBehaviorAware<Node> {
  87219. /** @hidden */
  87220. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  87221. private static _NodeConstructors;
  87222. /**
  87223. * Add a new node constructor
  87224. * @param type defines the type name of the node to construct
  87225. * @param constructorFunc defines the constructor function
  87226. */
  87227. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  87228. /**
  87229. * Returns a node constructor based on type name
  87230. * @param type defines the type name
  87231. * @param name defines the new node name
  87232. * @param scene defines the hosting scene
  87233. * @param options defines optional options to transmit to constructors
  87234. * @returns the new constructor or null
  87235. */
  87236. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  87237. /**
  87238. * Gets or sets the name of the node
  87239. */
  87240. name: string;
  87241. /**
  87242. * Gets or sets the id of the node
  87243. */
  87244. id: string;
  87245. /**
  87246. * Gets or sets the unique id of the node
  87247. */
  87248. uniqueId: number;
  87249. /**
  87250. * Gets or sets a string used to store user defined state for the node
  87251. */
  87252. state: string;
  87253. /**
  87254. * Gets or sets an object used to store user defined information for the node
  87255. */
  87256. metadata: any;
  87257. /**
  87258. * For internal use only. Please do not use.
  87259. */
  87260. reservedDataStore: any;
  87261. /**
  87262. * List of inspectable custom properties (used by the Inspector)
  87263. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  87264. */
  87265. inspectableCustomProperties: IInspectable[];
  87266. /**
  87267. * Gets or sets a boolean used to define if the node must be serialized
  87268. */
  87269. doNotSerialize: boolean;
  87270. /** @hidden */
  87271. _isDisposed: boolean;
  87272. /**
  87273. * Gets a list of Animations associated with the node
  87274. */
  87275. animations: Animation[];
  87276. protected _ranges: {
  87277. [name: string]: Nullable<AnimationRange>;
  87278. };
  87279. /**
  87280. * Callback raised when the node is ready to be used
  87281. */
  87282. onReady: Nullable<(node: Node) => void>;
  87283. private _isEnabled;
  87284. private _isParentEnabled;
  87285. private _isReady;
  87286. /** @hidden */
  87287. _currentRenderId: number;
  87288. private _parentUpdateId;
  87289. /** @hidden */
  87290. _childUpdateId: number;
  87291. /** @hidden */
  87292. _waitingParentId: Nullable<string>;
  87293. /** @hidden */
  87294. _scene: Scene;
  87295. /** @hidden */
  87296. _cache: any;
  87297. private _parentNode;
  87298. private _children;
  87299. /** @hidden */
  87300. _worldMatrix: Matrix;
  87301. /** @hidden */
  87302. _worldMatrixDeterminant: number;
  87303. /** @hidden */
  87304. _worldMatrixDeterminantIsDirty: boolean;
  87305. /** @hidden */
  87306. private _sceneRootNodesIndex;
  87307. /**
  87308. * Gets a boolean indicating if the node has been disposed
  87309. * @returns true if the node was disposed
  87310. */
  87311. isDisposed(): boolean;
  87312. /**
  87313. * Gets or sets the parent of the node (without keeping the current position in the scene)
  87314. * @see https://doc.babylonjs.com/how_to/parenting
  87315. */
  87316. parent: Nullable<Node>;
  87317. private addToSceneRootNodes;
  87318. private removeFromSceneRootNodes;
  87319. private _animationPropertiesOverride;
  87320. /**
  87321. * Gets or sets the animation properties override
  87322. */
  87323. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  87324. /**
  87325. * Gets a string idenfifying the name of the class
  87326. * @returns "Node" string
  87327. */
  87328. getClassName(): string;
  87329. /** @hidden */
  87330. readonly _isNode: boolean;
  87331. /**
  87332. * An event triggered when the mesh is disposed
  87333. */
  87334. onDisposeObservable: Observable<Node>;
  87335. private _onDisposeObserver;
  87336. /**
  87337. * Sets a callback that will be raised when the node will be disposed
  87338. */
  87339. onDispose: () => void;
  87340. /**
  87341. * Creates a new Node
  87342. * @param name the name and id to be given to this node
  87343. * @param scene the scene this node will be added to
  87344. * @param addToRootNodes the node will be added to scene.rootNodes
  87345. */
  87346. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  87347. /**
  87348. * Gets the scene of the node
  87349. * @returns a scene
  87350. */
  87351. getScene(): Scene;
  87352. /**
  87353. * Gets the engine of the node
  87354. * @returns a Engine
  87355. */
  87356. getEngine(): Engine;
  87357. private _behaviors;
  87358. /**
  87359. * Attach a behavior to the node
  87360. * @see http://doc.babylonjs.com/features/behaviour
  87361. * @param behavior defines the behavior to attach
  87362. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  87363. * @returns the current Node
  87364. */
  87365. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  87366. /**
  87367. * Remove an attached behavior
  87368. * @see http://doc.babylonjs.com/features/behaviour
  87369. * @param behavior defines the behavior to attach
  87370. * @returns the current Node
  87371. */
  87372. removeBehavior(behavior: Behavior<Node>): Node;
  87373. /**
  87374. * Gets the list of attached behaviors
  87375. * @see http://doc.babylonjs.com/features/behaviour
  87376. */
  87377. readonly behaviors: Behavior<Node>[];
  87378. /**
  87379. * Gets an attached behavior by name
  87380. * @param name defines the name of the behavior to look for
  87381. * @see http://doc.babylonjs.com/features/behaviour
  87382. * @returns null if behavior was not found else the requested behavior
  87383. */
  87384. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  87385. /**
  87386. * Returns the latest update of the World matrix
  87387. * @returns a Matrix
  87388. */
  87389. getWorldMatrix(): Matrix;
  87390. /** @hidden */
  87391. _getWorldMatrixDeterminant(): number;
  87392. /**
  87393. * Returns directly the latest state of the mesh World matrix.
  87394. * A Matrix is returned.
  87395. */
  87396. readonly worldMatrixFromCache: Matrix;
  87397. /** @hidden */
  87398. _initCache(): void;
  87399. /** @hidden */
  87400. updateCache(force?: boolean): void;
  87401. /** @hidden */
  87402. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  87403. /** @hidden */
  87404. _updateCache(ignoreParentClass?: boolean): void;
  87405. /** @hidden */
  87406. _isSynchronized(): boolean;
  87407. /** @hidden */
  87408. _markSyncedWithParent(): void;
  87409. /** @hidden */
  87410. isSynchronizedWithParent(): boolean;
  87411. /** @hidden */
  87412. isSynchronized(): boolean;
  87413. /**
  87414. * Is this node ready to be used/rendered
  87415. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  87416. * @return true if the node is ready
  87417. */
  87418. isReady(completeCheck?: boolean): boolean;
  87419. /**
  87420. * Is this node enabled?
  87421. * 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
  87422. * @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
  87423. * @return whether this node (and its parent) is enabled
  87424. */
  87425. isEnabled(checkAncestors?: boolean): boolean;
  87426. /** @hidden */
  87427. protected _syncParentEnabledState(): void;
  87428. /**
  87429. * Set the enabled state of this node
  87430. * @param value defines the new enabled state
  87431. */
  87432. setEnabled(value: boolean): void;
  87433. /**
  87434. * Is this node a descendant of the given node?
  87435. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  87436. * @param ancestor defines the parent node to inspect
  87437. * @returns a boolean indicating if this node is a descendant of the given node
  87438. */
  87439. isDescendantOf(ancestor: Node): boolean;
  87440. /** @hidden */
  87441. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  87442. /**
  87443. * Will return all nodes that have this node as ascendant
  87444. * @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
  87445. * @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
  87446. * @return all children nodes of all types
  87447. */
  87448. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  87449. /**
  87450. * Get all child-meshes of this node
  87451. * @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)
  87452. * @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
  87453. * @returns an array of AbstractMesh
  87454. */
  87455. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  87456. /**
  87457. * Get all direct children of this node
  87458. * @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
  87459. * @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)
  87460. * @returns an array of Node
  87461. */
  87462. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  87463. /** @hidden */
  87464. _setReady(state: boolean): void;
  87465. /**
  87466. * Get an animation by name
  87467. * @param name defines the name of the animation to look for
  87468. * @returns null if not found else the requested animation
  87469. */
  87470. getAnimationByName(name: string): Nullable<Animation>;
  87471. /**
  87472. * Creates an animation range for this node
  87473. * @param name defines the name of the range
  87474. * @param from defines the starting key
  87475. * @param to defines the end key
  87476. */
  87477. createAnimationRange(name: string, from: number, to: number): void;
  87478. /**
  87479. * Delete a specific animation range
  87480. * @param name defines the name of the range to delete
  87481. * @param deleteFrames defines if animation frames from the range must be deleted as well
  87482. */
  87483. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  87484. /**
  87485. * Get an animation range by name
  87486. * @param name defines the name of the animation range to look for
  87487. * @returns null if not found else the requested animation range
  87488. */
  87489. getAnimationRange(name: string): Nullable<AnimationRange>;
  87490. /**
  87491. * Gets the list of all animation ranges defined on this node
  87492. * @returns an array
  87493. */
  87494. getAnimationRanges(): Nullable<AnimationRange>[];
  87495. /**
  87496. * Will start the animation sequence
  87497. * @param name defines the range frames for animation sequence
  87498. * @param loop defines if the animation should loop (false by default)
  87499. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  87500. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  87501. * @returns the object created for this animation. If range does not exist, it will return null
  87502. */
  87503. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  87504. /**
  87505. * Serialize animation ranges into a JSON compatible object
  87506. * @returns serialization object
  87507. */
  87508. serializeAnimationRanges(): any;
  87509. /**
  87510. * Computes the world matrix of the node
  87511. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  87512. * @returns the world matrix
  87513. */
  87514. computeWorldMatrix(force?: boolean): Matrix;
  87515. /**
  87516. * Releases resources associated with this node.
  87517. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  87518. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  87519. */
  87520. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  87521. /**
  87522. * Parse animation range data from a serialization object and store them into a given node
  87523. * @param node defines where to store the animation ranges
  87524. * @param parsedNode defines the serialization object to read data from
  87525. * @param scene defines the hosting scene
  87526. */
  87527. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  87528. /**
  87529. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  87530. * @param includeDescendants Include bounding info from descendants as well (true by default)
  87531. * @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
  87532. * @returns the new bounding vectors
  87533. */
  87534. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  87535. min: Vector3;
  87536. max: Vector3;
  87537. };
  87538. }
  87539. }
  87540. declare module BABYLON {
  87541. /**
  87542. * @hidden
  87543. */
  87544. export class _IAnimationState {
  87545. key: number;
  87546. repeatCount: number;
  87547. workValue?: any;
  87548. loopMode?: number;
  87549. offsetValue?: any;
  87550. highLimitValue?: any;
  87551. }
  87552. /**
  87553. * Class used to store any kind of animation
  87554. */
  87555. export class Animation {
  87556. /**Name of the animation */
  87557. name: string;
  87558. /**Property to animate */
  87559. targetProperty: string;
  87560. /**The frames per second of the animation */
  87561. framePerSecond: number;
  87562. /**The data type of the animation */
  87563. dataType: number;
  87564. /**The loop mode of the animation */
  87565. loopMode?: number | undefined;
  87566. /**Specifies if blending should be enabled */
  87567. enableBlending?: boolean | undefined;
  87568. /**
  87569. * Use matrix interpolation instead of using direct key value when animating matrices
  87570. */
  87571. static AllowMatricesInterpolation: boolean;
  87572. /**
  87573. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  87574. */
  87575. static AllowMatrixDecomposeForInterpolation: boolean;
  87576. /**
  87577. * Stores the key frames of the animation
  87578. */
  87579. private _keys;
  87580. /**
  87581. * Stores the easing function of the animation
  87582. */
  87583. private _easingFunction;
  87584. /**
  87585. * @hidden Internal use only
  87586. */
  87587. _runtimeAnimations: RuntimeAnimation[];
  87588. /**
  87589. * The set of event that will be linked to this animation
  87590. */
  87591. private _events;
  87592. /**
  87593. * Stores an array of target property paths
  87594. */
  87595. targetPropertyPath: string[];
  87596. /**
  87597. * Stores the blending speed of the animation
  87598. */
  87599. blendingSpeed: number;
  87600. /**
  87601. * Stores the animation ranges for the animation
  87602. */
  87603. private _ranges;
  87604. /**
  87605. * @hidden Internal use
  87606. */
  87607. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  87608. /**
  87609. * Sets up an animation
  87610. * @param property The property to animate
  87611. * @param animationType The animation type to apply
  87612. * @param framePerSecond The frames per second of the animation
  87613. * @param easingFunction The easing function used in the animation
  87614. * @returns The created animation
  87615. */
  87616. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  87617. /**
  87618. * Create and start an animation on a node
  87619. * @param name defines the name of the global animation that will be run on all nodes
  87620. * @param node defines the root node where the animation will take place
  87621. * @param targetProperty defines property to animate
  87622. * @param framePerSecond defines the number of frame per second yo use
  87623. * @param totalFrame defines the number of frames in total
  87624. * @param from defines the initial value
  87625. * @param to defines the final value
  87626. * @param loopMode defines which loop mode you want to use (off by default)
  87627. * @param easingFunction defines the easing function to use (linear by default)
  87628. * @param onAnimationEnd defines the callback to call when animation end
  87629. * @returns the animatable created for this animation
  87630. */
  87631. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  87632. /**
  87633. * Create and start an animation on a node and its descendants
  87634. * @param name defines the name of the global animation that will be run on all nodes
  87635. * @param node defines the root node where the animation will take place
  87636. * @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
  87637. * @param targetProperty defines property to animate
  87638. * @param framePerSecond defines the number of frame per second to use
  87639. * @param totalFrame defines the number of frames in total
  87640. * @param from defines the initial value
  87641. * @param to defines the final value
  87642. * @param loopMode defines which loop mode you want to use (off by default)
  87643. * @param easingFunction defines the easing function to use (linear by default)
  87644. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  87645. * @returns the list of animatables created for all nodes
  87646. * @example https://www.babylonjs-playground.com/#MH0VLI
  87647. */
  87648. 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[]>;
  87649. /**
  87650. * Creates a new animation, merges it with the existing animations and starts it
  87651. * @param name Name of the animation
  87652. * @param node Node which contains the scene that begins the animations
  87653. * @param targetProperty Specifies which property to animate
  87654. * @param framePerSecond The frames per second of the animation
  87655. * @param totalFrame The total number of frames
  87656. * @param from The frame at the beginning of the animation
  87657. * @param to The frame at the end of the animation
  87658. * @param loopMode Specifies the loop mode of the animation
  87659. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  87660. * @param onAnimationEnd Callback to run once the animation is complete
  87661. * @returns Nullable animation
  87662. */
  87663. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  87664. /**
  87665. * Transition property of an host to the target Value
  87666. * @param property The property to transition
  87667. * @param targetValue The target Value of the property
  87668. * @param host The object where the property to animate belongs
  87669. * @param scene Scene used to run the animation
  87670. * @param frameRate Framerate (in frame/s) to use
  87671. * @param transition The transition type we want to use
  87672. * @param duration The duration of the animation, in milliseconds
  87673. * @param onAnimationEnd Callback trigger at the end of the animation
  87674. * @returns Nullable animation
  87675. */
  87676. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  87677. /**
  87678. * Return the array of runtime animations currently using this animation
  87679. */
  87680. readonly runtimeAnimations: RuntimeAnimation[];
  87681. /**
  87682. * Specifies if any of the runtime animations are currently running
  87683. */
  87684. readonly hasRunningRuntimeAnimations: boolean;
  87685. /**
  87686. * Initializes the animation
  87687. * @param name Name of the animation
  87688. * @param targetProperty Property to animate
  87689. * @param framePerSecond The frames per second of the animation
  87690. * @param dataType The data type of the animation
  87691. * @param loopMode The loop mode of the animation
  87692. * @param enableBlending Specifies if blending should be enabled
  87693. */
  87694. constructor(
  87695. /**Name of the animation */
  87696. name: string,
  87697. /**Property to animate */
  87698. targetProperty: string,
  87699. /**The frames per second of the animation */
  87700. framePerSecond: number,
  87701. /**The data type of the animation */
  87702. dataType: number,
  87703. /**The loop mode of the animation */
  87704. loopMode?: number | undefined,
  87705. /**Specifies if blending should be enabled */
  87706. enableBlending?: boolean | undefined);
  87707. /**
  87708. * Converts the animation to a string
  87709. * @param fullDetails support for multiple levels of logging within scene loading
  87710. * @returns String form of the animation
  87711. */
  87712. toString(fullDetails?: boolean): string;
  87713. /**
  87714. * Add an event to this animation
  87715. * @param event Event to add
  87716. */
  87717. addEvent(event: AnimationEvent): void;
  87718. /**
  87719. * Remove all events found at the given frame
  87720. * @param frame The frame to remove events from
  87721. */
  87722. removeEvents(frame: number): void;
  87723. /**
  87724. * Retrieves all the events from the animation
  87725. * @returns Events from the animation
  87726. */
  87727. getEvents(): AnimationEvent[];
  87728. /**
  87729. * Creates an animation range
  87730. * @param name Name of the animation range
  87731. * @param from Starting frame of the animation range
  87732. * @param to Ending frame of the animation
  87733. */
  87734. createRange(name: string, from: number, to: number): void;
  87735. /**
  87736. * Deletes an animation range by name
  87737. * @param name Name of the animation range to delete
  87738. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  87739. */
  87740. deleteRange(name: string, deleteFrames?: boolean): void;
  87741. /**
  87742. * Gets the animation range by name, or null if not defined
  87743. * @param name Name of the animation range
  87744. * @returns Nullable animation range
  87745. */
  87746. getRange(name: string): Nullable<AnimationRange>;
  87747. /**
  87748. * Gets the key frames from the animation
  87749. * @returns The key frames of the animation
  87750. */
  87751. getKeys(): Array<IAnimationKey>;
  87752. /**
  87753. * Gets the highest frame rate of the animation
  87754. * @returns Highest frame rate of the animation
  87755. */
  87756. getHighestFrame(): number;
  87757. /**
  87758. * Gets the easing function of the animation
  87759. * @returns Easing function of the animation
  87760. */
  87761. getEasingFunction(): IEasingFunction;
  87762. /**
  87763. * Sets the easing function of the animation
  87764. * @param easingFunction A custom mathematical formula for animation
  87765. */
  87766. setEasingFunction(easingFunction: EasingFunction): void;
  87767. /**
  87768. * Interpolates a scalar linearly
  87769. * @param startValue Start value of the animation curve
  87770. * @param endValue End value of the animation curve
  87771. * @param gradient Scalar amount to interpolate
  87772. * @returns Interpolated scalar value
  87773. */
  87774. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  87775. /**
  87776. * Interpolates a scalar cubically
  87777. * @param startValue Start value of the animation curve
  87778. * @param outTangent End tangent of the animation
  87779. * @param endValue End value of the animation curve
  87780. * @param inTangent Start tangent of the animation curve
  87781. * @param gradient Scalar amount to interpolate
  87782. * @returns Interpolated scalar value
  87783. */
  87784. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  87785. /**
  87786. * Interpolates a quaternion using a spherical linear interpolation
  87787. * @param startValue Start value of the animation curve
  87788. * @param endValue End value of the animation curve
  87789. * @param gradient Scalar amount to interpolate
  87790. * @returns Interpolated quaternion value
  87791. */
  87792. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  87793. /**
  87794. * Interpolates a quaternion cubically
  87795. * @param startValue Start value of the animation curve
  87796. * @param outTangent End tangent of the animation curve
  87797. * @param endValue End value of the animation curve
  87798. * @param inTangent Start tangent of the animation curve
  87799. * @param gradient Scalar amount to interpolate
  87800. * @returns Interpolated quaternion value
  87801. */
  87802. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  87803. /**
  87804. * Interpolates a Vector3 linearl
  87805. * @param startValue Start value of the animation curve
  87806. * @param endValue End value of the animation curve
  87807. * @param gradient Scalar amount to interpolate
  87808. * @returns Interpolated scalar value
  87809. */
  87810. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  87811. /**
  87812. * Interpolates a Vector3 cubically
  87813. * @param startValue Start value of the animation curve
  87814. * @param outTangent End tangent of the animation
  87815. * @param endValue End value of the animation curve
  87816. * @param inTangent Start tangent of the animation curve
  87817. * @param gradient Scalar amount to interpolate
  87818. * @returns InterpolatedVector3 value
  87819. */
  87820. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  87821. /**
  87822. * Interpolates a Vector2 linearly
  87823. * @param startValue Start value of the animation curve
  87824. * @param endValue End value of the animation curve
  87825. * @param gradient Scalar amount to interpolate
  87826. * @returns Interpolated Vector2 value
  87827. */
  87828. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  87829. /**
  87830. * Interpolates a Vector2 cubically
  87831. * @param startValue Start value of the animation curve
  87832. * @param outTangent End tangent of the animation
  87833. * @param endValue End value of the animation curve
  87834. * @param inTangent Start tangent of the animation curve
  87835. * @param gradient Scalar amount to interpolate
  87836. * @returns Interpolated Vector2 value
  87837. */
  87838. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  87839. /**
  87840. * Interpolates a size linearly
  87841. * @param startValue Start value of the animation curve
  87842. * @param endValue End value of the animation curve
  87843. * @param gradient Scalar amount to interpolate
  87844. * @returns Interpolated Size value
  87845. */
  87846. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  87847. /**
  87848. * Interpolates a Color3 linearly
  87849. * @param startValue Start value of the animation curve
  87850. * @param endValue End value of the animation curve
  87851. * @param gradient Scalar amount to interpolate
  87852. * @returns Interpolated Color3 value
  87853. */
  87854. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  87855. /**
  87856. * @hidden Internal use only
  87857. */
  87858. _getKeyValue(value: any): any;
  87859. /**
  87860. * @hidden Internal use only
  87861. */
  87862. _interpolate(currentFrame: number, state: _IAnimationState): any;
  87863. /**
  87864. * Defines the function to use to interpolate matrices
  87865. * @param startValue defines the start matrix
  87866. * @param endValue defines the end matrix
  87867. * @param gradient defines the gradient between both matrices
  87868. * @param result defines an optional target matrix where to store the interpolation
  87869. * @returns the interpolated matrix
  87870. */
  87871. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  87872. /**
  87873. * Makes a copy of the animation
  87874. * @returns Cloned animation
  87875. */
  87876. clone(): Animation;
  87877. /**
  87878. * Sets the key frames of the animation
  87879. * @param values The animation key frames to set
  87880. */
  87881. setKeys(values: Array<IAnimationKey>): void;
  87882. /**
  87883. * Serializes the animation to an object
  87884. * @returns Serialized object
  87885. */
  87886. serialize(): any;
  87887. /**
  87888. * Float animation type
  87889. */
  87890. private static _ANIMATIONTYPE_FLOAT;
  87891. /**
  87892. * Vector3 animation type
  87893. */
  87894. private static _ANIMATIONTYPE_VECTOR3;
  87895. /**
  87896. * Quaternion animation type
  87897. */
  87898. private static _ANIMATIONTYPE_QUATERNION;
  87899. /**
  87900. * Matrix animation type
  87901. */
  87902. private static _ANIMATIONTYPE_MATRIX;
  87903. /**
  87904. * Color3 animation type
  87905. */
  87906. private static _ANIMATIONTYPE_COLOR3;
  87907. /**
  87908. * Vector2 animation type
  87909. */
  87910. private static _ANIMATIONTYPE_VECTOR2;
  87911. /**
  87912. * Size animation type
  87913. */
  87914. private static _ANIMATIONTYPE_SIZE;
  87915. /**
  87916. * Relative Loop Mode
  87917. */
  87918. private static _ANIMATIONLOOPMODE_RELATIVE;
  87919. /**
  87920. * Cycle Loop Mode
  87921. */
  87922. private static _ANIMATIONLOOPMODE_CYCLE;
  87923. /**
  87924. * Constant Loop Mode
  87925. */
  87926. private static _ANIMATIONLOOPMODE_CONSTANT;
  87927. /**
  87928. * Get the float animation type
  87929. */
  87930. static readonly ANIMATIONTYPE_FLOAT: number;
  87931. /**
  87932. * Get the Vector3 animation type
  87933. */
  87934. static readonly ANIMATIONTYPE_VECTOR3: number;
  87935. /**
  87936. * Get the Vector2 animation type
  87937. */
  87938. static readonly ANIMATIONTYPE_VECTOR2: number;
  87939. /**
  87940. * Get the Size animation type
  87941. */
  87942. static readonly ANIMATIONTYPE_SIZE: number;
  87943. /**
  87944. * Get the Quaternion animation type
  87945. */
  87946. static readonly ANIMATIONTYPE_QUATERNION: number;
  87947. /**
  87948. * Get the Matrix animation type
  87949. */
  87950. static readonly ANIMATIONTYPE_MATRIX: number;
  87951. /**
  87952. * Get the Color3 animation type
  87953. */
  87954. static readonly ANIMATIONTYPE_COLOR3: number;
  87955. /**
  87956. * Get the Relative Loop Mode
  87957. */
  87958. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  87959. /**
  87960. * Get the Cycle Loop Mode
  87961. */
  87962. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  87963. /**
  87964. * Get the Constant Loop Mode
  87965. */
  87966. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  87967. /** @hidden */
  87968. static _UniversalLerp(left: any, right: any, amount: number): any;
  87969. /**
  87970. * Parses an animation object and creates an animation
  87971. * @param parsedAnimation Parsed animation object
  87972. * @returns Animation object
  87973. */
  87974. static Parse(parsedAnimation: any): Animation;
  87975. /**
  87976. * Appends the serialized animations from the source animations
  87977. * @param source Source containing the animations
  87978. * @param destination Target to store the animations
  87979. */
  87980. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  87981. }
  87982. }
  87983. declare module BABYLON {
  87984. /**
  87985. * Base class of all the textures in babylon.
  87986. * It groups all the common properties the materials, post process, lights... might need
  87987. * in order to make a correct use of the texture.
  87988. */
  87989. export class BaseTexture implements IAnimatable {
  87990. /**
  87991. * Default anisotropic filtering level for the application.
  87992. * It is set to 4 as a good tradeoff between perf and quality.
  87993. */
  87994. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  87995. /**
  87996. * Gets or sets the unique id of the texture
  87997. */
  87998. uniqueId: number;
  87999. /**
  88000. * Define the name of the texture.
  88001. */
  88002. name: string;
  88003. /**
  88004. * Gets or sets an object used to store user defined information.
  88005. */
  88006. metadata: any;
  88007. /**
  88008. * For internal use only. Please do not use.
  88009. */
  88010. reservedDataStore: any;
  88011. private _hasAlpha;
  88012. /**
  88013. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  88014. */
  88015. hasAlpha: boolean;
  88016. /**
  88017. * Defines if the alpha value should be determined via the rgb values.
  88018. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  88019. */
  88020. getAlphaFromRGB: boolean;
  88021. /**
  88022. * Intensity or strength of the texture.
  88023. * It is commonly used by materials to fine tune the intensity of the texture
  88024. */
  88025. level: number;
  88026. /**
  88027. * Define the UV chanel to use starting from 0 and defaulting to 0.
  88028. * This is part of the texture as textures usually maps to one uv set.
  88029. */
  88030. coordinatesIndex: number;
  88031. private _coordinatesMode;
  88032. /**
  88033. * How a texture is mapped.
  88034. *
  88035. * | Value | Type | Description |
  88036. * | ----- | ----------------------------------- | ----------- |
  88037. * | 0 | EXPLICIT_MODE | |
  88038. * | 1 | SPHERICAL_MODE | |
  88039. * | 2 | PLANAR_MODE | |
  88040. * | 3 | CUBIC_MODE | |
  88041. * | 4 | PROJECTION_MODE | |
  88042. * | 5 | SKYBOX_MODE | |
  88043. * | 6 | INVCUBIC_MODE | |
  88044. * | 7 | EQUIRECTANGULAR_MODE | |
  88045. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  88046. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  88047. */
  88048. coordinatesMode: number;
  88049. /**
  88050. * | Value | Type | Description |
  88051. * | ----- | ------------------ | ----------- |
  88052. * | 0 | CLAMP_ADDRESSMODE | |
  88053. * | 1 | WRAP_ADDRESSMODE | |
  88054. * | 2 | MIRROR_ADDRESSMODE | |
  88055. */
  88056. wrapU: number;
  88057. /**
  88058. * | Value | Type | Description |
  88059. * | ----- | ------------------ | ----------- |
  88060. * | 0 | CLAMP_ADDRESSMODE | |
  88061. * | 1 | WRAP_ADDRESSMODE | |
  88062. * | 2 | MIRROR_ADDRESSMODE | |
  88063. */
  88064. wrapV: number;
  88065. /**
  88066. * | Value | Type | Description |
  88067. * | ----- | ------------------ | ----------- |
  88068. * | 0 | CLAMP_ADDRESSMODE | |
  88069. * | 1 | WRAP_ADDRESSMODE | |
  88070. * | 2 | MIRROR_ADDRESSMODE | |
  88071. */
  88072. wrapR: number;
  88073. /**
  88074. * With compliant hardware and browser (supporting anisotropic filtering)
  88075. * this defines the level of anisotropic filtering in the texture.
  88076. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  88077. */
  88078. anisotropicFilteringLevel: number;
  88079. /**
  88080. * Define if the texture is a cube texture or if false a 2d texture.
  88081. */
  88082. isCube: boolean;
  88083. /**
  88084. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  88085. */
  88086. is3D: boolean;
  88087. /**
  88088. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  88089. * HDR texture are usually stored in linear space.
  88090. * This only impacts the PBR and Background materials
  88091. */
  88092. gammaSpace: boolean;
  88093. /**
  88094. * Gets whether or not the texture contains RGBD data.
  88095. */
  88096. readonly isRGBD: boolean;
  88097. /**
  88098. * Is Z inverted in the texture (useful in a cube texture).
  88099. */
  88100. invertZ: boolean;
  88101. /**
  88102. * Are mip maps generated for this texture or not.
  88103. */
  88104. readonly noMipmap: boolean;
  88105. /**
  88106. * @hidden
  88107. */
  88108. lodLevelInAlpha: boolean;
  88109. /**
  88110. * With prefiltered texture, defined the offset used during the prefiltering steps.
  88111. */
  88112. lodGenerationOffset: number;
  88113. /**
  88114. * With prefiltered texture, defined the scale used during the prefiltering steps.
  88115. */
  88116. lodGenerationScale: number;
  88117. /**
  88118. * Define if the texture is a render target.
  88119. */
  88120. isRenderTarget: boolean;
  88121. /**
  88122. * Define the unique id of the texture in the scene.
  88123. */
  88124. readonly uid: string;
  88125. /**
  88126. * Return a string representation of the texture.
  88127. * @returns the texture as a string
  88128. */
  88129. toString(): string;
  88130. /**
  88131. * Get the class name of the texture.
  88132. * @returns "BaseTexture"
  88133. */
  88134. getClassName(): string;
  88135. /**
  88136. * Define the list of animation attached to the texture.
  88137. */
  88138. animations: Animation[];
  88139. /**
  88140. * An event triggered when the texture is disposed.
  88141. */
  88142. onDisposeObservable: Observable<BaseTexture>;
  88143. private _onDisposeObserver;
  88144. /**
  88145. * Callback triggered when the texture has been disposed.
  88146. * Kept for back compatibility, you can use the onDisposeObservable instead.
  88147. */
  88148. onDispose: () => void;
  88149. /**
  88150. * Define the current state of the loading sequence when in delayed load mode.
  88151. */
  88152. delayLoadState: number;
  88153. private _scene;
  88154. /** @hidden */
  88155. _texture: Nullable<InternalTexture>;
  88156. private _uid;
  88157. /**
  88158. * Define if the texture is preventinga material to render or not.
  88159. * If not and the texture is not ready, the engine will use a default black texture instead.
  88160. */
  88161. readonly isBlocking: boolean;
  88162. /**
  88163. * Instantiates a new BaseTexture.
  88164. * Base class of all the textures in babylon.
  88165. * It groups all the common properties the materials, post process, lights... might need
  88166. * in order to make a correct use of the texture.
  88167. * @param scene Define the scene the texture blongs to
  88168. */
  88169. constructor(scene: Nullable<Scene>);
  88170. /**
  88171. * Get the scene the texture belongs to.
  88172. * @returns the scene or null if undefined
  88173. */
  88174. getScene(): Nullable<Scene>;
  88175. /**
  88176. * Get the texture transform matrix used to offset tile the texture for istance.
  88177. * @returns the transformation matrix
  88178. */
  88179. getTextureMatrix(): Matrix;
  88180. /**
  88181. * Get the texture reflection matrix used to rotate/transform the reflection.
  88182. * @returns the reflection matrix
  88183. */
  88184. getReflectionTextureMatrix(): Matrix;
  88185. /**
  88186. * Get the underlying lower level texture from Babylon.
  88187. * @returns the insternal texture
  88188. */
  88189. getInternalTexture(): Nullable<InternalTexture>;
  88190. /**
  88191. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  88192. * @returns true if ready or not blocking
  88193. */
  88194. isReadyOrNotBlocking(): boolean;
  88195. /**
  88196. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  88197. * @returns true if fully ready
  88198. */
  88199. isReady(): boolean;
  88200. private _cachedSize;
  88201. /**
  88202. * Get the size of the texture.
  88203. * @returns the texture size.
  88204. */
  88205. getSize(): ISize;
  88206. /**
  88207. * Get the base size of the texture.
  88208. * It can be different from the size if the texture has been resized for POT for instance
  88209. * @returns the base size
  88210. */
  88211. getBaseSize(): ISize;
  88212. /**
  88213. * Update the sampling mode of the texture.
  88214. * Default is Trilinear mode.
  88215. *
  88216. * | Value | Type | Description |
  88217. * | ----- | ------------------ | ----------- |
  88218. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  88219. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  88220. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  88221. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  88222. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  88223. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  88224. * | 7 | NEAREST_LINEAR | |
  88225. * | 8 | NEAREST_NEAREST | |
  88226. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  88227. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  88228. * | 11 | LINEAR_LINEAR | |
  88229. * | 12 | LINEAR_NEAREST | |
  88230. *
  88231. * > _mag_: magnification filter (close to the viewer)
  88232. * > _min_: minification filter (far from the viewer)
  88233. * > _mip_: filter used between mip map levels
  88234. *@param samplingMode Define the new sampling mode of the texture
  88235. */
  88236. updateSamplingMode(samplingMode: number): void;
  88237. /**
  88238. * Scales the texture if is `canRescale()`
  88239. * @param ratio the resize factor we want to use to rescale
  88240. */
  88241. scale(ratio: number): void;
  88242. /**
  88243. * Get if the texture can rescale.
  88244. */
  88245. readonly canRescale: boolean;
  88246. /** @hidden */
  88247. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  88248. /** @hidden */
  88249. _rebuild(): void;
  88250. /**
  88251. * Triggers the load sequence in delayed load mode.
  88252. */
  88253. delayLoad(): void;
  88254. /**
  88255. * Clones the texture.
  88256. * @returns the cloned texture
  88257. */
  88258. clone(): Nullable<BaseTexture>;
  88259. /**
  88260. * Get the texture underlying type (INT, FLOAT...)
  88261. */
  88262. readonly textureType: number;
  88263. /**
  88264. * Get the texture underlying format (RGB, RGBA...)
  88265. */
  88266. readonly textureFormat: number;
  88267. /**
  88268. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  88269. * This will returns an RGBA array buffer containing either in values (0-255) or
  88270. * float values (0-1) depending of the underlying buffer type.
  88271. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  88272. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  88273. * @param buffer defines a user defined buffer to fill with data (can be null)
  88274. * @returns The Array buffer containing the pixels data.
  88275. */
  88276. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  88277. /**
  88278. * Release and destroy the underlying lower level texture aka internalTexture.
  88279. */
  88280. releaseInternalTexture(): void;
  88281. /**
  88282. * Get the polynomial representation of the texture data.
  88283. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  88284. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  88285. */
  88286. sphericalPolynomial: Nullable<SphericalPolynomial>;
  88287. /** @hidden */
  88288. readonly _lodTextureHigh: Nullable<BaseTexture>;
  88289. /** @hidden */
  88290. readonly _lodTextureMid: Nullable<BaseTexture>;
  88291. /** @hidden */
  88292. readonly _lodTextureLow: Nullable<BaseTexture>;
  88293. /**
  88294. * Dispose the texture and release its associated resources.
  88295. */
  88296. dispose(): void;
  88297. /**
  88298. * Serialize the texture into a JSON representation that can be parsed later on.
  88299. * @returns the JSON representation of the texture
  88300. */
  88301. serialize(): any;
  88302. /**
  88303. * Helper function to be called back once a list of texture contains only ready textures.
  88304. * @param textures Define the list of textures to wait for
  88305. * @param callback Define the callback triggered once the entire list will be ready
  88306. */
  88307. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  88308. }
  88309. }
  88310. declare module BABYLON {
  88311. /**
  88312. * Uniform buffer objects.
  88313. *
  88314. * Handles blocks of uniform on the GPU.
  88315. *
  88316. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  88317. *
  88318. * For more information, please refer to :
  88319. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  88320. */
  88321. export class UniformBuffer {
  88322. private _engine;
  88323. private _buffer;
  88324. private _data;
  88325. private _bufferData;
  88326. private _dynamic?;
  88327. private _uniformLocations;
  88328. private _uniformSizes;
  88329. private _uniformLocationPointer;
  88330. private _needSync;
  88331. private _noUBO;
  88332. private _currentEffect;
  88333. private static _MAX_UNIFORM_SIZE;
  88334. private static _tempBuffer;
  88335. /**
  88336. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  88337. * This is dynamic to allow compat with webgl 1 and 2.
  88338. * You will need to pass the name of the uniform as well as the value.
  88339. */
  88340. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  88341. /**
  88342. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  88343. * This is dynamic to allow compat with webgl 1 and 2.
  88344. * You will need to pass the name of the uniform as well as the value.
  88345. */
  88346. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  88347. /**
  88348. * Lambda to Update a single float in a uniform buffer.
  88349. * This is dynamic to allow compat with webgl 1 and 2.
  88350. * You will need to pass the name of the uniform as well as the value.
  88351. */
  88352. updateFloat: (name: string, x: number) => void;
  88353. /**
  88354. * Lambda to Update a vec2 of float in a uniform buffer.
  88355. * This is dynamic to allow compat with webgl 1 and 2.
  88356. * You will need to pass the name of the uniform as well as the value.
  88357. */
  88358. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  88359. /**
  88360. * Lambda to Update a vec3 of float in a uniform buffer.
  88361. * This is dynamic to allow compat with webgl 1 and 2.
  88362. * You will need to pass the name of the uniform as well as the value.
  88363. */
  88364. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  88365. /**
  88366. * Lambda to Update a vec4 of float in a uniform buffer.
  88367. * This is dynamic to allow compat with webgl 1 and 2.
  88368. * You will need to pass the name of the uniform as well as the value.
  88369. */
  88370. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  88371. /**
  88372. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  88373. * This is dynamic to allow compat with webgl 1 and 2.
  88374. * You will need to pass the name of the uniform as well as the value.
  88375. */
  88376. updateMatrix: (name: string, mat: Matrix) => void;
  88377. /**
  88378. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  88379. * This is dynamic to allow compat with webgl 1 and 2.
  88380. * You will need to pass the name of the uniform as well as the value.
  88381. */
  88382. updateVector3: (name: string, vector: Vector3) => void;
  88383. /**
  88384. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  88385. * This is dynamic to allow compat with webgl 1 and 2.
  88386. * You will need to pass the name of the uniform as well as the value.
  88387. */
  88388. updateVector4: (name: string, vector: Vector4) => void;
  88389. /**
  88390. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  88391. * This is dynamic to allow compat with webgl 1 and 2.
  88392. * You will need to pass the name of the uniform as well as the value.
  88393. */
  88394. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  88395. /**
  88396. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  88397. * This is dynamic to allow compat with webgl 1 and 2.
  88398. * You will need to pass the name of the uniform as well as the value.
  88399. */
  88400. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  88401. /**
  88402. * Instantiates a new Uniform buffer objects.
  88403. *
  88404. * Handles blocks of uniform on the GPU.
  88405. *
  88406. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  88407. *
  88408. * For more information, please refer to :
  88409. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  88410. * @param engine Define the engine the buffer is associated with
  88411. * @param data Define the data contained in the buffer
  88412. * @param dynamic Define if the buffer is updatable
  88413. */
  88414. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  88415. /**
  88416. * Indicates if the buffer is using the WebGL2 UBO implementation,
  88417. * or just falling back on setUniformXXX calls.
  88418. */
  88419. readonly useUbo: boolean;
  88420. /**
  88421. * Indicates if the WebGL underlying uniform buffer is in sync
  88422. * with the javascript cache data.
  88423. */
  88424. readonly isSync: boolean;
  88425. /**
  88426. * Indicates if the WebGL underlying uniform buffer is dynamic.
  88427. * Also, a dynamic UniformBuffer will disable cache verification and always
  88428. * update the underlying WebGL uniform buffer to the GPU.
  88429. * @returns if Dynamic, otherwise false
  88430. */
  88431. isDynamic(): boolean;
  88432. /**
  88433. * The data cache on JS side.
  88434. * @returns the underlying data as a float array
  88435. */
  88436. getData(): Float32Array;
  88437. /**
  88438. * The underlying WebGL Uniform buffer.
  88439. * @returns the webgl buffer
  88440. */
  88441. getBuffer(): Nullable<DataBuffer>;
  88442. /**
  88443. * std140 layout specifies how to align data within an UBO structure.
  88444. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  88445. * for specs.
  88446. */
  88447. private _fillAlignment;
  88448. /**
  88449. * Adds an uniform in the buffer.
  88450. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  88451. * for the layout to be correct !
  88452. * @param name Name of the uniform, as used in the uniform block in the shader.
  88453. * @param size Data size, or data directly.
  88454. */
  88455. addUniform(name: string, size: number | number[]): void;
  88456. /**
  88457. * Adds a Matrix 4x4 to the uniform buffer.
  88458. * @param name Name of the uniform, as used in the uniform block in the shader.
  88459. * @param mat A 4x4 matrix.
  88460. */
  88461. addMatrix(name: string, mat: Matrix): void;
  88462. /**
  88463. * Adds a vec2 to the uniform buffer.
  88464. * @param name Name of the uniform, as used in the uniform block in the shader.
  88465. * @param x Define the x component value of the vec2
  88466. * @param y Define the y component value of the vec2
  88467. */
  88468. addFloat2(name: string, x: number, y: number): void;
  88469. /**
  88470. * Adds a vec3 to the uniform buffer.
  88471. * @param name Name of the uniform, as used in the uniform block in the shader.
  88472. * @param x Define the x component value of the vec3
  88473. * @param y Define the y component value of the vec3
  88474. * @param z Define the z component value of the vec3
  88475. */
  88476. addFloat3(name: string, x: number, y: number, z: number): void;
  88477. /**
  88478. * Adds a vec3 to the uniform buffer.
  88479. * @param name Name of the uniform, as used in the uniform block in the shader.
  88480. * @param color Define the vec3 from a Color
  88481. */
  88482. addColor3(name: string, color: Color3): void;
  88483. /**
  88484. * Adds a vec4 to the uniform buffer.
  88485. * @param name Name of the uniform, as used in the uniform block in the shader.
  88486. * @param color Define the rgb components from a Color
  88487. * @param alpha Define the a component of the vec4
  88488. */
  88489. addColor4(name: string, color: Color3, alpha: number): void;
  88490. /**
  88491. * Adds a vec3 to the uniform buffer.
  88492. * @param name Name of the uniform, as used in the uniform block in the shader.
  88493. * @param vector Define the vec3 components from a Vector
  88494. */
  88495. addVector3(name: string, vector: Vector3): void;
  88496. /**
  88497. * Adds a Matrix 3x3 to the uniform buffer.
  88498. * @param name Name of the uniform, as used in the uniform block in the shader.
  88499. */
  88500. addMatrix3x3(name: string): void;
  88501. /**
  88502. * Adds a Matrix 2x2 to the uniform buffer.
  88503. * @param name Name of the uniform, as used in the uniform block in the shader.
  88504. */
  88505. addMatrix2x2(name: string): void;
  88506. /**
  88507. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  88508. */
  88509. create(): void;
  88510. /** @hidden */
  88511. _rebuild(): void;
  88512. /**
  88513. * Updates the WebGL Uniform Buffer on the GPU.
  88514. * If the `dynamic` flag is set to true, no cache comparison is done.
  88515. * Otherwise, the buffer will be updated only if the cache differs.
  88516. */
  88517. update(): void;
  88518. /**
  88519. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  88520. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  88521. * @param data Define the flattened data
  88522. * @param size Define the size of the data.
  88523. */
  88524. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  88525. private _updateMatrix3x3ForUniform;
  88526. private _updateMatrix3x3ForEffect;
  88527. private _updateMatrix2x2ForEffect;
  88528. private _updateMatrix2x2ForUniform;
  88529. private _updateFloatForEffect;
  88530. private _updateFloatForUniform;
  88531. private _updateFloat2ForEffect;
  88532. private _updateFloat2ForUniform;
  88533. private _updateFloat3ForEffect;
  88534. private _updateFloat3ForUniform;
  88535. private _updateFloat4ForEffect;
  88536. private _updateFloat4ForUniform;
  88537. private _updateMatrixForEffect;
  88538. private _updateMatrixForUniform;
  88539. private _updateVector3ForEffect;
  88540. private _updateVector3ForUniform;
  88541. private _updateVector4ForEffect;
  88542. private _updateVector4ForUniform;
  88543. private _updateColor3ForEffect;
  88544. private _updateColor3ForUniform;
  88545. private _updateColor4ForEffect;
  88546. private _updateColor4ForUniform;
  88547. /**
  88548. * Sets a sampler uniform on the effect.
  88549. * @param name Define the name of the sampler.
  88550. * @param texture Define the texture to set in the sampler
  88551. */
  88552. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  88553. /**
  88554. * Directly updates the value of the uniform in the cache AND on the GPU.
  88555. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  88556. * @param data Define the flattened data
  88557. */
  88558. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  88559. /**
  88560. * Binds this uniform buffer to an effect.
  88561. * @param effect Define the effect to bind the buffer to
  88562. * @param name Name of the uniform block in the shader.
  88563. */
  88564. bindToEffect(effect: Effect, name: string): void;
  88565. /**
  88566. * Disposes the uniform buffer.
  88567. */
  88568. dispose(): void;
  88569. }
  88570. }
  88571. declare module BABYLON {
  88572. /**
  88573. * Class used to work with sound analyzer using fast fourier transform (FFT)
  88574. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  88575. */
  88576. export class Analyser {
  88577. /**
  88578. * Gets or sets the smoothing
  88579. * @ignorenaming
  88580. */
  88581. SMOOTHING: number;
  88582. /**
  88583. * Gets or sets the FFT table size
  88584. * @ignorenaming
  88585. */
  88586. FFT_SIZE: number;
  88587. /**
  88588. * Gets or sets the bar graph amplitude
  88589. * @ignorenaming
  88590. */
  88591. BARGRAPHAMPLITUDE: number;
  88592. /**
  88593. * Gets or sets the position of the debug canvas
  88594. * @ignorenaming
  88595. */
  88596. DEBUGCANVASPOS: {
  88597. x: number;
  88598. y: number;
  88599. };
  88600. /**
  88601. * Gets or sets the debug canvas size
  88602. * @ignorenaming
  88603. */
  88604. DEBUGCANVASSIZE: {
  88605. width: number;
  88606. height: number;
  88607. };
  88608. private _byteFreqs;
  88609. private _byteTime;
  88610. private _floatFreqs;
  88611. private _webAudioAnalyser;
  88612. private _debugCanvas;
  88613. private _debugCanvasContext;
  88614. private _scene;
  88615. private _registerFunc;
  88616. private _audioEngine;
  88617. /**
  88618. * Creates a new analyser
  88619. * @param scene defines hosting scene
  88620. */
  88621. constructor(scene: Scene);
  88622. /**
  88623. * Get the number of data values you will have to play with for the visualization
  88624. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  88625. * @returns a number
  88626. */
  88627. getFrequencyBinCount(): number;
  88628. /**
  88629. * Gets the current frequency data as a byte array
  88630. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  88631. * @returns a Uint8Array
  88632. */
  88633. getByteFrequencyData(): Uint8Array;
  88634. /**
  88635. * Gets the current waveform as a byte array
  88636. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  88637. * @returns a Uint8Array
  88638. */
  88639. getByteTimeDomainData(): Uint8Array;
  88640. /**
  88641. * Gets the current frequency data as a float array
  88642. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  88643. * @returns a Float32Array
  88644. */
  88645. getFloatFrequencyData(): Float32Array;
  88646. /**
  88647. * Renders the debug canvas
  88648. */
  88649. drawDebugCanvas(): void;
  88650. /**
  88651. * Stops rendering the debug canvas and removes it
  88652. */
  88653. stopDebugCanvas(): void;
  88654. /**
  88655. * Connects two audio nodes
  88656. * @param inputAudioNode defines first node to connect
  88657. * @param outputAudioNode defines second node to connect
  88658. */
  88659. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  88660. /**
  88661. * Releases all associated resources
  88662. */
  88663. dispose(): void;
  88664. }
  88665. }
  88666. declare module BABYLON {
  88667. /**
  88668. * This represents an audio engine and it is responsible
  88669. * to play, synchronize and analyse sounds throughout the application.
  88670. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  88671. */
  88672. export interface IAudioEngine extends IDisposable {
  88673. /**
  88674. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  88675. */
  88676. readonly canUseWebAudio: boolean;
  88677. /**
  88678. * Gets the current AudioContext if available.
  88679. */
  88680. readonly audioContext: Nullable<AudioContext>;
  88681. /**
  88682. * The master gain node defines the global audio volume of your audio engine.
  88683. */
  88684. readonly masterGain: GainNode;
  88685. /**
  88686. * Gets whether or not mp3 are supported by your browser.
  88687. */
  88688. readonly isMP3supported: boolean;
  88689. /**
  88690. * Gets whether or not ogg are supported by your browser.
  88691. */
  88692. readonly isOGGsupported: boolean;
  88693. /**
  88694. * Defines if Babylon should emit a warning if WebAudio is not supported.
  88695. * @ignoreNaming
  88696. */
  88697. WarnedWebAudioUnsupported: boolean;
  88698. /**
  88699. * Defines if the audio engine relies on a custom unlocked button.
  88700. * In this case, the embedded button will not be displayed.
  88701. */
  88702. useCustomUnlockedButton: boolean;
  88703. /**
  88704. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  88705. */
  88706. readonly unlocked: boolean;
  88707. /**
  88708. * Event raised when audio has been unlocked on the browser.
  88709. */
  88710. onAudioUnlockedObservable: Observable<AudioEngine>;
  88711. /**
  88712. * Event raised when audio has been locked on the browser.
  88713. */
  88714. onAudioLockedObservable: Observable<AudioEngine>;
  88715. /**
  88716. * Flags the audio engine in Locked state.
  88717. * This happens due to new browser policies preventing audio to autoplay.
  88718. */
  88719. lock(): void;
  88720. /**
  88721. * Unlocks the audio engine once a user action has been done on the dom.
  88722. * This is helpful to resume play once browser policies have been satisfied.
  88723. */
  88724. unlock(): void;
  88725. }
  88726. /**
  88727. * This represents the default audio engine used in babylon.
  88728. * It is responsible to play, synchronize and analyse sounds throughout the application.
  88729. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  88730. */
  88731. export class AudioEngine implements IAudioEngine {
  88732. private _audioContext;
  88733. private _audioContextInitialized;
  88734. private _muteButton;
  88735. private _hostElement;
  88736. /**
  88737. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  88738. */
  88739. canUseWebAudio: boolean;
  88740. /**
  88741. * The master gain node defines the global audio volume of your audio engine.
  88742. */
  88743. masterGain: GainNode;
  88744. /**
  88745. * Defines if Babylon should emit a warning if WebAudio is not supported.
  88746. * @ignoreNaming
  88747. */
  88748. WarnedWebAudioUnsupported: boolean;
  88749. /**
  88750. * Gets whether or not mp3 are supported by your browser.
  88751. */
  88752. isMP3supported: boolean;
  88753. /**
  88754. * Gets whether or not ogg are supported by your browser.
  88755. */
  88756. isOGGsupported: boolean;
  88757. /**
  88758. * Gets whether audio has been unlocked on the device.
  88759. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  88760. * a user interaction has happened.
  88761. */
  88762. unlocked: boolean;
  88763. /**
  88764. * Defines if the audio engine relies on a custom unlocked button.
  88765. * In this case, the embedded button will not be displayed.
  88766. */
  88767. useCustomUnlockedButton: boolean;
  88768. /**
  88769. * Event raised when audio has been unlocked on the browser.
  88770. */
  88771. onAudioUnlockedObservable: Observable<AudioEngine>;
  88772. /**
  88773. * Event raised when audio has been locked on the browser.
  88774. */
  88775. onAudioLockedObservable: Observable<AudioEngine>;
  88776. /**
  88777. * Gets the current AudioContext if available.
  88778. */
  88779. readonly audioContext: Nullable<AudioContext>;
  88780. private _connectedAnalyser;
  88781. /**
  88782. * Instantiates a new audio engine.
  88783. *
  88784. * There should be only one per page as some browsers restrict the number
  88785. * of audio contexts you can create.
  88786. * @param hostElement defines the host element where to display the mute icon if necessary
  88787. */
  88788. constructor(hostElement?: Nullable<HTMLElement>);
  88789. /**
  88790. * Flags the audio engine in Locked state.
  88791. * This happens due to new browser policies preventing audio to autoplay.
  88792. */
  88793. lock(): void;
  88794. /**
  88795. * Unlocks the audio engine once a user action has been done on the dom.
  88796. * This is helpful to resume play once browser policies have been satisfied.
  88797. */
  88798. unlock(): void;
  88799. private _resumeAudioContext;
  88800. private _initializeAudioContext;
  88801. private _tryToRun;
  88802. private _triggerRunningState;
  88803. private _triggerSuspendedState;
  88804. private _displayMuteButton;
  88805. private _moveButtonToTopLeft;
  88806. private _onResize;
  88807. private _hideMuteButton;
  88808. /**
  88809. * Destroy and release the resources associated with the audio ccontext.
  88810. */
  88811. dispose(): void;
  88812. /**
  88813. * Gets the global volume sets on the master gain.
  88814. * @returns the global volume if set or -1 otherwise
  88815. */
  88816. getGlobalVolume(): number;
  88817. /**
  88818. * Sets the global volume of your experience (sets on the master gain).
  88819. * @param newVolume Defines the new global volume of the application
  88820. */
  88821. setGlobalVolume(newVolume: number): void;
  88822. /**
  88823. * Connect the audio engine to an audio analyser allowing some amazing
  88824. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  88825. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  88826. * @param analyser The analyser to connect to the engine
  88827. */
  88828. connectToAnalyser(analyser: Analyser): void;
  88829. }
  88830. }
  88831. declare module BABYLON {
  88832. /**
  88833. * Interface used to present a loading screen while loading a scene
  88834. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  88835. */
  88836. export interface ILoadingScreen {
  88837. /**
  88838. * Function called to display the loading screen
  88839. */
  88840. displayLoadingUI: () => void;
  88841. /**
  88842. * Function called to hide the loading screen
  88843. */
  88844. hideLoadingUI: () => void;
  88845. /**
  88846. * Gets or sets the color to use for the background
  88847. */
  88848. loadingUIBackgroundColor: string;
  88849. /**
  88850. * Gets or sets the text to display while loading
  88851. */
  88852. loadingUIText: string;
  88853. }
  88854. /**
  88855. * Class used for the default loading screen
  88856. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  88857. */
  88858. export class DefaultLoadingScreen implements ILoadingScreen {
  88859. private _renderingCanvas;
  88860. private _loadingText;
  88861. private _loadingDivBackgroundColor;
  88862. private _loadingDiv;
  88863. private _loadingTextDiv;
  88864. /** Gets or sets the logo url to use for the default loading screen */
  88865. static DefaultLogoUrl: string;
  88866. /** Gets or sets the spinner url to use for the default loading screen */
  88867. static DefaultSpinnerUrl: string;
  88868. /**
  88869. * Creates a new default loading screen
  88870. * @param _renderingCanvas defines the canvas used to render the scene
  88871. * @param _loadingText defines the default text to display
  88872. * @param _loadingDivBackgroundColor defines the default background color
  88873. */
  88874. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  88875. /**
  88876. * Function called to display the loading screen
  88877. */
  88878. displayLoadingUI(): void;
  88879. /**
  88880. * Function called to hide the loading screen
  88881. */
  88882. hideLoadingUI(): void;
  88883. /**
  88884. * Gets or sets the text to display while loading
  88885. */
  88886. loadingUIText: string;
  88887. /**
  88888. * Gets or sets the color to use for the background
  88889. */
  88890. loadingUIBackgroundColor: string;
  88891. private _resizeLoadingUI;
  88892. }
  88893. }
  88894. declare module BABYLON {
  88895. /** @hidden */
  88896. export class WebGLPipelineContext implements IPipelineContext {
  88897. engine: Engine;
  88898. program: Nullable<WebGLProgram>;
  88899. context?: WebGLRenderingContext;
  88900. vertexShader?: WebGLShader;
  88901. fragmentShader?: WebGLShader;
  88902. isParallelCompiled: boolean;
  88903. onCompiled?: () => void;
  88904. transformFeedback?: WebGLTransformFeedback | null;
  88905. readonly isAsync: boolean;
  88906. readonly isReady: boolean;
  88907. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  88908. }
  88909. }
  88910. declare module BABYLON {
  88911. /** @hidden */
  88912. export class WebGLDataBuffer extends DataBuffer {
  88913. private _buffer;
  88914. constructor(resource: WebGLBuffer);
  88915. readonly underlyingResource: any;
  88916. }
  88917. }
  88918. declare module BABYLON {
  88919. /**
  88920. * Settings for finer control over video usage
  88921. */
  88922. export interface VideoTextureSettings {
  88923. /**
  88924. * Applies `autoplay` to video, if specified
  88925. */
  88926. autoPlay?: boolean;
  88927. /**
  88928. * Applies `loop` to video, if specified
  88929. */
  88930. loop?: boolean;
  88931. /**
  88932. * Automatically updates internal texture from video at every frame in the render loop
  88933. */
  88934. autoUpdateTexture: boolean;
  88935. /**
  88936. * Image src displayed during the video loading or until the user interacts with the video.
  88937. */
  88938. poster?: string;
  88939. }
  88940. /**
  88941. * If you want to display a video in your scene, this is the special texture for that.
  88942. * This special texture works similar to other textures, with the exception of a few parameters.
  88943. * @see https://doc.babylonjs.com/how_to/video_texture
  88944. */
  88945. export class VideoTexture extends Texture {
  88946. /**
  88947. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  88948. */
  88949. readonly autoUpdateTexture: boolean;
  88950. /**
  88951. * The video instance used by the texture internally
  88952. */
  88953. readonly video: HTMLVideoElement;
  88954. private _onUserActionRequestedObservable;
  88955. /**
  88956. * Event triggerd when a dom action is required by the user to play the video.
  88957. * This happens due to recent changes in browser policies preventing video to auto start.
  88958. */
  88959. readonly onUserActionRequestedObservable: Observable<Texture>;
  88960. private _generateMipMaps;
  88961. private _engine;
  88962. private _stillImageCaptured;
  88963. private _displayingPosterTexture;
  88964. private _settings;
  88965. private _createInternalTextureOnEvent;
  88966. /**
  88967. * Creates a video texture.
  88968. * If you want to display a video in your scene, this is the special texture for that.
  88969. * This special texture works similar to other textures, with the exception of a few parameters.
  88970. * @see https://doc.babylonjs.com/how_to/video_texture
  88971. * @param name optional name, will detect from video source, if not defined
  88972. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  88973. * @param scene is obviously the current scene.
  88974. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  88975. * @param invertY is false by default but can be used to invert video on Y axis
  88976. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  88977. * @param settings allows finer control over video usage
  88978. */
  88979. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  88980. private _getName;
  88981. private _getVideo;
  88982. private _createInternalTexture;
  88983. private reset;
  88984. /**
  88985. * @hidden Internal method to initiate `update`.
  88986. */
  88987. _rebuild(): void;
  88988. /**
  88989. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  88990. */
  88991. update(): void;
  88992. /**
  88993. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  88994. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  88995. */
  88996. updateTexture(isVisible: boolean): void;
  88997. protected _updateInternalTexture: () => void;
  88998. /**
  88999. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  89000. * @param url New url.
  89001. */
  89002. updateURL(url: string): void;
  89003. /**
  89004. * Dispose the texture and release its associated resources.
  89005. */
  89006. dispose(): void;
  89007. /**
  89008. * Creates a video texture straight from a stream.
  89009. * @param scene Define the scene the texture should be created in
  89010. * @param stream Define the stream the texture should be created from
  89011. * @returns The created video texture as a promise
  89012. */
  89013. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  89014. /**
  89015. * Creates a video texture straight from your WebCam video feed.
  89016. * @param scene Define the scene the texture should be created in
  89017. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  89018. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  89019. * @returns The created video texture as a promise
  89020. */
  89021. static CreateFromWebCamAsync(scene: Scene, constraints: {
  89022. minWidth: number;
  89023. maxWidth: number;
  89024. minHeight: number;
  89025. maxHeight: number;
  89026. deviceId: string;
  89027. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  89028. /**
  89029. * Creates a video texture straight from your WebCam video feed.
  89030. * @param scene Define the scene the texture should be created in
  89031. * @param onReady Define a callback to triggered once the texture will be ready
  89032. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  89033. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  89034. */
  89035. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  89036. minWidth: number;
  89037. maxWidth: number;
  89038. minHeight: number;
  89039. maxHeight: number;
  89040. deviceId: string;
  89041. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  89042. }
  89043. }
  89044. declare module BABYLON {
  89045. /**
  89046. * Interface for attribute information associated with buffer instanciation
  89047. */
  89048. export class InstancingAttributeInfo {
  89049. /**
  89050. * Index/offset of the attribute in the vertex shader
  89051. */
  89052. index: number;
  89053. /**
  89054. * size of the attribute, 1, 2, 3 or 4
  89055. */
  89056. attributeSize: number;
  89057. /**
  89058. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  89059. * default is FLOAT
  89060. */
  89061. attribyteType: number;
  89062. /**
  89063. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  89064. */
  89065. normalized: boolean;
  89066. /**
  89067. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  89068. */
  89069. offset: number;
  89070. /**
  89071. * Name of the GLSL attribute, for debugging purpose only
  89072. */
  89073. attributeName: string;
  89074. }
  89075. /**
  89076. * Define options used to create a depth texture
  89077. */
  89078. export class DepthTextureCreationOptions {
  89079. /** Specifies whether or not a stencil should be allocated in the texture */
  89080. generateStencil?: boolean;
  89081. /** Specifies whether or not bilinear filtering is enable on the texture */
  89082. bilinearFiltering?: boolean;
  89083. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  89084. comparisonFunction?: number;
  89085. /** Specifies if the created texture is a cube texture */
  89086. isCube?: boolean;
  89087. }
  89088. /**
  89089. * Class used to describe the capabilities of the engine relatively to the current browser
  89090. */
  89091. export class EngineCapabilities {
  89092. /** Maximum textures units per fragment shader */
  89093. maxTexturesImageUnits: number;
  89094. /** Maximum texture units per vertex shader */
  89095. maxVertexTextureImageUnits: number;
  89096. /** Maximum textures units in the entire pipeline */
  89097. maxCombinedTexturesImageUnits: number;
  89098. /** Maximum texture size */
  89099. maxTextureSize: number;
  89100. /** Maximum cube texture size */
  89101. maxCubemapTextureSize: number;
  89102. /** Maximum render texture size */
  89103. maxRenderTextureSize: number;
  89104. /** Maximum number of vertex attributes */
  89105. maxVertexAttribs: number;
  89106. /** Maximum number of varyings */
  89107. maxVaryingVectors: number;
  89108. /** Maximum number of uniforms per vertex shader */
  89109. maxVertexUniformVectors: number;
  89110. /** Maximum number of uniforms per fragment shader */
  89111. maxFragmentUniformVectors: number;
  89112. /** Defines if standard derivates (dx/dy) are supported */
  89113. standardDerivatives: boolean;
  89114. /** Defines if s3tc texture compression is supported */
  89115. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  89116. /** Defines if pvrtc texture compression is supported */
  89117. pvrtc: any;
  89118. /** Defines if etc1 texture compression is supported */
  89119. etc1: any;
  89120. /** Defines if etc2 texture compression is supported */
  89121. etc2: any;
  89122. /** Defines if astc texture compression is supported */
  89123. astc: any;
  89124. /** Defines if float textures are supported */
  89125. textureFloat: boolean;
  89126. /** Defines if vertex array objects are supported */
  89127. vertexArrayObject: boolean;
  89128. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  89129. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  89130. /** Gets the maximum level of anisotropy supported */
  89131. maxAnisotropy: number;
  89132. /** Defines if instancing is supported */
  89133. instancedArrays: boolean;
  89134. /** Defines if 32 bits indices are supported */
  89135. uintIndices: boolean;
  89136. /** Defines if high precision shaders are supported */
  89137. highPrecisionShaderSupported: boolean;
  89138. /** Defines if depth reading in the fragment shader is supported */
  89139. fragmentDepthSupported: boolean;
  89140. /** Defines if float texture linear filtering is supported*/
  89141. textureFloatLinearFiltering: boolean;
  89142. /** Defines if rendering to float textures is supported */
  89143. textureFloatRender: boolean;
  89144. /** Defines if half float textures are supported*/
  89145. textureHalfFloat: boolean;
  89146. /** Defines if half float texture linear filtering is supported*/
  89147. textureHalfFloatLinearFiltering: boolean;
  89148. /** Defines if rendering to half float textures is supported */
  89149. textureHalfFloatRender: boolean;
  89150. /** Defines if textureLOD shader command is supported */
  89151. textureLOD: boolean;
  89152. /** Defines if draw buffers extension is supported */
  89153. drawBuffersExtension: boolean;
  89154. /** Defines if depth textures are supported */
  89155. depthTextureExtension: boolean;
  89156. /** Defines if float color buffer are supported */
  89157. colorBufferFloat: boolean;
  89158. /** Gets disjoint timer query extension (null if not supported) */
  89159. timerQuery: EXT_disjoint_timer_query;
  89160. /** Defines if timestamp can be used with timer query */
  89161. canUseTimestampForTimerQuery: boolean;
  89162. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  89163. multiview: any;
  89164. /** Function used to let the system compiles shaders in background */
  89165. parallelShaderCompile: {
  89166. COMPLETION_STATUS_KHR: number;
  89167. };
  89168. }
  89169. /** Interface defining initialization parameters for Engine class */
  89170. export interface EngineOptions extends WebGLContextAttributes {
  89171. /**
  89172. * Defines if the engine should no exceed a specified device ratio
  89173. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  89174. */
  89175. limitDeviceRatio?: number;
  89176. /**
  89177. * Defines if webvr should be enabled automatically
  89178. * @see http://doc.babylonjs.com/how_to/webvr_camera
  89179. */
  89180. autoEnableWebVR?: boolean;
  89181. /**
  89182. * Defines if webgl2 should be turned off even if supported
  89183. * @see http://doc.babylonjs.com/features/webgl2
  89184. */
  89185. disableWebGL2Support?: boolean;
  89186. /**
  89187. * Defines if webaudio should be initialized as well
  89188. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  89189. */
  89190. audioEngine?: boolean;
  89191. /**
  89192. * Defines if animations should run using a deterministic lock step
  89193. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  89194. */
  89195. deterministicLockstep?: boolean;
  89196. /** Defines the maximum steps to use with deterministic lock step mode */
  89197. lockstepMaxSteps?: number;
  89198. /**
  89199. * Defines that engine should ignore context lost events
  89200. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  89201. */
  89202. doNotHandleContextLost?: boolean;
  89203. /**
  89204. * Defines that engine should ignore modifying touch action attribute and style
  89205. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  89206. */
  89207. doNotHandleTouchAction?: boolean;
  89208. /**
  89209. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  89210. */
  89211. useHighPrecisionFloats?: boolean;
  89212. }
  89213. /**
  89214. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  89215. */
  89216. export class Engine {
  89217. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  89218. static ExceptionList: ({
  89219. key: string;
  89220. capture: string;
  89221. captureConstraint: number;
  89222. targets: string[];
  89223. } | {
  89224. key: string;
  89225. capture: null;
  89226. captureConstraint: null;
  89227. targets: string[];
  89228. })[];
  89229. /** Gets the list of created engines */
  89230. static readonly Instances: Engine[];
  89231. /**
  89232. * Gets the latest created engine
  89233. */
  89234. static readonly LastCreatedEngine: Nullable<Engine>;
  89235. /**
  89236. * Gets the latest created scene
  89237. */
  89238. static readonly LastCreatedScene: Nullable<Scene>;
  89239. /**
  89240. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  89241. * @param flag defines which part of the materials must be marked as dirty
  89242. * @param predicate defines a predicate used to filter which materials should be affected
  89243. */
  89244. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  89245. /**
  89246. * Hidden
  89247. */
  89248. static _TextureLoaders: IInternalTextureLoader[];
  89249. /** Defines that alpha blending is disabled */
  89250. static readonly ALPHA_DISABLE: number;
  89251. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  89252. static readonly ALPHA_ADD: number;
  89253. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  89254. static readonly ALPHA_COMBINE: number;
  89255. /** Defines that alpha blending to DEST - SRC * DEST */
  89256. static readonly ALPHA_SUBTRACT: number;
  89257. /** Defines that alpha blending to SRC * DEST */
  89258. static readonly ALPHA_MULTIPLY: number;
  89259. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  89260. static readonly ALPHA_MAXIMIZED: number;
  89261. /** Defines that alpha blending to SRC + DEST */
  89262. static readonly ALPHA_ONEONE: number;
  89263. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  89264. static readonly ALPHA_PREMULTIPLIED: number;
  89265. /**
  89266. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  89267. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  89268. */
  89269. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  89270. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  89271. static readonly ALPHA_INTERPOLATE: number;
  89272. /**
  89273. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  89274. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  89275. */
  89276. static readonly ALPHA_SCREENMODE: number;
  89277. /** Defines that the ressource is not delayed*/
  89278. static readonly DELAYLOADSTATE_NONE: number;
  89279. /** Defines that the ressource was successfully delay loaded */
  89280. static readonly DELAYLOADSTATE_LOADED: number;
  89281. /** Defines that the ressource is currently delay loading */
  89282. static readonly DELAYLOADSTATE_LOADING: number;
  89283. /** Defines that the ressource is delayed and has not started loading */
  89284. static readonly DELAYLOADSTATE_NOTLOADED: number;
  89285. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  89286. static readonly NEVER: number;
  89287. /** 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 */
  89288. static readonly ALWAYS: number;
  89289. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  89290. static readonly LESS: number;
  89291. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  89292. static readonly EQUAL: number;
  89293. /** 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 */
  89294. static readonly LEQUAL: number;
  89295. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  89296. static readonly GREATER: number;
  89297. /** 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 */
  89298. static readonly GEQUAL: number;
  89299. /** 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 */
  89300. static readonly NOTEQUAL: number;
  89301. /** Passed to stencilOperation to specify that stencil value must be kept */
  89302. static readonly KEEP: number;
  89303. /** Passed to stencilOperation to specify that stencil value must be replaced */
  89304. static readonly REPLACE: number;
  89305. /** Passed to stencilOperation to specify that stencil value must be incremented */
  89306. static readonly INCR: number;
  89307. /** Passed to stencilOperation to specify that stencil value must be decremented */
  89308. static readonly DECR: number;
  89309. /** Passed to stencilOperation to specify that stencil value must be inverted */
  89310. static readonly INVERT: number;
  89311. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  89312. static readonly INCR_WRAP: number;
  89313. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  89314. static readonly DECR_WRAP: number;
  89315. /** Texture is not repeating outside of 0..1 UVs */
  89316. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  89317. /** Texture is repeating outside of 0..1 UVs */
  89318. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  89319. /** Texture is repeating and mirrored */
  89320. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  89321. /** ALPHA */
  89322. static readonly TEXTUREFORMAT_ALPHA: number;
  89323. /** LUMINANCE */
  89324. static readonly TEXTUREFORMAT_LUMINANCE: number;
  89325. /** LUMINANCE_ALPHA */
  89326. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  89327. /** RGB */
  89328. static readonly TEXTUREFORMAT_RGB: number;
  89329. /** RGBA */
  89330. static readonly TEXTUREFORMAT_RGBA: number;
  89331. /** RED */
  89332. static readonly TEXTUREFORMAT_RED: number;
  89333. /** RED (2nd reference) */
  89334. static readonly TEXTUREFORMAT_R: number;
  89335. /** RG */
  89336. static readonly TEXTUREFORMAT_RG: number;
  89337. /** RED_INTEGER */
  89338. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  89339. /** RED_INTEGER (2nd reference) */
  89340. static readonly TEXTUREFORMAT_R_INTEGER: number;
  89341. /** RG_INTEGER */
  89342. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  89343. /** RGB_INTEGER */
  89344. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  89345. /** RGBA_INTEGER */
  89346. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  89347. /** UNSIGNED_BYTE */
  89348. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  89349. /** UNSIGNED_BYTE (2nd reference) */
  89350. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  89351. /** FLOAT */
  89352. static readonly TEXTURETYPE_FLOAT: number;
  89353. /** HALF_FLOAT */
  89354. static readonly TEXTURETYPE_HALF_FLOAT: number;
  89355. /** BYTE */
  89356. static readonly TEXTURETYPE_BYTE: number;
  89357. /** SHORT */
  89358. static readonly TEXTURETYPE_SHORT: number;
  89359. /** UNSIGNED_SHORT */
  89360. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  89361. /** INT */
  89362. static readonly TEXTURETYPE_INT: number;
  89363. /** UNSIGNED_INT */
  89364. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  89365. /** UNSIGNED_SHORT_4_4_4_4 */
  89366. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  89367. /** UNSIGNED_SHORT_5_5_5_1 */
  89368. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  89369. /** UNSIGNED_SHORT_5_6_5 */
  89370. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  89371. /** UNSIGNED_INT_2_10_10_10_REV */
  89372. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  89373. /** UNSIGNED_INT_24_8 */
  89374. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  89375. /** UNSIGNED_INT_10F_11F_11F_REV */
  89376. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  89377. /** UNSIGNED_INT_5_9_9_9_REV */
  89378. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  89379. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  89380. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  89381. /** nearest is mag = nearest and min = nearest and mip = linear */
  89382. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  89383. /** Bilinear is mag = linear and min = linear and mip = nearest */
  89384. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  89385. /** Trilinear is mag = linear and min = linear and mip = linear */
  89386. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  89387. /** nearest is mag = nearest and min = nearest and mip = linear */
  89388. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  89389. /** Bilinear is mag = linear and min = linear and mip = nearest */
  89390. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  89391. /** Trilinear is mag = linear and min = linear and mip = linear */
  89392. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  89393. /** mag = nearest and min = nearest and mip = nearest */
  89394. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  89395. /** mag = nearest and min = linear and mip = nearest */
  89396. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  89397. /** mag = nearest and min = linear and mip = linear */
  89398. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  89399. /** mag = nearest and min = linear and mip = none */
  89400. static readonly TEXTURE_NEAREST_LINEAR: number;
  89401. /** mag = nearest and min = nearest and mip = none */
  89402. static readonly TEXTURE_NEAREST_NEAREST: number;
  89403. /** mag = linear and min = nearest and mip = nearest */
  89404. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  89405. /** mag = linear and min = nearest and mip = linear */
  89406. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  89407. /** mag = linear and min = linear and mip = none */
  89408. static readonly TEXTURE_LINEAR_LINEAR: number;
  89409. /** mag = linear and min = nearest and mip = none */
  89410. static readonly TEXTURE_LINEAR_NEAREST: number;
  89411. /** Explicit coordinates mode */
  89412. static readonly TEXTURE_EXPLICIT_MODE: number;
  89413. /** Spherical coordinates mode */
  89414. static readonly TEXTURE_SPHERICAL_MODE: number;
  89415. /** Planar coordinates mode */
  89416. static readonly TEXTURE_PLANAR_MODE: number;
  89417. /** Cubic coordinates mode */
  89418. static readonly TEXTURE_CUBIC_MODE: number;
  89419. /** Projection coordinates mode */
  89420. static readonly TEXTURE_PROJECTION_MODE: number;
  89421. /** Skybox coordinates mode */
  89422. static readonly TEXTURE_SKYBOX_MODE: number;
  89423. /** Inverse Cubic coordinates mode */
  89424. static readonly TEXTURE_INVCUBIC_MODE: number;
  89425. /** Equirectangular coordinates mode */
  89426. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  89427. /** Equirectangular Fixed coordinates mode */
  89428. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  89429. /** Equirectangular Fixed Mirrored coordinates mode */
  89430. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  89431. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  89432. static readonly SCALEMODE_FLOOR: number;
  89433. /** Defines that texture rescaling will look for the nearest power of 2 size */
  89434. static readonly SCALEMODE_NEAREST: number;
  89435. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  89436. static readonly SCALEMODE_CEILING: number;
  89437. /**
  89438. * Returns the current npm package of the sdk
  89439. */
  89440. static readonly NpmPackage: string;
  89441. /**
  89442. * Returns the current version of the framework
  89443. */
  89444. static readonly Version: string;
  89445. /**
  89446. * Returns a string describing the current engine
  89447. */
  89448. readonly description: string;
  89449. /**
  89450. * Gets or sets the epsilon value used by collision engine
  89451. */
  89452. static CollisionsEpsilon: number;
  89453. /**
  89454. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  89455. */
  89456. static ShadersRepository: string;
  89457. /**
  89458. * Method called to create the default loading screen.
  89459. * This can be overriden in your own app.
  89460. * @param canvas The rendering canvas element
  89461. * @returns The loading screen
  89462. */
  89463. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  89464. /**
  89465. * Method called to create the default rescale post process on each engine.
  89466. */
  89467. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  89468. /**
  89469. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  89470. */
  89471. forcePOTTextures: boolean;
  89472. /**
  89473. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  89474. */
  89475. isFullscreen: boolean;
  89476. /**
  89477. * Gets a boolean indicating if the pointer is currently locked
  89478. */
  89479. isPointerLock: boolean;
  89480. /**
  89481. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  89482. */
  89483. cullBackFaces: boolean;
  89484. /**
  89485. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  89486. */
  89487. renderEvenInBackground: boolean;
  89488. /**
  89489. * Gets or sets a boolean indicating that cache can be kept between frames
  89490. */
  89491. preventCacheWipeBetweenFrames: boolean;
  89492. /**
  89493. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  89494. **/
  89495. enableOfflineSupport: boolean;
  89496. /**
  89497. * 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)
  89498. **/
  89499. disableManifestCheck: boolean;
  89500. /**
  89501. * Gets the list of created scenes
  89502. */
  89503. scenes: Scene[];
  89504. /**
  89505. * Event raised when a new scene is created
  89506. */
  89507. onNewSceneAddedObservable: Observable<Scene>;
  89508. /**
  89509. * Gets the list of created postprocesses
  89510. */
  89511. postProcesses: PostProcess[];
  89512. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  89513. validateShaderPrograms: boolean;
  89514. /**
  89515. * Observable event triggered each time the rendering canvas is resized
  89516. */
  89517. onResizeObservable: Observable<Engine>;
  89518. /**
  89519. * Observable event triggered each time the canvas loses focus
  89520. */
  89521. onCanvasBlurObservable: Observable<Engine>;
  89522. /**
  89523. * Observable event triggered each time the canvas gains focus
  89524. */
  89525. onCanvasFocusObservable: Observable<Engine>;
  89526. /**
  89527. * Observable event triggered each time the canvas receives pointerout event
  89528. */
  89529. onCanvasPointerOutObservable: Observable<PointerEvent>;
  89530. /**
  89531. * Observable event triggered before each texture is initialized
  89532. */
  89533. onBeforeTextureInitObservable: Observable<Texture>;
  89534. /**
  89535. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  89536. */
  89537. disableUniformBuffers: boolean;
  89538. /** @hidden */
  89539. _uniformBuffers: UniformBuffer[];
  89540. /**
  89541. * Gets a boolean indicating that the engine supports uniform buffers
  89542. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  89543. */
  89544. readonly supportsUniformBuffers: boolean;
  89545. /**
  89546. * Observable raised when the engine begins a new frame
  89547. */
  89548. onBeginFrameObservable: Observable<Engine>;
  89549. /**
  89550. * If set, will be used to request the next animation frame for the render loop
  89551. */
  89552. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  89553. /**
  89554. * Observable raised when the engine ends the current frame
  89555. */
  89556. onEndFrameObservable: Observable<Engine>;
  89557. /**
  89558. * Observable raised when the engine is about to compile a shader
  89559. */
  89560. onBeforeShaderCompilationObservable: Observable<Engine>;
  89561. /**
  89562. * Observable raised when the engine has jsut compiled a shader
  89563. */
  89564. onAfterShaderCompilationObservable: Observable<Engine>;
  89565. /** @hidden */
  89566. _gl: WebGLRenderingContext;
  89567. private _renderingCanvas;
  89568. private _windowIsBackground;
  89569. private _webGLVersion;
  89570. protected _highPrecisionShadersAllowed: boolean;
  89571. /** @hidden */
  89572. readonly _shouldUseHighPrecisionShader: boolean;
  89573. /**
  89574. * Gets a boolean indicating that only power of 2 textures are supported
  89575. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  89576. */
  89577. readonly needPOTTextures: boolean;
  89578. /** @hidden */
  89579. _badOS: boolean;
  89580. /** @hidden */
  89581. _badDesktopOS: boolean;
  89582. /**
  89583. * Gets the audio engine
  89584. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  89585. * @ignorenaming
  89586. */
  89587. static audioEngine: IAudioEngine;
  89588. /**
  89589. * Default AudioEngine factory responsible of creating the Audio Engine.
  89590. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  89591. */
  89592. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  89593. /**
  89594. * Default offline support factory responsible of creating a tool used to store data locally.
  89595. * By default, this will create a Database object if the workload has been embedded.
  89596. */
  89597. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  89598. private _onFocus;
  89599. private _onBlur;
  89600. private _onCanvasPointerOut;
  89601. private _onCanvasBlur;
  89602. private _onCanvasFocus;
  89603. private _onFullscreenChange;
  89604. private _onPointerLockChange;
  89605. private _hardwareScalingLevel;
  89606. /** @hidden */
  89607. _caps: EngineCapabilities;
  89608. private _pointerLockRequested;
  89609. private _isStencilEnable;
  89610. private _colorWrite;
  89611. private _loadingScreen;
  89612. /** @hidden */
  89613. _drawCalls: PerfCounter;
  89614. private _glVersion;
  89615. private _glRenderer;
  89616. private _glVendor;
  89617. private _videoTextureSupported;
  89618. private _renderingQueueLaunched;
  89619. private _activeRenderLoops;
  89620. private _deterministicLockstep;
  89621. private _lockstepMaxSteps;
  89622. /**
  89623. * Observable signaled when a context lost event is raised
  89624. */
  89625. onContextLostObservable: Observable<Engine>;
  89626. /**
  89627. * Observable signaled when a context restored event is raised
  89628. */
  89629. onContextRestoredObservable: Observable<Engine>;
  89630. private _onContextLost;
  89631. private _onContextRestored;
  89632. private _contextWasLost;
  89633. /** @hidden */
  89634. _doNotHandleContextLost: boolean;
  89635. /**
  89636. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  89637. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  89638. */
  89639. doNotHandleContextLost: boolean;
  89640. private _performanceMonitor;
  89641. private _fps;
  89642. private _deltaTime;
  89643. /**
  89644. * Turn this value on if you want to pause FPS computation when in background
  89645. */
  89646. disablePerformanceMonitorInBackground: boolean;
  89647. /**
  89648. * Gets the performance monitor attached to this engine
  89649. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  89650. */
  89651. readonly performanceMonitor: PerformanceMonitor;
  89652. /**
  89653. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  89654. */
  89655. disableVertexArrayObjects: boolean;
  89656. /** @hidden */
  89657. protected _depthCullingState: _DepthCullingState;
  89658. /** @hidden */
  89659. protected _stencilState: _StencilState;
  89660. /** @hidden */
  89661. protected _alphaState: _AlphaState;
  89662. /** @hidden */
  89663. protected _alphaMode: number;
  89664. /** @hidden */
  89665. _internalTexturesCache: InternalTexture[];
  89666. /** @hidden */
  89667. protected _activeChannel: number;
  89668. private _currentTextureChannel;
  89669. /** @hidden */
  89670. protected _boundTexturesCache: {
  89671. [key: string]: Nullable<InternalTexture>;
  89672. };
  89673. /** @hidden */
  89674. protected _currentEffect: Nullable<Effect>;
  89675. /** @hidden */
  89676. protected _currentProgram: Nullable<WebGLProgram>;
  89677. private _compiledEffects;
  89678. private _vertexAttribArraysEnabled;
  89679. /** @hidden */
  89680. protected _cachedViewport: Nullable<Viewport>;
  89681. private _cachedVertexArrayObject;
  89682. /** @hidden */
  89683. protected _cachedVertexBuffers: any;
  89684. /** @hidden */
  89685. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  89686. /** @hidden */
  89687. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  89688. /** @hidden */
  89689. _currentRenderTarget: Nullable<InternalTexture>;
  89690. private _uintIndicesCurrentlySet;
  89691. private _currentBoundBuffer;
  89692. /** @hidden */
  89693. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  89694. private _currentBufferPointers;
  89695. private _currentInstanceLocations;
  89696. private _currentInstanceBuffers;
  89697. private _textureUnits;
  89698. /** @hidden */
  89699. _workingCanvas: Nullable<HTMLCanvasElement>;
  89700. /** @hidden */
  89701. _workingContext: Nullable<CanvasRenderingContext2D>;
  89702. private _rescalePostProcess;
  89703. private _dummyFramebuffer;
  89704. private _externalData;
  89705. /** @hidden */
  89706. _bindedRenderFunction: any;
  89707. private _vaoRecordInProgress;
  89708. private _mustWipeVertexAttributes;
  89709. private _emptyTexture;
  89710. private _emptyCubeTexture;
  89711. private _emptyTexture3D;
  89712. /** @hidden */
  89713. _frameHandler: number;
  89714. private _nextFreeTextureSlots;
  89715. private _maxSimultaneousTextures;
  89716. private _activeRequests;
  89717. private _texturesSupported;
  89718. /** @hidden */
  89719. _textureFormatInUse: Nullable<string>;
  89720. /**
  89721. * Gets the list of texture formats supported
  89722. */
  89723. readonly texturesSupported: Array<string>;
  89724. /**
  89725. * Gets the list of texture formats in use
  89726. */
  89727. readonly textureFormatInUse: Nullable<string>;
  89728. /**
  89729. * Gets the current viewport
  89730. */
  89731. readonly currentViewport: Nullable<Viewport>;
  89732. /**
  89733. * Gets the default empty texture
  89734. */
  89735. readonly emptyTexture: InternalTexture;
  89736. /**
  89737. * Gets the default empty 3D texture
  89738. */
  89739. readonly emptyTexture3D: InternalTexture;
  89740. /**
  89741. * Gets the default empty cube texture
  89742. */
  89743. readonly emptyCubeTexture: InternalTexture;
  89744. /**
  89745. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  89746. */
  89747. readonly premultipliedAlpha: boolean;
  89748. /**
  89749. * Creates a new engine
  89750. * @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
  89751. * @param antialias defines enable antialiasing (default: false)
  89752. * @param options defines further options to be sent to the getContext() function
  89753. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  89754. */
  89755. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  89756. /**
  89757. * Initializes a webVR display and starts listening to display change events
  89758. * The onVRDisplayChangedObservable will be notified upon these changes
  89759. * @returns The onVRDisplayChangedObservable
  89760. */
  89761. initWebVR(): Observable<IDisplayChangedEventArgs>;
  89762. /** @hidden */
  89763. _prepareVRComponent(): void;
  89764. /** @hidden */
  89765. _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  89766. /** @hidden */
  89767. _submitVRFrame(): void;
  89768. /**
  89769. * Call this function to leave webVR mode
  89770. * Will do nothing if webVR is not supported or if there is no webVR device
  89771. * @see http://doc.babylonjs.com/how_to/webvr_camera
  89772. */
  89773. disableVR(): void;
  89774. /**
  89775. * Gets a boolean indicating that the system is in VR mode and is presenting
  89776. * @returns true if VR mode is engaged
  89777. */
  89778. isVRPresenting(): boolean;
  89779. /** @hidden */
  89780. _requestVRFrame(): void;
  89781. private _disableTouchAction;
  89782. private _rebuildInternalTextures;
  89783. private _rebuildEffects;
  89784. /**
  89785. * Gets a boolean indicating if all created effects are ready
  89786. * @returns true if all effects are ready
  89787. */
  89788. areAllEffectsReady(): boolean;
  89789. private _rebuildBuffers;
  89790. private _initGLContext;
  89791. /**
  89792. * Gets version of the current webGL context
  89793. */
  89794. readonly webGLVersion: number;
  89795. /**
  89796. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  89797. */
  89798. readonly isStencilEnable: boolean;
  89799. /** @hidden */
  89800. _prepareWorkingCanvas(): void;
  89801. /**
  89802. * Reset the texture cache to empty state
  89803. */
  89804. resetTextureCache(): void;
  89805. /**
  89806. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  89807. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  89808. * @returns true if engine is in deterministic lock step mode
  89809. */
  89810. isDeterministicLockStep(): boolean;
  89811. /**
  89812. * Gets the max steps when engine is running in deterministic lock step
  89813. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  89814. * @returns the max steps
  89815. */
  89816. getLockstepMaxSteps(): number;
  89817. /**
  89818. * Gets an object containing information about the current webGL context
  89819. * @returns an object containing the vender, the renderer and the version of the current webGL context
  89820. */
  89821. getGlInfo(): {
  89822. vendor: string;
  89823. renderer: string;
  89824. version: string;
  89825. };
  89826. /**
  89827. * Gets current aspect ratio
  89828. * @param camera defines the camera to use to get the aspect ratio
  89829. * @param useScreen defines if screen size must be used (or the current render target if any)
  89830. * @returns a number defining the aspect ratio
  89831. */
  89832. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  89833. /**
  89834. * Gets current screen aspect ratio
  89835. * @returns a number defining the aspect ratio
  89836. */
  89837. getScreenAspectRatio(): number;
  89838. /**
  89839. * Gets the current render width
  89840. * @param useScreen defines if screen size must be used (or the current render target if any)
  89841. * @returns a number defining the current render width
  89842. */
  89843. getRenderWidth(useScreen?: boolean): number;
  89844. /**
  89845. * Gets the current render height
  89846. * @param useScreen defines if screen size must be used (or the current render target if any)
  89847. * @returns a number defining the current render height
  89848. */
  89849. getRenderHeight(useScreen?: boolean): number;
  89850. /**
  89851. * Gets the HTML canvas attached with the current webGL context
  89852. * @returns a HTML canvas
  89853. */
  89854. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  89855. /**
  89856. * Gets the client rect of the HTML canvas attached with the current webGL context
  89857. * @returns a client rectanglee
  89858. */
  89859. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  89860. /**
  89861. * Defines the hardware scaling level.
  89862. * By default the hardware scaling level is computed from the window device ratio.
  89863. * 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.
  89864. * @param level defines the level to use
  89865. */
  89866. setHardwareScalingLevel(level: number): void;
  89867. /**
  89868. * Gets the current hardware scaling level.
  89869. * By default the hardware scaling level is computed from the window device ratio.
  89870. * 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.
  89871. * @returns a number indicating the current hardware scaling level
  89872. */
  89873. getHardwareScalingLevel(): number;
  89874. /**
  89875. * Gets the list of loaded textures
  89876. * @returns an array containing all loaded textures
  89877. */
  89878. getLoadedTexturesCache(): InternalTexture[];
  89879. /**
  89880. * Gets the object containing all engine capabilities
  89881. * @returns the EngineCapabilities object
  89882. */
  89883. getCaps(): EngineCapabilities;
  89884. /**
  89885. * Gets the current depth function
  89886. * @returns a number defining the depth function
  89887. */
  89888. getDepthFunction(): Nullable<number>;
  89889. /**
  89890. * Sets the current depth function
  89891. * @param depthFunc defines the function to use
  89892. */
  89893. setDepthFunction(depthFunc: number): void;
  89894. /**
  89895. * Sets the current depth function to GREATER
  89896. */
  89897. setDepthFunctionToGreater(): void;
  89898. /**
  89899. * Sets the current depth function to GEQUAL
  89900. */
  89901. setDepthFunctionToGreaterOrEqual(): void;
  89902. /**
  89903. * Sets the current depth function to LESS
  89904. */
  89905. setDepthFunctionToLess(): void;
  89906. private _cachedStencilBuffer;
  89907. private _cachedStencilFunction;
  89908. private _cachedStencilMask;
  89909. private _cachedStencilOperationPass;
  89910. private _cachedStencilOperationFail;
  89911. private _cachedStencilOperationDepthFail;
  89912. private _cachedStencilReference;
  89913. /**
  89914. * Caches the the state of the stencil buffer
  89915. */
  89916. cacheStencilState(): void;
  89917. /**
  89918. * Restores the state of the stencil buffer
  89919. */
  89920. restoreStencilState(): void;
  89921. /**
  89922. * Sets the current depth function to LEQUAL
  89923. */
  89924. setDepthFunctionToLessOrEqual(): void;
  89925. /**
  89926. * Gets a boolean indicating if stencil buffer is enabled
  89927. * @returns the current stencil buffer state
  89928. */
  89929. getStencilBuffer(): boolean;
  89930. /**
  89931. * Enable or disable the stencil buffer
  89932. * @param enable defines if the stencil buffer must be enabled or disabled
  89933. */
  89934. setStencilBuffer(enable: boolean): void;
  89935. /**
  89936. * Gets the current stencil mask
  89937. * @returns a number defining the new stencil mask to use
  89938. */
  89939. getStencilMask(): number;
  89940. /**
  89941. * Sets the current stencil mask
  89942. * @param mask defines the new stencil mask to use
  89943. */
  89944. setStencilMask(mask: number): void;
  89945. /**
  89946. * Gets the current stencil function
  89947. * @returns a number defining the stencil function to use
  89948. */
  89949. getStencilFunction(): number;
  89950. /**
  89951. * Gets the current stencil reference value
  89952. * @returns a number defining the stencil reference value to use
  89953. */
  89954. getStencilFunctionReference(): number;
  89955. /**
  89956. * Gets the current stencil mask
  89957. * @returns a number defining the stencil mask to use
  89958. */
  89959. getStencilFunctionMask(): number;
  89960. /**
  89961. * Sets the current stencil function
  89962. * @param stencilFunc defines the new stencil function to use
  89963. */
  89964. setStencilFunction(stencilFunc: number): void;
  89965. /**
  89966. * Sets the current stencil reference
  89967. * @param reference defines the new stencil reference to use
  89968. */
  89969. setStencilFunctionReference(reference: number): void;
  89970. /**
  89971. * Sets the current stencil mask
  89972. * @param mask defines the new stencil mask to use
  89973. */
  89974. setStencilFunctionMask(mask: number): void;
  89975. /**
  89976. * Gets the current stencil operation when stencil fails
  89977. * @returns a number defining stencil operation to use when stencil fails
  89978. */
  89979. getStencilOperationFail(): number;
  89980. /**
  89981. * Gets the current stencil operation when depth fails
  89982. * @returns a number defining stencil operation to use when depth fails
  89983. */
  89984. getStencilOperationDepthFail(): number;
  89985. /**
  89986. * Gets the current stencil operation when stencil passes
  89987. * @returns a number defining stencil operation to use when stencil passes
  89988. */
  89989. getStencilOperationPass(): number;
  89990. /**
  89991. * Sets the stencil operation to use when stencil fails
  89992. * @param operation defines the stencil operation to use when stencil fails
  89993. */
  89994. setStencilOperationFail(operation: number): void;
  89995. /**
  89996. * Sets the stencil operation to use when depth fails
  89997. * @param operation defines the stencil operation to use when depth fails
  89998. */
  89999. setStencilOperationDepthFail(operation: number): void;
  90000. /**
  90001. * Sets the stencil operation to use when stencil passes
  90002. * @param operation defines the stencil operation to use when stencil passes
  90003. */
  90004. setStencilOperationPass(operation: number): void;
  90005. /**
  90006. * Sets a boolean indicating if the dithering state is enabled or disabled
  90007. * @param value defines the dithering state
  90008. */
  90009. setDitheringState(value: boolean): void;
  90010. /**
  90011. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  90012. * @param value defines the rasterizer state
  90013. */
  90014. setRasterizerState(value: boolean): void;
  90015. /**
  90016. * stop executing a render loop function and remove it from the execution array
  90017. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  90018. */
  90019. stopRenderLoop(renderFunction?: () => void): void;
  90020. /** @hidden */
  90021. _renderLoop(): void;
  90022. /**
  90023. * Register and execute a render loop. The engine can have more than one render function
  90024. * @param renderFunction defines the function to continuously execute
  90025. */
  90026. runRenderLoop(renderFunction: () => void): void;
  90027. /**
  90028. * Toggle full screen mode
  90029. * @param requestPointerLock defines if a pointer lock should be requested from the user
  90030. */
  90031. switchFullscreen(requestPointerLock: boolean): void;
  90032. /**
  90033. * Enters full screen mode
  90034. * @param requestPointerLock defines if a pointer lock should be requested from the user
  90035. */
  90036. enterFullscreen(requestPointerLock: boolean): void;
  90037. /**
  90038. * Exits full screen mode
  90039. */
  90040. exitFullscreen(): void;
  90041. /**
  90042. * Clear the current render buffer or the current render target (if any is set up)
  90043. * @param color defines the color to use
  90044. * @param backBuffer defines if the back buffer must be cleared
  90045. * @param depth defines if the depth buffer must be cleared
  90046. * @param stencil defines if the stencil buffer must be cleared
  90047. */
  90048. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  90049. /**
  90050. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  90051. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  90052. * @param y defines the y-coordinate of the corner of the clear rectangle
  90053. * @param width defines the width of the clear rectangle
  90054. * @param height defines the height of the clear rectangle
  90055. * @param clearColor defines the clear color
  90056. */
  90057. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  90058. /**
  90059. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  90060. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  90061. * @param y defines the y-coordinate of the corner of the clear rectangle
  90062. * @param width defines the width of the clear rectangle
  90063. * @param height defines the height of the clear rectangle
  90064. */
  90065. enableScissor(x: number, y: number, width: number, height: number): void;
  90066. /**
  90067. * Disable previously set scissor test rectangle
  90068. */
  90069. disableScissor(): void;
  90070. private _viewportCached;
  90071. /** @hidden */
  90072. _viewport(x: number, y: number, width: number, height: number): void;
  90073. /**
  90074. * Set the WebGL's viewport
  90075. * @param viewport defines the viewport element to be used
  90076. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  90077. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  90078. */
  90079. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  90080. /**
  90081. * Directly set the WebGL Viewport
  90082. * @param x defines the x coordinate of the viewport (in screen space)
  90083. * @param y defines the y coordinate of the viewport (in screen space)
  90084. * @param width defines the width of the viewport (in screen space)
  90085. * @param height defines the height of the viewport (in screen space)
  90086. * @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
  90087. */
  90088. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  90089. /**
  90090. * Begin a new frame
  90091. */
  90092. beginFrame(): void;
  90093. /**
  90094. * Enf the current frame
  90095. */
  90096. endFrame(): void;
  90097. /**
  90098. * Resize the view according to the canvas' size
  90099. */
  90100. resize(): void;
  90101. /**
  90102. * Force a specific size of the canvas
  90103. * @param width defines the new canvas' width
  90104. * @param height defines the new canvas' height
  90105. */
  90106. setSize(width: number, height: number): void;
  90107. /**
  90108. * Binds the frame buffer to the specified texture.
  90109. * @param texture The texture to render to or null for the default canvas
  90110. * @param faceIndex The face of the texture to render to in case of cube texture
  90111. * @param requiredWidth The width of the target to render to
  90112. * @param requiredHeight The height of the target to render to
  90113. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  90114. * @param depthStencilTexture The depth stencil texture to use to render
  90115. * @param lodLevel defines le lod level to bind to the frame buffer
  90116. */
  90117. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  90118. /** @hidden */
  90119. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  90120. /**
  90121. * Unbind the current render target texture from the webGL context
  90122. * @param texture defines the render target texture to unbind
  90123. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  90124. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  90125. */
  90126. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  90127. /**
  90128. * Force the mipmap generation for the given render target texture
  90129. * @param texture defines the render target texture to use
  90130. */
  90131. generateMipMapsForCubemap(texture: InternalTexture): void;
  90132. /**
  90133. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  90134. */
  90135. flushFramebuffer(): void;
  90136. /**
  90137. * Unbind the current render target and bind the default framebuffer
  90138. */
  90139. restoreDefaultFramebuffer(): void;
  90140. /**
  90141. * Create an uniform buffer
  90142. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  90143. * @param elements defines the content of the uniform buffer
  90144. * @returns the webGL uniform buffer
  90145. */
  90146. createUniformBuffer(elements: FloatArray): DataBuffer;
  90147. /**
  90148. * Create a dynamic uniform buffer
  90149. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  90150. * @param elements defines the content of the uniform buffer
  90151. * @returns the webGL uniform buffer
  90152. */
  90153. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  90154. /**
  90155. * Update an existing uniform buffer
  90156. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  90157. * @param uniformBuffer defines the target uniform buffer
  90158. * @param elements defines the content to update
  90159. * @param offset defines the offset in the uniform buffer where update should start
  90160. * @param count defines the size of the data to update
  90161. */
  90162. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  90163. private _resetVertexBufferBinding;
  90164. /**
  90165. * Creates a vertex buffer
  90166. * @param data the data for the vertex buffer
  90167. * @returns the new WebGL static buffer
  90168. */
  90169. createVertexBuffer(data: DataArray): DataBuffer;
  90170. /**
  90171. * Creates a dynamic vertex buffer
  90172. * @param data the data for the dynamic vertex buffer
  90173. * @returns the new WebGL dynamic buffer
  90174. */
  90175. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  90176. /**
  90177. * Update a dynamic index buffer
  90178. * @param indexBuffer defines the target index buffer
  90179. * @param indices defines the data to update
  90180. * @param offset defines the offset in the target index buffer where update should start
  90181. */
  90182. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  90183. /**
  90184. * Updates a dynamic vertex buffer.
  90185. * @param vertexBuffer the vertex buffer to update
  90186. * @param data the data used to update the vertex buffer
  90187. * @param byteOffset the byte offset of the data
  90188. * @param byteLength the byte length of the data
  90189. */
  90190. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  90191. private _resetIndexBufferBinding;
  90192. /**
  90193. * Creates a new index buffer
  90194. * @param indices defines the content of the index buffer
  90195. * @param updatable defines if the index buffer must be updatable
  90196. * @returns a new webGL buffer
  90197. */
  90198. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  90199. /**
  90200. * Bind a webGL buffer to the webGL context
  90201. * @param buffer defines the buffer to bind
  90202. */
  90203. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  90204. /**
  90205. * Bind an uniform buffer to the current webGL context
  90206. * @param buffer defines the buffer to bind
  90207. */
  90208. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  90209. /**
  90210. * Bind a buffer to the current webGL context at a given location
  90211. * @param buffer defines the buffer to bind
  90212. * @param location defines the index where to bind the buffer
  90213. */
  90214. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  90215. /**
  90216. * Bind a specific block at a given index in a specific shader program
  90217. * @param pipelineContext defines the pipeline context to use
  90218. * @param blockName defines the block name
  90219. * @param index defines the index where to bind the block
  90220. */
  90221. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  90222. private bindIndexBuffer;
  90223. private bindBuffer;
  90224. /**
  90225. * update the bound buffer with the given data
  90226. * @param data defines the data to update
  90227. */
  90228. updateArrayBuffer(data: Float32Array): void;
  90229. private _vertexAttribPointer;
  90230. private _bindIndexBufferWithCache;
  90231. private _bindVertexBuffersAttributes;
  90232. /**
  90233. * Records a vertex array object
  90234. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  90235. * @param vertexBuffers defines the list of vertex buffers to store
  90236. * @param indexBuffer defines the index buffer to store
  90237. * @param effect defines the effect to store
  90238. * @returns the new vertex array object
  90239. */
  90240. recordVertexArrayObject(vertexBuffers: {
  90241. [key: string]: VertexBuffer;
  90242. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  90243. /**
  90244. * Bind a specific vertex array object
  90245. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  90246. * @param vertexArrayObject defines the vertex array object to bind
  90247. * @param indexBuffer defines the index buffer to bind
  90248. */
  90249. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  90250. /**
  90251. * Bind webGl buffers directly to the webGL context
  90252. * @param vertexBuffer defines the vertex buffer to bind
  90253. * @param indexBuffer defines the index buffer to bind
  90254. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  90255. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  90256. * @param effect defines the effect associated with the vertex buffer
  90257. */
  90258. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  90259. private _unbindVertexArrayObject;
  90260. /**
  90261. * Bind a list of vertex buffers to the webGL context
  90262. * @param vertexBuffers defines the list of vertex buffers to bind
  90263. * @param indexBuffer defines the index buffer to bind
  90264. * @param effect defines the effect associated with the vertex buffers
  90265. */
  90266. bindBuffers(vertexBuffers: {
  90267. [key: string]: Nullable<VertexBuffer>;
  90268. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  90269. /**
  90270. * Unbind all instance attributes
  90271. */
  90272. unbindInstanceAttributes(): void;
  90273. /**
  90274. * Release and free the memory of a vertex array object
  90275. * @param vao defines the vertex array object to delete
  90276. */
  90277. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  90278. /** @hidden */
  90279. _releaseBuffer(buffer: DataBuffer): boolean;
  90280. /**
  90281. * Creates a webGL buffer to use with instanciation
  90282. * @param capacity defines the size of the buffer
  90283. * @returns the webGL buffer
  90284. */
  90285. createInstancesBuffer(capacity: number): DataBuffer;
  90286. /**
  90287. * Delete a webGL buffer used with instanciation
  90288. * @param buffer defines the webGL buffer to delete
  90289. */
  90290. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  90291. /**
  90292. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  90293. * @param instancesBuffer defines the webGL buffer to update and bind
  90294. * @param data defines the data to store in the buffer
  90295. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  90296. */
  90297. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  90298. /**
  90299. * Apply all cached states (depth, culling, stencil and alpha)
  90300. */
  90301. applyStates(): void;
  90302. /**
  90303. * Send a draw order
  90304. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  90305. * @param indexStart defines the starting index
  90306. * @param indexCount defines the number of index to draw
  90307. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  90308. */
  90309. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  90310. /**
  90311. * Draw a list of points
  90312. * @param verticesStart defines the index of first vertex to draw
  90313. * @param verticesCount defines the count of vertices to draw
  90314. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  90315. */
  90316. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  90317. /**
  90318. * Draw a list of unindexed primitives
  90319. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  90320. * @param verticesStart defines the index of first vertex to draw
  90321. * @param verticesCount defines the count of vertices to draw
  90322. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  90323. */
  90324. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  90325. /**
  90326. * Draw a list of indexed primitives
  90327. * @param fillMode defines the primitive to use
  90328. * @param indexStart defines the starting index
  90329. * @param indexCount defines the number of index to draw
  90330. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  90331. */
  90332. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  90333. /**
  90334. * Draw a list of unindexed primitives
  90335. * @param fillMode defines the primitive to use
  90336. * @param verticesStart defines the index of first vertex to draw
  90337. * @param verticesCount defines the count of vertices to draw
  90338. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  90339. */
  90340. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  90341. private _drawMode;
  90342. /** @hidden */
  90343. _releaseEffect(effect: Effect): void;
  90344. /** @hidden */
  90345. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  90346. /**
  90347. * Create a new effect (used to store vertex/fragment shaders)
  90348. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  90349. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  90350. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  90351. * @param samplers defines an array of string used to represent textures
  90352. * @param defines defines the string containing the defines to use to compile the shaders
  90353. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  90354. * @param onCompiled defines a function to call when the effect creation is successful
  90355. * @param onError defines a function to call when the effect creation has failed
  90356. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  90357. * @returns the new Effect
  90358. */
  90359. 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;
  90360. private _compileShader;
  90361. private _compileRawShader;
  90362. /**
  90363. * Directly creates a webGL program
  90364. * @param pipelineContext defines the pipeline context to attach to
  90365. * @param vertexCode defines the vertex shader code to use
  90366. * @param fragmentCode defines the fragment shader code to use
  90367. * @param context defines the webGL context to use (if not set, the current one will be used)
  90368. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  90369. * @returns the new webGL program
  90370. */
  90371. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  90372. /**
  90373. * Creates a webGL program
  90374. * @param pipelineContext defines the pipeline context to attach to
  90375. * @param vertexCode defines the vertex shader code to use
  90376. * @param fragmentCode defines the fragment shader code to use
  90377. * @param defines defines the string containing the defines to use to compile the shaders
  90378. * @param context defines the webGL context to use (if not set, the current one will be used)
  90379. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  90380. * @returns the new webGL program
  90381. */
  90382. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  90383. /**
  90384. * Creates a new pipeline context
  90385. * @returns the new pipeline
  90386. */
  90387. createPipelineContext(): WebGLPipelineContext;
  90388. private _createShaderProgram;
  90389. private _finalizePipelineContext;
  90390. /** @hidden */
  90391. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  90392. /** @hidden */
  90393. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  90394. /** @hidden */
  90395. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  90396. /**
  90397. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  90398. * @param pipelineContext defines the pipeline context to use
  90399. * @param uniformsNames defines the list of uniform names
  90400. * @returns an array of webGL uniform locations
  90401. */
  90402. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  90403. /**
  90404. * Gets the lsit of active attributes for a given webGL program
  90405. * @param pipelineContext defines the pipeline context to use
  90406. * @param attributesNames defines the list of attribute names to get
  90407. * @returns an array of indices indicating the offset of each attribute
  90408. */
  90409. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  90410. /**
  90411. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  90412. * @param effect defines the effect to activate
  90413. */
  90414. enableEffect(effect: Nullable<Effect>): void;
  90415. /**
  90416. * Set the value of an uniform to an array of int32
  90417. * @param uniform defines the webGL uniform location where to store the value
  90418. * @param array defines the array of int32 to store
  90419. */
  90420. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  90421. /**
  90422. * Set the value of an uniform to an array of int32 (stored as vec2)
  90423. * @param uniform defines the webGL uniform location where to store the value
  90424. * @param array defines the array of int32 to store
  90425. */
  90426. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  90427. /**
  90428. * Set the value of an uniform to an array of int32 (stored as vec3)
  90429. * @param uniform defines the webGL uniform location where to store the value
  90430. * @param array defines the array of int32 to store
  90431. */
  90432. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  90433. /**
  90434. * Set the value of an uniform to an array of int32 (stored as vec4)
  90435. * @param uniform defines the webGL uniform location where to store the value
  90436. * @param array defines the array of int32 to store
  90437. */
  90438. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  90439. /**
  90440. * Set the value of an uniform to an array of float32
  90441. * @param uniform defines the webGL uniform location where to store the value
  90442. * @param array defines the array of float32 to store
  90443. */
  90444. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  90445. /**
  90446. * Set the value of an uniform to an array of float32 (stored as vec2)
  90447. * @param uniform defines the webGL uniform location where to store the value
  90448. * @param array defines the array of float32 to store
  90449. */
  90450. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  90451. /**
  90452. * Set the value of an uniform to an array of float32 (stored as vec3)
  90453. * @param uniform defines the webGL uniform location where to store the value
  90454. * @param array defines the array of float32 to store
  90455. */
  90456. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  90457. /**
  90458. * Set the value of an uniform to an array of float32 (stored as vec4)
  90459. * @param uniform defines the webGL uniform location where to store the value
  90460. * @param array defines the array of float32 to store
  90461. */
  90462. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  90463. /**
  90464. * Set the value of an uniform to an array of number
  90465. * @param uniform defines the webGL uniform location where to store the value
  90466. * @param array defines the array of number to store
  90467. */
  90468. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  90469. /**
  90470. * Set the value of an uniform to an array of number (stored as vec2)
  90471. * @param uniform defines the webGL uniform location where to store the value
  90472. * @param array defines the array of number to store
  90473. */
  90474. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  90475. /**
  90476. * Set the value of an uniform to an array of number (stored as vec3)
  90477. * @param uniform defines the webGL uniform location where to store the value
  90478. * @param array defines the array of number to store
  90479. */
  90480. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  90481. /**
  90482. * Set the value of an uniform to an array of number (stored as vec4)
  90483. * @param uniform defines the webGL uniform location where to store the value
  90484. * @param array defines the array of number to store
  90485. */
  90486. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  90487. /**
  90488. * Set the value of an uniform to an array of float32 (stored as matrices)
  90489. * @param uniform defines the webGL uniform location where to store the value
  90490. * @param matrices defines the array of float32 to store
  90491. */
  90492. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  90493. /**
  90494. * Set the value of an uniform to a matrix
  90495. * @param uniform defines the webGL uniform location where to store the value
  90496. * @param matrix defines the matrix to store
  90497. */
  90498. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  90499. /**
  90500. * Set the value of an uniform to a matrix (3x3)
  90501. * @param uniform defines the webGL uniform location where to store the value
  90502. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  90503. */
  90504. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  90505. /**
  90506. * Set the value of an uniform to a matrix (2x2)
  90507. * @param uniform defines the webGL uniform location where to store the value
  90508. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  90509. */
  90510. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  90511. /**
  90512. * Set the value of an uniform to a number (int)
  90513. * @param uniform defines the webGL uniform location where to store the value
  90514. * @param value defines the int number to store
  90515. */
  90516. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  90517. /**
  90518. * Set the value of an uniform to a number (float)
  90519. * @param uniform defines the webGL uniform location where to store the value
  90520. * @param value defines the float number to store
  90521. */
  90522. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  90523. /**
  90524. * Set the value of an uniform to a vec2
  90525. * @param uniform defines the webGL uniform location where to store the value
  90526. * @param x defines the 1st component of the value
  90527. * @param y defines the 2nd component of the value
  90528. */
  90529. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  90530. /**
  90531. * Set the value of an uniform to a vec3
  90532. * @param uniform defines the webGL uniform location where to store the value
  90533. * @param x defines the 1st component of the value
  90534. * @param y defines the 2nd component of the value
  90535. * @param z defines the 3rd component of the value
  90536. */
  90537. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  90538. /**
  90539. * Set the value of an uniform to a boolean
  90540. * @param uniform defines the webGL uniform location where to store the value
  90541. * @param bool defines the boolean to store
  90542. */
  90543. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  90544. /**
  90545. * Set the value of an uniform to a vec4
  90546. * @param uniform defines the webGL uniform location where to store the value
  90547. * @param x defines the 1st component of the value
  90548. * @param y defines the 2nd component of the value
  90549. * @param z defines the 3rd component of the value
  90550. * @param w defines the 4th component of the value
  90551. */
  90552. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  90553. /**
  90554. * Set the value of an uniform to a Color3
  90555. * @param uniform defines the webGL uniform location where to store the value
  90556. * @param color3 defines the color to store
  90557. */
  90558. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  90559. /**
  90560. * Set the value of an uniform to a Color3 and an alpha value
  90561. * @param uniform defines the webGL uniform location where to store the value
  90562. * @param color3 defines the color to store
  90563. * @param alpha defines the alpha component to store
  90564. */
  90565. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  90566. /**
  90567. * Sets a Color4 on a uniform variable
  90568. * @param uniform defines the uniform location
  90569. * @param color4 defines the value to be set
  90570. */
  90571. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  90572. /**
  90573. * Set various states to the webGL context
  90574. * @param culling defines backface culling state
  90575. * @param zOffset defines the value to apply to zOffset (0 by default)
  90576. * @param force defines if states must be applied even if cache is up to date
  90577. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  90578. */
  90579. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  90580. /**
  90581. * Set the z offset to apply to current rendering
  90582. * @param value defines the offset to apply
  90583. */
  90584. setZOffset(value: number): void;
  90585. /**
  90586. * Gets the current value of the zOffset
  90587. * @returns the current zOffset state
  90588. */
  90589. getZOffset(): number;
  90590. /**
  90591. * Enable or disable depth buffering
  90592. * @param enable defines the state to set
  90593. */
  90594. setDepthBuffer(enable: boolean): void;
  90595. /**
  90596. * Gets a boolean indicating if depth writing is enabled
  90597. * @returns the current depth writing state
  90598. */
  90599. getDepthWrite(): boolean;
  90600. /**
  90601. * Enable or disable depth writing
  90602. * @param enable defines the state to set
  90603. */
  90604. setDepthWrite(enable: boolean): void;
  90605. /**
  90606. * Enable or disable color writing
  90607. * @param enable defines the state to set
  90608. */
  90609. setColorWrite(enable: boolean): void;
  90610. /**
  90611. * Gets a boolean indicating if color writing is enabled
  90612. * @returns the current color writing state
  90613. */
  90614. getColorWrite(): boolean;
  90615. /**
  90616. * Sets alpha constants used by some alpha blending modes
  90617. * @param r defines the red component
  90618. * @param g defines the green component
  90619. * @param b defines the blue component
  90620. * @param a defines the alpha component
  90621. */
  90622. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  90623. /**
  90624. * Sets the current alpha mode
  90625. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  90626. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  90627. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  90628. */
  90629. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  90630. /**
  90631. * Gets the current alpha mode
  90632. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  90633. * @returns the current alpha mode
  90634. */
  90635. getAlphaMode(): number;
  90636. /**
  90637. * Clears the list of texture accessible through engine.
  90638. * This can help preventing texture load conflict due to name collision.
  90639. */
  90640. clearInternalTexturesCache(): void;
  90641. /**
  90642. * Force the entire cache to be cleared
  90643. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  90644. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  90645. */
  90646. wipeCaches(bruteForce?: boolean): void;
  90647. /**
  90648. * Set the compressed texture format to use, based on the formats you have, and the formats
  90649. * supported by the hardware / browser.
  90650. *
  90651. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  90652. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  90653. * to API arguments needed to compressed textures. This puts the burden on the container
  90654. * generator to house the arcane code for determining these for current & future formats.
  90655. *
  90656. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  90657. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  90658. *
  90659. * Note: The result of this call is not taken into account when a texture is base64.
  90660. *
  90661. * @param formatsAvailable defines the list of those format families you have created
  90662. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  90663. *
  90664. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  90665. * @returns The extension selected.
  90666. */
  90667. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  90668. /** @hidden */
  90669. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  90670. min: number;
  90671. mag: number;
  90672. };
  90673. /** @hidden */
  90674. _createTexture(): WebGLTexture;
  90675. /**
  90676. * Usually called from Texture.ts.
  90677. * Passed information to create a WebGLTexture
  90678. * @param urlArg defines a value which contains one of the following:
  90679. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  90680. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  90681. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  90682. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  90683. * @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)
  90684. * @param scene needed for loading to the correct scene
  90685. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  90686. * @param onLoad optional callback to be called upon successful completion
  90687. * @param onError optional callback to be called upon failure
  90688. * @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
  90689. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  90690. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  90691. * @param forcedExtension defines the extension to use to pick the right loader
  90692. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  90693. * @returns a InternalTexture for assignment back into BABYLON.Texture
  90694. */
  90695. 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;
  90696. private _rescaleTexture;
  90697. private _unpackFlipYCached;
  90698. /**
  90699. * In case you are sharing the context with other applications, it might
  90700. * be interested to not cache the unpack flip y state to ensure a consistent
  90701. * value would be set.
  90702. */
  90703. enableUnpackFlipYCached: boolean;
  90704. /** @hidden */
  90705. _unpackFlipY(value: boolean): void;
  90706. /** @hidden */
  90707. _getUnpackAlignement(): number;
  90708. /**
  90709. * Creates a dynamic texture
  90710. * @param width defines the width of the texture
  90711. * @param height defines the height of the texture
  90712. * @param generateMipMaps defines if the engine should generate the mip levels
  90713. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  90714. * @returns the dynamic texture inside an InternalTexture
  90715. */
  90716. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  90717. /**
  90718. * Update the sampling mode of a given texture
  90719. * @param samplingMode defines the required sampling mode
  90720. * @param texture defines the texture to update
  90721. */
  90722. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  90723. /**
  90724. * Update the content of a dynamic texture
  90725. * @param texture defines the texture to update
  90726. * @param canvas defines the canvas containing the source
  90727. * @param invertY defines if data must be stored with Y axis inverted
  90728. * @param premulAlpha defines if alpha is stored as premultiplied
  90729. * @param format defines the format of the data
  90730. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  90731. */
  90732. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  90733. /**
  90734. * Update a video texture
  90735. * @param texture defines the texture to update
  90736. * @param video defines the video element to use
  90737. * @param invertY defines if data must be stored with Y axis inverted
  90738. */
  90739. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  90740. /**
  90741. * Updates a depth texture Comparison Mode and Function.
  90742. * If the comparison Function is equal to 0, the mode will be set to none.
  90743. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  90744. * @param texture The texture to set the comparison function for
  90745. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  90746. */
  90747. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  90748. /** @hidden */
  90749. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  90750. width: number;
  90751. height: number;
  90752. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  90753. /**
  90754. * Creates a depth stencil texture.
  90755. * This is only available in WebGL 2 or with the depth texture extension available.
  90756. * @param size The size of face edge in the texture.
  90757. * @param options The options defining the texture.
  90758. * @returns The texture
  90759. */
  90760. createDepthStencilTexture(size: number | {
  90761. width: number;
  90762. height: number;
  90763. }, options: DepthTextureCreationOptions): InternalTexture;
  90764. /**
  90765. * Creates a depth stencil texture.
  90766. * This is only available in WebGL 2 or with the depth texture extension available.
  90767. * @param size The size of face edge in the texture.
  90768. * @param options The options defining the texture.
  90769. * @returns The texture
  90770. */
  90771. private _createDepthStencilTexture;
  90772. /**
  90773. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  90774. * @param renderTarget The render target to set the frame buffer for
  90775. */
  90776. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  90777. /**
  90778. * Creates a new render target texture
  90779. * @param size defines the size of the texture
  90780. * @param options defines the options used to create the texture
  90781. * @returns a new render target texture stored in an InternalTexture
  90782. */
  90783. createRenderTargetTexture(size: number | {
  90784. width: number;
  90785. height: number;
  90786. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  90787. /** @hidden */
  90788. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  90789. /**
  90790. * Updates the sample count of a render target texture
  90791. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  90792. * @param texture defines the texture to update
  90793. * @param samples defines the sample count to set
  90794. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  90795. */
  90796. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  90797. /** @hidden */
  90798. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  90799. /** @hidden */
  90800. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  90801. /** @hidden */
  90802. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  90803. /** @hidden */
  90804. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  90805. /**
  90806. * @hidden
  90807. */
  90808. _setCubeMapTextureParams(loadMipmap: boolean): void;
  90809. private _prepareWebGLTextureContinuation;
  90810. private _prepareWebGLTexture;
  90811. /** @hidden */
  90812. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  90813. /** @hidden */
  90814. _releaseFramebufferObjects(texture: InternalTexture): void;
  90815. /** @hidden */
  90816. _releaseTexture(texture: InternalTexture): void;
  90817. private setProgram;
  90818. private _boundUniforms;
  90819. /**
  90820. * Binds an effect to the webGL context
  90821. * @param effect defines the effect to bind
  90822. */
  90823. bindSamplers(effect: Effect): void;
  90824. private _activateCurrentTexture;
  90825. /** @hidden */
  90826. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  90827. /** @hidden */
  90828. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  90829. /**
  90830. * Sets a texture to the webGL context from a postprocess
  90831. * @param channel defines the channel to use
  90832. * @param postProcess defines the source postprocess
  90833. */
  90834. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  90835. /**
  90836. * Binds the output of the passed in post process to the texture channel specified
  90837. * @param channel The channel the texture should be bound to
  90838. * @param postProcess The post process which's output should be bound
  90839. */
  90840. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  90841. /**
  90842. * Unbind all textures from the webGL context
  90843. */
  90844. unbindAllTextures(): void;
  90845. /**
  90846. * Sets a texture to the according uniform.
  90847. * @param channel The texture channel
  90848. * @param uniform The uniform to set
  90849. * @param texture The texture to apply
  90850. */
  90851. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  90852. /**
  90853. * Sets a depth stencil texture from a render target to the according uniform.
  90854. * @param channel The texture channel
  90855. * @param uniform The uniform to set
  90856. * @param texture The render target texture containing the depth stencil texture to apply
  90857. */
  90858. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  90859. private _bindSamplerUniformToChannel;
  90860. private _getTextureWrapMode;
  90861. private _setTexture;
  90862. /**
  90863. * Sets an array of texture to the webGL context
  90864. * @param channel defines the channel where the texture array must be set
  90865. * @param uniform defines the associated uniform location
  90866. * @param textures defines the array of textures to bind
  90867. */
  90868. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  90869. /** @hidden */
  90870. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  90871. private _setTextureParameterFloat;
  90872. private _setTextureParameterInteger;
  90873. /**
  90874. * Reads pixels from the current frame buffer. Please note that this function can be slow
  90875. * @param x defines the x coordinate of the rectangle where pixels must be read
  90876. * @param y defines the y coordinate of the rectangle where pixels must be read
  90877. * @param width defines the width of the rectangle where pixels must be read
  90878. * @param height defines the height of the rectangle where pixels must be read
  90879. * @returns a Uint8Array containing RGBA colors
  90880. */
  90881. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  90882. /**
  90883. * Add an externaly attached data from its key.
  90884. * This method call will fail and return false, if such key already exists.
  90885. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  90886. * @param key the unique key that identifies the data
  90887. * @param data the data object to associate to the key for this Engine instance
  90888. * @return true if no such key were already present and the data was added successfully, false otherwise
  90889. */
  90890. addExternalData<T>(key: string, data: T): boolean;
  90891. /**
  90892. * Get an externaly attached data from its key
  90893. * @param key the unique key that identifies the data
  90894. * @return the associated data, if present (can be null), or undefined if not present
  90895. */
  90896. getExternalData<T>(key: string): T;
  90897. /**
  90898. * Get an externaly attached data from its key, create it using a factory if it's not already present
  90899. * @param key the unique key that identifies the data
  90900. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  90901. * @return the associated data, can be null if the factory returned null.
  90902. */
  90903. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  90904. /**
  90905. * Remove an externaly attached data from the Engine instance
  90906. * @param key the unique key that identifies the data
  90907. * @return true if the data was successfully removed, false if it doesn't exist
  90908. */
  90909. removeExternalData(key: string): boolean;
  90910. /**
  90911. * Unbind all vertex attributes from the webGL context
  90912. */
  90913. unbindAllAttributes(): void;
  90914. /**
  90915. * 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
  90916. */
  90917. releaseEffects(): void;
  90918. /**
  90919. * Dispose and release all associated resources
  90920. */
  90921. dispose(): void;
  90922. /**
  90923. * Display the loading screen
  90924. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  90925. */
  90926. displayLoadingUI(): void;
  90927. /**
  90928. * Hide the loading screen
  90929. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  90930. */
  90931. hideLoadingUI(): void;
  90932. /**
  90933. * Gets the current loading screen object
  90934. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  90935. */
  90936. /**
  90937. * Sets the current loading screen object
  90938. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  90939. */
  90940. loadingScreen: ILoadingScreen;
  90941. /**
  90942. * Sets the current loading screen text
  90943. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  90944. */
  90945. loadingUIText: string;
  90946. /**
  90947. * Sets the current loading screen background color
  90948. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  90949. */
  90950. loadingUIBackgroundColor: string;
  90951. /**
  90952. * Attach a new callback raised when context lost event is fired
  90953. * @param callback defines the callback to call
  90954. */
  90955. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  90956. /**
  90957. * Attach a new callback raised when context restored event is fired
  90958. * @param callback defines the callback to call
  90959. */
  90960. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  90961. /**
  90962. * Gets the source code of the vertex shader associated with a specific webGL program
  90963. * @param program defines the program to use
  90964. * @returns a string containing the source code of the vertex shader associated with the program
  90965. */
  90966. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  90967. /**
  90968. * Gets the source code of the fragment shader associated with a specific webGL program
  90969. * @param program defines the program to use
  90970. * @returns a string containing the source code of the fragment shader associated with the program
  90971. */
  90972. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  90973. /**
  90974. * Get the current error code of the webGL context
  90975. * @returns the error code
  90976. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  90977. */
  90978. getError(): number;
  90979. /**
  90980. * Gets the current framerate
  90981. * @returns a number representing the framerate
  90982. */
  90983. getFps(): number;
  90984. /**
  90985. * Gets the time spent between current and previous frame
  90986. * @returns a number representing the delta time in ms
  90987. */
  90988. getDeltaTime(): number;
  90989. private _measureFps;
  90990. /** @hidden */
  90991. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  90992. private _canRenderToFloatFramebuffer;
  90993. private _canRenderToHalfFloatFramebuffer;
  90994. private _canRenderToFramebuffer;
  90995. /** @hidden */
  90996. _getWebGLTextureType(type: number): number;
  90997. /** @hidden */
  90998. _getInternalFormat(format: number): number;
  90999. /** @hidden */
  91000. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  91001. /** @hidden */
  91002. _getRGBAMultiSampleBufferFormat(type: number): number;
  91003. /** @hidden */
  91004. _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;
  91005. /** @hidden */
  91006. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  91007. /**
  91008. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  91009. * @returns true if the engine can be created
  91010. * @ignorenaming
  91011. */
  91012. static isSupported(): boolean;
  91013. }
  91014. }
  91015. declare module BABYLON {
  91016. /**
  91017. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  91018. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  91019. */
  91020. export class EffectFallbacks {
  91021. private _defines;
  91022. private _currentRank;
  91023. private _maxRank;
  91024. private _mesh;
  91025. /**
  91026. * Removes the fallback from the bound mesh.
  91027. */
  91028. unBindMesh(): void;
  91029. /**
  91030. * Adds a fallback on the specified property.
  91031. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  91032. * @param define The name of the define in the shader
  91033. */
  91034. addFallback(rank: number, define: string): void;
  91035. /**
  91036. * Sets the mesh to use CPU skinning when needing to fallback.
  91037. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  91038. * @param mesh The mesh to use the fallbacks.
  91039. */
  91040. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  91041. /**
  91042. * Checks to see if more fallbacks are still availible.
  91043. */
  91044. readonly isMoreFallbacks: boolean;
  91045. /**
  91046. * Removes the defines that shoould be removed when falling back.
  91047. * @param currentDefines defines the current define statements for the shader.
  91048. * @param effect defines the current effect we try to compile
  91049. * @returns The resulting defines with defines of the current rank removed.
  91050. */
  91051. reduce(currentDefines: string, effect: Effect): string;
  91052. }
  91053. /**
  91054. * Options to be used when creating an effect.
  91055. */
  91056. export class EffectCreationOptions {
  91057. /**
  91058. * Atrributes that will be used in the shader.
  91059. */
  91060. attributes: string[];
  91061. /**
  91062. * Uniform varible names that will be set in the shader.
  91063. */
  91064. uniformsNames: string[];
  91065. /**
  91066. * Uniform buffer varible names that will be set in the shader.
  91067. */
  91068. uniformBuffersNames: string[];
  91069. /**
  91070. * Sampler texture variable names that will be set in the shader.
  91071. */
  91072. samplers: string[];
  91073. /**
  91074. * Define statements that will be set in the shader.
  91075. */
  91076. defines: any;
  91077. /**
  91078. * Possible fallbacks for this effect to improve performance when needed.
  91079. */
  91080. fallbacks: Nullable<EffectFallbacks>;
  91081. /**
  91082. * Callback that will be called when the shader is compiled.
  91083. */
  91084. onCompiled: Nullable<(effect: Effect) => void>;
  91085. /**
  91086. * Callback that will be called if an error occurs during shader compilation.
  91087. */
  91088. onError: Nullable<(effect: Effect, errors: string) => void>;
  91089. /**
  91090. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  91091. */
  91092. indexParameters: any;
  91093. /**
  91094. * Max number of lights that can be used in the shader.
  91095. */
  91096. maxSimultaneousLights: number;
  91097. /**
  91098. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  91099. */
  91100. transformFeedbackVaryings: Nullable<string[]>;
  91101. }
  91102. /**
  91103. * Effect containing vertex and fragment shader that can be executed on an object.
  91104. */
  91105. export class Effect implements IDisposable {
  91106. /**
  91107. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  91108. */
  91109. static ShadersRepository: string;
  91110. /**
  91111. * Name of the effect.
  91112. */
  91113. name: any;
  91114. /**
  91115. * String container all the define statements that should be set on the shader.
  91116. */
  91117. defines: string;
  91118. /**
  91119. * Callback that will be called when the shader is compiled.
  91120. */
  91121. onCompiled: Nullable<(effect: Effect) => void>;
  91122. /**
  91123. * Callback that will be called if an error occurs during shader compilation.
  91124. */
  91125. onError: Nullable<(effect: Effect, errors: string) => void>;
  91126. /**
  91127. * Callback that will be called when effect is bound.
  91128. */
  91129. onBind: Nullable<(effect: Effect) => void>;
  91130. /**
  91131. * Unique ID of the effect.
  91132. */
  91133. uniqueId: number;
  91134. /**
  91135. * Observable that will be called when the shader is compiled.
  91136. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  91137. */
  91138. onCompileObservable: Observable<Effect>;
  91139. /**
  91140. * Observable that will be called if an error occurs during shader compilation.
  91141. */
  91142. onErrorObservable: Observable<Effect>;
  91143. /** @hidden */
  91144. _onBindObservable: Nullable<Observable<Effect>>;
  91145. /**
  91146. * Observable that will be called when effect is bound.
  91147. */
  91148. readonly onBindObservable: Observable<Effect>;
  91149. /** @hidden */
  91150. _bonesComputationForcedToCPU: boolean;
  91151. private static _uniqueIdSeed;
  91152. private _engine;
  91153. private _uniformBuffersNames;
  91154. private _uniformsNames;
  91155. private _samplerList;
  91156. private _samplers;
  91157. private _isReady;
  91158. private _compilationError;
  91159. private _attributesNames;
  91160. private _attributes;
  91161. private _uniforms;
  91162. /**
  91163. * Key for the effect.
  91164. * @hidden
  91165. */
  91166. _key: string;
  91167. private _indexParameters;
  91168. private _fallbacks;
  91169. private _vertexSourceCode;
  91170. private _fragmentSourceCode;
  91171. private _vertexSourceCodeOverride;
  91172. private _fragmentSourceCodeOverride;
  91173. private _transformFeedbackVaryings;
  91174. /**
  91175. * Compiled shader to webGL program.
  91176. * @hidden
  91177. */
  91178. _pipelineContext: Nullable<IPipelineContext>;
  91179. private _valueCache;
  91180. private static _baseCache;
  91181. /**
  91182. * Instantiates an effect.
  91183. * An effect can be used to create/manage/execute vertex and fragment shaders.
  91184. * @param baseName Name of the effect.
  91185. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  91186. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  91187. * @param samplers List of sampler variables that will be passed to the shader.
  91188. * @param engine Engine to be used to render the effect
  91189. * @param defines Define statements to be added to the shader.
  91190. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  91191. * @param onCompiled Callback that will be called when the shader is compiled.
  91192. * @param onError Callback that will be called if an error occurs during shader compilation.
  91193. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  91194. */
  91195. 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);
  91196. /**
  91197. * Unique key for this effect
  91198. */
  91199. readonly key: string;
  91200. /**
  91201. * If the effect has been compiled and prepared.
  91202. * @returns if the effect is compiled and prepared.
  91203. */
  91204. isReady(): boolean;
  91205. /**
  91206. * The engine the effect was initialized with.
  91207. * @returns the engine.
  91208. */
  91209. getEngine(): Engine;
  91210. /**
  91211. * The pipeline context for this effect
  91212. * @returns the associated pipeline context
  91213. */
  91214. getPipelineContext(): Nullable<IPipelineContext>;
  91215. /**
  91216. * The set of names of attribute variables for the shader.
  91217. * @returns An array of attribute names.
  91218. */
  91219. getAttributesNames(): string[];
  91220. /**
  91221. * Returns the attribute at the given index.
  91222. * @param index The index of the attribute.
  91223. * @returns The location of the attribute.
  91224. */
  91225. getAttributeLocation(index: number): number;
  91226. /**
  91227. * Returns the attribute based on the name of the variable.
  91228. * @param name of the attribute to look up.
  91229. * @returns the attribute location.
  91230. */
  91231. getAttributeLocationByName(name: string): number;
  91232. /**
  91233. * The number of attributes.
  91234. * @returns the numnber of attributes.
  91235. */
  91236. getAttributesCount(): number;
  91237. /**
  91238. * Gets the index of a uniform variable.
  91239. * @param uniformName of the uniform to look up.
  91240. * @returns the index.
  91241. */
  91242. getUniformIndex(uniformName: string): number;
  91243. /**
  91244. * Returns the attribute based on the name of the variable.
  91245. * @param uniformName of the uniform to look up.
  91246. * @returns the location of the uniform.
  91247. */
  91248. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  91249. /**
  91250. * Returns an array of sampler variable names
  91251. * @returns The array of sampler variable neames.
  91252. */
  91253. getSamplers(): string[];
  91254. /**
  91255. * The error from the last compilation.
  91256. * @returns the error string.
  91257. */
  91258. getCompilationError(): string;
  91259. /**
  91260. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  91261. * @param func The callback to be used.
  91262. */
  91263. executeWhenCompiled(func: (effect: Effect) => void): void;
  91264. private _checkIsReady;
  91265. /** @hidden */
  91266. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  91267. /** @hidden */
  91268. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  91269. /** @hidden */
  91270. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  91271. private _processShaderConversion;
  91272. private _processIncludes;
  91273. private _processPrecision;
  91274. /**
  91275. * Recompiles the webGL program
  91276. * @param vertexSourceCode The source code for the vertex shader.
  91277. * @param fragmentSourceCode The source code for the fragment shader.
  91278. * @param onCompiled Callback called when completed.
  91279. * @param onError Callback called on error.
  91280. * @hidden
  91281. */
  91282. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  91283. /**
  91284. * Prepares the effect
  91285. * @hidden
  91286. */
  91287. _prepareEffect(): void;
  91288. /**
  91289. * Checks if the effect is supported. (Must be called after compilation)
  91290. */
  91291. readonly isSupported: boolean;
  91292. /**
  91293. * Binds a texture to the engine to be used as output of the shader.
  91294. * @param channel Name of the output variable.
  91295. * @param texture Texture to bind.
  91296. * @hidden
  91297. */
  91298. _bindTexture(channel: string, texture: InternalTexture): void;
  91299. /**
  91300. * Sets a texture on the engine to be used in the shader.
  91301. * @param channel Name of the sampler variable.
  91302. * @param texture Texture to set.
  91303. */
  91304. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  91305. /**
  91306. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  91307. * @param channel Name of the sampler variable.
  91308. * @param texture Texture to set.
  91309. */
  91310. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  91311. /**
  91312. * Sets an array of textures on the engine to be used in the shader.
  91313. * @param channel Name of the variable.
  91314. * @param textures Textures to set.
  91315. */
  91316. setTextureArray(channel: string, textures: BaseTexture[]): void;
  91317. /**
  91318. * 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)
  91319. * @param channel Name of the sampler variable.
  91320. * @param postProcess Post process to get the input texture from.
  91321. */
  91322. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  91323. /**
  91324. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  91325. * 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)
  91326. * @param channel Name of the sampler variable.
  91327. * @param postProcess Post process to get the output texture from.
  91328. */
  91329. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  91330. /** @hidden */
  91331. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  91332. /** @hidden */
  91333. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  91334. /** @hidden */
  91335. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  91336. /** @hidden */
  91337. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  91338. /**
  91339. * Binds a buffer to a uniform.
  91340. * @param buffer Buffer to bind.
  91341. * @param name Name of the uniform variable to bind to.
  91342. */
  91343. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  91344. /**
  91345. * Binds block to a uniform.
  91346. * @param blockName Name of the block to bind.
  91347. * @param index Index to bind.
  91348. */
  91349. bindUniformBlock(blockName: string, index: number): void;
  91350. /**
  91351. * Sets an interger value on a uniform variable.
  91352. * @param uniformName Name of the variable.
  91353. * @param value Value to be set.
  91354. * @returns this effect.
  91355. */
  91356. setInt(uniformName: string, value: number): Effect;
  91357. /**
  91358. * Sets an int array on a uniform variable.
  91359. * @param uniformName Name of the variable.
  91360. * @param array array to be set.
  91361. * @returns this effect.
  91362. */
  91363. setIntArray(uniformName: string, array: Int32Array): Effect;
  91364. /**
  91365. * 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)
  91366. * @param uniformName Name of the variable.
  91367. * @param array array to be set.
  91368. * @returns this effect.
  91369. */
  91370. setIntArray2(uniformName: string, array: Int32Array): Effect;
  91371. /**
  91372. * 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)
  91373. * @param uniformName Name of the variable.
  91374. * @param array array to be set.
  91375. * @returns this effect.
  91376. */
  91377. setIntArray3(uniformName: string, array: Int32Array): Effect;
  91378. /**
  91379. * 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)
  91380. * @param uniformName Name of the variable.
  91381. * @param array array to be set.
  91382. * @returns this effect.
  91383. */
  91384. setIntArray4(uniformName: string, array: Int32Array): Effect;
  91385. /**
  91386. * Sets an float array on a uniform variable.
  91387. * @param uniformName Name of the variable.
  91388. * @param array array to be set.
  91389. * @returns this effect.
  91390. */
  91391. setFloatArray(uniformName: string, array: Float32Array): Effect;
  91392. /**
  91393. * 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)
  91394. * @param uniformName Name of the variable.
  91395. * @param array array to be set.
  91396. * @returns this effect.
  91397. */
  91398. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  91399. /**
  91400. * 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)
  91401. * @param uniformName Name of the variable.
  91402. * @param array array to be set.
  91403. * @returns this effect.
  91404. */
  91405. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  91406. /**
  91407. * 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)
  91408. * @param uniformName Name of the variable.
  91409. * @param array array to be set.
  91410. * @returns this effect.
  91411. */
  91412. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  91413. /**
  91414. * Sets an array on a uniform variable.
  91415. * @param uniformName Name of the variable.
  91416. * @param array array to be set.
  91417. * @returns this effect.
  91418. */
  91419. setArray(uniformName: string, array: number[]): Effect;
  91420. /**
  91421. * 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)
  91422. * @param uniformName Name of the variable.
  91423. * @param array array to be set.
  91424. * @returns this effect.
  91425. */
  91426. setArray2(uniformName: string, array: number[]): Effect;
  91427. /**
  91428. * 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)
  91429. * @param uniformName Name of the variable.
  91430. * @param array array to be set.
  91431. * @returns this effect.
  91432. */
  91433. setArray3(uniformName: string, array: number[]): Effect;
  91434. /**
  91435. * 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)
  91436. * @param uniformName Name of the variable.
  91437. * @param array array to be set.
  91438. * @returns this effect.
  91439. */
  91440. setArray4(uniformName: string, array: number[]): Effect;
  91441. /**
  91442. * Sets matrices on a uniform variable.
  91443. * @param uniformName Name of the variable.
  91444. * @param matrices matrices to be set.
  91445. * @returns this effect.
  91446. */
  91447. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  91448. /**
  91449. * Sets matrix on a uniform variable.
  91450. * @param uniformName Name of the variable.
  91451. * @param matrix matrix to be set.
  91452. * @returns this effect.
  91453. */
  91454. setMatrix(uniformName: string, matrix: Matrix): Effect;
  91455. /**
  91456. * 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)
  91457. * @param uniformName Name of the variable.
  91458. * @param matrix matrix to be set.
  91459. * @returns this effect.
  91460. */
  91461. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  91462. /**
  91463. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  91464. * @param uniformName Name of the variable.
  91465. * @param matrix matrix to be set.
  91466. * @returns this effect.
  91467. */
  91468. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  91469. /**
  91470. * Sets a float on a uniform variable.
  91471. * @param uniformName Name of the variable.
  91472. * @param value value to be set.
  91473. * @returns this effect.
  91474. */
  91475. setFloat(uniformName: string, value: number): Effect;
  91476. /**
  91477. * Sets a boolean on a uniform variable.
  91478. * @param uniformName Name of the variable.
  91479. * @param bool value to be set.
  91480. * @returns this effect.
  91481. */
  91482. setBool(uniformName: string, bool: boolean): Effect;
  91483. /**
  91484. * Sets a Vector2 on a uniform variable.
  91485. * @param uniformName Name of the variable.
  91486. * @param vector2 vector2 to be set.
  91487. * @returns this effect.
  91488. */
  91489. setVector2(uniformName: string, vector2: Vector2): Effect;
  91490. /**
  91491. * Sets a float2 on a uniform variable.
  91492. * @param uniformName Name of the variable.
  91493. * @param x First float in float2.
  91494. * @param y Second float in float2.
  91495. * @returns this effect.
  91496. */
  91497. setFloat2(uniformName: string, x: number, y: number): Effect;
  91498. /**
  91499. * Sets a Vector3 on a uniform variable.
  91500. * @param uniformName Name of the variable.
  91501. * @param vector3 Value to be set.
  91502. * @returns this effect.
  91503. */
  91504. setVector3(uniformName: string, vector3: Vector3): Effect;
  91505. /**
  91506. * Sets a float3 on a uniform variable.
  91507. * @param uniformName Name of the variable.
  91508. * @param x First float in float3.
  91509. * @param y Second float in float3.
  91510. * @param z Third float in float3.
  91511. * @returns this effect.
  91512. */
  91513. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  91514. /**
  91515. * Sets a Vector4 on a uniform variable.
  91516. * @param uniformName Name of the variable.
  91517. * @param vector4 Value to be set.
  91518. * @returns this effect.
  91519. */
  91520. setVector4(uniformName: string, vector4: Vector4): Effect;
  91521. /**
  91522. * Sets a float4 on a uniform variable.
  91523. * @param uniformName Name of the variable.
  91524. * @param x First float in float4.
  91525. * @param y Second float in float4.
  91526. * @param z Third float in float4.
  91527. * @param w Fourth float in float4.
  91528. * @returns this effect.
  91529. */
  91530. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  91531. /**
  91532. * Sets a Color3 on a uniform variable.
  91533. * @param uniformName Name of the variable.
  91534. * @param color3 Value to be set.
  91535. * @returns this effect.
  91536. */
  91537. setColor3(uniformName: string, color3: Color3): Effect;
  91538. /**
  91539. * Sets a Color4 on a uniform variable.
  91540. * @param uniformName Name of the variable.
  91541. * @param color3 Value to be set.
  91542. * @param alpha Alpha value to be set.
  91543. * @returns this effect.
  91544. */
  91545. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  91546. /**
  91547. * Sets a Color4 on a uniform variable
  91548. * @param uniformName defines the name of the variable
  91549. * @param color4 defines the value to be set
  91550. * @returns this effect.
  91551. */
  91552. setDirectColor4(uniformName: string, color4: Color4): Effect;
  91553. /** Release all associated resources */
  91554. dispose(): void;
  91555. /**
  91556. * This function will add a new shader to the shader store
  91557. * @param name the name of the shader
  91558. * @param pixelShader optional pixel shader content
  91559. * @param vertexShader optional vertex shader content
  91560. */
  91561. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  91562. /**
  91563. * Store of each shader (The can be looked up using effect.key)
  91564. */
  91565. static ShadersStore: {
  91566. [key: string]: string;
  91567. };
  91568. /**
  91569. * Store of each included file for a shader (The can be looked up using effect.key)
  91570. */
  91571. static IncludesShadersStore: {
  91572. [key: string]: string;
  91573. };
  91574. /**
  91575. * Resets the cache of effects.
  91576. */
  91577. static ResetCache(): void;
  91578. }
  91579. }
  91580. declare module BABYLON {
  91581. /**
  91582. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  91583. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  91584. * 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;
  91585. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  91586. */
  91587. export class ColorCurves {
  91588. private _dirty;
  91589. private _tempColor;
  91590. private _globalCurve;
  91591. private _highlightsCurve;
  91592. private _midtonesCurve;
  91593. private _shadowsCurve;
  91594. private _positiveCurve;
  91595. private _negativeCurve;
  91596. private _globalHue;
  91597. private _globalDensity;
  91598. private _globalSaturation;
  91599. private _globalExposure;
  91600. /**
  91601. * Gets the global Hue value.
  91602. * 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).
  91603. */
  91604. /**
  91605. * Sets the global Hue value.
  91606. * 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).
  91607. */
  91608. globalHue: number;
  91609. /**
  91610. * Gets the global Density value.
  91611. * 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.
  91612. * Values less than zero provide a filter of opposite hue.
  91613. */
  91614. /**
  91615. * Sets the global Density value.
  91616. * 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.
  91617. * Values less than zero provide a filter of opposite hue.
  91618. */
  91619. globalDensity: number;
  91620. /**
  91621. * Gets the global Saturation value.
  91622. * 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.
  91623. */
  91624. /**
  91625. * Sets the global Saturation value.
  91626. * 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.
  91627. */
  91628. globalSaturation: number;
  91629. /**
  91630. * Gets the global Exposure value.
  91631. * 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.
  91632. */
  91633. /**
  91634. * Sets the global Exposure value.
  91635. * 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.
  91636. */
  91637. globalExposure: number;
  91638. private _highlightsHue;
  91639. private _highlightsDensity;
  91640. private _highlightsSaturation;
  91641. private _highlightsExposure;
  91642. /**
  91643. * Gets the highlights Hue value.
  91644. * 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).
  91645. */
  91646. /**
  91647. * Sets the highlights Hue value.
  91648. * 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).
  91649. */
  91650. highlightsHue: number;
  91651. /**
  91652. * Gets the highlights Density value.
  91653. * 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.
  91654. * Values less than zero provide a filter of opposite hue.
  91655. */
  91656. /**
  91657. * Sets the highlights Density value.
  91658. * 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.
  91659. * Values less than zero provide a filter of opposite hue.
  91660. */
  91661. highlightsDensity: number;
  91662. /**
  91663. * Gets the highlights Saturation value.
  91664. * 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.
  91665. */
  91666. /**
  91667. * Sets the highlights Saturation value.
  91668. * 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.
  91669. */
  91670. highlightsSaturation: number;
  91671. /**
  91672. * Gets the highlights Exposure value.
  91673. * 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.
  91674. */
  91675. /**
  91676. * Sets the highlights Exposure value.
  91677. * 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.
  91678. */
  91679. highlightsExposure: number;
  91680. private _midtonesHue;
  91681. private _midtonesDensity;
  91682. private _midtonesSaturation;
  91683. private _midtonesExposure;
  91684. /**
  91685. * Gets the midtones Hue value.
  91686. * 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).
  91687. */
  91688. /**
  91689. * Sets the midtones Hue value.
  91690. * 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).
  91691. */
  91692. midtonesHue: number;
  91693. /**
  91694. * Gets the midtones Density value.
  91695. * 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.
  91696. * Values less than zero provide a filter of opposite hue.
  91697. */
  91698. /**
  91699. * Sets the midtones Density value.
  91700. * 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.
  91701. * Values less than zero provide a filter of opposite hue.
  91702. */
  91703. midtonesDensity: number;
  91704. /**
  91705. * Gets the midtones Saturation value.
  91706. * 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.
  91707. */
  91708. /**
  91709. * Sets the midtones Saturation value.
  91710. * 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.
  91711. */
  91712. midtonesSaturation: number;
  91713. /**
  91714. * Gets the midtones Exposure value.
  91715. * 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.
  91716. */
  91717. /**
  91718. * Sets the midtones Exposure value.
  91719. * 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.
  91720. */
  91721. midtonesExposure: number;
  91722. private _shadowsHue;
  91723. private _shadowsDensity;
  91724. private _shadowsSaturation;
  91725. private _shadowsExposure;
  91726. /**
  91727. * Gets the shadows Hue value.
  91728. * 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).
  91729. */
  91730. /**
  91731. * Sets the shadows Hue value.
  91732. * 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).
  91733. */
  91734. shadowsHue: number;
  91735. /**
  91736. * Gets the shadows Density value.
  91737. * 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.
  91738. * Values less than zero provide a filter of opposite hue.
  91739. */
  91740. /**
  91741. * Sets the shadows Density value.
  91742. * 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.
  91743. * Values less than zero provide a filter of opposite hue.
  91744. */
  91745. shadowsDensity: number;
  91746. /**
  91747. * Gets the shadows Saturation value.
  91748. * 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.
  91749. */
  91750. /**
  91751. * Sets the shadows Saturation value.
  91752. * 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.
  91753. */
  91754. shadowsSaturation: number;
  91755. /**
  91756. * Gets the shadows Exposure value.
  91757. * 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.
  91758. */
  91759. /**
  91760. * Sets the shadows Exposure value.
  91761. * 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.
  91762. */
  91763. shadowsExposure: number;
  91764. /**
  91765. * Returns the class name
  91766. * @returns The class name
  91767. */
  91768. getClassName(): string;
  91769. /**
  91770. * Binds the color curves to the shader.
  91771. * @param colorCurves The color curve to bind
  91772. * @param effect The effect to bind to
  91773. * @param positiveUniform The positive uniform shader parameter
  91774. * @param neutralUniform The neutral uniform shader parameter
  91775. * @param negativeUniform The negative uniform shader parameter
  91776. */
  91777. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  91778. /**
  91779. * Prepare the list of uniforms associated with the ColorCurves effects.
  91780. * @param uniformsList The list of uniforms used in the effect
  91781. */
  91782. static PrepareUniforms(uniformsList: string[]): void;
  91783. /**
  91784. * Returns color grading data based on a hue, density, saturation and exposure value.
  91785. * @param filterHue The hue of the color filter.
  91786. * @param filterDensity The density of the color filter.
  91787. * @param saturation The saturation.
  91788. * @param exposure The exposure.
  91789. * @param result The result data container.
  91790. */
  91791. private getColorGradingDataToRef;
  91792. /**
  91793. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  91794. * @param value The input slider value in range [-100,100].
  91795. * @returns Adjusted value.
  91796. */
  91797. private static applyColorGradingSliderNonlinear;
  91798. /**
  91799. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  91800. * @param hue The hue (H) input.
  91801. * @param saturation The saturation (S) input.
  91802. * @param brightness The brightness (B) input.
  91803. * @result An RGBA color represented as Vector4.
  91804. */
  91805. private static fromHSBToRef;
  91806. /**
  91807. * Returns a value clamped between min and max
  91808. * @param value The value to clamp
  91809. * @param min The minimum of value
  91810. * @param max The maximum of value
  91811. * @returns The clamped value.
  91812. */
  91813. private static clamp;
  91814. /**
  91815. * Clones the current color curve instance.
  91816. * @return The cloned curves
  91817. */
  91818. clone(): ColorCurves;
  91819. /**
  91820. * Serializes the current color curve instance to a json representation.
  91821. * @return a JSON representation
  91822. */
  91823. serialize(): any;
  91824. /**
  91825. * Parses the color curve from a json representation.
  91826. * @param source the JSON source to parse
  91827. * @return The parsed curves
  91828. */
  91829. static Parse(source: any): ColorCurves;
  91830. }
  91831. }
  91832. declare module BABYLON {
  91833. /**
  91834. * Interface to follow in your material defines to integrate easily the
  91835. * Image proccessing functions.
  91836. * @hidden
  91837. */
  91838. export interface IImageProcessingConfigurationDefines {
  91839. IMAGEPROCESSING: boolean;
  91840. VIGNETTE: boolean;
  91841. VIGNETTEBLENDMODEMULTIPLY: boolean;
  91842. VIGNETTEBLENDMODEOPAQUE: boolean;
  91843. TONEMAPPING: boolean;
  91844. TONEMAPPING_ACES: boolean;
  91845. CONTRAST: boolean;
  91846. EXPOSURE: boolean;
  91847. COLORCURVES: boolean;
  91848. COLORGRADING: boolean;
  91849. COLORGRADING3D: boolean;
  91850. SAMPLER3DGREENDEPTH: boolean;
  91851. SAMPLER3DBGRMAP: boolean;
  91852. IMAGEPROCESSINGPOSTPROCESS: boolean;
  91853. }
  91854. /**
  91855. * @hidden
  91856. */
  91857. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  91858. IMAGEPROCESSING: boolean;
  91859. VIGNETTE: boolean;
  91860. VIGNETTEBLENDMODEMULTIPLY: boolean;
  91861. VIGNETTEBLENDMODEOPAQUE: boolean;
  91862. TONEMAPPING: boolean;
  91863. TONEMAPPING_ACES: boolean;
  91864. CONTRAST: boolean;
  91865. COLORCURVES: boolean;
  91866. COLORGRADING: boolean;
  91867. COLORGRADING3D: boolean;
  91868. SAMPLER3DGREENDEPTH: boolean;
  91869. SAMPLER3DBGRMAP: boolean;
  91870. IMAGEPROCESSINGPOSTPROCESS: boolean;
  91871. EXPOSURE: boolean;
  91872. constructor();
  91873. }
  91874. /**
  91875. * This groups together the common properties used for image processing either in direct forward pass
  91876. * or through post processing effect depending on the use of the image processing pipeline in your scene
  91877. * or not.
  91878. */
  91879. export class ImageProcessingConfiguration {
  91880. /**
  91881. * Default tone mapping applied in BabylonJS.
  91882. */
  91883. static readonly TONEMAPPING_STANDARD: number;
  91884. /**
  91885. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  91886. * to other engines rendering to increase portability.
  91887. */
  91888. static readonly TONEMAPPING_ACES: number;
  91889. /**
  91890. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  91891. */
  91892. colorCurves: Nullable<ColorCurves>;
  91893. private _colorCurvesEnabled;
  91894. /**
  91895. * Gets wether the color curves effect is enabled.
  91896. */
  91897. /**
  91898. * Sets wether the color curves effect is enabled.
  91899. */
  91900. colorCurvesEnabled: boolean;
  91901. private _colorGradingTexture;
  91902. /**
  91903. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  91904. */
  91905. /**
  91906. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  91907. */
  91908. colorGradingTexture: Nullable<BaseTexture>;
  91909. private _colorGradingEnabled;
  91910. /**
  91911. * Gets wether the color grading effect is enabled.
  91912. */
  91913. /**
  91914. * Sets wether the color grading effect is enabled.
  91915. */
  91916. colorGradingEnabled: boolean;
  91917. private _colorGradingWithGreenDepth;
  91918. /**
  91919. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  91920. */
  91921. /**
  91922. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  91923. */
  91924. colorGradingWithGreenDepth: boolean;
  91925. private _colorGradingBGR;
  91926. /**
  91927. * Gets wether the color grading texture contains BGR values.
  91928. */
  91929. /**
  91930. * Sets wether the color grading texture contains BGR values.
  91931. */
  91932. colorGradingBGR: boolean;
  91933. /** @hidden */
  91934. _exposure: number;
  91935. /**
  91936. * Gets the Exposure used in the effect.
  91937. */
  91938. /**
  91939. * Sets the Exposure used in the effect.
  91940. */
  91941. exposure: number;
  91942. private _toneMappingEnabled;
  91943. /**
  91944. * Gets wether the tone mapping effect is enabled.
  91945. */
  91946. /**
  91947. * Sets wether the tone mapping effect is enabled.
  91948. */
  91949. toneMappingEnabled: boolean;
  91950. private _toneMappingType;
  91951. /**
  91952. * Gets the type of tone mapping effect.
  91953. */
  91954. /**
  91955. * Sets the type of tone mapping effect used in BabylonJS.
  91956. */
  91957. toneMappingType: number;
  91958. protected _contrast: number;
  91959. /**
  91960. * Gets the contrast used in the effect.
  91961. */
  91962. /**
  91963. * Sets the contrast used in the effect.
  91964. */
  91965. contrast: number;
  91966. /**
  91967. * Vignette stretch size.
  91968. */
  91969. vignetteStretch: number;
  91970. /**
  91971. * Vignette centre X Offset.
  91972. */
  91973. vignetteCentreX: number;
  91974. /**
  91975. * Vignette centre Y Offset.
  91976. */
  91977. vignetteCentreY: number;
  91978. /**
  91979. * Vignette weight or intensity of the vignette effect.
  91980. */
  91981. vignetteWeight: number;
  91982. /**
  91983. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  91984. * if vignetteEnabled is set to true.
  91985. */
  91986. vignetteColor: Color4;
  91987. /**
  91988. * Camera field of view used by the Vignette effect.
  91989. */
  91990. vignetteCameraFov: number;
  91991. private _vignetteBlendMode;
  91992. /**
  91993. * Gets the vignette blend mode allowing different kind of effect.
  91994. */
  91995. /**
  91996. * Sets the vignette blend mode allowing different kind of effect.
  91997. */
  91998. vignetteBlendMode: number;
  91999. private _vignetteEnabled;
  92000. /**
  92001. * Gets wether the vignette effect is enabled.
  92002. */
  92003. /**
  92004. * Sets wether the vignette effect is enabled.
  92005. */
  92006. vignetteEnabled: boolean;
  92007. private _applyByPostProcess;
  92008. /**
  92009. * Gets wether the image processing is applied through a post process or not.
  92010. */
  92011. /**
  92012. * Sets wether the image processing is applied through a post process or not.
  92013. */
  92014. applyByPostProcess: boolean;
  92015. private _isEnabled;
  92016. /**
  92017. * Gets wether the image processing is enabled or not.
  92018. */
  92019. /**
  92020. * Sets wether the image processing is enabled or not.
  92021. */
  92022. isEnabled: boolean;
  92023. /**
  92024. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  92025. */
  92026. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  92027. /**
  92028. * Method called each time the image processing information changes requires to recompile the effect.
  92029. */
  92030. protected _updateParameters(): void;
  92031. /**
  92032. * Gets the current class name.
  92033. * @return "ImageProcessingConfiguration"
  92034. */
  92035. getClassName(): string;
  92036. /**
  92037. * Prepare the list of uniforms associated with the Image Processing effects.
  92038. * @param uniforms The list of uniforms used in the effect
  92039. * @param defines the list of defines currently in use
  92040. */
  92041. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  92042. /**
  92043. * Prepare the list of samplers associated with the Image Processing effects.
  92044. * @param samplersList The list of uniforms used in the effect
  92045. * @param defines the list of defines currently in use
  92046. */
  92047. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  92048. /**
  92049. * Prepare the list of defines associated to the shader.
  92050. * @param defines the list of defines to complete
  92051. * @param forPostProcess Define if we are currently in post process mode or not
  92052. */
  92053. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  92054. /**
  92055. * Returns true if all the image processing information are ready.
  92056. * @returns True if ready, otherwise, false
  92057. */
  92058. isReady(): boolean;
  92059. /**
  92060. * Binds the image processing to the shader.
  92061. * @param effect The effect to bind to
  92062. * @param aspectRatio Define the current aspect ratio of the effect
  92063. */
  92064. bind(effect: Effect, aspectRatio?: number): void;
  92065. /**
  92066. * Clones the current image processing instance.
  92067. * @return The cloned image processing
  92068. */
  92069. clone(): ImageProcessingConfiguration;
  92070. /**
  92071. * Serializes the current image processing instance to a json representation.
  92072. * @return a JSON representation
  92073. */
  92074. serialize(): any;
  92075. /**
  92076. * Parses the image processing from a json representation.
  92077. * @param source the JSON source to parse
  92078. * @return The parsed image processing
  92079. */
  92080. static Parse(source: any): ImageProcessingConfiguration;
  92081. private static _VIGNETTEMODE_MULTIPLY;
  92082. private static _VIGNETTEMODE_OPAQUE;
  92083. /**
  92084. * Used to apply the vignette as a mix with the pixel color.
  92085. */
  92086. static readonly VIGNETTEMODE_MULTIPLY: number;
  92087. /**
  92088. * Used to apply the vignette as a replacement of the pixel color.
  92089. */
  92090. static readonly VIGNETTEMODE_OPAQUE: number;
  92091. }
  92092. }
  92093. declare module BABYLON {
  92094. /**
  92095. * This represents all the required information to add a fresnel effect on a material:
  92096. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  92097. */
  92098. export class FresnelParameters {
  92099. private _isEnabled;
  92100. /**
  92101. * Define if the fresnel effect is enable or not.
  92102. */
  92103. isEnabled: boolean;
  92104. /**
  92105. * Define the color used on edges (grazing angle)
  92106. */
  92107. leftColor: Color3;
  92108. /**
  92109. * Define the color used on center
  92110. */
  92111. rightColor: Color3;
  92112. /**
  92113. * Define bias applied to computed fresnel term
  92114. */
  92115. bias: number;
  92116. /**
  92117. * Defined the power exponent applied to fresnel term
  92118. */
  92119. power: number;
  92120. /**
  92121. * Clones the current fresnel and its valuues
  92122. * @returns a clone fresnel configuration
  92123. */
  92124. clone(): FresnelParameters;
  92125. /**
  92126. * Serializes the current fresnel parameters to a JSON representation.
  92127. * @return the JSON serialization
  92128. */
  92129. serialize(): any;
  92130. /**
  92131. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  92132. * @param parsedFresnelParameters Define the JSON representation
  92133. * @returns the parsed parameters
  92134. */
  92135. static Parse(parsedFresnelParameters: any): FresnelParameters;
  92136. }
  92137. }
  92138. declare module BABYLON {
  92139. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  92140. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92141. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92142. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92143. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92144. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92145. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92146. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92147. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92148. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92149. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92150. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92151. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92152. /**
  92153. * Decorator used to define property that can be serialized as reference to a camera
  92154. * @param sourceName defines the name of the property to decorate
  92155. */
  92156. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92157. /**
  92158. * Class used to help serialization objects
  92159. */
  92160. export class SerializationHelper {
  92161. /** hidden */
  92162. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  92163. /** hidden */
  92164. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  92165. /** hidden */
  92166. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  92167. /** hidden */
  92168. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  92169. /**
  92170. * Appends the serialized animations from the source animations
  92171. * @param source Source containing the animations
  92172. * @param destination Target to store the animations
  92173. */
  92174. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  92175. /**
  92176. * Static function used to serialized a specific entity
  92177. * @param entity defines the entity to serialize
  92178. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  92179. * @returns a JSON compatible object representing the serialization of the entity
  92180. */
  92181. static Serialize<T>(entity: T, serializationObject?: any): any;
  92182. /**
  92183. * Creates a new entity from a serialization data object
  92184. * @param creationFunction defines a function used to instanciated the new entity
  92185. * @param source defines the source serialization data
  92186. * @param scene defines the hosting scene
  92187. * @param rootUrl defines the root url for resources
  92188. * @returns a new entity
  92189. */
  92190. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  92191. /**
  92192. * Clones an object
  92193. * @param creationFunction defines the function used to instanciate the new object
  92194. * @param source defines the source object
  92195. * @returns the cloned object
  92196. */
  92197. static Clone<T>(creationFunction: () => T, source: T): T;
  92198. /**
  92199. * Instanciates a new object based on a source one (some data will be shared between both object)
  92200. * @param creationFunction defines the function used to instanciate the new object
  92201. * @param source defines the source object
  92202. * @returns the new object
  92203. */
  92204. static Instanciate<T>(creationFunction: () => T, source: T): T;
  92205. }
  92206. }
  92207. declare module BABYLON {
  92208. /**
  92209. * This is the base class of all the camera used in the application.
  92210. * @see http://doc.babylonjs.com/features/cameras
  92211. */
  92212. export class Camera extends Node {
  92213. /** @hidden */
  92214. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  92215. /**
  92216. * This is the default projection mode used by the cameras.
  92217. * It helps recreating a feeling of perspective and better appreciate depth.
  92218. * This is the best way to simulate real life cameras.
  92219. */
  92220. static readonly PERSPECTIVE_CAMERA: number;
  92221. /**
  92222. * This helps creating camera with an orthographic mode.
  92223. * 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.
  92224. */
  92225. static readonly ORTHOGRAPHIC_CAMERA: number;
  92226. /**
  92227. * This is the default FOV mode for perspective cameras.
  92228. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  92229. */
  92230. static readonly FOVMODE_VERTICAL_FIXED: number;
  92231. /**
  92232. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  92233. */
  92234. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  92235. /**
  92236. * This specifies ther is no need for a camera rig.
  92237. * Basically only one eye is rendered corresponding to the camera.
  92238. */
  92239. static readonly RIG_MODE_NONE: number;
  92240. /**
  92241. * Simulates a camera Rig with one blue eye and one red eye.
  92242. * This can be use with 3d blue and red glasses.
  92243. */
  92244. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  92245. /**
  92246. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  92247. */
  92248. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  92249. /**
  92250. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  92251. */
  92252. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  92253. /**
  92254. * Defines that both eyes of the camera will be rendered over under each other.
  92255. */
  92256. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  92257. /**
  92258. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  92259. */
  92260. static readonly RIG_MODE_VR: number;
  92261. /**
  92262. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  92263. */
  92264. static readonly RIG_MODE_WEBVR: number;
  92265. /**
  92266. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  92267. */
  92268. static readonly RIG_MODE_CUSTOM: number;
  92269. /**
  92270. * Defines if by default attaching controls should prevent the default javascript event to continue.
  92271. */
  92272. static ForceAttachControlToAlwaysPreventDefault: boolean;
  92273. /**
  92274. * Define the input manager associated with the camera.
  92275. */
  92276. inputs: CameraInputsManager<Camera>;
  92277. /** @hidden */
  92278. _position: Vector3;
  92279. /**
  92280. * Define the current local position of the camera in the scene
  92281. */
  92282. position: Vector3;
  92283. /**
  92284. * The vector the camera should consider as up.
  92285. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  92286. */
  92287. upVector: Vector3;
  92288. /**
  92289. * Define the current limit on the left side for an orthographic camera
  92290. * In scene unit
  92291. */
  92292. orthoLeft: Nullable<number>;
  92293. /**
  92294. * Define the current limit on the right side for an orthographic camera
  92295. * In scene unit
  92296. */
  92297. orthoRight: Nullable<number>;
  92298. /**
  92299. * Define the current limit on the bottom side for an orthographic camera
  92300. * In scene unit
  92301. */
  92302. orthoBottom: Nullable<number>;
  92303. /**
  92304. * Define the current limit on the top side for an orthographic camera
  92305. * In scene unit
  92306. */
  92307. orthoTop: Nullable<number>;
  92308. /**
  92309. * Field Of View is set in Radians. (default is 0.8)
  92310. */
  92311. fov: number;
  92312. /**
  92313. * Define the minimum distance the camera can see from.
  92314. * This is important to note that the depth buffer are not infinite and the closer it starts
  92315. * the more your scene might encounter depth fighting issue.
  92316. */
  92317. minZ: number;
  92318. /**
  92319. * Define the maximum distance the camera can see to.
  92320. * This is important to note that the depth buffer are not infinite and the further it end
  92321. * the more your scene might encounter depth fighting issue.
  92322. */
  92323. maxZ: number;
  92324. /**
  92325. * Define the default inertia of the camera.
  92326. * This helps giving a smooth feeling to the camera movement.
  92327. */
  92328. inertia: number;
  92329. /**
  92330. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  92331. */
  92332. mode: number;
  92333. /**
  92334. * Define wether the camera is intermediate.
  92335. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  92336. */
  92337. isIntermediate: boolean;
  92338. /**
  92339. * Define the viewport of the camera.
  92340. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  92341. */
  92342. viewport: Viewport;
  92343. /**
  92344. * Restricts the camera to viewing objects with the same layerMask.
  92345. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  92346. */
  92347. layerMask: number;
  92348. /**
  92349. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  92350. */
  92351. fovMode: number;
  92352. /**
  92353. * Rig mode of the camera.
  92354. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  92355. * This is normally controlled byt the camera themselves as internal use.
  92356. */
  92357. cameraRigMode: number;
  92358. /**
  92359. * Defines the distance between both "eyes" in case of a RIG
  92360. */
  92361. interaxialDistance: number;
  92362. /**
  92363. * Defines if stereoscopic rendering is done side by side or over under.
  92364. */
  92365. isStereoscopicSideBySide: boolean;
  92366. /**
  92367. * 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
  92368. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  92369. * else in the scene.
  92370. */
  92371. customRenderTargets: RenderTargetTexture[];
  92372. /**
  92373. * When set, the camera will render to this render target instead of the default canvas
  92374. */
  92375. outputRenderTarget: Nullable<RenderTargetTexture>;
  92376. /**
  92377. * Observable triggered when the camera view matrix has changed.
  92378. */
  92379. onViewMatrixChangedObservable: Observable<Camera>;
  92380. /**
  92381. * Observable triggered when the camera Projection matrix has changed.
  92382. */
  92383. onProjectionMatrixChangedObservable: Observable<Camera>;
  92384. /**
  92385. * Observable triggered when the inputs have been processed.
  92386. */
  92387. onAfterCheckInputsObservable: Observable<Camera>;
  92388. /**
  92389. * Observable triggered when reset has been called and applied to the camera.
  92390. */
  92391. onRestoreStateObservable: Observable<Camera>;
  92392. /** @hidden */
  92393. _cameraRigParams: any;
  92394. /** @hidden */
  92395. _rigCameras: Camera[];
  92396. /** @hidden */
  92397. _rigPostProcess: Nullable<PostProcess>;
  92398. protected _webvrViewMatrix: Matrix;
  92399. /** @hidden */
  92400. _skipRendering: boolean;
  92401. /** @hidden */
  92402. _projectionMatrix: Matrix;
  92403. /** @hidden */
  92404. _postProcesses: Nullable<PostProcess>[];
  92405. /** @hidden */
  92406. _activeMeshes: SmartArray<AbstractMesh>;
  92407. protected _globalPosition: Vector3;
  92408. /** hidden */
  92409. _computedViewMatrix: Matrix;
  92410. private _doNotComputeProjectionMatrix;
  92411. private _transformMatrix;
  92412. private _frustumPlanes;
  92413. private _refreshFrustumPlanes;
  92414. private _storedFov;
  92415. private _stateStored;
  92416. /**
  92417. * Instantiates a new camera object.
  92418. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  92419. * @see http://doc.babylonjs.com/features/cameras
  92420. * @param name Defines the name of the camera in the scene
  92421. * @param position Defines the position of the camera
  92422. * @param scene Defines the scene the camera belongs too
  92423. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  92424. */
  92425. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  92426. /**
  92427. * Store current camera state (fov, position, etc..)
  92428. * @returns the camera
  92429. */
  92430. storeState(): Camera;
  92431. /**
  92432. * Restores the camera state values if it has been stored. You must call storeState() first
  92433. */
  92434. protected _restoreStateValues(): boolean;
  92435. /**
  92436. * Restored camera state. You must call storeState() first.
  92437. * @returns true if restored and false otherwise
  92438. */
  92439. restoreState(): boolean;
  92440. /**
  92441. * Gets the class name of the camera.
  92442. * @returns the class name
  92443. */
  92444. getClassName(): string;
  92445. /** @hidden */
  92446. readonly _isCamera: boolean;
  92447. /**
  92448. * Gets a string representation of the camera useful for debug purpose.
  92449. * @param fullDetails Defines that a more verboe level of logging is required
  92450. * @returns the string representation
  92451. */
  92452. toString(fullDetails?: boolean): string;
  92453. /**
  92454. * Gets the current world space position of the camera.
  92455. */
  92456. readonly globalPosition: Vector3;
  92457. /**
  92458. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  92459. * @returns the active meshe list
  92460. */
  92461. getActiveMeshes(): SmartArray<AbstractMesh>;
  92462. /**
  92463. * Check wether a mesh is part of the current active mesh list of the camera
  92464. * @param mesh Defines the mesh to check
  92465. * @returns true if active, false otherwise
  92466. */
  92467. isActiveMesh(mesh: Mesh): boolean;
  92468. /**
  92469. * Is this camera ready to be used/rendered
  92470. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  92471. * @return true if the camera is ready
  92472. */
  92473. isReady(completeCheck?: boolean): boolean;
  92474. /** @hidden */
  92475. _initCache(): void;
  92476. /** @hidden */
  92477. _updateCache(ignoreParentClass?: boolean): void;
  92478. /** @hidden */
  92479. _isSynchronized(): boolean;
  92480. /** @hidden */
  92481. _isSynchronizedViewMatrix(): boolean;
  92482. /** @hidden */
  92483. _isSynchronizedProjectionMatrix(): boolean;
  92484. /**
  92485. * Attach the input controls to a specific dom element to get the input from.
  92486. * @param element Defines the element the controls should be listened from
  92487. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  92488. */
  92489. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92490. /**
  92491. * Detach the current controls from the specified dom element.
  92492. * @param element Defines the element to stop listening the inputs from
  92493. */
  92494. detachControl(element: HTMLElement): void;
  92495. /**
  92496. * Update the camera state according to the different inputs gathered during the frame.
  92497. */
  92498. update(): void;
  92499. /** @hidden */
  92500. _checkInputs(): void;
  92501. /** @hidden */
  92502. readonly rigCameras: Camera[];
  92503. /**
  92504. * Gets the post process used by the rig cameras
  92505. */
  92506. readonly rigPostProcess: Nullable<PostProcess>;
  92507. /**
  92508. * Internal, gets the first post proces.
  92509. * @returns the first post process to be run on this camera.
  92510. */
  92511. _getFirstPostProcess(): Nullable<PostProcess>;
  92512. private _cascadePostProcessesToRigCams;
  92513. /**
  92514. * Attach a post process to the camera.
  92515. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  92516. * @param postProcess The post process to attach to the camera
  92517. * @param insertAt The position of the post process in case several of them are in use in the scene
  92518. * @returns the position the post process has been inserted at
  92519. */
  92520. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  92521. /**
  92522. * Detach a post process to the camera.
  92523. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  92524. * @param postProcess The post process to detach from the camera
  92525. */
  92526. detachPostProcess(postProcess: PostProcess): void;
  92527. /**
  92528. * Gets the current world matrix of the camera
  92529. */
  92530. getWorldMatrix(): Matrix;
  92531. /** @hidden */
  92532. _getViewMatrix(): Matrix;
  92533. /**
  92534. * Gets the current view matrix of the camera.
  92535. * @param force forces the camera to recompute the matrix without looking at the cached state
  92536. * @returns the view matrix
  92537. */
  92538. getViewMatrix(force?: boolean): Matrix;
  92539. /**
  92540. * Freeze the projection matrix.
  92541. * It will prevent the cache check of the camera projection compute and can speed up perf
  92542. * if no parameter of the camera are meant to change
  92543. * @param projection Defines manually a projection if necessary
  92544. */
  92545. freezeProjectionMatrix(projection?: Matrix): void;
  92546. /**
  92547. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  92548. */
  92549. unfreezeProjectionMatrix(): void;
  92550. /**
  92551. * Gets the current projection matrix of the camera.
  92552. * @param force forces the camera to recompute the matrix without looking at the cached state
  92553. * @returns the projection matrix
  92554. */
  92555. getProjectionMatrix(force?: boolean): Matrix;
  92556. /**
  92557. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  92558. * @returns a Matrix
  92559. */
  92560. getTransformationMatrix(): Matrix;
  92561. private _updateFrustumPlanes;
  92562. /**
  92563. * Checks if a cullable object (mesh...) is in the camera frustum
  92564. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  92565. * @param target The object to check
  92566. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  92567. * @returns true if the object is in frustum otherwise false
  92568. */
  92569. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  92570. /**
  92571. * Checks if a cullable object (mesh...) is in the camera frustum
  92572. * Unlike isInFrustum this cheks the full bounding box
  92573. * @param target The object to check
  92574. * @returns true if the object is in frustum otherwise false
  92575. */
  92576. isCompletelyInFrustum(target: ICullable): boolean;
  92577. /**
  92578. * Gets a ray in the forward direction from the camera.
  92579. * @param length Defines the length of the ray to create
  92580. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  92581. * @param origin Defines the start point of the ray which defaults to the camera position
  92582. * @returns the forward ray
  92583. */
  92584. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  92585. /**
  92586. * Releases resources associated with this node.
  92587. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  92588. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  92589. */
  92590. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  92591. /** @hidden */
  92592. _isLeftCamera: boolean;
  92593. /**
  92594. * Gets the left camera of a rig setup in case of Rigged Camera
  92595. */
  92596. readonly isLeftCamera: boolean;
  92597. /** @hidden */
  92598. _isRightCamera: boolean;
  92599. /**
  92600. * Gets the right camera of a rig setup in case of Rigged Camera
  92601. */
  92602. readonly isRightCamera: boolean;
  92603. /**
  92604. * Gets the left camera of a rig setup in case of Rigged Camera
  92605. */
  92606. readonly leftCamera: Nullable<FreeCamera>;
  92607. /**
  92608. * Gets the right camera of a rig setup in case of Rigged Camera
  92609. */
  92610. readonly rightCamera: Nullable<FreeCamera>;
  92611. /**
  92612. * Gets the left camera target of a rig setup in case of Rigged Camera
  92613. * @returns the target position
  92614. */
  92615. getLeftTarget(): Nullable<Vector3>;
  92616. /**
  92617. * Gets the right camera target of a rig setup in case of Rigged Camera
  92618. * @returns the target position
  92619. */
  92620. getRightTarget(): Nullable<Vector3>;
  92621. /**
  92622. * @hidden
  92623. */
  92624. setCameraRigMode(mode: number, rigParams: any): void;
  92625. /** @hidden */
  92626. static _setStereoscopicRigMode(camera: Camera): void;
  92627. /** @hidden */
  92628. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  92629. /** @hidden */
  92630. static _setVRRigMode(camera: Camera, rigParams: any): void;
  92631. /** @hidden */
  92632. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  92633. /** @hidden */
  92634. _getVRProjectionMatrix(): Matrix;
  92635. protected _updateCameraRotationMatrix(): void;
  92636. protected _updateWebVRCameraRotationMatrix(): void;
  92637. /**
  92638. * This function MUST be overwritten by the different WebVR cameras available.
  92639. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  92640. * @hidden
  92641. */
  92642. _getWebVRProjectionMatrix(): Matrix;
  92643. /**
  92644. * This function MUST be overwritten by the different WebVR cameras available.
  92645. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  92646. * @hidden
  92647. */
  92648. _getWebVRViewMatrix(): Matrix;
  92649. /** @hidden */
  92650. setCameraRigParameter(name: string, value: any): void;
  92651. /**
  92652. * needs to be overridden by children so sub has required properties to be copied
  92653. * @hidden
  92654. */
  92655. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  92656. /**
  92657. * May need to be overridden by children
  92658. * @hidden
  92659. */
  92660. _updateRigCameras(): void;
  92661. /** @hidden */
  92662. _setupInputs(): void;
  92663. /**
  92664. * Serialiaze the camera setup to a json represention
  92665. * @returns the JSON representation
  92666. */
  92667. serialize(): any;
  92668. /**
  92669. * Clones the current camera.
  92670. * @param name The cloned camera name
  92671. * @returns the cloned camera
  92672. */
  92673. clone(name: string): Camera;
  92674. /**
  92675. * Gets the direction of the camera relative to a given local axis.
  92676. * @param localAxis Defines the reference axis to provide a relative direction.
  92677. * @return the direction
  92678. */
  92679. getDirection(localAxis: Vector3): Vector3;
  92680. /**
  92681. * Gets the direction of the camera relative to a given local axis into a passed vector.
  92682. * @param localAxis Defines the reference axis to provide a relative direction.
  92683. * @param result Defines the vector to store the result in
  92684. */
  92685. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  92686. /**
  92687. * Gets a camera constructor for a given camera type
  92688. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  92689. * @param name The name of the camera the result will be able to instantiate
  92690. * @param scene The scene the result will construct the camera in
  92691. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  92692. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  92693. * @returns a factory method to construc the camera
  92694. */
  92695. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  92696. /**
  92697. * Compute the world matrix of the camera.
  92698. * @returns the camera workd matrix
  92699. */
  92700. computeWorldMatrix(): Matrix;
  92701. /**
  92702. * Parse a JSON and creates the camera from the parsed information
  92703. * @param parsedCamera The JSON to parse
  92704. * @param scene The scene to instantiate the camera in
  92705. * @returns the newly constructed camera
  92706. */
  92707. static Parse(parsedCamera: any, scene: Scene): Camera;
  92708. }
  92709. }
  92710. declare module BABYLON {
  92711. /**
  92712. * Interface for any object that can request an animation frame
  92713. */
  92714. export interface ICustomAnimationFrameRequester {
  92715. /**
  92716. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  92717. */
  92718. renderFunction?: Function;
  92719. /**
  92720. * Called to request the next frame to render to
  92721. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  92722. */
  92723. requestAnimationFrame: Function;
  92724. /**
  92725. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  92726. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  92727. */
  92728. requestID?: number;
  92729. }
  92730. /**
  92731. * Interface containing an array of animations
  92732. */
  92733. export interface IAnimatable {
  92734. /**
  92735. * Array of animations
  92736. */
  92737. animations: Nullable<Array<Animation>>;
  92738. }
  92739. /** Interface used by value gradients (color, factor, ...) */
  92740. export interface IValueGradient {
  92741. /**
  92742. * Gets or sets the gradient value (between 0 and 1)
  92743. */
  92744. gradient: number;
  92745. }
  92746. /** Class used to store color4 gradient */
  92747. export class ColorGradient implements IValueGradient {
  92748. /**
  92749. * Gets or sets the gradient value (between 0 and 1)
  92750. */
  92751. gradient: number;
  92752. /**
  92753. * Gets or sets first associated color
  92754. */
  92755. color1: Color4;
  92756. /**
  92757. * Gets or sets second associated color
  92758. */
  92759. color2?: Color4;
  92760. /**
  92761. * Will get a color picked randomly between color1 and color2.
  92762. * If color2 is undefined then color1 will be used
  92763. * @param result defines the target Color4 to store the result in
  92764. */
  92765. getColorToRef(result: Color4): void;
  92766. }
  92767. /** Class used to store color 3 gradient */
  92768. export class Color3Gradient implements IValueGradient {
  92769. /**
  92770. * Gets or sets the gradient value (between 0 and 1)
  92771. */
  92772. gradient: number;
  92773. /**
  92774. * Gets or sets the associated color
  92775. */
  92776. color: Color3;
  92777. }
  92778. /** Class used to store factor gradient */
  92779. export class FactorGradient implements IValueGradient {
  92780. /**
  92781. * Gets or sets the gradient value (between 0 and 1)
  92782. */
  92783. gradient: number;
  92784. /**
  92785. * Gets or sets first associated factor
  92786. */
  92787. factor1: number;
  92788. /**
  92789. * Gets or sets second associated factor
  92790. */
  92791. factor2?: number;
  92792. /**
  92793. * Will get a number picked randomly between factor1 and factor2.
  92794. * If factor2 is undefined then factor1 will be used
  92795. * @returns the picked number
  92796. */
  92797. getFactor(): number;
  92798. }
  92799. /**
  92800. * @ignore
  92801. * Application error to support additional information when loading a file
  92802. */
  92803. export class LoadFileError extends Error {
  92804. /** defines the optional web request */
  92805. request?: WebRequest | undefined;
  92806. private static _setPrototypeOf;
  92807. /**
  92808. * Creates a new LoadFileError
  92809. * @param message defines the message of the error
  92810. * @param request defines the optional web request
  92811. */
  92812. constructor(message: string,
  92813. /** defines the optional web request */
  92814. request?: WebRequest | undefined);
  92815. }
  92816. /**
  92817. * Class used to define a retry strategy when error happens while loading assets
  92818. */
  92819. export class RetryStrategy {
  92820. /**
  92821. * Function used to defines an exponential back off strategy
  92822. * @param maxRetries defines the maximum number of retries (3 by default)
  92823. * @param baseInterval defines the interval between retries
  92824. * @returns the strategy function to use
  92825. */
  92826. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  92827. }
  92828. /**
  92829. * File request interface
  92830. */
  92831. export interface IFileRequest {
  92832. /**
  92833. * Raised when the request is complete (success or error).
  92834. */
  92835. onCompleteObservable: Observable<IFileRequest>;
  92836. /**
  92837. * Aborts the request for a file.
  92838. */
  92839. abort: () => void;
  92840. }
  92841. /**
  92842. * Class containing a set of static utilities functions
  92843. */
  92844. export class Tools {
  92845. /**
  92846. * Gets or sets the base URL to use to load assets
  92847. */
  92848. static BaseUrl: string;
  92849. /**
  92850. * Enable/Disable Custom HTTP Request Headers globally.
  92851. * default = false
  92852. * @see CustomRequestHeaders
  92853. */
  92854. static UseCustomRequestHeaders: boolean;
  92855. /**
  92856. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  92857. * i.e. when loading files, where the server/service expects an Authorization header
  92858. */
  92859. static CustomRequestHeaders: {
  92860. [key: string]: string;
  92861. };
  92862. /**
  92863. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  92864. */
  92865. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  92866. /**
  92867. * Default behaviour for cors in the application.
  92868. * It can be a string if the expected behavior is identical in the entire app.
  92869. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  92870. */
  92871. static CorsBehavior: string | ((url: string | string[]) => string);
  92872. /**
  92873. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  92874. * @ignorenaming
  92875. */
  92876. static UseFallbackTexture: boolean;
  92877. /**
  92878. * Use this object to register external classes like custom textures or material
  92879. * to allow the laoders to instantiate them
  92880. */
  92881. static RegisteredExternalClasses: {
  92882. [key: string]: Object;
  92883. };
  92884. /**
  92885. * Texture content used if a texture cannot loaded
  92886. * @ignorenaming
  92887. */
  92888. static fallbackTexture: string;
  92889. /**
  92890. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  92891. * @param u defines the coordinate on X axis
  92892. * @param v defines the coordinate on Y axis
  92893. * @param width defines the width of the source data
  92894. * @param height defines the height of the source data
  92895. * @param pixels defines the source byte array
  92896. * @param color defines the output color
  92897. */
  92898. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  92899. /**
  92900. * Interpolates between a and b via alpha
  92901. * @param a The lower value (returned when alpha = 0)
  92902. * @param b The upper value (returned when alpha = 1)
  92903. * @param alpha The interpolation-factor
  92904. * @return The mixed value
  92905. */
  92906. static Mix(a: number, b: number, alpha: number): number;
  92907. /**
  92908. * Tries to instantiate a new object from a given class name
  92909. * @param className defines the class name to instantiate
  92910. * @returns the new object or null if the system was not able to do the instantiation
  92911. */
  92912. static Instantiate(className: string): any;
  92913. /**
  92914. * Provides a slice function that will work even on IE
  92915. * @param data defines the array to slice
  92916. * @param start defines the start of the data (optional)
  92917. * @param end defines the end of the data (optional)
  92918. * @returns the new sliced array
  92919. */
  92920. static Slice<T>(data: T, start?: number, end?: number): T;
  92921. /**
  92922. * Polyfill for setImmediate
  92923. * @param action defines the action to execute after the current execution block
  92924. */
  92925. static SetImmediate(action: () => void): void;
  92926. /**
  92927. * Function indicating if a number is an exponent of 2
  92928. * @param value defines the value to test
  92929. * @returns true if the value is an exponent of 2
  92930. */
  92931. static IsExponentOfTwo(value: number): boolean;
  92932. private static _tmpFloatArray;
  92933. /**
  92934. * Returns the nearest 32-bit single precision float representation of a Number
  92935. * @param value A Number. If the parameter is of a different type, it will get converted
  92936. * to a number or to NaN if it cannot be converted
  92937. * @returns number
  92938. */
  92939. static FloatRound(value: number): number;
  92940. /**
  92941. * Find the next highest power of two.
  92942. * @param x Number to start search from.
  92943. * @return Next highest power of two.
  92944. */
  92945. static CeilingPOT(x: number): number;
  92946. /**
  92947. * Find the next lowest power of two.
  92948. * @param x Number to start search from.
  92949. * @return Next lowest power of two.
  92950. */
  92951. static FloorPOT(x: number): number;
  92952. /**
  92953. * Find the nearest power of two.
  92954. * @param x Number to start search from.
  92955. * @return Next nearest power of two.
  92956. */
  92957. static NearestPOT(x: number): number;
  92958. /**
  92959. * Get the closest exponent of two
  92960. * @param value defines the value to approximate
  92961. * @param max defines the maximum value to return
  92962. * @param mode defines how to define the closest value
  92963. * @returns closest exponent of two of the given value
  92964. */
  92965. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  92966. /**
  92967. * Extracts the filename from a path
  92968. * @param path defines the path to use
  92969. * @returns the filename
  92970. */
  92971. static GetFilename(path: string): string;
  92972. /**
  92973. * Extracts the "folder" part of a path (everything before the filename).
  92974. * @param uri The URI to extract the info from
  92975. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  92976. * @returns The "folder" part of the path
  92977. */
  92978. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  92979. /**
  92980. * Extracts text content from a DOM element hierarchy
  92981. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  92982. */
  92983. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  92984. /**
  92985. * Convert an angle in radians to degrees
  92986. * @param angle defines the angle to convert
  92987. * @returns the angle in degrees
  92988. */
  92989. static ToDegrees(angle: number): number;
  92990. /**
  92991. * Convert an angle in degrees to radians
  92992. * @param angle defines the angle to convert
  92993. * @returns the angle in radians
  92994. */
  92995. static ToRadians(angle: number): number;
  92996. /**
  92997. * Encode a buffer to a base64 string
  92998. * @param buffer defines the buffer to encode
  92999. * @returns the encoded string
  93000. */
  93001. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  93002. /**
  93003. * Extracts minimum and maximum values from a list of indexed positions
  93004. * @param positions defines the positions to use
  93005. * @param indices defines the indices to the positions
  93006. * @param indexStart defines the start index
  93007. * @param indexCount defines the end index
  93008. * @param bias defines bias value to add to the result
  93009. * @return minimum and maximum values
  93010. */
  93011. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  93012. minimum: Vector3;
  93013. maximum: Vector3;
  93014. };
  93015. /**
  93016. * Extracts minimum and maximum values from a list of positions
  93017. * @param positions defines the positions to use
  93018. * @param start defines the start index in the positions array
  93019. * @param count defines the number of positions to handle
  93020. * @param bias defines bias value to add to the result
  93021. * @param stride defines the stride size to use (distance between two positions in the positions array)
  93022. * @return minimum and maximum values
  93023. */
  93024. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  93025. minimum: Vector3;
  93026. maximum: Vector3;
  93027. };
  93028. /**
  93029. * Returns an array if obj is not an array
  93030. * @param obj defines the object to evaluate as an array
  93031. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  93032. * @returns either obj directly if obj is an array or a new array containing obj
  93033. */
  93034. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  93035. /**
  93036. * Gets the pointer prefix to use
  93037. * @returns "pointer" if touch is enabled. Else returns "mouse"
  93038. */
  93039. static GetPointerPrefix(): string;
  93040. /**
  93041. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  93042. * @param func - the function to be called
  93043. * @param requester - the object that will request the next frame. Falls back to window.
  93044. * @returns frame number
  93045. */
  93046. static QueueNewFrame(func: () => void, requester?: any): number;
  93047. /**
  93048. * Ask the browser to promote the current element to fullscreen rendering mode
  93049. * @param element defines the DOM element to promote
  93050. */
  93051. static RequestFullscreen(element: HTMLElement): void;
  93052. /**
  93053. * Asks the browser to exit fullscreen mode
  93054. */
  93055. static ExitFullscreen(): void;
  93056. /**
  93057. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  93058. * @param url define the url we are trying
  93059. * @param element define the dom element where to configure the cors policy
  93060. */
  93061. static SetCorsBehavior(url: string | string[], element: {
  93062. crossOrigin: string | null;
  93063. }): void;
  93064. /**
  93065. * Removes unwanted characters from an url
  93066. * @param url defines the url to clean
  93067. * @returns the cleaned url
  93068. */
  93069. static CleanUrl(url: string): string;
  93070. /**
  93071. * Gets or sets a function used to pre-process url before using them to load assets
  93072. */
  93073. static PreprocessUrl: (url: string) => string;
  93074. /**
  93075. * Loads an image as an HTMLImageElement.
  93076. * @param input url string, ArrayBuffer, or Blob to load
  93077. * @param onLoad callback called when the image successfully loads
  93078. * @param onError callback called when the image fails to load
  93079. * @param offlineProvider offline provider for caching
  93080. * @returns the HTMLImageElement of the loaded image
  93081. */
  93082. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  93083. /**
  93084. * Loads a file
  93085. * @param url url string, ArrayBuffer, or Blob to load
  93086. * @param onSuccess callback called when the file successfully loads
  93087. * @param onProgress callback called while file is loading (if the server supports this mode)
  93088. * @param offlineProvider defines the offline provider for caching
  93089. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  93090. * @param onError callback called when the file fails to load
  93091. * @returns a file request object
  93092. */
  93093. 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;
  93094. /**
  93095. * Load a script (identified by an url). When the url returns, the
  93096. * content of this file is added into a new script element, attached to the DOM (body element)
  93097. * @param scriptUrl defines the url of the script to laod
  93098. * @param onSuccess defines the callback called when the script is loaded
  93099. * @param onError defines the callback to call if an error occurs
  93100. * @param scriptId defines the id of the script element
  93101. */
  93102. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  93103. /**
  93104. * Load an asynchronous script (identified by an url). When the url returns, the
  93105. * content of this file is added into a new script element, attached to the DOM (body element)
  93106. * @param scriptUrl defines the url of the script to laod
  93107. * @param scriptId defines the id of the script element
  93108. * @returns a promise request object
  93109. */
  93110. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Nullable<Promise<boolean>>;
  93111. /**
  93112. * Loads a file from a blob
  93113. * @param fileToLoad defines the blob to use
  93114. * @param callback defines the callback to call when data is loaded
  93115. * @param progressCallback defines the callback to call during loading process
  93116. * @returns a file request object
  93117. */
  93118. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  93119. /**
  93120. * Loads a file
  93121. * @param fileToLoad defines the file to load
  93122. * @param callback defines the callback to call when data is loaded
  93123. * @param progressCallBack defines the callback to call during loading process
  93124. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  93125. * @returns a file request object
  93126. */
  93127. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  93128. /**
  93129. * Creates a data url from a given string content
  93130. * @param content defines the content to convert
  93131. * @returns the new data url link
  93132. */
  93133. static FileAsURL(content: string): string;
  93134. /**
  93135. * Format the given number to a specific decimal format
  93136. * @param value defines the number to format
  93137. * @param decimals defines the number of decimals to use
  93138. * @returns the formatted string
  93139. */
  93140. static Format(value: number, decimals?: number): string;
  93141. /**
  93142. * Checks if a given vector is inside a specific range
  93143. * @param v defines the vector to test
  93144. * @param min defines the minimum range
  93145. * @param max defines the maximum range
  93146. */
  93147. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  93148. /**
  93149. * Tries to copy an object by duplicating every property
  93150. * @param source defines the source object
  93151. * @param destination defines the target object
  93152. * @param doNotCopyList defines a list of properties to avoid
  93153. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  93154. */
  93155. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  93156. /**
  93157. * Gets a boolean indicating if the given object has no own property
  93158. * @param obj defines the object to test
  93159. * @returns true if object has no own property
  93160. */
  93161. static IsEmpty(obj: any): boolean;
  93162. /**
  93163. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  93164. * @param str Source string
  93165. * @param suffix Suffix to search for in the source string
  93166. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  93167. */
  93168. static EndsWith(str: string, suffix: string): boolean;
  93169. /**
  93170. * Function used to register events at window level
  93171. * @param events defines the events to register
  93172. */
  93173. static RegisterTopRootEvents(events: {
  93174. name: string;
  93175. handler: Nullable<(e: FocusEvent) => any>;
  93176. }[]): void;
  93177. /**
  93178. * Function used to unregister events from window level
  93179. * @param events defines the events to unregister
  93180. */
  93181. static UnregisterTopRootEvents(events: {
  93182. name: string;
  93183. handler: Nullable<(e: FocusEvent) => any>;
  93184. }[]): void;
  93185. /**
  93186. * @ignore
  93187. */
  93188. static _ScreenshotCanvas: HTMLCanvasElement;
  93189. /**
  93190. * Dumps the current bound framebuffer
  93191. * @param width defines the rendering width
  93192. * @param height defines the rendering height
  93193. * @param engine defines the hosting engine
  93194. * @param successCallback defines the callback triggered once the data are available
  93195. * @param mimeType defines the mime type of the result
  93196. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  93197. */
  93198. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  93199. /**
  93200. * Converts the canvas data to blob.
  93201. * This acts as a polyfill for browsers not supporting the to blob function.
  93202. * @param canvas Defines the canvas to extract the data from
  93203. * @param successCallback Defines the callback triggered once the data are available
  93204. * @param mimeType Defines the mime type of the result
  93205. */
  93206. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  93207. /**
  93208. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  93209. * @param successCallback defines the callback triggered once the data are available
  93210. * @param mimeType defines the mime type of the result
  93211. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  93212. */
  93213. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  93214. /**
  93215. * Downloads a blob in the browser
  93216. * @param blob defines the blob to download
  93217. * @param fileName defines the name of the downloaded file
  93218. */
  93219. static Download(blob: Blob, fileName: string): void;
  93220. /**
  93221. * Captures a screenshot of the current rendering
  93222. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  93223. * @param engine defines the rendering engine
  93224. * @param camera defines the source camera
  93225. * @param size This parameter can be set to a single number or to an object with the
  93226. * following (optional) properties: precision, width, height. If a single number is passed,
  93227. * it will be used for both width and height. If an object is passed, the screenshot size
  93228. * will be derived from the parameters. The precision property is a multiplier allowing
  93229. * rendering at a higher or lower resolution
  93230. * @param successCallback defines the callback receives a single parameter which contains the
  93231. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  93232. * src parameter of an <img> to display it
  93233. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  93234. * Check your browser for supported MIME types
  93235. */
  93236. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  93237. /**
  93238. * Generates an image screenshot from the specified camera.
  93239. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  93240. * @param engine The engine to use for rendering
  93241. * @param camera The camera to use for rendering
  93242. * @param size This parameter can be set to a single number or to an object with the
  93243. * following (optional) properties: precision, width, height. If a single number is passed,
  93244. * it will be used for both width and height. If an object is passed, the screenshot size
  93245. * will be derived from the parameters. The precision property is a multiplier allowing
  93246. * rendering at a higher or lower resolution
  93247. * @param successCallback The callback receives a single parameter which contains the
  93248. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  93249. * src parameter of an <img> to display it
  93250. * @param mimeType The MIME type of the screenshot image (default: image/png).
  93251. * Check your browser for supported MIME types
  93252. * @param samples Texture samples (default: 1)
  93253. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  93254. * @param fileName A name for for the downloaded file.
  93255. */
  93256. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  93257. /**
  93258. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  93259. * Be aware Math.random() could cause collisions, but:
  93260. * "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"
  93261. * @returns a pseudo random id
  93262. */
  93263. static RandomId(): string;
  93264. /**
  93265. * Test if the given uri is a base64 string
  93266. * @param uri The uri to test
  93267. * @return True if the uri is a base64 string or false otherwise
  93268. */
  93269. static IsBase64(uri: string): boolean;
  93270. /**
  93271. * Decode the given base64 uri.
  93272. * @param uri The uri to decode
  93273. * @return The decoded base64 data.
  93274. */
  93275. static DecodeBase64(uri: string): ArrayBuffer;
  93276. /**
  93277. * Gets the absolute url.
  93278. * @param url the input url
  93279. * @return the absolute url
  93280. */
  93281. static GetAbsoluteUrl(url: string): string;
  93282. /**
  93283. * No log
  93284. */
  93285. static readonly NoneLogLevel: number;
  93286. /**
  93287. * Only message logs
  93288. */
  93289. static readonly MessageLogLevel: number;
  93290. /**
  93291. * Only warning logs
  93292. */
  93293. static readonly WarningLogLevel: number;
  93294. /**
  93295. * Only error logs
  93296. */
  93297. static readonly ErrorLogLevel: number;
  93298. /**
  93299. * All logs
  93300. */
  93301. static readonly AllLogLevel: number;
  93302. /**
  93303. * Gets a value indicating the number of loading errors
  93304. * @ignorenaming
  93305. */
  93306. static readonly errorsCount: number;
  93307. /**
  93308. * Callback called when a new log is added
  93309. */
  93310. static OnNewCacheEntry: (entry: string) => void;
  93311. /**
  93312. * Log a message to the console
  93313. * @param message defines the message to log
  93314. */
  93315. static Log(message: string): void;
  93316. /**
  93317. * Write a warning message to the console
  93318. * @param message defines the message to log
  93319. */
  93320. static Warn(message: string): void;
  93321. /**
  93322. * Write an error message to the console
  93323. * @param message defines the message to log
  93324. */
  93325. static Error(message: string): void;
  93326. /**
  93327. * Gets current log cache (list of logs)
  93328. */
  93329. static readonly LogCache: string;
  93330. /**
  93331. * Clears the log cache
  93332. */
  93333. static ClearLogCache(): void;
  93334. /**
  93335. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  93336. */
  93337. static LogLevels: number;
  93338. /**
  93339. * Checks if the loaded document was accessed via `file:`-Protocol.
  93340. * @returns boolean
  93341. */
  93342. static IsFileURL(): boolean;
  93343. /**
  93344. * Checks if the window object exists
  93345. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  93346. */
  93347. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  93348. /**
  93349. * No performance log
  93350. */
  93351. static readonly PerformanceNoneLogLevel: number;
  93352. /**
  93353. * Use user marks to log performance
  93354. */
  93355. static readonly PerformanceUserMarkLogLevel: number;
  93356. /**
  93357. * Log performance to the console
  93358. */
  93359. static readonly PerformanceConsoleLogLevel: number;
  93360. private static _performance;
  93361. /**
  93362. * Sets the current performance log level
  93363. */
  93364. static PerformanceLogLevel: number;
  93365. private static _StartPerformanceCounterDisabled;
  93366. private static _EndPerformanceCounterDisabled;
  93367. private static _StartUserMark;
  93368. private static _EndUserMark;
  93369. private static _StartPerformanceConsole;
  93370. private static _EndPerformanceConsole;
  93371. /**
  93372. * Starts a performance counter
  93373. */
  93374. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  93375. /**
  93376. * Ends a specific performance coutner
  93377. */
  93378. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  93379. /**
  93380. * Gets either window.performance.now() if supported or Date.now() else
  93381. */
  93382. static readonly Now: number;
  93383. /**
  93384. * This method will return the name of the class used to create the instance of the given object.
  93385. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  93386. * @param object the object to get the class name from
  93387. * @param isType defines if the object is actually a type
  93388. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  93389. */
  93390. static GetClassName(object: any, isType?: boolean): string;
  93391. /**
  93392. * Gets the first element of an array satisfying a given predicate
  93393. * @param array defines the array to browse
  93394. * @param predicate defines the predicate to use
  93395. * @returns null if not found or the element
  93396. */
  93397. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  93398. /**
  93399. * This method will return the name of the full name of the class, including its owning module (if any).
  93400. * 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).
  93401. * @param object the object to get the class name from
  93402. * @param isType defines if the object is actually a type
  93403. * @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.
  93404. * @ignorenaming
  93405. */
  93406. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  93407. /**
  93408. * Returns a promise that resolves after the given amount of time.
  93409. * @param delay Number of milliseconds to delay
  93410. * @returns Promise that resolves after the given amount of time
  93411. */
  93412. static DelayAsync(delay: number): Promise<void>;
  93413. /**
  93414. * Gets the current gradient from an array of IValueGradient
  93415. * @param ratio defines the current ratio to get
  93416. * @param gradients defines the array of IValueGradient
  93417. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  93418. */
  93419. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  93420. }
  93421. /**
  93422. * This class is used to track a performance counter which is number based.
  93423. * The user has access to many properties which give statistics of different nature.
  93424. *
  93425. * The implementer can track two kinds of Performance Counter: time and count.
  93426. * 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.
  93427. * 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.
  93428. */
  93429. export class PerfCounter {
  93430. /**
  93431. * Gets or sets a global boolean to turn on and off all the counters
  93432. */
  93433. static Enabled: boolean;
  93434. /**
  93435. * Returns the smallest value ever
  93436. */
  93437. readonly min: number;
  93438. /**
  93439. * Returns the biggest value ever
  93440. */
  93441. readonly max: number;
  93442. /**
  93443. * Returns the average value since the performance counter is running
  93444. */
  93445. readonly average: number;
  93446. /**
  93447. * Returns the average value of the last second the counter was monitored
  93448. */
  93449. readonly lastSecAverage: number;
  93450. /**
  93451. * Returns the current value
  93452. */
  93453. readonly current: number;
  93454. /**
  93455. * Gets the accumulated total
  93456. */
  93457. readonly total: number;
  93458. /**
  93459. * Gets the total value count
  93460. */
  93461. readonly count: number;
  93462. /**
  93463. * Creates a new counter
  93464. */
  93465. constructor();
  93466. /**
  93467. * Call this method to start monitoring a new frame.
  93468. * 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.
  93469. */
  93470. fetchNewFrame(): void;
  93471. /**
  93472. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  93473. * @param newCount the count value to add to the monitored count
  93474. * @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.
  93475. */
  93476. addCount(newCount: number, fetchResult: boolean): void;
  93477. /**
  93478. * Start monitoring this performance counter
  93479. */
  93480. beginMonitoring(): void;
  93481. /**
  93482. * Compute the time lapsed since the previous beginMonitoring() call.
  93483. * @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
  93484. */
  93485. endMonitoring(newFrame?: boolean): void;
  93486. private _fetchResult;
  93487. private _startMonitoringTime;
  93488. private _min;
  93489. private _max;
  93490. private _average;
  93491. private _current;
  93492. private _totalValueCount;
  93493. private _totalAccumulated;
  93494. private _lastSecAverage;
  93495. private _lastSecAccumulated;
  93496. private _lastSecTime;
  93497. private _lastSecValueCount;
  93498. }
  93499. /**
  93500. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  93501. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  93502. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  93503. * @param name The name of the class, case should be preserved
  93504. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  93505. */
  93506. export function className(name: string, module?: string): (target: Object) => void;
  93507. /**
  93508. * An implementation of a loop for asynchronous functions.
  93509. */
  93510. export class AsyncLoop {
  93511. /**
  93512. * Defines the number of iterations for the loop
  93513. */
  93514. iterations: number;
  93515. /**
  93516. * Defines the current index of the loop.
  93517. */
  93518. index: number;
  93519. private _done;
  93520. private _fn;
  93521. private _successCallback;
  93522. /**
  93523. * Constructor.
  93524. * @param iterations the number of iterations.
  93525. * @param func the function to run each iteration
  93526. * @param successCallback the callback that will be called upon succesful execution
  93527. * @param offset starting offset.
  93528. */
  93529. constructor(
  93530. /**
  93531. * Defines the number of iterations for the loop
  93532. */
  93533. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  93534. /**
  93535. * Execute the next iteration. Must be called after the last iteration was finished.
  93536. */
  93537. executeNext(): void;
  93538. /**
  93539. * Break the loop and run the success callback.
  93540. */
  93541. breakLoop(): void;
  93542. /**
  93543. * Create and run an async loop.
  93544. * @param iterations the number of iterations.
  93545. * @param fn the function to run each iteration
  93546. * @param successCallback the callback that will be called upon succesful execution
  93547. * @param offset starting offset.
  93548. * @returns the created async loop object
  93549. */
  93550. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  93551. /**
  93552. * A for-loop that will run a given number of iterations synchronous and the rest async.
  93553. * @param iterations total number of iterations
  93554. * @param syncedIterations number of synchronous iterations in each async iteration.
  93555. * @param fn the function to call each iteration.
  93556. * @param callback a success call back that will be called when iterating stops.
  93557. * @param breakFunction a break condition (optional)
  93558. * @param timeout timeout settings for the setTimeout function. default - 0.
  93559. * @returns the created async loop object
  93560. */
  93561. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  93562. }
  93563. }
  93564. declare module BABYLON {
  93565. /** @hidden */
  93566. export interface ICollisionCoordinator {
  93567. createCollider(): Collider;
  93568. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  93569. init(scene: Scene): void;
  93570. }
  93571. /** @hidden */
  93572. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  93573. private _scene;
  93574. private _scaledPosition;
  93575. private _scaledVelocity;
  93576. private _finalPosition;
  93577. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  93578. createCollider(): Collider;
  93579. init(scene: Scene): void;
  93580. private _collideWithWorld;
  93581. }
  93582. }
  93583. declare module BABYLON {
  93584. /**
  93585. * Class used to manage all inputs for the scene.
  93586. */
  93587. export class InputManager {
  93588. /** The distance in pixel that you have to move to prevent some events */
  93589. static DragMovementThreshold: number;
  93590. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  93591. static LongPressDelay: number;
  93592. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  93593. static DoubleClickDelay: number;
  93594. /** If you need to check double click without raising a single click at first click, enable this flag */
  93595. static ExclusiveDoubleClickMode: boolean;
  93596. private _wheelEventName;
  93597. private _onPointerMove;
  93598. private _onPointerDown;
  93599. private _onPointerUp;
  93600. private _initClickEvent;
  93601. private _initActionManager;
  93602. private _delayedSimpleClick;
  93603. private _delayedSimpleClickTimeout;
  93604. private _previousDelayedSimpleClickTimeout;
  93605. private _meshPickProceed;
  93606. private _previousButtonPressed;
  93607. private _currentPickResult;
  93608. private _previousPickResult;
  93609. private _totalPointersPressed;
  93610. private _doubleClickOccured;
  93611. private _pointerOverMesh;
  93612. private _pickedDownMesh;
  93613. private _pickedUpMesh;
  93614. private _pointerX;
  93615. private _pointerY;
  93616. private _unTranslatedPointerX;
  93617. private _unTranslatedPointerY;
  93618. private _startingPointerPosition;
  93619. private _previousStartingPointerPosition;
  93620. private _startingPointerTime;
  93621. private _previousStartingPointerTime;
  93622. private _pointerCaptures;
  93623. private _onKeyDown;
  93624. private _onKeyUp;
  93625. private _onCanvasFocusObserver;
  93626. private _onCanvasBlurObserver;
  93627. private _scene;
  93628. /**
  93629. * Creates a new InputManager
  93630. * @param scene defines the hosting scene
  93631. */
  93632. constructor(scene: Scene);
  93633. /**
  93634. * Gets the mesh that is currently under the pointer
  93635. */
  93636. readonly meshUnderPointer: Nullable<AbstractMesh>;
  93637. /**
  93638. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  93639. */
  93640. readonly unTranslatedPointer: Vector2;
  93641. /**
  93642. * Gets or sets the current on-screen X position of the pointer
  93643. */
  93644. pointerX: number;
  93645. /**
  93646. * Gets or sets the current on-screen Y position of the pointer
  93647. */
  93648. pointerY: number;
  93649. private _updatePointerPosition;
  93650. private _processPointerMove;
  93651. private _setRayOnPointerInfo;
  93652. private _checkPrePointerObservable;
  93653. /**
  93654. * Use this method to simulate a pointer move on a mesh
  93655. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  93656. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  93657. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  93658. */
  93659. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  93660. /**
  93661. * Use this method to simulate a pointer down on a mesh
  93662. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  93663. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  93664. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  93665. */
  93666. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  93667. private _processPointerDown;
  93668. /** @hidden */
  93669. _isPointerSwiping(): boolean;
  93670. /**
  93671. * Use this method to simulate a pointer up on a mesh
  93672. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  93673. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  93674. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  93675. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  93676. */
  93677. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  93678. private _processPointerUp;
  93679. /**
  93680. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  93681. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  93682. * @returns true if the pointer was captured
  93683. */
  93684. isPointerCaptured(pointerId?: number): boolean;
  93685. /**
  93686. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  93687. * @param attachUp defines if you want to attach events to pointerup
  93688. * @param attachDown defines if you want to attach events to pointerdown
  93689. * @param attachMove defines if you want to attach events to pointermove
  93690. */
  93691. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  93692. /**
  93693. * Detaches all event handlers
  93694. */
  93695. detachControl(): void;
  93696. /**
  93697. * Force the value of meshUnderPointer
  93698. * @param mesh defines the mesh to use
  93699. */
  93700. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  93701. /**
  93702. * Gets the mesh under the pointer
  93703. * @returns a Mesh or null if no mesh is under the pointer
  93704. */
  93705. getPointerOverMesh(): Nullable<AbstractMesh>;
  93706. }
  93707. }
  93708. declare module BABYLON {
  93709. /**
  93710. * This class defines the direct association between an animation and a target
  93711. */
  93712. export class TargetedAnimation {
  93713. /**
  93714. * Animation to perform
  93715. */
  93716. animation: Animation;
  93717. /**
  93718. * Target to animate
  93719. */
  93720. target: any;
  93721. /**
  93722. * Serialize the object
  93723. * @returns the JSON object representing the current entity
  93724. */
  93725. serialize(): any;
  93726. }
  93727. /**
  93728. * Use this class to create coordinated animations on multiple targets
  93729. */
  93730. export class AnimationGroup implements IDisposable {
  93731. /** The name of the animation group */
  93732. name: string;
  93733. private _scene;
  93734. private _targetedAnimations;
  93735. private _animatables;
  93736. private _from;
  93737. private _to;
  93738. private _isStarted;
  93739. private _isPaused;
  93740. private _speedRatio;
  93741. private _loopAnimation;
  93742. /**
  93743. * Gets or sets the unique id of the node
  93744. */
  93745. uniqueId: number;
  93746. /**
  93747. * This observable will notify when one animation have ended
  93748. */
  93749. onAnimationEndObservable: Observable<TargetedAnimation>;
  93750. /**
  93751. * Observer raised when one animation loops
  93752. */
  93753. onAnimationLoopObservable: Observable<TargetedAnimation>;
  93754. /**
  93755. * This observable will notify when all animations have ended.
  93756. */
  93757. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  93758. /**
  93759. * This observable will notify when all animations have paused.
  93760. */
  93761. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  93762. /**
  93763. * This observable will notify when all animations are playing.
  93764. */
  93765. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  93766. /**
  93767. * Gets the first frame
  93768. */
  93769. readonly from: number;
  93770. /**
  93771. * Gets the last frame
  93772. */
  93773. readonly to: number;
  93774. /**
  93775. * Define if the animations are started
  93776. */
  93777. readonly isStarted: boolean;
  93778. /**
  93779. * Gets a value indicating that the current group is playing
  93780. */
  93781. readonly isPlaying: boolean;
  93782. /**
  93783. * Gets or sets the speed ratio to use for all animations
  93784. */
  93785. /**
  93786. * Gets or sets the speed ratio to use for all animations
  93787. */
  93788. speedRatio: number;
  93789. /**
  93790. * Gets or sets if all animations should loop or not
  93791. */
  93792. loopAnimation: boolean;
  93793. /**
  93794. * Gets the targeted animations for this animation group
  93795. */
  93796. readonly targetedAnimations: Array<TargetedAnimation>;
  93797. /**
  93798. * returning the list of animatables controlled by this animation group.
  93799. */
  93800. readonly animatables: Array<Animatable>;
  93801. /**
  93802. * Instantiates a new Animation Group.
  93803. * This helps managing several animations at once.
  93804. * @see http://doc.babylonjs.com/how_to/group
  93805. * @param name Defines the name of the group
  93806. * @param scene Defines the scene the group belongs to
  93807. */
  93808. constructor(
  93809. /** The name of the animation group */
  93810. name: string, scene?: Nullable<Scene>);
  93811. /**
  93812. * Add an animation (with its target) in the group
  93813. * @param animation defines the animation we want to add
  93814. * @param target defines the target of the animation
  93815. * @returns the TargetedAnimation object
  93816. */
  93817. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  93818. /**
  93819. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  93820. * It can add constant keys at begin or end
  93821. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  93822. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  93823. * @returns the animation group
  93824. */
  93825. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  93826. /**
  93827. * Start all animations on given targets
  93828. * @param loop defines if animations must loop
  93829. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  93830. * @param from defines the from key (optional)
  93831. * @param to defines the to key (optional)
  93832. * @returns the current animation group
  93833. */
  93834. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  93835. /**
  93836. * Pause all animations
  93837. * @returns the animation group
  93838. */
  93839. pause(): AnimationGroup;
  93840. /**
  93841. * Play all animations to initial state
  93842. * This function will start() the animations if they were not started or will restart() them if they were paused
  93843. * @param loop defines if animations must loop
  93844. * @returns the animation group
  93845. */
  93846. play(loop?: boolean): AnimationGroup;
  93847. /**
  93848. * Reset all animations to initial state
  93849. * @returns the animation group
  93850. */
  93851. reset(): AnimationGroup;
  93852. /**
  93853. * Restart animations from key 0
  93854. * @returns the animation group
  93855. */
  93856. restart(): AnimationGroup;
  93857. /**
  93858. * Stop all animations
  93859. * @returns the animation group
  93860. */
  93861. stop(): AnimationGroup;
  93862. /**
  93863. * Set animation weight for all animatables
  93864. * @param weight defines the weight to use
  93865. * @return the animationGroup
  93866. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  93867. */
  93868. setWeightForAllAnimatables(weight: number): AnimationGroup;
  93869. /**
  93870. * Synchronize and normalize all animatables with a source animatable
  93871. * @param root defines the root animatable to synchronize with
  93872. * @return the animationGroup
  93873. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  93874. */
  93875. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  93876. /**
  93877. * Goes to a specific frame in this animation group
  93878. * @param frame the frame number to go to
  93879. * @return the animationGroup
  93880. */
  93881. goToFrame(frame: number): AnimationGroup;
  93882. /**
  93883. * Dispose all associated resources
  93884. */
  93885. dispose(): void;
  93886. private _checkAnimationGroupEnded;
  93887. /**
  93888. * Clone the current animation group and returns a copy
  93889. * @param newName defines the name of the new group
  93890. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  93891. * @returns the new aniamtion group
  93892. */
  93893. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  93894. /**
  93895. * Serializes the animationGroup to an object
  93896. * @returns Serialized object
  93897. */
  93898. serialize(): any;
  93899. /**
  93900. * Returns a new AnimationGroup object parsed from the source provided.
  93901. * @param parsedAnimationGroup defines the source
  93902. * @param scene defines the scene that will receive the animationGroup
  93903. * @returns a new AnimationGroup
  93904. */
  93905. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  93906. /**
  93907. * Returns the string "AnimationGroup"
  93908. * @returns "AnimationGroup"
  93909. */
  93910. getClassName(): string;
  93911. /**
  93912. * Creates a detailled string about the object
  93913. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  93914. * @returns a string representing the object
  93915. */
  93916. toString(fullDetails?: boolean): string;
  93917. }
  93918. }
  93919. declare module BABYLON {
  93920. /**
  93921. * Define an interface for all classes that will hold resources
  93922. */
  93923. export interface IDisposable {
  93924. /**
  93925. * Releases all held resources
  93926. */
  93927. dispose(): void;
  93928. }
  93929. /** Interface defining initialization parameters for Scene class */
  93930. export interface SceneOptions {
  93931. /**
  93932. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  93933. * It will improve performance when the number of geometries becomes important.
  93934. */
  93935. useGeometryUniqueIdsMap?: boolean;
  93936. /**
  93937. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  93938. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  93939. */
  93940. useMaterialMeshMap?: boolean;
  93941. /**
  93942. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  93943. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  93944. */
  93945. useClonedMeshhMap?: boolean;
  93946. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  93947. virtual?: boolean;
  93948. }
  93949. /**
  93950. * Represents a scene to be rendered by the engine.
  93951. * @see http://doc.babylonjs.com/features/scene
  93952. */
  93953. export class Scene extends AbstractScene implements IAnimatable {
  93954. private static _uniqueIdCounter;
  93955. /** The fog is deactivated */
  93956. static readonly FOGMODE_NONE: number;
  93957. /** The fog density is following an exponential function */
  93958. static readonly FOGMODE_EXP: number;
  93959. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  93960. static readonly FOGMODE_EXP2: number;
  93961. /** The fog density is following a linear function. */
  93962. static readonly FOGMODE_LINEAR: number;
  93963. /**
  93964. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  93965. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  93966. */
  93967. static MinDeltaTime: number;
  93968. /**
  93969. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  93970. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  93971. */
  93972. static MaxDeltaTime: number;
  93973. /**
  93974. * Factory used to create the default material.
  93975. * @param name The name of the material to create
  93976. * @param scene The scene to create the material for
  93977. * @returns The default material
  93978. */
  93979. static DefaultMaterialFactory(scene: Scene): Material;
  93980. /**
  93981. * Factory used to create the a collision coordinator.
  93982. * @returns The collision coordinator
  93983. */
  93984. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  93985. /** @hidden */
  93986. _inputManager: InputManager;
  93987. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  93988. cameraToUseForPointers: Nullable<Camera>;
  93989. /** @hidden */
  93990. readonly _isScene: boolean;
  93991. /**
  93992. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  93993. */
  93994. autoClear: boolean;
  93995. /**
  93996. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  93997. */
  93998. autoClearDepthAndStencil: boolean;
  93999. /**
  94000. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  94001. */
  94002. clearColor: Color4;
  94003. /**
  94004. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  94005. */
  94006. ambientColor: Color3;
  94007. /**
  94008. * This is use to store the default BRDF lookup for PBR materials in your scene.
  94009. * It should only be one of the following (if not the default embedded one):
  94010. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  94011. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  94012. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  94013. * The material properties need to be setup according to the type of texture in use.
  94014. */
  94015. environmentBRDFTexture: BaseTexture;
  94016. /** @hidden */
  94017. protected _environmentTexture: Nullable<BaseTexture>;
  94018. /**
  94019. * Texture used in all pbr material as the reflection texture.
  94020. * As in the majority of the scene they are the same (exception for multi room and so on),
  94021. * this is easier to reference from here than from all the materials.
  94022. */
  94023. /**
  94024. * Texture used in all pbr material as the reflection texture.
  94025. * As in the majority of the scene they are the same (exception for multi room and so on),
  94026. * this is easier to set here than in all the materials.
  94027. */
  94028. environmentTexture: Nullable<BaseTexture>;
  94029. /** @hidden */
  94030. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  94031. /**
  94032. * Default image processing configuration used either in the rendering
  94033. * Forward main pass or through the imageProcessingPostProcess if present.
  94034. * As in the majority of the scene they are the same (exception for multi camera),
  94035. * this is easier to reference from here than from all the materials and post process.
  94036. *
  94037. * No setter as we it is a shared configuration, you can set the values instead.
  94038. */
  94039. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  94040. private _forceWireframe;
  94041. /**
  94042. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  94043. */
  94044. forceWireframe: boolean;
  94045. private _forcePointsCloud;
  94046. /**
  94047. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  94048. */
  94049. forcePointsCloud: boolean;
  94050. /**
  94051. * Gets or sets the active clipplane 1
  94052. */
  94053. clipPlane: Nullable<Plane>;
  94054. /**
  94055. * Gets or sets the active clipplane 2
  94056. */
  94057. clipPlane2: Nullable<Plane>;
  94058. /**
  94059. * Gets or sets the active clipplane 3
  94060. */
  94061. clipPlane3: Nullable<Plane>;
  94062. /**
  94063. * Gets or sets the active clipplane 4
  94064. */
  94065. clipPlane4: Nullable<Plane>;
  94066. /**
  94067. * Gets or sets a boolean indicating if animations are enabled
  94068. */
  94069. animationsEnabled: boolean;
  94070. private _animationPropertiesOverride;
  94071. /**
  94072. * Gets or sets the animation properties override
  94073. */
  94074. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  94075. /**
  94076. * Gets or sets a boolean indicating if a constant deltatime has to be used
  94077. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  94078. */
  94079. useConstantAnimationDeltaTime: boolean;
  94080. /**
  94081. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  94082. * Please note that it requires to run a ray cast through the scene on every frame
  94083. */
  94084. constantlyUpdateMeshUnderPointer: boolean;
  94085. /**
  94086. * Defines the HTML cursor to use when hovering over interactive elements
  94087. */
  94088. hoverCursor: string;
  94089. /**
  94090. * Defines the HTML default cursor to use (empty by default)
  94091. */
  94092. defaultCursor: string;
  94093. /**
  94094. * This is used to call preventDefault() on pointer down
  94095. * in order to block unwanted artifacts like system double clicks
  94096. */
  94097. preventDefaultOnPointerDown: boolean;
  94098. /**
  94099. * This is used to call preventDefault() on pointer up
  94100. * in order to block unwanted artifacts like system double clicks
  94101. */
  94102. preventDefaultOnPointerUp: boolean;
  94103. /**
  94104. * Gets or sets user defined metadata
  94105. */
  94106. metadata: any;
  94107. /**
  94108. * For internal use only. Please do not use.
  94109. */
  94110. reservedDataStore: any;
  94111. /**
  94112. * Gets the name of the plugin used to load this scene (null by default)
  94113. */
  94114. loadingPluginName: string;
  94115. /**
  94116. * Use this array to add regular expressions used to disable offline support for specific urls
  94117. */
  94118. disableOfflineSupportExceptionRules: RegExp[];
  94119. /**
  94120. * An event triggered when the scene is disposed.
  94121. */
  94122. onDisposeObservable: Observable<Scene>;
  94123. private _onDisposeObserver;
  94124. /** Sets a function to be executed when this scene is disposed. */
  94125. onDispose: () => void;
  94126. /**
  94127. * An event triggered before rendering the scene (right after animations and physics)
  94128. */
  94129. onBeforeRenderObservable: Observable<Scene>;
  94130. private _onBeforeRenderObserver;
  94131. /** Sets a function to be executed before rendering this scene */
  94132. beforeRender: Nullable<() => void>;
  94133. /**
  94134. * An event triggered after rendering the scene
  94135. */
  94136. onAfterRenderObservable: Observable<Scene>;
  94137. private _onAfterRenderObserver;
  94138. /** Sets a function to be executed after rendering this scene */
  94139. afterRender: Nullable<() => void>;
  94140. /**
  94141. * An event triggered before animating the scene
  94142. */
  94143. onBeforeAnimationsObservable: Observable<Scene>;
  94144. /**
  94145. * An event triggered after animations processing
  94146. */
  94147. onAfterAnimationsObservable: Observable<Scene>;
  94148. /**
  94149. * An event triggered before draw calls are ready to be sent
  94150. */
  94151. onBeforeDrawPhaseObservable: Observable<Scene>;
  94152. /**
  94153. * An event triggered after draw calls have been sent
  94154. */
  94155. onAfterDrawPhaseObservable: Observable<Scene>;
  94156. /**
  94157. * An event triggered when the scene is ready
  94158. */
  94159. onReadyObservable: Observable<Scene>;
  94160. /**
  94161. * An event triggered before rendering a camera
  94162. */
  94163. onBeforeCameraRenderObservable: Observable<Camera>;
  94164. private _onBeforeCameraRenderObserver;
  94165. /** Sets a function to be executed before rendering a camera*/
  94166. beforeCameraRender: () => void;
  94167. /**
  94168. * An event triggered after rendering a camera
  94169. */
  94170. onAfterCameraRenderObservable: Observable<Camera>;
  94171. private _onAfterCameraRenderObserver;
  94172. /** Sets a function to be executed after rendering a camera*/
  94173. afterCameraRender: () => void;
  94174. /**
  94175. * An event triggered when active meshes evaluation is about to start
  94176. */
  94177. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  94178. /**
  94179. * An event triggered when active meshes evaluation is done
  94180. */
  94181. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  94182. /**
  94183. * An event triggered when particles rendering is about to start
  94184. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  94185. */
  94186. onBeforeParticlesRenderingObservable: Observable<Scene>;
  94187. /**
  94188. * An event triggered when particles rendering is done
  94189. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  94190. */
  94191. onAfterParticlesRenderingObservable: Observable<Scene>;
  94192. /**
  94193. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  94194. */
  94195. onDataLoadedObservable: Observable<Scene>;
  94196. /**
  94197. * An event triggered when a camera is created
  94198. */
  94199. onNewCameraAddedObservable: Observable<Camera>;
  94200. /**
  94201. * An event triggered when a camera is removed
  94202. */
  94203. onCameraRemovedObservable: Observable<Camera>;
  94204. /**
  94205. * An event triggered when a light is created
  94206. */
  94207. onNewLightAddedObservable: Observable<Light>;
  94208. /**
  94209. * An event triggered when a light is removed
  94210. */
  94211. onLightRemovedObservable: Observable<Light>;
  94212. /**
  94213. * An event triggered when a geometry is created
  94214. */
  94215. onNewGeometryAddedObservable: Observable<Geometry>;
  94216. /**
  94217. * An event triggered when a geometry is removed
  94218. */
  94219. onGeometryRemovedObservable: Observable<Geometry>;
  94220. /**
  94221. * An event triggered when a transform node is created
  94222. */
  94223. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  94224. /**
  94225. * An event triggered when a transform node is removed
  94226. */
  94227. onTransformNodeRemovedObservable: Observable<TransformNode>;
  94228. /**
  94229. * An event triggered when a mesh is created
  94230. */
  94231. onNewMeshAddedObservable: Observable<AbstractMesh>;
  94232. /**
  94233. * An event triggered when a mesh is removed
  94234. */
  94235. onMeshRemovedObservable: Observable<AbstractMesh>;
  94236. /**
  94237. * An event triggered when a skeleton is created
  94238. */
  94239. onNewSkeletonAddedObservable: Observable<Skeleton>;
  94240. /**
  94241. * An event triggered when a skeleton is removed
  94242. */
  94243. onSkeletonRemovedObservable: Observable<Skeleton>;
  94244. /**
  94245. * An event triggered when a material is created
  94246. */
  94247. onNewMaterialAddedObservable: Observable<Material>;
  94248. /**
  94249. * An event triggered when a material is removed
  94250. */
  94251. onMaterialRemovedObservable: Observable<Material>;
  94252. /**
  94253. * An event triggered when a texture is created
  94254. */
  94255. onNewTextureAddedObservable: Observable<BaseTexture>;
  94256. /**
  94257. * An event triggered when a texture is removed
  94258. */
  94259. onTextureRemovedObservable: Observable<BaseTexture>;
  94260. /**
  94261. * An event triggered when render targets are about to be rendered
  94262. * Can happen multiple times per frame.
  94263. */
  94264. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  94265. /**
  94266. * An event triggered when render targets were rendered.
  94267. * Can happen multiple times per frame.
  94268. */
  94269. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  94270. /**
  94271. * An event triggered before calculating deterministic simulation step
  94272. */
  94273. onBeforeStepObservable: Observable<Scene>;
  94274. /**
  94275. * An event triggered after calculating deterministic simulation step
  94276. */
  94277. onAfterStepObservable: Observable<Scene>;
  94278. /**
  94279. * An event triggered when the activeCamera property is updated
  94280. */
  94281. onActiveCameraChanged: Observable<Scene>;
  94282. /**
  94283. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  94284. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  94285. * 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)
  94286. */
  94287. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  94288. /**
  94289. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  94290. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  94291. * 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)
  94292. */
  94293. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  94294. /**
  94295. * This Observable will when a mesh has been imported into the scene.
  94296. */
  94297. onMeshImportedObservable: Observable<AbstractMesh>;
  94298. /**
  94299. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  94300. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  94301. */
  94302. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  94303. /** @hidden */
  94304. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  94305. /**
  94306. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  94307. */
  94308. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  94309. /**
  94310. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  94311. */
  94312. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  94313. /**
  94314. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  94315. */
  94316. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  94317. /** Callback called when a pointer move is detected */
  94318. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  94319. /** Callback called when a pointer down is detected */
  94320. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  94321. /** Callback called when a pointer up is detected */
  94322. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  94323. /** Callback called when a pointer pick is detected */
  94324. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  94325. /**
  94326. * 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).
  94327. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  94328. */
  94329. onPrePointerObservable: Observable<PointerInfoPre>;
  94330. /**
  94331. * Observable event triggered each time an input event is received from the rendering canvas
  94332. */
  94333. onPointerObservable: Observable<PointerInfo>;
  94334. /**
  94335. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  94336. */
  94337. readonly unTranslatedPointer: Vector2;
  94338. /**
  94339. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  94340. */
  94341. static DragMovementThreshold: number;
  94342. /**
  94343. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  94344. */
  94345. static LongPressDelay: number;
  94346. /**
  94347. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  94348. */
  94349. static DoubleClickDelay: number;
  94350. /** If you need to check double click without raising a single click at first click, enable this flag */
  94351. static ExclusiveDoubleClickMode: boolean;
  94352. /** @hidden */
  94353. _mirroredCameraPosition: Nullable<Vector3>;
  94354. /**
  94355. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  94356. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  94357. */
  94358. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  94359. /**
  94360. * Observable event triggered each time an keyboard event is received from the hosting window
  94361. */
  94362. onKeyboardObservable: Observable<KeyboardInfo>;
  94363. private _useRightHandedSystem;
  94364. /**
  94365. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  94366. */
  94367. useRightHandedSystem: boolean;
  94368. private _timeAccumulator;
  94369. private _currentStepId;
  94370. private _currentInternalStep;
  94371. /**
  94372. * Sets the step Id used by deterministic lock step
  94373. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  94374. * @param newStepId defines the step Id
  94375. */
  94376. setStepId(newStepId: number): void;
  94377. /**
  94378. * Gets the step Id used by deterministic lock step
  94379. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  94380. * @returns the step Id
  94381. */
  94382. getStepId(): number;
  94383. /**
  94384. * Gets the internal step used by deterministic lock step
  94385. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  94386. * @returns the internal step
  94387. */
  94388. getInternalStep(): number;
  94389. private _fogEnabled;
  94390. /**
  94391. * Gets or sets a boolean indicating if fog is enabled on this scene
  94392. * @see http://doc.babylonjs.com/babylon101/environment#fog
  94393. * (Default is true)
  94394. */
  94395. fogEnabled: boolean;
  94396. private _fogMode;
  94397. /**
  94398. * Gets or sets the fog mode to use
  94399. * @see http://doc.babylonjs.com/babylon101/environment#fog
  94400. * | mode | value |
  94401. * | --- | --- |
  94402. * | FOGMODE_NONE | 0 |
  94403. * | FOGMODE_EXP | 1 |
  94404. * | FOGMODE_EXP2 | 2 |
  94405. * | FOGMODE_LINEAR | 3 |
  94406. */
  94407. fogMode: number;
  94408. /**
  94409. * Gets or sets the fog color to use
  94410. * @see http://doc.babylonjs.com/babylon101/environment#fog
  94411. * (Default is Color3(0.2, 0.2, 0.3))
  94412. */
  94413. fogColor: Color3;
  94414. /**
  94415. * Gets or sets the fog density to use
  94416. * @see http://doc.babylonjs.com/babylon101/environment#fog
  94417. * (Default is 0.1)
  94418. */
  94419. fogDensity: number;
  94420. /**
  94421. * Gets or sets the fog start distance to use
  94422. * @see http://doc.babylonjs.com/babylon101/environment#fog
  94423. * (Default is 0)
  94424. */
  94425. fogStart: number;
  94426. /**
  94427. * Gets or sets the fog end distance to use
  94428. * @see http://doc.babylonjs.com/babylon101/environment#fog
  94429. * (Default is 1000)
  94430. */
  94431. fogEnd: number;
  94432. private _shadowsEnabled;
  94433. /**
  94434. * Gets or sets a boolean indicating if shadows are enabled on this scene
  94435. */
  94436. shadowsEnabled: boolean;
  94437. private _lightsEnabled;
  94438. /**
  94439. * Gets or sets a boolean indicating if lights are enabled on this scene
  94440. */
  94441. lightsEnabled: boolean;
  94442. /** All of the active cameras added to this scene. */
  94443. activeCameras: Camera[];
  94444. /** @hidden */
  94445. _activeCamera: Nullable<Camera>;
  94446. /** Gets or sets the current active camera */
  94447. activeCamera: Nullable<Camera>;
  94448. private _defaultMaterial;
  94449. /** The default material used on meshes when no material is affected */
  94450. /** The default material used on meshes when no material is affected */
  94451. defaultMaterial: Material;
  94452. private _texturesEnabled;
  94453. /**
  94454. * Gets or sets a boolean indicating if textures are enabled on this scene
  94455. */
  94456. texturesEnabled: boolean;
  94457. /**
  94458. * Gets or sets a boolean indicating if particles are enabled on this scene
  94459. */
  94460. particlesEnabled: boolean;
  94461. /**
  94462. * Gets or sets a boolean indicating if sprites are enabled on this scene
  94463. */
  94464. spritesEnabled: boolean;
  94465. private _skeletonsEnabled;
  94466. /**
  94467. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  94468. */
  94469. skeletonsEnabled: boolean;
  94470. /**
  94471. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  94472. */
  94473. lensFlaresEnabled: boolean;
  94474. /**
  94475. * Gets or sets a boolean indicating if collisions are enabled on this scene
  94476. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  94477. */
  94478. collisionsEnabled: boolean;
  94479. private _collisionCoordinator;
  94480. /** @hidden */
  94481. readonly collisionCoordinator: ICollisionCoordinator;
  94482. /**
  94483. * Defines the gravity applied to this scene (used only for collisions)
  94484. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  94485. */
  94486. gravity: Vector3;
  94487. /**
  94488. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  94489. */
  94490. postProcessesEnabled: boolean;
  94491. /**
  94492. * The list of postprocesses added to the scene
  94493. */
  94494. postProcesses: PostProcess[];
  94495. /**
  94496. * Gets the current postprocess manager
  94497. */
  94498. postProcessManager: PostProcessManager;
  94499. /**
  94500. * Gets or sets a boolean indicating if render targets are enabled on this scene
  94501. */
  94502. renderTargetsEnabled: boolean;
  94503. /**
  94504. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  94505. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  94506. */
  94507. dumpNextRenderTargets: boolean;
  94508. /**
  94509. * The list of user defined render targets added to the scene
  94510. */
  94511. customRenderTargets: RenderTargetTexture[];
  94512. /**
  94513. * Defines if texture loading must be delayed
  94514. * If true, textures will only be loaded when they need to be rendered
  94515. */
  94516. useDelayedTextureLoading: boolean;
  94517. /**
  94518. * Gets the list of meshes imported to the scene through SceneLoader
  94519. */
  94520. importedMeshesFiles: String[];
  94521. /**
  94522. * Gets or sets a boolean indicating if probes are enabled on this scene
  94523. */
  94524. probesEnabled: boolean;
  94525. /**
  94526. * Gets or sets the current offline provider to use to store scene data
  94527. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  94528. */
  94529. offlineProvider: IOfflineProvider;
  94530. /**
  94531. * Gets or sets the action manager associated with the scene
  94532. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  94533. */
  94534. actionManager: AbstractActionManager;
  94535. private _meshesForIntersections;
  94536. /**
  94537. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  94538. */
  94539. proceduralTexturesEnabled: boolean;
  94540. private _engine;
  94541. private _totalVertices;
  94542. /** @hidden */
  94543. _activeIndices: PerfCounter;
  94544. /** @hidden */
  94545. _activeParticles: PerfCounter;
  94546. /** @hidden */
  94547. _activeBones: PerfCounter;
  94548. private _animationRatio;
  94549. /** @hidden */
  94550. _animationTimeLast: number;
  94551. /** @hidden */
  94552. _animationTime: number;
  94553. /**
  94554. * Gets or sets a general scale for animation speed
  94555. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  94556. */
  94557. animationTimeScale: number;
  94558. /** @hidden */
  94559. _cachedMaterial: Nullable<Material>;
  94560. /** @hidden */
  94561. _cachedEffect: Nullable<Effect>;
  94562. /** @hidden */
  94563. _cachedVisibility: Nullable<number>;
  94564. private _renderId;
  94565. private _frameId;
  94566. private _executeWhenReadyTimeoutId;
  94567. private _intermediateRendering;
  94568. private _viewUpdateFlag;
  94569. private _projectionUpdateFlag;
  94570. /** @hidden */
  94571. _toBeDisposed: Nullable<IDisposable>[];
  94572. private _activeRequests;
  94573. /** @hidden */
  94574. _pendingData: any[];
  94575. private _isDisposed;
  94576. /**
  94577. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  94578. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  94579. */
  94580. dispatchAllSubMeshesOfActiveMeshes: boolean;
  94581. private _activeMeshes;
  94582. private _processedMaterials;
  94583. private _renderTargets;
  94584. /** @hidden */
  94585. _activeParticleSystems: SmartArray<IParticleSystem>;
  94586. private _activeSkeletons;
  94587. private _softwareSkinnedMeshes;
  94588. private _renderingManager;
  94589. /** @hidden */
  94590. _activeAnimatables: Animatable[];
  94591. private _transformMatrix;
  94592. private _sceneUbo;
  94593. /** @hidden */
  94594. _viewMatrix: Matrix;
  94595. private _projectionMatrix;
  94596. /** @hidden */
  94597. _forcedViewPosition: Nullable<Vector3>;
  94598. /** @hidden */
  94599. _frustumPlanes: Plane[];
  94600. /**
  94601. * Gets the list of frustum planes (built from the active camera)
  94602. */
  94603. readonly frustumPlanes: Plane[];
  94604. /**
  94605. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  94606. * This is useful if there are more lights that the maximum simulteanous authorized
  94607. */
  94608. requireLightSorting: boolean;
  94609. /** @hidden */
  94610. readonly useMaterialMeshMap: boolean;
  94611. /** @hidden */
  94612. readonly useClonedMeshhMap: boolean;
  94613. private _externalData;
  94614. private _uid;
  94615. /**
  94616. * @hidden
  94617. * Backing store of defined scene components.
  94618. */
  94619. _components: ISceneComponent[];
  94620. /**
  94621. * @hidden
  94622. * Backing store of defined scene components.
  94623. */
  94624. _serializableComponents: ISceneSerializableComponent[];
  94625. /**
  94626. * List of components to register on the next registration step.
  94627. */
  94628. private _transientComponents;
  94629. /**
  94630. * Registers the transient components if needed.
  94631. */
  94632. private _registerTransientComponents;
  94633. /**
  94634. * @hidden
  94635. * Add a component to the scene.
  94636. * Note that the ccomponent could be registered on th next frame if this is called after
  94637. * the register component stage.
  94638. * @param component Defines the component to add to the scene
  94639. */
  94640. _addComponent(component: ISceneComponent): void;
  94641. /**
  94642. * @hidden
  94643. * Gets a component from the scene.
  94644. * @param name defines the name of the component to retrieve
  94645. * @returns the component or null if not present
  94646. */
  94647. _getComponent(name: string): Nullable<ISceneComponent>;
  94648. /**
  94649. * @hidden
  94650. * Defines the actions happening before camera updates.
  94651. */
  94652. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  94653. /**
  94654. * @hidden
  94655. * Defines the actions happening before clear the canvas.
  94656. */
  94657. _beforeClearStage: Stage<SimpleStageAction>;
  94658. /**
  94659. * @hidden
  94660. * Defines the actions when collecting render targets for the frame.
  94661. */
  94662. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  94663. /**
  94664. * @hidden
  94665. * Defines the actions happening for one camera in the frame.
  94666. */
  94667. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  94668. /**
  94669. * @hidden
  94670. * Defines the actions happening during the per mesh ready checks.
  94671. */
  94672. _isReadyForMeshStage: Stage<MeshStageAction>;
  94673. /**
  94674. * @hidden
  94675. * Defines the actions happening before evaluate active mesh checks.
  94676. */
  94677. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  94678. /**
  94679. * @hidden
  94680. * Defines the actions happening during the evaluate sub mesh checks.
  94681. */
  94682. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  94683. /**
  94684. * @hidden
  94685. * Defines the actions happening during the active mesh stage.
  94686. */
  94687. _activeMeshStage: Stage<ActiveMeshStageAction>;
  94688. /**
  94689. * @hidden
  94690. * Defines the actions happening during the per camera render target step.
  94691. */
  94692. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  94693. /**
  94694. * @hidden
  94695. * Defines the actions happening just before the active camera is drawing.
  94696. */
  94697. _beforeCameraDrawStage: Stage<CameraStageAction>;
  94698. /**
  94699. * @hidden
  94700. * Defines the actions happening just before a render target is drawing.
  94701. */
  94702. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  94703. /**
  94704. * @hidden
  94705. * Defines the actions happening just before a rendering group is drawing.
  94706. */
  94707. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  94708. /**
  94709. * @hidden
  94710. * Defines the actions happening just before a mesh is drawing.
  94711. */
  94712. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  94713. /**
  94714. * @hidden
  94715. * Defines the actions happening just after a mesh has been drawn.
  94716. */
  94717. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  94718. /**
  94719. * @hidden
  94720. * Defines the actions happening just after a rendering group has been drawn.
  94721. */
  94722. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  94723. /**
  94724. * @hidden
  94725. * Defines the actions happening just after the active camera has been drawn.
  94726. */
  94727. _afterCameraDrawStage: Stage<CameraStageAction>;
  94728. /**
  94729. * @hidden
  94730. * Defines the actions happening just after a render target has been drawn.
  94731. */
  94732. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  94733. /**
  94734. * @hidden
  94735. * Defines the actions happening just after rendering all cameras and computing intersections.
  94736. */
  94737. _afterRenderStage: Stage<SimpleStageAction>;
  94738. /**
  94739. * @hidden
  94740. * Defines the actions happening when a pointer move event happens.
  94741. */
  94742. _pointerMoveStage: Stage<PointerMoveStageAction>;
  94743. /**
  94744. * @hidden
  94745. * Defines the actions happening when a pointer down event happens.
  94746. */
  94747. _pointerDownStage: Stage<PointerUpDownStageAction>;
  94748. /**
  94749. * @hidden
  94750. * Defines the actions happening when a pointer up event happens.
  94751. */
  94752. _pointerUpStage: Stage<PointerUpDownStageAction>;
  94753. /**
  94754. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  94755. */
  94756. private geometriesByUniqueId;
  94757. /**
  94758. * Creates a new Scene
  94759. * @param engine defines the engine to use to render this scene
  94760. * @param options defines the scene options
  94761. */
  94762. constructor(engine: Engine, options?: SceneOptions);
  94763. /**
  94764. * Gets a string idenfifying the name of the class
  94765. * @returns "Scene" string
  94766. */
  94767. getClassName(): string;
  94768. private _defaultMeshCandidates;
  94769. /**
  94770. * @hidden
  94771. */
  94772. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  94773. private _defaultSubMeshCandidates;
  94774. /**
  94775. * @hidden
  94776. */
  94777. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  94778. /**
  94779. * Sets the default candidate providers for the scene.
  94780. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  94781. * and getCollidingSubMeshCandidates to their default function
  94782. */
  94783. setDefaultCandidateProviders(): void;
  94784. /**
  94785. * Gets the mesh that is currently under the pointer
  94786. */
  94787. readonly meshUnderPointer: Nullable<AbstractMesh>;
  94788. /**
  94789. * Gets or sets the current on-screen X position of the pointer
  94790. */
  94791. pointerX: number;
  94792. /**
  94793. * Gets or sets the current on-screen Y position of the pointer
  94794. */
  94795. pointerY: number;
  94796. /**
  94797. * Gets the cached material (ie. the latest rendered one)
  94798. * @returns the cached material
  94799. */
  94800. getCachedMaterial(): Nullable<Material>;
  94801. /**
  94802. * Gets the cached effect (ie. the latest rendered one)
  94803. * @returns the cached effect
  94804. */
  94805. getCachedEffect(): Nullable<Effect>;
  94806. /**
  94807. * Gets the cached visibility state (ie. the latest rendered one)
  94808. * @returns the cached visibility state
  94809. */
  94810. getCachedVisibility(): Nullable<number>;
  94811. /**
  94812. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  94813. * @param material defines the current material
  94814. * @param effect defines the current effect
  94815. * @param visibility defines the current visibility state
  94816. * @returns true if one parameter is not cached
  94817. */
  94818. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  94819. /**
  94820. * Gets the engine associated with the scene
  94821. * @returns an Engine
  94822. */
  94823. getEngine(): Engine;
  94824. /**
  94825. * Gets the total number of vertices rendered per frame
  94826. * @returns the total number of vertices rendered per frame
  94827. */
  94828. getTotalVertices(): number;
  94829. /**
  94830. * Gets the performance counter for total vertices
  94831. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  94832. */
  94833. readonly totalVerticesPerfCounter: PerfCounter;
  94834. /**
  94835. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  94836. * @returns the total number of active indices rendered per frame
  94837. */
  94838. getActiveIndices(): number;
  94839. /**
  94840. * Gets the performance counter for active indices
  94841. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  94842. */
  94843. readonly totalActiveIndicesPerfCounter: PerfCounter;
  94844. /**
  94845. * Gets the total number of active particles rendered per frame
  94846. * @returns the total number of active particles rendered per frame
  94847. */
  94848. getActiveParticles(): number;
  94849. /**
  94850. * Gets the performance counter for active particles
  94851. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  94852. */
  94853. readonly activeParticlesPerfCounter: PerfCounter;
  94854. /**
  94855. * Gets the total number of active bones rendered per frame
  94856. * @returns the total number of active bones rendered per frame
  94857. */
  94858. getActiveBones(): number;
  94859. /**
  94860. * Gets the performance counter for active bones
  94861. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  94862. */
  94863. readonly activeBonesPerfCounter: PerfCounter;
  94864. /**
  94865. * Gets the array of active meshes
  94866. * @returns an array of AbstractMesh
  94867. */
  94868. getActiveMeshes(): SmartArray<AbstractMesh>;
  94869. /**
  94870. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  94871. * @returns a number
  94872. */
  94873. getAnimationRatio(): number;
  94874. /**
  94875. * Gets an unique Id for the current render phase
  94876. * @returns a number
  94877. */
  94878. getRenderId(): number;
  94879. /**
  94880. * Gets an unique Id for the current frame
  94881. * @returns a number
  94882. */
  94883. getFrameId(): number;
  94884. /** Call this function if you want to manually increment the render Id*/
  94885. incrementRenderId(): void;
  94886. private _createUbo;
  94887. /**
  94888. * Use this method to simulate a pointer move on a mesh
  94889. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  94890. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  94891. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  94892. * @returns the current scene
  94893. */
  94894. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  94895. /**
  94896. * Use this method to simulate a pointer down on a mesh
  94897. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  94898. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  94899. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  94900. * @returns the current scene
  94901. */
  94902. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  94903. /**
  94904. * Use this method to simulate a pointer up on a mesh
  94905. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  94906. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  94907. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  94908. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  94909. * @returns the current scene
  94910. */
  94911. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  94912. /**
  94913. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  94914. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  94915. * @returns true if the pointer was captured
  94916. */
  94917. isPointerCaptured(pointerId?: number): boolean;
  94918. /**
  94919. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  94920. * @param attachUp defines if you want to attach events to pointerup
  94921. * @param attachDown defines if you want to attach events to pointerdown
  94922. * @param attachMove defines if you want to attach events to pointermove
  94923. */
  94924. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  94925. /** Detaches all event handlers*/
  94926. detachControl(): void;
  94927. /**
  94928. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  94929. * Delay loaded resources are not taking in account
  94930. * @return true if all required resources are ready
  94931. */
  94932. isReady(): boolean;
  94933. /** Resets all cached information relative to material (including effect and visibility) */
  94934. resetCachedMaterial(): void;
  94935. /**
  94936. * Registers a function to be called before every frame render
  94937. * @param func defines the function to register
  94938. */
  94939. registerBeforeRender(func: () => void): void;
  94940. /**
  94941. * Unregisters a function called before every frame render
  94942. * @param func defines the function to unregister
  94943. */
  94944. unregisterBeforeRender(func: () => void): void;
  94945. /**
  94946. * Registers a function to be called after every frame render
  94947. * @param func defines the function to register
  94948. */
  94949. registerAfterRender(func: () => void): void;
  94950. /**
  94951. * Unregisters a function called after every frame render
  94952. * @param func defines the function to unregister
  94953. */
  94954. unregisterAfterRender(func: () => void): void;
  94955. private _executeOnceBeforeRender;
  94956. /**
  94957. * The provided function will run before render once and will be disposed afterwards.
  94958. * A timeout delay can be provided so that the function will be executed in N ms.
  94959. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  94960. * @param func The function to be executed.
  94961. * @param timeout optional delay in ms
  94962. */
  94963. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  94964. /** @hidden */
  94965. _addPendingData(data: any): void;
  94966. /** @hidden */
  94967. _removePendingData(data: any): void;
  94968. /**
  94969. * Returns the number of items waiting to be loaded
  94970. * @returns the number of items waiting to be loaded
  94971. */
  94972. getWaitingItemsCount(): number;
  94973. /**
  94974. * Returns a boolean indicating if the scene is still loading data
  94975. */
  94976. readonly isLoading: boolean;
  94977. /**
  94978. * Registers a function to be executed when the scene is ready
  94979. * @param {Function} func - the function to be executed
  94980. */
  94981. executeWhenReady(func: () => void): void;
  94982. /**
  94983. * Returns a promise that resolves when the scene is ready
  94984. * @returns A promise that resolves when the scene is ready
  94985. */
  94986. whenReadyAsync(): Promise<void>;
  94987. /** @hidden */
  94988. _checkIsReady(): void;
  94989. /**
  94990. * Gets all animatable attached to the scene
  94991. */
  94992. readonly animatables: Animatable[];
  94993. /**
  94994. * Resets the last animation time frame.
  94995. * Useful to override when animations start running when loading a scene for the first time.
  94996. */
  94997. resetLastAnimationTimeFrame(): void;
  94998. /**
  94999. * Gets the current view matrix
  95000. * @returns a Matrix
  95001. */
  95002. getViewMatrix(): Matrix;
  95003. /**
  95004. * Gets the current projection matrix
  95005. * @returns a Matrix
  95006. */
  95007. getProjectionMatrix(): Matrix;
  95008. /**
  95009. * Gets the current transform matrix
  95010. * @returns a Matrix made of View * Projection
  95011. */
  95012. getTransformMatrix(): Matrix;
  95013. /**
  95014. * Sets the current transform matrix
  95015. * @param viewL defines the View matrix to use
  95016. * @param projectionL defines the Projection matrix to use
  95017. * @param viewR defines the right View matrix to use (if provided)
  95018. * @param projectionR defines the right Projection matrix to use (if provided)
  95019. */
  95020. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  95021. /**
  95022. * Gets the uniform buffer used to store scene data
  95023. * @returns a UniformBuffer
  95024. */
  95025. getSceneUniformBuffer(): UniformBuffer;
  95026. /**
  95027. * Gets an unique (relatively to the current scene) Id
  95028. * @returns an unique number for the scene
  95029. */
  95030. getUniqueId(): number;
  95031. /**
  95032. * Add a mesh to the list of scene's meshes
  95033. * @param newMesh defines the mesh to add
  95034. * @param recursive if all child meshes should also be added to the scene
  95035. */
  95036. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  95037. /**
  95038. * Remove a mesh for the list of scene's meshes
  95039. * @param toRemove defines the mesh to remove
  95040. * @param recursive if all child meshes should also be removed from the scene
  95041. * @returns the index where the mesh was in the mesh list
  95042. */
  95043. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  95044. /**
  95045. * Add a transform node to the list of scene's transform nodes
  95046. * @param newTransformNode defines the transform node to add
  95047. */
  95048. addTransformNode(newTransformNode: TransformNode): void;
  95049. /**
  95050. * Remove a transform node for the list of scene's transform nodes
  95051. * @param toRemove defines the transform node to remove
  95052. * @returns the index where the transform node was in the transform node list
  95053. */
  95054. removeTransformNode(toRemove: TransformNode): number;
  95055. /**
  95056. * Remove a skeleton for the list of scene's skeletons
  95057. * @param toRemove defines the skeleton to remove
  95058. * @returns the index where the skeleton was in the skeleton list
  95059. */
  95060. removeSkeleton(toRemove: Skeleton): number;
  95061. /**
  95062. * Remove a morph target for the list of scene's morph targets
  95063. * @param toRemove defines the morph target to remove
  95064. * @returns the index where the morph target was in the morph target list
  95065. */
  95066. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  95067. /**
  95068. * Remove a light for the list of scene's lights
  95069. * @param toRemove defines the light to remove
  95070. * @returns the index where the light was in the light list
  95071. */
  95072. removeLight(toRemove: Light): number;
  95073. /**
  95074. * Remove a camera for the list of scene's cameras
  95075. * @param toRemove defines the camera to remove
  95076. * @returns the index where the camera was in the camera list
  95077. */
  95078. removeCamera(toRemove: Camera): number;
  95079. /**
  95080. * Remove a particle system for the list of scene's particle systems
  95081. * @param toRemove defines the particle system to remove
  95082. * @returns the index where the particle system was in the particle system list
  95083. */
  95084. removeParticleSystem(toRemove: IParticleSystem): number;
  95085. /**
  95086. * Remove a animation for the list of scene's animations
  95087. * @param toRemove defines the animation to remove
  95088. * @returns the index where the animation was in the animation list
  95089. */
  95090. removeAnimation(toRemove: Animation): number;
  95091. /**
  95092. * Will stop the animation of the given target
  95093. * @param target - the target
  95094. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  95095. * @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)
  95096. */
  95097. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  95098. /**
  95099. * Removes the given animation group from this scene.
  95100. * @param toRemove The animation group to remove
  95101. * @returns The index of the removed animation group
  95102. */
  95103. removeAnimationGroup(toRemove: AnimationGroup): number;
  95104. /**
  95105. * Removes the given multi-material from this scene.
  95106. * @param toRemove The multi-material to remove
  95107. * @returns The index of the removed multi-material
  95108. */
  95109. removeMultiMaterial(toRemove: MultiMaterial): number;
  95110. /**
  95111. * Removes the given material from this scene.
  95112. * @param toRemove The material to remove
  95113. * @returns The index of the removed material
  95114. */
  95115. removeMaterial(toRemove: Material): number;
  95116. /**
  95117. * Removes the given action manager from this scene.
  95118. * @param toRemove The action manager to remove
  95119. * @returns The index of the removed action manager
  95120. */
  95121. removeActionManager(toRemove: AbstractActionManager): number;
  95122. /**
  95123. * Removes the given texture from this scene.
  95124. * @param toRemove The texture to remove
  95125. * @returns The index of the removed texture
  95126. */
  95127. removeTexture(toRemove: BaseTexture): number;
  95128. /**
  95129. * Adds the given light to this scene
  95130. * @param newLight The light to add
  95131. */
  95132. addLight(newLight: Light): void;
  95133. /**
  95134. * Sorts the list list based on light priorities
  95135. */
  95136. sortLightsByPriority(): void;
  95137. /**
  95138. * Adds the given camera to this scene
  95139. * @param newCamera The camera to add
  95140. */
  95141. addCamera(newCamera: Camera): void;
  95142. /**
  95143. * Adds the given skeleton to this scene
  95144. * @param newSkeleton The skeleton to add
  95145. */
  95146. addSkeleton(newSkeleton: Skeleton): void;
  95147. /**
  95148. * Adds the given particle system to this scene
  95149. * @param newParticleSystem The particle system to add
  95150. */
  95151. addParticleSystem(newParticleSystem: IParticleSystem): void;
  95152. /**
  95153. * Adds the given animation to this scene
  95154. * @param newAnimation The animation to add
  95155. */
  95156. addAnimation(newAnimation: Animation): void;
  95157. /**
  95158. * Adds the given animation group to this scene.
  95159. * @param newAnimationGroup The animation group to add
  95160. */
  95161. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  95162. /**
  95163. * Adds the given multi-material to this scene
  95164. * @param newMultiMaterial The multi-material to add
  95165. */
  95166. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  95167. /**
  95168. * Adds the given material to this scene
  95169. * @param newMaterial The material to add
  95170. */
  95171. addMaterial(newMaterial: Material): void;
  95172. /**
  95173. * Adds the given morph target to this scene
  95174. * @param newMorphTargetManager The morph target to add
  95175. */
  95176. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  95177. /**
  95178. * Adds the given geometry to this scene
  95179. * @param newGeometry The geometry to add
  95180. */
  95181. addGeometry(newGeometry: Geometry): void;
  95182. /**
  95183. * Adds the given action manager to this scene
  95184. * @param newActionManager The action manager to add
  95185. */
  95186. addActionManager(newActionManager: AbstractActionManager): void;
  95187. /**
  95188. * Adds the given texture to this scene.
  95189. * @param newTexture The texture to add
  95190. */
  95191. addTexture(newTexture: BaseTexture): void;
  95192. /**
  95193. * Switch active camera
  95194. * @param newCamera defines the new active camera
  95195. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  95196. */
  95197. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  95198. /**
  95199. * sets the active camera of the scene using its ID
  95200. * @param id defines the camera's ID
  95201. * @return the new active camera or null if none found.
  95202. */
  95203. setActiveCameraByID(id: string): Nullable<Camera>;
  95204. /**
  95205. * sets the active camera of the scene using its name
  95206. * @param name defines the camera's name
  95207. * @returns the new active camera or null if none found.
  95208. */
  95209. setActiveCameraByName(name: string): Nullable<Camera>;
  95210. /**
  95211. * get an animation group using its name
  95212. * @param name defines the material's name
  95213. * @return the animation group or null if none found.
  95214. */
  95215. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  95216. /**
  95217. * Get a material using its unique id
  95218. * @param uniqueId defines the material's unique id
  95219. * @return the material or null if none found.
  95220. */
  95221. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  95222. /**
  95223. * get a material using its id
  95224. * @param id defines the material's ID
  95225. * @return the material or null if none found.
  95226. */
  95227. getMaterialByID(id: string): Nullable<Material>;
  95228. /**
  95229. * Gets a material using its name
  95230. * @param name defines the material's name
  95231. * @return the material or null if none found.
  95232. */
  95233. getMaterialByName(name: string): Nullable<Material>;
  95234. /**
  95235. * Gets a camera using its id
  95236. * @param id defines the id to look for
  95237. * @returns the camera or null if not found
  95238. */
  95239. getCameraByID(id: string): Nullable<Camera>;
  95240. /**
  95241. * Gets a camera using its unique id
  95242. * @param uniqueId defines the unique id to look for
  95243. * @returns the camera or null if not found
  95244. */
  95245. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  95246. /**
  95247. * Gets a camera using its name
  95248. * @param name defines the camera's name
  95249. * @return the camera or null if none found.
  95250. */
  95251. getCameraByName(name: string): Nullable<Camera>;
  95252. /**
  95253. * Gets a bone using its id
  95254. * @param id defines the bone's id
  95255. * @return the bone or null if not found
  95256. */
  95257. getBoneByID(id: string): Nullable<Bone>;
  95258. /**
  95259. * Gets a bone using its id
  95260. * @param name defines the bone's name
  95261. * @return the bone or null if not found
  95262. */
  95263. getBoneByName(name: string): Nullable<Bone>;
  95264. /**
  95265. * Gets a light node using its name
  95266. * @param name defines the the light's name
  95267. * @return the light or null if none found.
  95268. */
  95269. getLightByName(name: string): Nullable<Light>;
  95270. /**
  95271. * Gets a light node using its id
  95272. * @param id defines the light's id
  95273. * @return the light or null if none found.
  95274. */
  95275. getLightByID(id: string): Nullable<Light>;
  95276. /**
  95277. * Gets a light node using its scene-generated unique ID
  95278. * @param uniqueId defines the light's unique id
  95279. * @return the light or null if none found.
  95280. */
  95281. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  95282. /**
  95283. * Gets a particle system by id
  95284. * @param id defines the particle system id
  95285. * @return the corresponding system or null if none found
  95286. */
  95287. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  95288. /**
  95289. * Gets a geometry using its ID
  95290. * @param id defines the geometry's id
  95291. * @return the geometry or null if none found.
  95292. */
  95293. getGeometryByID(id: string): Nullable<Geometry>;
  95294. private _getGeometryByUniqueID;
  95295. /**
  95296. * Add a new geometry to this scene
  95297. * @param geometry defines the geometry to be added to the scene.
  95298. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  95299. * @return a boolean defining if the geometry was added or not
  95300. */
  95301. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  95302. /**
  95303. * Removes an existing geometry
  95304. * @param geometry defines the geometry to be removed from the scene
  95305. * @return a boolean defining if the geometry was removed or not
  95306. */
  95307. removeGeometry(geometry: Geometry): boolean;
  95308. /**
  95309. * Gets the list of geometries attached to the scene
  95310. * @returns an array of Geometry
  95311. */
  95312. getGeometries(): Geometry[];
  95313. /**
  95314. * Gets the first added mesh found of a given ID
  95315. * @param id defines the id to search for
  95316. * @return the mesh found or null if not found at all
  95317. */
  95318. getMeshByID(id: string): Nullable<AbstractMesh>;
  95319. /**
  95320. * Gets a list of meshes using their id
  95321. * @param id defines the id to search for
  95322. * @returns a list of meshes
  95323. */
  95324. getMeshesByID(id: string): Array<AbstractMesh>;
  95325. /**
  95326. * Gets the first added transform node found of a given ID
  95327. * @param id defines the id to search for
  95328. * @return the found transform node or null if not found at all.
  95329. */
  95330. getTransformNodeByID(id: string): Nullable<TransformNode>;
  95331. /**
  95332. * Gets a transform node with its auto-generated unique id
  95333. * @param uniqueId efines the unique id to search for
  95334. * @return the found transform node or null if not found at all.
  95335. */
  95336. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  95337. /**
  95338. * Gets a list of transform nodes using their id
  95339. * @param id defines the id to search for
  95340. * @returns a list of transform nodes
  95341. */
  95342. getTransformNodesByID(id: string): Array<TransformNode>;
  95343. /**
  95344. * Gets a mesh with its auto-generated unique id
  95345. * @param uniqueId defines the unique id to search for
  95346. * @return the found mesh or null if not found at all.
  95347. */
  95348. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  95349. /**
  95350. * Gets a the last added mesh using a given id
  95351. * @param id defines the id to search for
  95352. * @return the found mesh or null if not found at all.
  95353. */
  95354. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  95355. /**
  95356. * Gets a the last added node (Mesh, Camera, Light) using a given id
  95357. * @param id defines the id to search for
  95358. * @return the found node or null if not found at all
  95359. */
  95360. getLastEntryByID(id: string): Nullable<Node>;
  95361. /**
  95362. * Gets a node (Mesh, Camera, Light) using a given id
  95363. * @param id defines the id to search for
  95364. * @return the found node or null if not found at all
  95365. */
  95366. getNodeByID(id: string): Nullable<Node>;
  95367. /**
  95368. * Gets a node (Mesh, Camera, Light) using a given name
  95369. * @param name defines the name to search for
  95370. * @return the found node or null if not found at all.
  95371. */
  95372. getNodeByName(name: string): Nullable<Node>;
  95373. /**
  95374. * Gets a mesh using a given name
  95375. * @param name defines the name to search for
  95376. * @return the found mesh or null if not found at all.
  95377. */
  95378. getMeshByName(name: string): Nullable<AbstractMesh>;
  95379. /**
  95380. * Gets a transform node using a given name
  95381. * @param name defines the name to search for
  95382. * @return the found transform node or null if not found at all.
  95383. */
  95384. getTransformNodeByName(name: string): Nullable<TransformNode>;
  95385. /**
  95386. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  95387. * @param id defines the id to search for
  95388. * @return the found skeleton or null if not found at all.
  95389. */
  95390. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  95391. /**
  95392. * Gets a skeleton using a given auto generated unique id
  95393. * @param uniqueId defines the unique id to search for
  95394. * @return the found skeleton or null if not found at all.
  95395. */
  95396. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  95397. /**
  95398. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  95399. * @param id defines the id to search for
  95400. * @return the found skeleton or null if not found at all.
  95401. */
  95402. getSkeletonById(id: string): Nullable<Skeleton>;
  95403. /**
  95404. * Gets a skeleton using a given name
  95405. * @param name defines the name to search for
  95406. * @return the found skeleton or null if not found at all.
  95407. */
  95408. getSkeletonByName(name: string): Nullable<Skeleton>;
  95409. /**
  95410. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  95411. * @param id defines the id to search for
  95412. * @return the found morph target manager or null if not found at all.
  95413. */
  95414. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  95415. /**
  95416. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  95417. * @param id defines the id to search for
  95418. * @return the found morph target or null if not found at all.
  95419. */
  95420. getMorphTargetById(id: string): Nullable<MorphTarget>;
  95421. /**
  95422. * Gets a boolean indicating if the given mesh is active
  95423. * @param mesh defines the mesh to look for
  95424. * @returns true if the mesh is in the active list
  95425. */
  95426. isActiveMesh(mesh: AbstractMesh): boolean;
  95427. /**
  95428. * Return a unique id as a string which can serve as an identifier for the scene
  95429. */
  95430. readonly uid: string;
  95431. /**
  95432. * Add an externaly attached data from its key.
  95433. * This method call will fail and return false, if such key already exists.
  95434. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  95435. * @param key the unique key that identifies the data
  95436. * @param data the data object to associate to the key for this Engine instance
  95437. * @return true if no such key were already present and the data was added successfully, false otherwise
  95438. */
  95439. addExternalData<T>(key: string, data: T): boolean;
  95440. /**
  95441. * Get an externaly attached data from its key
  95442. * @param key the unique key that identifies the data
  95443. * @return the associated data, if present (can be null), or undefined if not present
  95444. */
  95445. getExternalData<T>(key: string): Nullable<T>;
  95446. /**
  95447. * Get an externaly attached data from its key, create it using a factory if it's not already present
  95448. * @param key the unique key that identifies the data
  95449. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  95450. * @return the associated data, can be null if the factory returned null.
  95451. */
  95452. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  95453. /**
  95454. * Remove an externaly attached data from the Engine instance
  95455. * @param key the unique key that identifies the data
  95456. * @return true if the data was successfully removed, false if it doesn't exist
  95457. */
  95458. removeExternalData(key: string): boolean;
  95459. private _evaluateSubMesh;
  95460. /**
  95461. * Clear the processed materials smart array preventing retention point in material dispose.
  95462. */
  95463. freeProcessedMaterials(): void;
  95464. private _preventFreeActiveMeshesAndRenderingGroups;
  95465. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  95466. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  95467. * when disposing several meshes in a row or a hierarchy of meshes.
  95468. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  95469. */
  95470. blockfreeActiveMeshesAndRenderingGroups: boolean;
  95471. /**
  95472. * Clear the active meshes smart array preventing retention point in mesh dispose.
  95473. */
  95474. freeActiveMeshes(): void;
  95475. /**
  95476. * Clear the info related to rendering groups preventing retention points during dispose.
  95477. */
  95478. freeRenderingGroups(): void;
  95479. /** @hidden */
  95480. _isInIntermediateRendering(): boolean;
  95481. /**
  95482. * Lambda returning the list of potentially active meshes.
  95483. */
  95484. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  95485. /**
  95486. * Lambda returning the list of potentially active sub meshes.
  95487. */
  95488. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  95489. /**
  95490. * Lambda returning the list of potentially intersecting sub meshes.
  95491. */
  95492. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  95493. /**
  95494. * Lambda returning the list of potentially colliding sub meshes.
  95495. */
  95496. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  95497. private _activeMeshesFrozen;
  95498. /**
  95499. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  95500. * @returns the current scene
  95501. */
  95502. freezeActiveMeshes(): Scene;
  95503. /**
  95504. * Use this function to restart evaluating active meshes on every frame
  95505. * @returns the current scene
  95506. */
  95507. unfreezeActiveMeshes(): Scene;
  95508. private _evaluateActiveMeshes;
  95509. private _activeMesh;
  95510. /**
  95511. * Update the transform matrix to update from the current active camera
  95512. * @param force defines a boolean used to force the update even if cache is up to date
  95513. */
  95514. updateTransformMatrix(force?: boolean): void;
  95515. private _bindFrameBuffer;
  95516. /** @hidden */
  95517. _allowPostProcessClearColor: boolean;
  95518. /** @hidden */
  95519. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  95520. private _processSubCameras;
  95521. private _checkIntersections;
  95522. /** @hidden */
  95523. _advancePhysicsEngineStep(step: number): void;
  95524. /**
  95525. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  95526. */
  95527. getDeterministicFrameTime: () => number;
  95528. /** @hidden */
  95529. _animate(): void;
  95530. /** Execute all animations (for a frame) */
  95531. animate(): void;
  95532. /**
  95533. * Render the scene
  95534. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  95535. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  95536. */
  95537. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  95538. /**
  95539. * Freeze all materials
  95540. * A frozen material will not be updatable but should be faster to render
  95541. */
  95542. freezeMaterials(): void;
  95543. /**
  95544. * Unfreeze all materials
  95545. * A frozen material will not be updatable but should be faster to render
  95546. */
  95547. unfreezeMaterials(): void;
  95548. /**
  95549. * Releases all held ressources
  95550. */
  95551. dispose(): void;
  95552. /**
  95553. * Gets if the scene is already disposed
  95554. */
  95555. readonly isDisposed: boolean;
  95556. /**
  95557. * Call this function to reduce memory footprint of the scene.
  95558. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  95559. */
  95560. clearCachedVertexData(): void;
  95561. /**
  95562. * This function will remove the local cached buffer data from texture.
  95563. * It will save memory but will prevent the texture from being rebuilt
  95564. */
  95565. cleanCachedTextureBuffer(): void;
  95566. /**
  95567. * Get the world extend vectors with an optional filter
  95568. *
  95569. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  95570. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  95571. */
  95572. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  95573. min: Vector3;
  95574. max: Vector3;
  95575. };
  95576. /**
  95577. * Creates a ray that can be used to pick in the scene
  95578. * @param x defines the x coordinate of the origin (on-screen)
  95579. * @param y defines the y coordinate of the origin (on-screen)
  95580. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  95581. * @param camera defines the camera to use for the picking
  95582. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  95583. * @returns a Ray
  95584. */
  95585. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  95586. /**
  95587. * Creates a ray that can be used to pick in the scene
  95588. * @param x defines the x coordinate of the origin (on-screen)
  95589. * @param y defines the y coordinate of the origin (on-screen)
  95590. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  95591. * @param result defines the ray where to store the picking ray
  95592. * @param camera defines the camera to use for the picking
  95593. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  95594. * @returns the current scene
  95595. */
  95596. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  95597. /**
  95598. * Creates a ray that can be used to pick in the scene
  95599. * @param x defines the x coordinate of the origin (on-screen)
  95600. * @param y defines the y coordinate of the origin (on-screen)
  95601. * @param camera defines the camera to use for the picking
  95602. * @returns a Ray
  95603. */
  95604. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  95605. /**
  95606. * Creates a ray that can be used to pick in the scene
  95607. * @param x defines the x coordinate of the origin (on-screen)
  95608. * @param y defines the y coordinate of the origin (on-screen)
  95609. * @param result defines the ray where to store the picking ray
  95610. * @param camera defines the camera to use for the picking
  95611. * @returns the current scene
  95612. */
  95613. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  95614. /** Launch a ray to try to pick a mesh in the scene
  95615. * @param x position on screen
  95616. * @param y position on screen
  95617. * @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
  95618. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  95619. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  95620. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  95621. * @returns a PickingInfo
  95622. */
  95623. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: (p0: Vector3, p1: Vector3, p2: Vector3) => boolean): Nullable<PickingInfo>;
  95624. /** Use the given ray to pick a mesh in the scene
  95625. * @param ray The ray to use to pick meshes
  95626. * @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
  95627. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  95628. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  95629. * @returns a PickingInfo
  95630. */
  95631. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  95632. /**
  95633. * Launch a ray to try to pick a mesh in the scene
  95634. * @param x X position on screen
  95635. * @param y Y position on screen
  95636. * @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
  95637. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  95638. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  95639. * @returns an array of PickingInfo
  95640. */
  95641. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  95642. /**
  95643. * Launch a ray to try to pick a mesh in the scene
  95644. * @param ray Ray to use
  95645. * @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
  95646. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  95647. * @returns an array of PickingInfo
  95648. */
  95649. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  95650. /**
  95651. * Force the value of meshUnderPointer
  95652. * @param mesh defines the mesh to use
  95653. */
  95654. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  95655. /**
  95656. * Gets the mesh under the pointer
  95657. * @returns a Mesh or null if no mesh is under the pointer
  95658. */
  95659. getPointerOverMesh(): Nullable<AbstractMesh>;
  95660. /** @hidden */
  95661. _rebuildGeometries(): void;
  95662. /** @hidden */
  95663. _rebuildTextures(): void;
  95664. private _getByTags;
  95665. /**
  95666. * Get a list of meshes by tags
  95667. * @param tagsQuery defines the tags query to use
  95668. * @param forEach defines a predicate used to filter results
  95669. * @returns an array of Mesh
  95670. */
  95671. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  95672. /**
  95673. * Get a list of cameras by tags
  95674. * @param tagsQuery defines the tags query to use
  95675. * @param forEach defines a predicate used to filter results
  95676. * @returns an array of Camera
  95677. */
  95678. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  95679. /**
  95680. * Get a list of lights by tags
  95681. * @param tagsQuery defines the tags query to use
  95682. * @param forEach defines a predicate used to filter results
  95683. * @returns an array of Light
  95684. */
  95685. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  95686. /**
  95687. * Get a list of materials by tags
  95688. * @param tagsQuery defines the tags query to use
  95689. * @param forEach defines a predicate used to filter results
  95690. * @returns an array of Material
  95691. */
  95692. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  95693. /**
  95694. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  95695. * This allowed control for front to back rendering or reversly depending of the special needs.
  95696. *
  95697. * @param renderingGroupId The rendering group id corresponding to its index
  95698. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  95699. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  95700. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  95701. */
  95702. 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;
  95703. /**
  95704. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  95705. *
  95706. * @param renderingGroupId The rendering group id corresponding to its index
  95707. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  95708. * @param depth Automatically clears depth between groups if true and autoClear is true.
  95709. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  95710. */
  95711. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  95712. /**
  95713. * Gets the current auto clear configuration for one rendering group of the rendering
  95714. * manager.
  95715. * @param index the rendering group index to get the information for
  95716. * @returns The auto clear setup for the requested rendering group
  95717. */
  95718. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  95719. private _blockMaterialDirtyMechanism;
  95720. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  95721. blockMaterialDirtyMechanism: boolean;
  95722. /**
  95723. * Will flag all materials as dirty to trigger new shader compilation
  95724. * @param flag defines the flag used to specify which material part must be marked as dirty
  95725. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  95726. */
  95727. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  95728. /** @hidden */
  95729. _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;
  95730. /** @hidden */
  95731. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  95732. }
  95733. }
  95734. declare module BABYLON {
  95735. /**
  95736. * Set of assets to keep when moving a scene into an asset container.
  95737. */
  95738. export class KeepAssets extends AbstractScene {
  95739. }
  95740. /**
  95741. * Container with a set of assets that can be added or removed from a scene.
  95742. */
  95743. export class AssetContainer extends AbstractScene {
  95744. /**
  95745. * The scene the AssetContainer belongs to.
  95746. */
  95747. scene: Scene;
  95748. /**
  95749. * Instantiates an AssetContainer.
  95750. * @param scene The scene the AssetContainer belongs to.
  95751. */
  95752. constructor(scene: Scene);
  95753. /**
  95754. * Adds all the assets from the container to the scene.
  95755. */
  95756. addAllToScene(): void;
  95757. /**
  95758. * Removes all the assets in the container from the scene
  95759. */
  95760. removeAllFromScene(): void;
  95761. /**
  95762. * Disposes all the assets in the container
  95763. */
  95764. dispose(): void;
  95765. private _moveAssets;
  95766. /**
  95767. * Removes all the assets contained in the scene and adds them to the container.
  95768. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  95769. */
  95770. moveAllFromScene(keepAssets?: KeepAssets): void;
  95771. /**
  95772. * 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.
  95773. * @returns the root mesh
  95774. */
  95775. createRootMesh(): Mesh;
  95776. }
  95777. }
  95778. declare module BABYLON {
  95779. /**
  95780. * Defines how the parser contract is defined.
  95781. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  95782. */
  95783. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  95784. /**
  95785. * Defines how the individual parser contract is defined.
  95786. * These parser can parse an individual asset
  95787. */
  95788. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  95789. /**
  95790. * Base class of the scene acting as a container for the different elements composing a scene.
  95791. * This class is dynamically extended by the different components of the scene increasing
  95792. * flexibility and reducing coupling
  95793. */
  95794. export abstract class AbstractScene {
  95795. /**
  95796. * Stores the list of available parsers in the application.
  95797. */
  95798. private static _BabylonFileParsers;
  95799. /**
  95800. * Stores the list of available individual parsers in the application.
  95801. */
  95802. private static _IndividualBabylonFileParsers;
  95803. /**
  95804. * Adds a parser in the list of available ones
  95805. * @param name Defines the name of the parser
  95806. * @param parser Defines the parser to add
  95807. */
  95808. static AddParser(name: string, parser: BabylonFileParser): void;
  95809. /**
  95810. * Gets a general parser from the list of avaialble ones
  95811. * @param name Defines the name of the parser
  95812. * @returns the requested parser or null
  95813. */
  95814. static GetParser(name: string): Nullable<BabylonFileParser>;
  95815. /**
  95816. * Adds n individual parser in the list of available ones
  95817. * @param name Defines the name of the parser
  95818. * @param parser Defines the parser to add
  95819. */
  95820. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  95821. /**
  95822. * Gets an individual parser from the list of avaialble ones
  95823. * @param name Defines the name of the parser
  95824. * @returns the requested parser or null
  95825. */
  95826. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  95827. /**
  95828. * Parser json data and populate both a scene and its associated container object
  95829. * @param jsonData Defines the data to parse
  95830. * @param scene Defines the scene to parse the data for
  95831. * @param container Defines the container attached to the parsing sequence
  95832. * @param rootUrl Defines the root url of the data
  95833. */
  95834. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  95835. /**
  95836. * Gets the list of root nodes (ie. nodes with no parent)
  95837. */
  95838. rootNodes: Node[];
  95839. /** All of the cameras added to this scene
  95840. * @see http://doc.babylonjs.com/babylon101/cameras
  95841. */
  95842. cameras: Camera[];
  95843. /**
  95844. * All of the lights added to this scene
  95845. * @see http://doc.babylonjs.com/babylon101/lights
  95846. */
  95847. lights: Light[];
  95848. /**
  95849. * All of the (abstract) meshes added to this scene
  95850. */
  95851. meshes: AbstractMesh[];
  95852. /**
  95853. * The list of skeletons added to the scene
  95854. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  95855. */
  95856. skeletons: Skeleton[];
  95857. /**
  95858. * All of the particle systems added to this scene
  95859. * @see http://doc.babylonjs.com/babylon101/particles
  95860. */
  95861. particleSystems: IParticleSystem[];
  95862. /**
  95863. * Gets a list of Animations associated with the scene
  95864. */
  95865. animations: Animation[];
  95866. /**
  95867. * All of the animation groups added to this scene
  95868. * @see http://doc.babylonjs.com/how_to/group
  95869. */
  95870. animationGroups: AnimationGroup[];
  95871. /**
  95872. * All of the multi-materials added to this scene
  95873. * @see http://doc.babylonjs.com/how_to/multi_materials
  95874. */
  95875. multiMaterials: MultiMaterial[];
  95876. /**
  95877. * All of the materials added to this scene
  95878. * In the context of a Scene, it is not supposed to be modified manually.
  95879. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  95880. * Note also that the order of the Material wihin the array is not significant and might change.
  95881. * @see http://doc.babylonjs.com/babylon101/materials
  95882. */
  95883. materials: Material[];
  95884. /**
  95885. * The list of morph target managers added to the scene
  95886. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  95887. */
  95888. morphTargetManagers: MorphTargetManager[];
  95889. /**
  95890. * The list of geometries used in the scene.
  95891. */
  95892. geometries: Geometry[];
  95893. /**
  95894. * All of the tranform nodes added to this scene
  95895. * In the context of a Scene, it is not supposed to be modified manually.
  95896. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  95897. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  95898. * @see http://doc.babylonjs.com/how_to/transformnode
  95899. */
  95900. transformNodes: TransformNode[];
  95901. /**
  95902. * ActionManagers available on the scene.
  95903. */
  95904. actionManagers: AbstractActionManager[];
  95905. /**
  95906. * Textures to keep.
  95907. */
  95908. textures: BaseTexture[];
  95909. /**
  95910. * Environment texture for the scene
  95911. */
  95912. environmentTexture: Nullable<BaseTexture>;
  95913. }
  95914. }
  95915. declare module BABYLON {
  95916. /**
  95917. * Defines a sound that can be played in the application.
  95918. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  95919. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  95920. */
  95921. export class Sound {
  95922. /**
  95923. * The name of the sound in the scene.
  95924. */
  95925. name: string;
  95926. /**
  95927. * Does the sound autoplay once loaded.
  95928. */
  95929. autoplay: boolean;
  95930. /**
  95931. * Does the sound loop after it finishes playing once.
  95932. */
  95933. loop: boolean;
  95934. /**
  95935. * Does the sound use a custom attenuation curve to simulate the falloff
  95936. * happening when the source gets further away from the camera.
  95937. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  95938. */
  95939. useCustomAttenuation: boolean;
  95940. /**
  95941. * The sound track id this sound belongs to.
  95942. */
  95943. soundTrackId: number;
  95944. /**
  95945. * Is this sound currently played.
  95946. */
  95947. isPlaying: boolean;
  95948. /**
  95949. * Is this sound currently paused.
  95950. */
  95951. isPaused: boolean;
  95952. /**
  95953. * Does this sound enables spatial sound.
  95954. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  95955. */
  95956. spatialSound: boolean;
  95957. /**
  95958. * Define the reference distance the sound should be heard perfectly.
  95959. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  95960. */
  95961. refDistance: number;
  95962. /**
  95963. * Define the roll off factor of spatial sounds.
  95964. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  95965. */
  95966. rolloffFactor: number;
  95967. /**
  95968. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  95969. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  95970. */
  95971. maxDistance: number;
  95972. /**
  95973. * Define the distance attenuation model the sound will follow.
  95974. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  95975. */
  95976. distanceModel: string;
  95977. /**
  95978. * @hidden
  95979. * Back Compat
  95980. **/
  95981. onended: () => any;
  95982. /**
  95983. * Observable event when the current playing sound finishes.
  95984. */
  95985. onEndedObservable: Observable<Sound>;
  95986. private _panningModel;
  95987. private _playbackRate;
  95988. private _streaming;
  95989. private _startTime;
  95990. private _startOffset;
  95991. private _position;
  95992. /** @hidden */
  95993. _positionInEmitterSpace: boolean;
  95994. private _localDirection;
  95995. private _volume;
  95996. private _isReadyToPlay;
  95997. private _isDirectional;
  95998. private _readyToPlayCallback;
  95999. private _audioBuffer;
  96000. private _soundSource;
  96001. private _streamingSource;
  96002. private _soundPanner;
  96003. private _soundGain;
  96004. private _inputAudioNode;
  96005. private _outputAudioNode;
  96006. private _coneInnerAngle;
  96007. private _coneOuterAngle;
  96008. private _coneOuterGain;
  96009. private _scene;
  96010. private _connectedTransformNode;
  96011. private _customAttenuationFunction;
  96012. private _registerFunc;
  96013. private _isOutputConnected;
  96014. private _htmlAudioElement;
  96015. private _urlType;
  96016. /** @hidden */
  96017. static _SceneComponentInitialization: (scene: Scene) => void;
  96018. /**
  96019. * Create a sound and attach it to a scene
  96020. * @param name Name of your sound
  96021. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  96022. * @param scene defines the scene the sound belongs to
  96023. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  96024. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  96025. */
  96026. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  96027. /**
  96028. * Release the sound and its associated resources
  96029. */
  96030. dispose(): void;
  96031. /**
  96032. * Gets if the sounds is ready to be played or not.
  96033. * @returns true if ready, otherwise false
  96034. */
  96035. isReady(): boolean;
  96036. private _soundLoaded;
  96037. /**
  96038. * Sets the data of the sound from an audiobuffer
  96039. * @param audioBuffer The audioBuffer containing the data
  96040. */
  96041. setAudioBuffer(audioBuffer: AudioBuffer): void;
  96042. /**
  96043. * Updates the current sounds options such as maxdistance, loop...
  96044. * @param options A JSON object containing values named as the object properties
  96045. */
  96046. updateOptions(options: any): void;
  96047. private _createSpatialParameters;
  96048. private _updateSpatialParameters;
  96049. /**
  96050. * Switch the panning model to HRTF:
  96051. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  96052. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  96053. */
  96054. switchPanningModelToHRTF(): void;
  96055. /**
  96056. * Switch the panning model to Equal Power:
  96057. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  96058. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  96059. */
  96060. switchPanningModelToEqualPower(): void;
  96061. private _switchPanningModel;
  96062. /**
  96063. * Connect this sound to a sound track audio node like gain...
  96064. * @param soundTrackAudioNode the sound track audio node to connect to
  96065. */
  96066. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  96067. /**
  96068. * Transform this sound into a directional source
  96069. * @param coneInnerAngle Size of the inner cone in degree
  96070. * @param coneOuterAngle Size of the outer cone in degree
  96071. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  96072. */
  96073. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  96074. /**
  96075. * Gets or sets the inner angle for the directional cone.
  96076. */
  96077. /**
  96078. * Gets or sets the inner angle for the directional cone.
  96079. */
  96080. directionalConeInnerAngle: number;
  96081. /**
  96082. * Gets or sets the outer angle for the directional cone.
  96083. */
  96084. /**
  96085. * Gets or sets the outer angle for the directional cone.
  96086. */
  96087. directionalConeOuterAngle: number;
  96088. /**
  96089. * Sets the position of the emitter if spatial sound is enabled
  96090. * @param newPosition Defines the new posisiton
  96091. */
  96092. setPosition(newPosition: Vector3): void;
  96093. /**
  96094. * Sets the local direction of the emitter if spatial sound is enabled
  96095. * @param newLocalDirection Defines the new local direction
  96096. */
  96097. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  96098. private _updateDirection;
  96099. /** @hidden */
  96100. updateDistanceFromListener(): void;
  96101. /**
  96102. * Sets a new custom attenuation function for the sound.
  96103. * @param callback Defines the function used for the attenuation
  96104. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  96105. */
  96106. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  96107. /**
  96108. * Play the sound
  96109. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  96110. * @param offset (optional) Start the sound setting it at a specific time
  96111. */
  96112. play(time?: number, offset?: number): void;
  96113. private _onended;
  96114. /**
  96115. * Stop the sound
  96116. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  96117. */
  96118. stop(time?: number): void;
  96119. /**
  96120. * Put the sound in pause
  96121. */
  96122. pause(): void;
  96123. /**
  96124. * Sets a dedicated volume for this sounds
  96125. * @param newVolume Define the new volume of the sound
  96126. * @param time Define in how long the sound should be at this value
  96127. */
  96128. setVolume(newVolume: number, time?: number): void;
  96129. /**
  96130. * Set the sound play back rate
  96131. * @param newPlaybackRate Define the playback rate the sound should be played at
  96132. */
  96133. setPlaybackRate(newPlaybackRate: number): void;
  96134. /**
  96135. * Gets the volume of the sound.
  96136. * @returns the volume of the sound
  96137. */
  96138. getVolume(): number;
  96139. /**
  96140. * Attach the sound to a dedicated mesh
  96141. * @param transformNode The transform node to connect the sound with
  96142. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  96143. */
  96144. attachToMesh(transformNode: TransformNode): void;
  96145. /**
  96146. * Detach the sound from the previously attached mesh
  96147. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  96148. */
  96149. detachFromMesh(): void;
  96150. private _onRegisterAfterWorldMatrixUpdate;
  96151. /**
  96152. * Clone the current sound in the scene.
  96153. * @returns the new sound clone
  96154. */
  96155. clone(): Nullable<Sound>;
  96156. /**
  96157. * Gets the current underlying audio buffer containing the data
  96158. * @returns the audio buffer
  96159. */
  96160. getAudioBuffer(): Nullable<AudioBuffer>;
  96161. /**
  96162. * Serializes the Sound in a JSON representation
  96163. * @returns the JSON representation of the sound
  96164. */
  96165. serialize(): any;
  96166. /**
  96167. * Parse a JSON representation of a sound to innstantiate in a given scene
  96168. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  96169. * @param scene Define the scene the new parsed sound should be created in
  96170. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  96171. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  96172. * @returns the newly parsed sound
  96173. */
  96174. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  96175. }
  96176. }
  96177. declare module BABYLON {
  96178. /**
  96179. * This defines an action helpful to play a defined sound on a triggered action.
  96180. */
  96181. export class PlaySoundAction extends Action {
  96182. private _sound;
  96183. /**
  96184. * Instantiate the action
  96185. * @param triggerOptions defines the trigger options
  96186. * @param sound defines the sound to play
  96187. * @param condition defines the trigger related conditions
  96188. */
  96189. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  96190. /** @hidden */
  96191. _prepare(): void;
  96192. /**
  96193. * Execute the action and play the sound.
  96194. */
  96195. execute(): void;
  96196. /**
  96197. * Serializes the actions and its related information.
  96198. * @param parent defines the object to serialize in
  96199. * @returns the serialized object
  96200. */
  96201. serialize(parent: any): any;
  96202. }
  96203. /**
  96204. * This defines an action helpful to stop a defined sound on a triggered action.
  96205. */
  96206. export class StopSoundAction extends Action {
  96207. private _sound;
  96208. /**
  96209. * Instantiate the action
  96210. * @param triggerOptions defines the trigger options
  96211. * @param sound defines the sound to stop
  96212. * @param condition defines the trigger related conditions
  96213. */
  96214. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  96215. /** @hidden */
  96216. _prepare(): void;
  96217. /**
  96218. * Execute the action and stop the sound.
  96219. */
  96220. execute(): void;
  96221. /**
  96222. * Serializes the actions and its related information.
  96223. * @param parent defines the object to serialize in
  96224. * @returns the serialized object
  96225. */
  96226. serialize(parent: any): any;
  96227. }
  96228. }
  96229. declare module BABYLON {
  96230. /**
  96231. * This defines an action responsible to change the value of a property
  96232. * by interpolating between its current value and the newly set one once triggered.
  96233. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  96234. */
  96235. export class InterpolateValueAction extends Action {
  96236. /**
  96237. * Defines the path of the property where the value should be interpolated
  96238. */
  96239. propertyPath: string;
  96240. /**
  96241. * Defines the target value at the end of the interpolation.
  96242. */
  96243. value: any;
  96244. /**
  96245. * Defines the time it will take for the property to interpolate to the value.
  96246. */
  96247. duration: number;
  96248. /**
  96249. * Defines if the other scene animations should be stopped when the action has been triggered
  96250. */
  96251. stopOtherAnimations?: boolean;
  96252. /**
  96253. * Defines a callback raised once the interpolation animation has been done.
  96254. */
  96255. onInterpolationDone?: () => void;
  96256. /**
  96257. * Observable triggered once the interpolation animation has been done.
  96258. */
  96259. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  96260. private _target;
  96261. private _effectiveTarget;
  96262. private _property;
  96263. /**
  96264. * Instantiate the action
  96265. * @param triggerOptions defines the trigger options
  96266. * @param target defines the object containing the value to interpolate
  96267. * @param propertyPath defines the path to the property in the target object
  96268. * @param value defines the target value at the end of the interpolation
  96269. * @param duration deines the time it will take for the property to interpolate to the value.
  96270. * @param condition defines the trigger related conditions
  96271. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  96272. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  96273. */
  96274. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  96275. /** @hidden */
  96276. _prepare(): void;
  96277. /**
  96278. * Execute the action starts the value interpolation.
  96279. */
  96280. execute(): void;
  96281. /**
  96282. * Serializes the actions and its related information.
  96283. * @param parent defines the object to serialize in
  96284. * @returns the serialized object
  96285. */
  96286. serialize(parent: any): any;
  96287. }
  96288. }
  96289. declare module BABYLON {
  96290. /**
  96291. * Options allowed during the creation of a sound track.
  96292. */
  96293. export interface ISoundTrackOptions {
  96294. /**
  96295. * The volume the sound track should take during creation
  96296. */
  96297. volume?: number;
  96298. /**
  96299. * Define if the sound track is the main sound track of the scene
  96300. */
  96301. mainTrack?: boolean;
  96302. }
  96303. /**
  96304. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  96305. * It will be also used in a future release to apply effects on a specific track.
  96306. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  96307. */
  96308. export class SoundTrack {
  96309. /**
  96310. * The unique identifier of the sound track in the scene.
  96311. */
  96312. id: number;
  96313. /**
  96314. * The list of sounds included in the sound track.
  96315. */
  96316. soundCollection: Array<Sound>;
  96317. private _outputAudioNode;
  96318. private _scene;
  96319. private _isMainTrack;
  96320. private _connectedAnalyser;
  96321. private _options;
  96322. private _isInitialized;
  96323. /**
  96324. * Creates a new sound track.
  96325. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  96326. * @param scene Define the scene the sound track belongs to
  96327. * @param options
  96328. */
  96329. constructor(scene: Scene, options?: ISoundTrackOptions);
  96330. private _initializeSoundTrackAudioGraph;
  96331. /**
  96332. * Release the sound track and its associated resources
  96333. */
  96334. dispose(): void;
  96335. /**
  96336. * Adds a sound to this sound track
  96337. * @param sound define the cound to add
  96338. * @ignoreNaming
  96339. */
  96340. AddSound(sound: Sound): void;
  96341. /**
  96342. * Removes a sound to this sound track
  96343. * @param sound define the cound to remove
  96344. * @ignoreNaming
  96345. */
  96346. RemoveSound(sound: Sound): void;
  96347. /**
  96348. * Set a global volume for the full sound track.
  96349. * @param newVolume Define the new volume of the sound track
  96350. */
  96351. setVolume(newVolume: number): void;
  96352. /**
  96353. * Switch the panning model to HRTF:
  96354. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  96355. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  96356. */
  96357. switchPanningModelToHRTF(): void;
  96358. /**
  96359. * Switch the panning model to Equal Power:
  96360. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  96361. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  96362. */
  96363. switchPanningModelToEqualPower(): void;
  96364. /**
  96365. * Connect the sound track to an audio analyser allowing some amazing
  96366. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  96367. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  96368. * @param analyser The analyser to connect to the engine
  96369. */
  96370. connectToAnalyser(analyser: Analyser): void;
  96371. }
  96372. }
  96373. declare module BABYLON {
  96374. interface AbstractScene {
  96375. /**
  96376. * The list of sounds used in the scene.
  96377. */
  96378. sounds: Nullable<Array<Sound>>;
  96379. }
  96380. interface Scene {
  96381. /**
  96382. * @hidden
  96383. * Backing field
  96384. */
  96385. _mainSoundTrack: SoundTrack;
  96386. /**
  96387. * The main sound track played by the scene.
  96388. * It cotains your primary collection of sounds.
  96389. */
  96390. mainSoundTrack: SoundTrack;
  96391. /**
  96392. * The list of sound tracks added to the scene
  96393. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  96394. */
  96395. soundTracks: Nullable<Array<SoundTrack>>;
  96396. /**
  96397. * Gets a sound using a given name
  96398. * @param name defines the name to search for
  96399. * @return the found sound or null if not found at all.
  96400. */
  96401. getSoundByName(name: string): Nullable<Sound>;
  96402. /**
  96403. * Gets or sets if audio support is enabled
  96404. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  96405. */
  96406. audioEnabled: boolean;
  96407. /**
  96408. * Gets or sets if audio will be output to headphones
  96409. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  96410. */
  96411. headphone: boolean;
  96412. }
  96413. /**
  96414. * Defines the sound scene component responsible to manage any sounds
  96415. * in a given scene.
  96416. */
  96417. export class AudioSceneComponent implements ISceneSerializableComponent {
  96418. /**
  96419. * The component name helpfull to identify the component in the list of scene components.
  96420. */
  96421. readonly name: string;
  96422. /**
  96423. * The scene the component belongs to.
  96424. */
  96425. scene: Scene;
  96426. private _audioEnabled;
  96427. /**
  96428. * Gets whether audio is enabled or not.
  96429. * Please use related enable/disable method to switch state.
  96430. */
  96431. readonly audioEnabled: boolean;
  96432. private _headphone;
  96433. /**
  96434. * Gets whether audio is outputing to headphone or not.
  96435. * Please use the according Switch methods to change output.
  96436. */
  96437. readonly headphone: boolean;
  96438. /**
  96439. * Creates a new instance of the component for the given scene
  96440. * @param scene Defines the scene to register the component in
  96441. */
  96442. constructor(scene: Scene);
  96443. /**
  96444. * Registers the component in a given scene
  96445. */
  96446. register(): void;
  96447. /**
  96448. * Rebuilds the elements related to this component in case of
  96449. * context lost for instance.
  96450. */
  96451. rebuild(): void;
  96452. /**
  96453. * Serializes the component data to the specified json object
  96454. * @param serializationObject The object to serialize to
  96455. */
  96456. serialize(serializationObject: any): void;
  96457. /**
  96458. * Adds all the elements from the container to the scene
  96459. * @param container the container holding the elements
  96460. */
  96461. addFromContainer(container: AbstractScene): void;
  96462. /**
  96463. * Removes all the elements in the container from the scene
  96464. * @param container contains the elements to remove
  96465. * @param dispose if the removed element should be disposed (default: false)
  96466. */
  96467. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  96468. /**
  96469. * Disposes the component and the associated ressources.
  96470. */
  96471. dispose(): void;
  96472. /**
  96473. * Disables audio in the associated scene.
  96474. */
  96475. disableAudio(): void;
  96476. /**
  96477. * Enables audio in the associated scene.
  96478. */
  96479. enableAudio(): void;
  96480. /**
  96481. * Switch audio to headphone output.
  96482. */
  96483. switchAudioModeForHeadphones(): void;
  96484. /**
  96485. * Switch audio to normal speakers.
  96486. */
  96487. switchAudioModeForNormalSpeakers(): void;
  96488. private _afterRender;
  96489. }
  96490. }
  96491. declare module BABYLON {
  96492. /**
  96493. * Wraps one or more Sound objects and selects one with random weight for playback.
  96494. */
  96495. export class WeightedSound {
  96496. /** When true a Sound will be selected and played when the current playing Sound completes. */
  96497. loop: boolean;
  96498. private _coneInnerAngle;
  96499. private _coneOuterAngle;
  96500. private _volume;
  96501. /** A Sound is currently playing. */
  96502. isPlaying: boolean;
  96503. /** A Sound is currently paused. */
  96504. isPaused: boolean;
  96505. private _sounds;
  96506. private _weights;
  96507. private _currentIndex?;
  96508. /**
  96509. * Creates a new WeightedSound from the list of sounds given.
  96510. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  96511. * @param sounds Array of Sounds that will be selected from.
  96512. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  96513. */
  96514. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  96515. /**
  96516. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  96517. */
  96518. /**
  96519. * The size of cone in degress for a directional sound in which there will be no attenuation.
  96520. */
  96521. directionalConeInnerAngle: number;
  96522. /**
  96523. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  96524. * Listener angles between innerAngle and outerAngle will falloff linearly.
  96525. */
  96526. /**
  96527. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  96528. * Listener angles between innerAngle and outerAngle will falloff linearly.
  96529. */
  96530. directionalConeOuterAngle: number;
  96531. /**
  96532. * Playback volume.
  96533. */
  96534. /**
  96535. * Playback volume.
  96536. */
  96537. volume: number;
  96538. private _onended;
  96539. /**
  96540. * Suspend playback
  96541. */
  96542. pause(): void;
  96543. /**
  96544. * Stop playback
  96545. */
  96546. stop(): void;
  96547. /**
  96548. * Start playback.
  96549. * @param startOffset Position the clip head at a specific time in seconds.
  96550. */
  96551. play(startOffset?: number): void;
  96552. }
  96553. }
  96554. declare module BABYLON {
  96555. /**
  96556. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  96557. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  96558. */
  96559. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  96560. /**
  96561. * Gets the name of the behavior.
  96562. */
  96563. readonly name: string;
  96564. /**
  96565. * The easing function used by animations
  96566. */
  96567. static EasingFunction: BackEase;
  96568. /**
  96569. * The easing mode used by animations
  96570. */
  96571. static EasingMode: number;
  96572. /**
  96573. * The duration of the animation, in milliseconds
  96574. */
  96575. transitionDuration: number;
  96576. /**
  96577. * Length of the distance animated by the transition when lower radius is reached
  96578. */
  96579. lowerRadiusTransitionRange: number;
  96580. /**
  96581. * Length of the distance animated by the transition when upper radius is reached
  96582. */
  96583. upperRadiusTransitionRange: number;
  96584. private _autoTransitionRange;
  96585. /**
  96586. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  96587. */
  96588. /**
  96589. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  96590. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  96591. */
  96592. autoTransitionRange: boolean;
  96593. private _attachedCamera;
  96594. private _onAfterCheckInputsObserver;
  96595. private _onMeshTargetChangedObserver;
  96596. /**
  96597. * Initializes the behavior.
  96598. */
  96599. init(): void;
  96600. /**
  96601. * Attaches the behavior to its arc rotate camera.
  96602. * @param camera Defines the camera to attach the behavior to
  96603. */
  96604. attach(camera: ArcRotateCamera): void;
  96605. /**
  96606. * Detaches the behavior from its current arc rotate camera.
  96607. */
  96608. detach(): void;
  96609. private _radiusIsAnimating;
  96610. private _radiusBounceTransition;
  96611. private _animatables;
  96612. private _cachedWheelPrecision;
  96613. /**
  96614. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  96615. * @param radiusLimit The limit to check against.
  96616. * @return Bool to indicate if at limit.
  96617. */
  96618. private _isRadiusAtLimit;
  96619. /**
  96620. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  96621. * @param radiusDelta The delta by which to animate to. Can be negative.
  96622. */
  96623. private _applyBoundRadiusAnimation;
  96624. /**
  96625. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  96626. */
  96627. protected _clearAnimationLocks(): void;
  96628. /**
  96629. * Stops and removes all animations that have been applied to the camera
  96630. */
  96631. stopAllAnimations(): void;
  96632. }
  96633. }
  96634. declare module BABYLON {
  96635. /**
  96636. * 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.
  96637. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  96638. */
  96639. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  96640. /**
  96641. * Gets the name of the behavior.
  96642. */
  96643. readonly name: string;
  96644. private _mode;
  96645. private _radiusScale;
  96646. private _positionScale;
  96647. private _defaultElevation;
  96648. private _elevationReturnTime;
  96649. private _elevationReturnWaitTime;
  96650. private _zoomStopsAnimation;
  96651. private _framingTime;
  96652. /**
  96653. * The easing function used by animations
  96654. */
  96655. static EasingFunction: ExponentialEase;
  96656. /**
  96657. * The easing mode used by animations
  96658. */
  96659. static EasingMode: number;
  96660. /**
  96661. * Sets the current mode used by the behavior
  96662. */
  96663. /**
  96664. * Gets current mode used by the behavior.
  96665. */
  96666. mode: number;
  96667. /**
  96668. * Sets the scale applied to the radius (1 by default)
  96669. */
  96670. /**
  96671. * Gets the scale applied to the radius
  96672. */
  96673. radiusScale: number;
  96674. /**
  96675. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  96676. */
  96677. /**
  96678. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  96679. */
  96680. positionScale: number;
  96681. /**
  96682. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  96683. * behaviour is triggered, in radians.
  96684. */
  96685. /**
  96686. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  96687. * behaviour is triggered, in radians.
  96688. */
  96689. defaultElevation: number;
  96690. /**
  96691. * Sets the time (in milliseconds) taken to return to the default beta position.
  96692. * Negative value indicates camera should not return to default.
  96693. */
  96694. /**
  96695. * Gets the time (in milliseconds) taken to return to the default beta position.
  96696. * Negative value indicates camera should not return to default.
  96697. */
  96698. elevationReturnTime: number;
  96699. /**
  96700. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  96701. */
  96702. /**
  96703. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  96704. */
  96705. elevationReturnWaitTime: number;
  96706. /**
  96707. * Sets the flag that indicates if user zooming should stop animation.
  96708. */
  96709. /**
  96710. * Gets the flag that indicates if user zooming should stop animation.
  96711. */
  96712. zoomStopsAnimation: boolean;
  96713. /**
  96714. * Sets the transition time when framing the mesh, in milliseconds
  96715. */
  96716. /**
  96717. * Gets the transition time when framing the mesh, in milliseconds
  96718. */
  96719. framingTime: number;
  96720. /**
  96721. * Define if the behavior should automatically change the configured
  96722. * camera limits and sensibilities.
  96723. */
  96724. autoCorrectCameraLimitsAndSensibility: boolean;
  96725. private _onPrePointerObservableObserver;
  96726. private _onAfterCheckInputsObserver;
  96727. private _onMeshTargetChangedObserver;
  96728. private _attachedCamera;
  96729. private _isPointerDown;
  96730. private _lastInteractionTime;
  96731. /**
  96732. * Initializes the behavior.
  96733. */
  96734. init(): void;
  96735. /**
  96736. * Attaches the behavior to its arc rotate camera.
  96737. * @param camera Defines the camera to attach the behavior to
  96738. */
  96739. attach(camera: ArcRotateCamera): void;
  96740. /**
  96741. * Detaches the behavior from its current arc rotate camera.
  96742. */
  96743. detach(): void;
  96744. private _animatables;
  96745. private _betaIsAnimating;
  96746. private _betaTransition;
  96747. private _radiusTransition;
  96748. private _vectorTransition;
  96749. /**
  96750. * Targets the given mesh and updates zoom level accordingly.
  96751. * @param mesh The mesh to target.
  96752. * @param radius Optional. If a cached radius position already exists, overrides default.
  96753. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  96754. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  96755. * @param onAnimationEnd Callback triggered at the end of the framing animation
  96756. */
  96757. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  96758. /**
  96759. * Targets the given mesh with its children and updates zoom level accordingly.
  96760. * @param mesh The mesh to target.
  96761. * @param radius Optional. If a cached radius position already exists, overrides default.
  96762. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  96763. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  96764. * @param onAnimationEnd Callback triggered at the end of the framing animation
  96765. */
  96766. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  96767. /**
  96768. * Targets the given meshes with their children and updates zoom level accordingly.
  96769. * @param meshes The mesh to target.
  96770. * @param radius Optional. If a cached radius position already exists, overrides default.
  96771. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  96772. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  96773. * @param onAnimationEnd Callback triggered at the end of the framing animation
  96774. */
  96775. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  96776. /**
  96777. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  96778. * @param minimumWorld Determines the smaller position of the bounding box extend
  96779. * @param maximumWorld Determines the bigger position of the bounding box extend
  96780. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  96781. * @param onAnimationEnd Callback triggered at the end of the framing animation
  96782. */
  96783. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  96784. /**
  96785. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  96786. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  96787. * frustum width.
  96788. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  96789. * to fully enclose the mesh in the viewing frustum.
  96790. */
  96791. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  96792. /**
  96793. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  96794. * is automatically returned to its default position (expected to be above ground plane).
  96795. */
  96796. private _maintainCameraAboveGround;
  96797. /**
  96798. * Returns the frustum slope based on the canvas ratio and camera FOV
  96799. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  96800. */
  96801. private _getFrustumSlope;
  96802. /**
  96803. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  96804. */
  96805. private _clearAnimationLocks;
  96806. /**
  96807. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  96808. */
  96809. private _applyUserInteraction;
  96810. /**
  96811. * Stops and removes all animations that have been applied to the camera
  96812. */
  96813. stopAllAnimations(): void;
  96814. /**
  96815. * Gets a value indicating if the user is moving the camera
  96816. */
  96817. readonly isUserIsMoving: boolean;
  96818. /**
  96819. * The camera can move all the way towards the mesh.
  96820. */
  96821. static IgnoreBoundsSizeMode: number;
  96822. /**
  96823. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  96824. */
  96825. static FitFrustumSidesMode: number;
  96826. }
  96827. }
  96828. declare module BABYLON {
  96829. /**
  96830. * Base class for Camera Pointer Inputs.
  96831. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  96832. * for example usage.
  96833. */
  96834. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  96835. /**
  96836. * Defines the camera the input is attached to.
  96837. */
  96838. abstract camera: Camera;
  96839. /**
  96840. * Whether keyboard modifier keys are pressed at time of last mouse event.
  96841. */
  96842. protected _altKey: boolean;
  96843. protected _ctrlKey: boolean;
  96844. protected _metaKey: boolean;
  96845. protected _shiftKey: boolean;
  96846. /**
  96847. * Which mouse buttons were pressed at time of last mouse event.
  96848. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  96849. */
  96850. protected _buttonsPressed: number;
  96851. /**
  96852. * Defines the buttons associated with the input to handle camera move.
  96853. */
  96854. buttons: number[];
  96855. /**
  96856. * Attach the input controls to a specific dom element to get the input from.
  96857. * @param element Defines the element the controls should be listened from
  96858. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96859. */
  96860. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96861. /**
  96862. * Detach the current controls from the specified dom element.
  96863. * @param element Defines the element to stop listening the inputs from
  96864. */
  96865. detachControl(element: Nullable<HTMLElement>): void;
  96866. /**
  96867. * Gets the class name of the current input.
  96868. * @returns the class name
  96869. */
  96870. getClassName(): string;
  96871. /**
  96872. * Get the friendly name associated with the input class.
  96873. * @returns the input friendly name
  96874. */
  96875. getSimpleName(): string;
  96876. /**
  96877. * Called on pointer POINTERDOUBLETAP event.
  96878. * Override this method to provide functionality on POINTERDOUBLETAP event.
  96879. */
  96880. protected onDoubleTap(type: string): void;
  96881. /**
  96882. * Called on pointer POINTERMOVE event if only a single touch is active.
  96883. * Override this method to provide functionality.
  96884. */
  96885. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  96886. /**
  96887. * Called on pointer POINTERMOVE event if multiple touches are active.
  96888. * Override this method to provide functionality.
  96889. */
  96890. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  96891. /**
  96892. * Called on JS contextmenu event.
  96893. * Override this method to provide functionality.
  96894. */
  96895. protected onContextMenu(evt: PointerEvent): void;
  96896. /**
  96897. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  96898. * press.
  96899. * Override this method to provide functionality.
  96900. */
  96901. protected onButtonDown(evt: PointerEvent): void;
  96902. /**
  96903. * Called each time a new POINTERUP event occurs. Ie, for each button
  96904. * release.
  96905. * Override this method to provide functionality.
  96906. */
  96907. protected onButtonUp(evt: PointerEvent): void;
  96908. /**
  96909. * Called when window becomes inactive.
  96910. * Override this method to provide functionality.
  96911. */
  96912. protected onLostFocus(): void;
  96913. private _pointerInput;
  96914. private _observer;
  96915. private _onLostFocus;
  96916. private pointA;
  96917. private pointB;
  96918. }
  96919. }
  96920. declare module BABYLON {
  96921. /**
  96922. * Manage the pointers inputs to control an arc rotate camera.
  96923. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96924. */
  96925. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  96926. /**
  96927. * Defines the camera the input is attached to.
  96928. */
  96929. camera: ArcRotateCamera;
  96930. /**
  96931. * Gets the class name of the current input.
  96932. * @returns the class name
  96933. */
  96934. getClassName(): string;
  96935. /**
  96936. * Defines the buttons associated with the input to handle camera move.
  96937. */
  96938. buttons: number[];
  96939. /**
  96940. * Defines the pointer angular sensibility along the X axis or how fast is
  96941. * the camera rotating.
  96942. */
  96943. angularSensibilityX: number;
  96944. /**
  96945. * Defines the pointer angular sensibility along the Y axis or how fast is
  96946. * the camera rotating.
  96947. */
  96948. angularSensibilityY: number;
  96949. /**
  96950. * Defines the pointer pinch precision or how fast is the camera zooming.
  96951. */
  96952. pinchPrecision: number;
  96953. /**
  96954. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  96955. * from 0.
  96956. * It defines the percentage of current camera.radius to use as delta when
  96957. * pinch zoom is used.
  96958. */
  96959. pinchDeltaPercentage: number;
  96960. /**
  96961. * Defines the pointer panning sensibility or how fast is the camera moving.
  96962. */
  96963. panningSensibility: number;
  96964. /**
  96965. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  96966. */
  96967. multiTouchPanning: boolean;
  96968. /**
  96969. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  96970. * zoom (pinch) through multitouch.
  96971. */
  96972. multiTouchPanAndZoom: boolean;
  96973. /**
  96974. * Revers pinch action direction.
  96975. */
  96976. pinchInwards: boolean;
  96977. private _isPanClick;
  96978. private _twoFingerActivityCount;
  96979. private _isPinching;
  96980. /**
  96981. * Called on pointer POINTERMOVE event if only a single touch is active.
  96982. */
  96983. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  96984. /**
  96985. * Called on pointer POINTERDOUBLETAP event.
  96986. */
  96987. protected onDoubleTap(type: string): void;
  96988. /**
  96989. * Called on pointer POINTERMOVE event if multiple touches are active.
  96990. */
  96991. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  96992. /**
  96993. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  96994. * press.
  96995. */
  96996. protected onButtonDown(evt: PointerEvent): void;
  96997. /**
  96998. * Called each time a new POINTERUP event occurs. Ie, for each button
  96999. * release.
  97000. */
  97001. protected onButtonUp(evt: PointerEvent): void;
  97002. /**
  97003. * Called when window becomes inactive.
  97004. */
  97005. protected onLostFocus(): void;
  97006. }
  97007. }
  97008. declare module BABYLON {
  97009. /**
  97010. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  97011. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  97012. */
  97013. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  97014. /**
  97015. * Defines the camera the input is attached to.
  97016. */
  97017. camera: ArcRotateCamera;
  97018. /**
  97019. * Defines the list of key codes associated with the up action (increase alpha)
  97020. */
  97021. keysUp: number[];
  97022. /**
  97023. * Defines the list of key codes associated with the down action (decrease alpha)
  97024. */
  97025. keysDown: number[];
  97026. /**
  97027. * Defines the list of key codes associated with the left action (increase beta)
  97028. */
  97029. keysLeft: number[];
  97030. /**
  97031. * Defines the list of key codes associated with the right action (decrease beta)
  97032. */
  97033. keysRight: number[];
  97034. /**
  97035. * Defines the list of key codes associated with the reset action.
  97036. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  97037. */
  97038. keysReset: number[];
  97039. /**
  97040. * Defines the panning sensibility of the inputs.
  97041. * (How fast is the camera paning)
  97042. */
  97043. panningSensibility: number;
  97044. /**
  97045. * Defines the zooming sensibility of the inputs.
  97046. * (How fast is the camera zooming)
  97047. */
  97048. zoomingSensibility: number;
  97049. /**
  97050. * Defines wether maintaining the alt key down switch the movement mode from
  97051. * orientation to zoom.
  97052. */
  97053. useAltToZoom: boolean;
  97054. /**
  97055. * Rotation speed of the camera
  97056. */
  97057. angularSpeed: number;
  97058. private _keys;
  97059. private _ctrlPressed;
  97060. private _altPressed;
  97061. private _onCanvasBlurObserver;
  97062. private _onKeyboardObserver;
  97063. private _engine;
  97064. private _scene;
  97065. /**
  97066. * Attach the input controls to a specific dom element to get the input from.
  97067. * @param element Defines the element the controls should be listened from
  97068. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  97069. */
  97070. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  97071. /**
  97072. * Detach the current controls from the specified dom element.
  97073. * @param element Defines the element to stop listening the inputs from
  97074. */
  97075. detachControl(element: Nullable<HTMLElement>): void;
  97076. /**
  97077. * Update the current camera state depending on the inputs that have been used this frame.
  97078. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  97079. */
  97080. checkInputs(): void;
  97081. /**
  97082. * Gets the class name of the current intput.
  97083. * @returns the class name
  97084. */
  97085. getClassName(): string;
  97086. /**
  97087. * Get the friendly name associated with the input class.
  97088. * @returns the input friendly name
  97089. */
  97090. getSimpleName(): string;
  97091. }
  97092. }
  97093. declare module BABYLON {
  97094. /**
  97095. * Manage the mouse wheel inputs to control an arc rotate camera.
  97096. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  97097. */
  97098. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  97099. /**
  97100. * Defines the camera the input is attached to.
  97101. */
  97102. camera: ArcRotateCamera;
  97103. /**
  97104. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  97105. */
  97106. wheelPrecision: number;
  97107. /**
  97108. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  97109. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  97110. */
  97111. wheelDeltaPercentage: number;
  97112. private _wheel;
  97113. private _observer;
  97114. private computeDeltaFromMouseWheelLegacyEvent;
  97115. /**
  97116. * Attach the input controls to a specific dom element to get the input from.
  97117. * @param element Defines the element the controls should be listened from
  97118. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  97119. */
  97120. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  97121. /**
  97122. * Detach the current controls from the specified dom element.
  97123. * @param element Defines the element to stop listening the inputs from
  97124. */
  97125. detachControl(element: Nullable<HTMLElement>): void;
  97126. /**
  97127. * Gets the class name of the current intput.
  97128. * @returns the class name
  97129. */
  97130. getClassName(): string;
  97131. /**
  97132. * Get the friendly name associated with the input class.
  97133. * @returns the input friendly name
  97134. */
  97135. getSimpleName(): string;
  97136. }
  97137. }
  97138. declare module BABYLON {
  97139. /**
  97140. * Default Inputs manager for the ArcRotateCamera.
  97141. * It groups all the default supported inputs for ease of use.
  97142. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  97143. */
  97144. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  97145. /**
  97146. * Instantiates a new ArcRotateCameraInputsManager.
  97147. * @param camera Defines the camera the inputs belong to
  97148. */
  97149. constructor(camera: ArcRotateCamera);
  97150. /**
  97151. * Add mouse wheel input support to the input manager.
  97152. * @returns the current input manager
  97153. */
  97154. addMouseWheel(): ArcRotateCameraInputsManager;
  97155. /**
  97156. * Add pointers input support to the input manager.
  97157. * @returns the current input manager
  97158. */
  97159. addPointers(): ArcRotateCameraInputsManager;
  97160. /**
  97161. * Add keyboard input support to the input manager.
  97162. * @returns the current input manager
  97163. */
  97164. addKeyboard(): ArcRotateCameraInputsManager;
  97165. }
  97166. }
  97167. declare module BABYLON {
  97168. /**
  97169. * This represents an orbital type of camera.
  97170. *
  97171. * 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.
  97172. * 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.
  97173. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  97174. */
  97175. export class ArcRotateCamera extends TargetCamera {
  97176. /**
  97177. * Defines the rotation angle of the camera along the longitudinal axis.
  97178. */
  97179. alpha: number;
  97180. /**
  97181. * Defines the rotation angle of the camera along the latitudinal axis.
  97182. */
  97183. beta: number;
  97184. /**
  97185. * Defines the radius of the camera from it s target point.
  97186. */
  97187. radius: number;
  97188. protected _target: Vector3;
  97189. protected _targetHost: Nullable<AbstractMesh>;
  97190. /**
  97191. * Defines the target point of the camera.
  97192. * The camera looks towards it form the radius distance.
  97193. */
  97194. target: Vector3;
  97195. /**
  97196. * Define the current local position of the camera in the scene
  97197. */
  97198. position: Vector3;
  97199. protected _upVector: Vector3;
  97200. protected _upToYMatrix: Matrix;
  97201. protected _YToUpMatrix: Matrix;
  97202. /**
  97203. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  97204. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  97205. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  97206. */
  97207. upVector: Vector3;
  97208. /**
  97209. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  97210. */
  97211. setMatUp(): void;
  97212. /**
  97213. * Current inertia value on the longitudinal axis.
  97214. * The bigger this number the longer it will take for the camera to stop.
  97215. */
  97216. inertialAlphaOffset: number;
  97217. /**
  97218. * Current inertia value on the latitudinal axis.
  97219. * The bigger this number the longer it will take for the camera to stop.
  97220. */
  97221. inertialBetaOffset: number;
  97222. /**
  97223. * Current inertia value on the radius axis.
  97224. * The bigger this number the longer it will take for the camera to stop.
  97225. */
  97226. inertialRadiusOffset: number;
  97227. /**
  97228. * Minimum allowed angle on the longitudinal axis.
  97229. * This can help limiting how the Camera is able to move in the scene.
  97230. */
  97231. lowerAlphaLimit: Nullable<number>;
  97232. /**
  97233. * Maximum allowed angle on the longitudinal axis.
  97234. * This can help limiting how the Camera is able to move in the scene.
  97235. */
  97236. upperAlphaLimit: Nullable<number>;
  97237. /**
  97238. * Minimum allowed angle on the latitudinal axis.
  97239. * This can help limiting how the Camera is able to move in the scene.
  97240. */
  97241. lowerBetaLimit: number;
  97242. /**
  97243. * Maximum allowed angle on the latitudinal axis.
  97244. * This can help limiting how the Camera is able to move in the scene.
  97245. */
  97246. upperBetaLimit: number;
  97247. /**
  97248. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  97249. * This can help limiting how the Camera is able to move in the scene.
  97250. */
  97251. lowerRadiusLimit: Nullable<number>;
  97252. /**
  97253. * Maximum allowed distance of the camera to the target (The camera can not get further).
  97254. * This can help limiting how the Camera is able to move in the scene.
  97255. */
  97256. upperRadiusLimit: Nullable<number>;
  97257. /**
  97258. * Defines the current inertia value used during panning of the camera along the X axis.
  97259. */
  97260. inertialPanningX: number;
  97261. /**
  97262. * Defines the current inertia value used during panning of the camera along the Y axis.
  97263. */
  97264. inertialPanningY: number;
  97265. /**
  97266. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  97267. * Basically if your fingers moves away from more than this distance you will be considered
  97268. * in pinch mode.
  97269. */
  97270. pinchToPanMaxDistance: number;
  97271. /**
  97272. * Defines the maximum distance the camera can pan.
  97273. * This could help keeping the cammera always in your scene.
  97274. */
  97275. panningDistanceLimit: Nullable<number>;
  97276. /**
  97277. * Defines the target of the camera before paning.
  97278. */
  97279. panningOriginTarget: Vector3;
  97280. /**
  97281. * Defines the value of the inertia used during panning.
  97282. * 0 would mean stop inertia and one would mean no decelleration at all.
  97283. */
  97284. panningInertia: number;
  97285. /**
  97286. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  97287. */
  97288. angularSensibilityX: number;
  97289. /**
  97290. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  97291. */
  97292. angularSensibilityY: number;
  97293. /**
  97294. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  97295. */
  97296. pinchPrecision: number;
  97297. /**
  97298. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  97299. * It will be used instead of pinchDeltaPrecision if different from 0.
  97300. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  97301. */
  97302. pinchDeltaPercentage: number;
  97303. /**
  97304. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  97305. */
  97306. panningSensibility: number;
  97307. /**
  97308. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  97309. */
  97310. keysUp: number[];
  97311. /**
  97312. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  97313. */
  97314. keysDown: number[];
  97315. /**
  97316. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  97317. */
  97318. keysLeft: number[];
  97319. /**
  97320. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  97321. */
  97322. keysRight: number[];
  97323. /**
  97324. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  97325. */
  97326. wheelPrecision: number;
  97327. /**
  97328. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  97329. * It will be used instead of pinchDeltaPrecision if different from 0.
  97330. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  97331. */
  97332. wheelDeltaPercentage: number;
  97333. /**
  97334. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  97335. */
  97336. zoomOnFactor: number;
  97337. /**
  97338. * Defines a screen offset for the camera position.
  97339. */
  97340. targetScreenOffset: Vector2;
  97341. /**
  97342. * Allows the camera to be completely reversed.
  97343. * If false the camera can not arrive upside down.
  97344. */
  97345. allowUpsideDown: boolean;
  97346. /**
  97347. * Define if double tap/click is used to restore the previously saved state of the camera.
  97348. */
  97349. useInputToRestoreState: boolean;
  97350. /** @hidden */
  97351. _viewMatrix: Matrix;
  97352. /** @hidden */
  97353. _useCtrlForPanning: boolean;
  97354. /** @hidden */
  97355. _panningMouseButton: number;
  97356. /**
  97357. * Defines the input associated to the camera.
  97358. */
  97359. inputs: ArcRotateCameraInputsManager;
  97360. /** @hidden */
  97361. _reset: () => void;
  97362. /**
  97363. * Defines the allowed panning axis.
  97364. */
  97365. panningAxis: Vector3;
  97366. protected _localDirection: Vector3;
  97367. protected _transformedDirection: Vector3;
  97368. private _bouncingBehavior;
  97369. /**
  97370. * Gets the bouncing behavior of the camera if it has been enabled.
  97371. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  97372. */
  97373. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  97374. /**
  97375. * Defines if the bouncing behavior of the camera is enabled on the camera.
  97376. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  97377. */
  97378. useBouncingBehavior: boolean;
  97379. private _framingBehavior;
  97380. /**
  97381. * Gets the framing behavior of the camera if it has been enabled.
  97382. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  97383. */
  97384. readonly framingBehavior: Nullable<FramingBehavior>;
  97385. /**
  97386. * Defines if the framing behavior of the camera is enabled on the camera.
  97387. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  97388. */
  97389. useFramingBehavior: boolean;
  97390. private _autoRotationBehavior;
  97391. /**
  97392. * Gets the auto rotation behavior of the camera if it has been enabled.
  97393. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  97394. */
  97395. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  97396. /**
  97397. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  97398. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  97399. */
  97400. useAutoRotationBehavior: boolean;
  97401. /**
  97402. * Observable triggered when the mesh target has been changed on the camera.
  97403. */
  97404. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  97405. /**
  97406. * Event raised when the camera is colliding with a mesh.
  97407. */
  97408. onCollide: (collidedMesh: AbstractMesh) => void;
  97409. /**
  97410. * Defines whether the camera should check collision with the objects oh the scene.
  97411. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  97412. */
  97413. checkCollisions: boolean;
  97414. /**
  97415. * Defines the collision radius of the camera.
  97416. * This simulates a sphere around the camera.
  97417. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  97418. */
  97419. collisionRadius: Vector3;
  97420. protected _collider: Collider;
  97421. protected _previousPosition: Vector3;
  97422. protected _collisionVelocity: Vector3;
  97423. protected _newPosition: Vector3;
  97424. protected _previousAlpha: number;
  97425. protected _previousBeta: number;
  97426. protected _previousRadius: number;
  97427. protected _collisionTriggered: boolean;
  97428. protected _targetBoundingCenter: Nullable<Vector3>;
  97429. private _computationVector;
  97430. /**
  97431. * Instantiates a new ArcRotateCamera in a given scene
  97432. * @param name Defines the name of the camera
  97433. * @param alpha Defines the camera rotation along the logitudinal axis
  97434. * @param beta Defines the camera rotation along the latitudinal axis
  97435. * @param radius Defines the camera distance from its target
  97436. * @param target Defines the camera target
  97437. * @param scene Defines the scene the camera belongs to
  97438. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  97439. */
  97440. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  97441. /** @hidden */
  97442. _initCache(): void;
  97443. /** @hidden */
  97444. _updateCache(ignoreParentClass?: boolean): void;
  97445. protected _getTargetPosition(): Vector3;
  97446. private _storedAlpha;
  97447. private _storedBeta;
  97448. private _storedRadius;
  97449. private _storedTarget;
  97450. /**
  97451. * Stores the current state of the camera (alpha, beta, radius and target)
  97452. * @returns the camera itself
  97453. */
  97454. storeState(): Camera;
  97455. /**
  97456. * @hidden
  97457. * Restored camera state. You must call storeState() first
  97458. */
  97459. _restoreStateValues(): boolean;
  97460. /** @hidden */
  97461. _isSynchronizedViewMatrix(): boolean;
  97462. /**
  97463. * Attached controls to the current camera.
  97464. * @param element Defines the element the controls should be listened from
  97465. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  97466. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  97467. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  97468. */
  97469. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  97470. /**
  97471. * Detach the current controls from the camera.
  97472. * The camera will stop reacting to inputs.
  97473. * @param element Defines the element to stop listening the inputs from
  97474. */
  97475. detachControl(element: HTMLElement): void;
  97476. /** @hidden */
  97477. _checkInputs(): void;
  97478. protected _checkLimits(): void;
  97479. /**
  97480. * Rebuilds angles (alpha, beta) and radius from the give position and target
  97481. */
  97482. rebuildAnglesAndRadius(): void;
  97483. /**
  97484. * Use a position to define the current camera related information like aplha, beta and radius
  97485. * @param position Defines the position to set the camera at
  97486. */
  97487. setPosition(position: Vector3): void;
  97488. /**
  97489. * Defines the target the camera should look at.
  97490. * This will automatically adapt alpha beta and radius to fit within the new target.
  97491. * @param target Defines the new target as a Vector or a mesh
  97492. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  97493. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  97494. */
  97495. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  97496. /** @hidden */
  97497. _getViewMatrix(): Matrix;
  97498. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  97499. /**
  97500. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  97501. * @param meshes Defines the mesh to zoom on
  97502. * @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)
  97503. */
  97504. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  97505. /**
  97506. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  97507. * The target will be changed but the radius
  97508. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  97509. * @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)
  97510. */
  97511. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  97512. min: Vector3;
  97513. max: Vector3;
  97514. distance: number;
  97515. }, doNotUpdateMaxZ?: boolean): void;
  97516. /**
  97517. * @override
  97518. * Override Camera.createRigCamera
  97519. */
  97520. createRigCamera(name: string, cameraIndex: number): Camera;
  97521. /**
  97522. * @hidden
  97523. * @override
  97524. * Override Camera._updateRigCameras
  97525. */
  97526. _updateRigCameras(): void;
  97527. /**
  97528. * Destroy the camera and release the current resources hold by it.
  97529. */
  97530. dispose(): void;
  97531. /**
  97532. * Gets the current object class name.
  97533. * @return the class name
  97534. */
  97535. getClassName(): string;
  97536. }
  97537. }
  97538. declare module BABYLON {
  97539. /**
  97540. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  97541. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  97542. */
  97543. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  97544. /**
  97545. * Gets the name of the behavior.
  97546. */
  97547. readonly name: string;
  97548. private _zoomStopsAnimation;
  97549. private _idleRotationSpeed;
  97550. private _idleRotationWaitTime;
  97551. private _idleRotationSpinupTime;
  97552. /**
  97553. * Sets the flag that indicates if user zooming should stop animation.
  97554. */
  97555. /**
  97556. * Gets the flag that indicates if user zooming should stop animation.
  97557. */
  97558. zoomStopsAnimation: boolean;
  97559. /**
  97560. * Sets the default speed at which the camera rotates around the model.
  97561. */
  97562. /**
  97563. * Gets the default speed at which the camera rotates around the model.
  97564. */
  97565. idleRotationSpeed: number;
  97566. /**
  97567. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  97568. */
  97569. /**
  97570. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  97571. */
  97572. idleRotationWaitTime: number;
  97573. /**
  97574. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  97575. */
  97576. /**
  97577. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  97578. */
  97579. idleRotationSpinupTime: number;
  97580. /**
  97581. * Gets a value indicating if the camera is currently rotating because of this behavior
  97582. */
  97583. readonly rotationInProgress: boolean;
  97584. private _onPrePointerObservableObserver;
  97585. private _onAfterCheckInputsObserver;
  97586. private _attachedCamera;
  97587. private _isPointerDown;
  97588. private _lastFrameTime;
  97589. private _lastInteractionTime;
  97590. private _cameraRotationSpeed;
  97591. /**
  97592. * Initializes the behavior.
  97593. */
  97594. init(): void;
  97595. /**
  97596. * Attaches the behavior to its arc rotate camera.
  97597. * @param camera Defines the camera to attach the behavior to
  97598. */
  97599. attach(camera: ArcRotateCamera): void;
  97600. /**
  97601. * Detaches the behavior from its current arc rotate camera.
  97602. */
  97603. detach(): void;
  97604. /**
  97605. * Returns true if user is scrolling.
  97606. * @return true if user is scrolling.
  97607. */
  97608. private _userIsZooming;
  97609. private _lastFrameRadius;
  97610. private _shouldAnimationStopForInteraction;
  97611. /**
  97612. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  97613. */
  97614. private _applyUserInteraction;
  97615. private _userIsMoving;
  97616. }
  97617. }
  97618. declare module BABYLON {
  97619. /**
  97620. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  97621. */
  97622. export class AttachToBoxBehavior implements Behavior<Mesh> {
  97623. private ui;
  97624. /**
  97625. * The name of the behavior
  97626. */
  97627. name: string;
  97628. /**
  97629. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  97630. */
  97631. distanceAwayFromFace: number;
  97632. /**
  97633. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  97634. */
  97635. distanceAwayFromBottomOfFace: number;
  97636. private _faceVectors;
  97637. private _target;
  97638. private _scene;
  97639. private _onRenderObserver;
  97640. private _tmpMatrix;
  97641. private _tmpVector;
  97642. /**
  97643. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  97644. * @param ui The transform node that should be attched to the mesh
  97645. */
  97646. constructor(ui: TransformNode);
  97647. /**
  97648. * Initializes the behavior
  97649. */
  97650. init(): void;
  97651. private _closestFace;
  97652. private _zeroVector;
  97653. private _lookAtTmpMatrix;
  97654. private _lookAtToRef;
  97655. /**
  97656. * Attaches the AttachToBoxBehavior to the passed in mesh
  97657. * @param target The mesh that the specified node will be attached to
  97658. */
  97659. attach(target: Mesh): void;
  97660. /**
  97661. * Detaches the behavior from the mesh
  97662. */
  97663. detach(): void;
  97664. }
  97665. }
  97666. declare module BABYLON {
  97667. /**
  97668. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  97669. */
  97670. export class FadeInOutBehavior implements Behavior<Mesh> {
  97671. /**
  97672. * Time in milliseconds to delay before fading in (Default: 0)
  97673. */
  97674. delay: number;
  97675. /**
  97676. * Time in milliseconds for the mesh to fade in (Default: 300)
  97677. */
  97678. fadeInTime: number;
  97679. private _millisecondsPerFrame;
  97680. private _hovered;
  97681. private _hoverValue;
  97682. private _ownerNode;
  97683. /**
  97684. * Instatiates the FadeInOutBehavior
  97685. */
  97686. constructor();
  97687. /**
  97688. * The name of the behavior
  97689. */
  97690. readonly name: string;
  97691. /**
  97692. * Initializes the behavior
  97693. */
  97694. init(): void;
  97695. /**
  97696. * Attaches the fade behavior on the passed in mesh
  97697. * @param ownerNode The mesh that will be faded in/out once attached
  97698. */
  97699. attach(ownerNode: Mesh): void;
  97700. /**
  97701. * Detaches the behavior from the mesh
  97702. */
  97703. detach(): void;
  97704. /**
  97705. * Triggers the mesh to begin fading in or out
  97706. * @param value if the object should fade in or out (true to fade in)
  97707. */
  97708. fadeIn(value: boolean): void;
  97709. private _update;
  97710. private _setAllVisibility;
  97711. }
  97712. }
  97713. declare module BABYLON {
  97714. /**
  97715. * Class containing a set of static utilities functions for managing Pivots
  97716. * @hidden
  97717. */
  97718. export class PivotTools {
  97719. private static _PivotCached;
  97720. private static _OldPivotPoint;
  97721. private static _PivotTranslation;
  97722. private static _PivotTmpVector;
  97723. /** @hidden */
  97724. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  97725. /** @hidden */
  97726. static _RestorePivotPoint(mesh: AbstractMesh): void;
  97727. }
  97728. }
  97729. declare module BABYLON {
  97730. /**
  97731. * Class containing static functions to help procedurally build meshes
  97732. */
  97733. export class PlaneBuilder {
  97734. /**
  97735. * Creates a plane mesh
  97736. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  97737. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  97738. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  97739. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  97740. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  97741. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  97742. * @param name defines the name of the mesh
  97743. * @param options defines the options used to create the mesh
  97744. * @param scene defines the hosting scene
  97745. * @returns the plane mesh
  97746. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  97747. */
  97748. static CreatePlane(name: string, options: {
  97749. size?: number;
  97750. width?: number;
  97751. height?: number;
  97752. sideOrientation?: number;
  97753. frontUVs?: Vector4;
  97754. backUVs?: Vector4;
  97755. updatable?: boolean;
  97756. sourcePlane?: Plane;
  97757. }, scene?: Nullable<Scene>): Mesh;
  97758. }
  97759. }
  97760. declare module BABYLON {
  97761. /**
  97762. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  97763. */
  97764. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  97765. private static _AnyMouseID;
  97766. /**
  97767. * Abstract mesh the behavior is set on
  97768. */
  97769. attachedNode: AbstractMesh;
  97770. private _dragPlane;
  97771. private _scene;
  97772. private _pointerObserver;
  97773. private _beforeRenderObserver;
  97774. private static _planeScene;
  97775. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  97776. /**
  97777. * 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)
  97778. */
  97779. maxDragAngle: number;
  97780. /**
  97781. * @hidden
  97782. */
  97783. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  97784. /**
  97785. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  97786. */
  97787. currentDraggingPointerID: number;
  97788. /**
  97789. * The last position where the pointer hit the drag plane in world space
  97790. */
  97791. lastDragPosition: Vector3;
  97792. /**
  97793. * If the behavior is currently in a dragging state
  97794. */
  97795. dragging: boolean;
  97796. /**
  97797. * 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)
  97798. */
  97799. dragDeltaRatio: number;
  97800. /**
  97801. * If the drag plane orientation should be updated during the dragging (Default: true)
  97802. */
  97803. updateDragPlane: boolean;
  97804. private _debugMode;
  97805. private _moving;
  97806. /**
  97807. * Fires each time the attached mesh is dragged with the pointer
  97808. * * delta between last drag position and current drag position in world space
  97809. * * dragDistance along the drag axis
  97810. * * dragPlaneNormal normal of the current drag plane used during the drag
  97811. * * dragPlanePoint in world space where the drag intersects the drag plane
  97812. */
  97813. onDragObservable: Observable<{
  97814. delta: Vector3;
  97815. dragPlanePoint: Vector3;
  97816. dragPlaneNormal: Vector3;
  97817. dragDistance: number;
  97818. pointerId: number;
  97819. }>;
  97820. /**
  97821. * Fires each time a drag begins (eg. mouse down on mesh)
  97822. */
  97823. onDragStartObservable: Observable<{
  97824. dragPlanePoint: Vector3;
  97825. pointerId: number;
  97826. }>;
  97827. /**
  97828. * Fires each time a drag ends (eg. mouse release after drag)
  97829. */
  97830. onDragEndObservable: Observable<{
  97831. dragPlanePoint: Vector3;
  97832. pointerId: number;
  97833. }>;
  97834. /**
  97835. * If the attached mesh should be moved when dragged
  97836. */
  97837. moveAttached: boolean;
  97838. /**
  97839. * If the drag behavior will react to drag events (Default: true)
  97840. */
  97841. enabled: boolean;
  97842. /**
  97843. * If camera controls should be detached during the drag
  97844. */
  97845. detachCameraControls: boolean;
  97846. /**
  97847. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  97848. */
  97849. useObjectOrienationForDragging: boolean;
  97850. private _options;
  97851. /**
  97852. * Creates a pointer drag behavior that can be attached to a mesh
  97853. * @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)
  97854. */
  97855. constructor(options?: {
  97856. dragAxis?: Vector3;
  97857. dragPlaneNormal?: Vector3;
  97858. });
  97859. /**
  97860. * Predicate to determine if it is valid to move the object to a new position when it is moved
  97861. */
  97862. validateDrag: (targetPosition: Vector3) => boolean;
  97863. /**
  97864. * The name of the behavior
  97865. */
  97866. readonly name: string;
  97867. /**
  97868. * Initializes the behavior
  97869. */
  97870. init(): void;
  97871. private _tmpVector;
  97872. private _alternatePickedPoint;
  97873. private _worldDragAxis;
  97874. private _targetPosition;
  97875. private _attachedElement;
  97876. /**
  97877. * Attaches the drag behavior the passed in mesh
  97878. * @param ownerNode The mesh that will be dragged around once attached
  97879. */
  97880. attach(ownerNode: AbstractMesh): void;
  97881. /**
  97882. * Force relase the drag action by code.
  97883. */
  97884. releaseDrag(): void;
  97885. private _startDragRay;
  97886. private _lastPointerRay;
  97887. /**
  97888. * Simulates the start of a pointer drag event on the behavior
  97889. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  97890. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  97891. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  97892. */
  97893. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  97894. private _startDrag;
  97895. private _dragDelta;
  97896. private _moveDrag;
  97897. private _pickWithRayOnDragPlane;
  97898. private _pointA;
  97899. private _pointB;
  97900. private _pointC;
  97901. private _lineA;
  97902. private _lineB;
  97903. private _localAxis;
  97904. private _lookAt;
  97905. private _updateDragPlanePosition;
  97906. /**
  97907. * Detaches the behavior from the mesh
  97908. */
  97909. detach(): void;
  97910. }
  97911. }
  97912. declare module BABYLON {
  97913. /**
  97914. * A behavior that when attached to a mesh will allow the mesh to be scaled
  97915. */
  97916. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  97917. private _dragBehaviorA;
  97918. private _dragBehaviorB;
  97919. private _startDistance;
  97920. private _initialScale;
  97921. private _targetScale;
  97922. private _ownerNode;
  97923. private _sceneRenderObserver;
  97924. /**
  97925. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  97926. */
  97927. constructor();
  97928. /**
  97929. * The name of the behavior
  97930. */
  97931. readonly name: string;
  97932. /**
  97933. * Initializes the behavior
  97934. */
  97935. init(): void;
  97936. private _getCurrentDistance;
  97937. /**
  97938. * Attaches the scale behavior the passed in mesh
  97939. * @param ownerNode The mesh that will be scaled around once attached
  97940. */
  97941. attach(ownerNode: Mesh): void;
  97942. /**
  97943. * Detaches the behavior from the mesh
  97944. */
  97945. detach(): void;
  97946. }
  97947. }
  97948. declare module BABYLON {
  97949. /**
  97950. * 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
  97951. */
  97952. export class SixDofDragBehavior implements Behavior<Mesh> {
  97953. private static _virtualScene;
  97954. private _ownerNode;
  97955. private _sceneRenderObserver;
  97956. private _scene;
  97957. private _targetPosition;
  97958. private _virtualOriginMesh;
  97959. private _virtualDragMesh;
  97960. private _pointerObserver;
  97961. private _moving;
  97962. private _startingOrientation;
  97963. /**
  97964. * 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)
  97965. */
  97966. private zDragFactor;
  97967. /**
  97968. * If the object should rotate to face the drag origin
  97969. */
  97970. rotateDraggedObject: boolean;
  97971. /**
  97972. * If the behavior is currently in a dragging state
  97973. */
  97974. dragging: boolean;
  97975. /**
  97976. * 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)
  97977. */
  97978. dragDeltaRatio: number;
  97979. /**
  97980. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  97981. */
  97982. currentDraggingPointerID: number;
  97983. /**
  97984. * If camera controls should be detached during the drag
  97985. */
  97986. detachCameraControls: boolean;
  97987. /**
  97988. * Fires each time a drag starts
  97989. */
  97990. onDragStartObservable: Observable<{}>;
  97991. /**
  97992. * Fires each time a drag ends (eg. mouse release after drag)
  97993. */
  97994. onDragEndObservable: Observable<{}>;
  97995. /**
  97996. * 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
  97997. */
  97998. constructor();
  97999. /**
  98000. * The name of the behavior
  98001. */
  98002. readonly name: string;
  98003. /**
  98004. * Initializes the behavior
  98005. */
  98006. init(): void;
  98007. /**
  98008. * Attaches the scale behavior the passed in mesh
  98009. * @param ownerNode The mesh that will be scaled around once attached
  98010. */
  98011. attach(ownerNode: Mesh): void;
  98012. /**
  98013. * Detaches the behavior from the mesh
  98014. */
  98015. detach(): void;
  98016. }
  98017. }
  98018. declare module BABYLON {
  98019. /**
  98020. * Class used to apply inverse kinematics to bones
  98021. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  98022. */
  98023. export class BoneIKController {
  98024. private static _tmpVecs;
  98025. private static _tmpQuat;
  98026. private static _tmpMats;
  98027. /**
  98028. * Gets or sets the target mesh
  98029. */
  98030. targetMesh: AbstractMesh;
  98031. /** Gets or sets the mesh used as pole */
  98032. poleTargetMesh: AbstractMesh;
  98033. /**
  98034. * Gets or sets the bone used as pole
  98035. */
  98036. poleTargetBone: Nullable<Bone>;
  98037. /**
  98038. * Gets or sets the target position
  98039. */
  98040. targetPosition: Vector3;
  98041. /**
  98042. * Gets or sets the pole target position
  98043. */
  98044. poleTargetPosition: Vector3;
  98045. /**
  98046. * Gets or sets the pole target local offset
  98047. */
  98048. poleTargetLocalOffset: Vector3;
  98049. /**
  98050. * Gets or sets the pole angle
  98051. */
  98052. poleAngle: number;
  98053. /**
  98054. * Gets or sets the mesh associated with the controller
  98055. */
  98056. mesh: AbstractMesh;
  98057. /**
  98058. * 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)
  98059. */
  98060. slerpAmount: number;
  98061. private _bone1Quat;
  98062. private _bone1Mat;
  98063. private _bone2Ang;
  98064. private _bone1;
  98065. private _bone2;
  98066. private _bone1Length;
  98067. private _bone2Length;
  98068. private _maxAngle;
  98069. private _maxReach;
  98070. private _rightHandedSystem;
  98071. private _bendAxis;
  98072. private _slerping;
  98073. private _adjustRoll;
  98074. /**
  98075. * Gets or sets maximum allowed angle
  98076. */
  98077. maxAngle: number;
  98078. /**
  98079. * Creates a new BoneIKController
  98080. * @param mesh defines the mesh to control
  98081. * @param bone defines the bone to control
  98082. * @param options defines options to set up the controller
  98083. */
  98084. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  98085. targetMesh?: AbstractMesh;
  98086. poleTargetMesh?: AbstractMesh;
  98087. poleTargetBone?: Bone;
  98088. poleTargetLocalOffset?: Vector3;
  98089. poleAngle?: number;
  98090. bendAxis?: Vector3;
  98091. maxAngle?: number;
  98092. slerpAmount?: number;
  98093. });
  98094. private _setMaxAngle;
  98095. /**
  98096. * Force the controller to update the bones
  98097. */
  98098. update(): void;
  98099. }
  98100. }
  98101. declare module BABYLON {
  98102. /**
  98103. * Class used to make a bone look toward a point in space
  98104. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  98105. */
  98106. export class BoneLookController {
  98107. private static _tmpVecs;
  98108. private static _tmpQuat;
  98109. private static _tmpMats;
  98110. /**
  98111. * The target Vector3 that the bone will look at
  98112. */
  98113. target: Vector3;
  98114. /**
  98115. * The mesh that the bone is attached to
  98116. */
  98117. mesh: AbstractMesh;
  98118. /**
  98119. * The bone that will be looking to the target
  98120. */
  98121. bone: Bone;
  98122. /**
  98123. * The up axis of the coordinate system that is used when the bone is rotated
  98124. */
  98125. upAxis: Vector3;
  98126. /**
  98127. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  98128. */
  98129. upAxisSpace: Space;
  98130. /**
  98131. * Used to make an adjustment to the yaw of the bone
  98132. */
  98133. adjustYaw: number;
  98134. /**
  98135. * Used to make an adjustment to the pitch of the bone
  98136. */
  98137. adjustPitch: number;
  98138. /**
  98139. * Used to make an adjustment to the roll of the bone
  98140. */
  98141. adjustRoll: number;
  98142. /**
  98143. * 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)
  98144. */
  98145. slerpAmount: number;
  98146. private _minYaw;
  98147. private _maxYaw;
  98148. private _minPitch;
  98149. private _maxPitch;
  98150. private _minYawSin;
  98151. private _minYawCos;
  98152. private _maxYawSin;
  98153. private _maxYawCos;
  98154. private _midYawConstraint;
  98155. private _minPitchTan;
  98156. private _maxPitchTan;
  98157. private _boneQuat;
  98158. private _slerping;
  98159. private _transformYawPitch;
  98160. private _transformYawPitchInv;
  98161. private _firstFrameSkipped;
  98162. private _yawRange;
  98163. private _fowardAxis;
  98164. /**
  98165. * Gets or sets the minimum yaw angle that the bone can look to
  98166. */
  98167. minYaw: number;
  98168. /**
  98169. * Gets or sets the maximum yaw angle that the bone can look to
  98170. */
  98171. maxYaw: number;
  98172. /**
  98173. * Gets or sets the minimum pitch angle that the bone can look to
  98174. */
  98175. minPitch: number;
  98176. /**
  98177. * Gets or sets the maximum pitch angle that the bone can look to
  98178. */
  98179. maxPitch: number;
  98180. /**
  98181. * Create a BoneLookController
  98182. * @param mesh the mesh that the bone belongs to
  98183. * @param bone the bone that will be looking to the target
  98184. * @param target the target Vector3 to look at
  98185. * @param options optional settings:
  98186. * * maxYaw: the maximum angle the bone will yaw to
  98187. * * minYaw: the minimum angle the bone will yaw to
  98188. * * maxPitch: the maximum angle the bone will pitch to
  98189. * * minPitch: the minimum angle the bone will yaw to
  98190. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  98191. * * upAxis: the up axis of the coordinate system
  98192. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  98193. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  98194. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  98195. * * adjustYaw: used to make an adjustment to the yaw of the bone
  98196. * * adjustPitch: used to make an adjustment to the pitch of the bone
  98197. * * adjustRoll: used to make an adjustment to the roll of the bone
  98198. **/
  98199. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  98200. maxYaw?: number;
  98201. minYaw?: number;
  98202. maxPitch?: number;
  98203. minPitch?: number;
  98204. slerpAmount?: number;
  98205. upAxis?: Vector3;
  98206. upAxisSpace?: Space;
  98207. yawAxis?: Vector3;
  98208. pitchAxis?: Vector3;
  98209. adjustYaw?: number;
  98210. adjustPitch?: number;
  98211. adjustRoll?: number;
  98212. });
  98213. /**
  98214. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  98215. */
  98216. update(): void;
  98217. private _getAngleDiff;
  98218. private _getAngleBetween;
  98219. private _isAngleBetween;
  98220. }
  98221. }
  98222. declare module BABYLON {
  98223. /**
  98224. * Manage the gamepad inputs to control an arc rotate camera.
  98225. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  98226. */
  98227. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  98228. /**
  98229. * Defines the camera the input is attached to.
  98230. */
  98231. camera: ArcRotateCamera;
  98232. /**
  98233. * Defines the gamepad the input is gathering event from.
  98234. */
  98235. gamepad: Nullable<Gamepad>;
  98236. /**
  98237. * Defines the gamepad rotation sensiblity.
  98238. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  98239. */
  98240. gamepadRotationSensibility: number;
  98241. /**
  98242. * Defines the gamepad move sensiblity.
  98243. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  98244. */
  98245. gamepadMoveSensibility: number;
  98246. private _onGamepadConnectedObserver;
  98247. private _onGamepadDisconnectedObserver;
  98248. /**
  98249. * Attach the input controls to a specific dom element to get the input from.
  98250. * @param element Defines the element the controls should be listened from
  98251. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  98252. */
  98253. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  98254. /**
  98255. * Detach the current controls from the specified dom element.
  98256. * @param element Defines the element to stop listening the inputs from
  98257. */
  98258. detachControl(element: Nullable<HTMLElement>): void;
  98259. /**
  98260. * Update the current camera state depending on the inputs that have been used this frame.
  98261. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  98262. */
  98263. checkInputs(): void;
  98264. /**
  98265. * Gets the class name of the current intput.
  98266. * @returns the class name
  98267. */
  98268. getClassName(): string;
  98269. /**
  98270. * Get the friendly name associated with the input class.
  98271. * @returns the input friendly name
  98272. */
  98273. getSimpleName(): string;
  98274. }
  98275. }
  98276. declare module BABYLON {
  98277. interface ArcRotateCameraInputsManager {
  98278. /**
  98279. * Add orientation input support to the input manager.
  98280. * @returns the current input manager
  98281. */
  98282. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  98283. }
  98284. /**
  98285. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  98286. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  98287. */
  98288. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  98289. /**
  98290. * Defines the camera the input is attached to.
  98291. */
  98292. camera: ArcRotateCamera;
  98293. /**
  98294. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  98295. */
  98296. alphaCorrection: number;
  98297. /**
  98298. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  98299. */
  98300. gammaCorrection: number;
  98301. private _alpha;
  98302. private _gamma;
  98303. private _dirty;
  98304. private _deviceOrientationHandler;
  98305. /**
  98306. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  98307. */
  98308. constructor();
  98309. /**
  98310. * Attach the input controls to a specific dom element to get the input from.
  98311. * @param element Defines the element the controls should be listened from
  98312. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  98313. */
  98314. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  98315. /** @hidden */
  98316. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  98317. /**
  98318. * Update the current camera state depending on the inputs that have been used this frame.
  98319. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  98320. */
  98321. checkInputs(): void;
  98322. /**
  98323. * Detach the current controls from the specified dom element.
  98324. * @param element Defines the element to stop listening the inputs from
  98325. */
  98326. detachControl(element: Nullable<HTMLElement>): void;
  98327. /**
  98328. * Gets the class name of the current intput.
  98329. * @returns the class name
  98330. */
  98331. getClassName(): string;
  98332. /**
  98333. * Get the friendly name associated with the input class.
  98334. * @returns the input friendly name
  98335. */
  98336. getSimpleName(): string;
  98337. }
  98338. }
  98339. declare module BABYLON {
  98340. /**
  98341. * Listen to mouse events to control the camera.
  98342. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  98343. */
  98344. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  98345. /**
  98346. * Defines the camera the input is attached to.
  98347. */
  98348. camera: FlyCamera;
  98349. /**
  98350. * Defines if touch is enabled. (Default is true.)
  98351. */
  98352. touchEnabled: boolean;
  98353. /**
  98354. * Defines the buttons associated with the input to handle camera rotation.
  98355. */
  98356. buttons: number[];
  98357. /**
  98358. * Assign buttons for Yaw control.
  98359. */
  98360. buttonsYaw: number[];
  98361. /**
  98362. * Assign buttons for Pitch control.
  98363. */
  98364. buttonsPitch: number[];
  98365. /**
  98366. * Assign buttons for Roll control.
  98367. */
  98368. buttonsRoll: number[];
  98369. /**
  98370. * Detect if any button is being pressed while mouse is moved.
  98371. * -1 = Mouse locked.
  98372. * 0 = Left button.
  98373. * 1 = Middle Button.
  98374. * 2 = Right Button.
  98375. */
  98376. activeButton: number;
  98377. /**
  98378. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  98379. * Higher values reduce its sensitivity.
  98380. */
  98381. angularSensibility: number;
  98382. private _mousemoveCallback;
  98383. private _observer;
  98384. private _rollObserver;
  98385. private previousPosition;
  98386. private noPreventDefault;
  98387. private element;
  98388. /**
  98389. * Listen to mouse events to control the camera.
  98390. * @param touchEnabled Define if touch is enabled. (Default is true.)
  98391. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  98392. */
  98393. constructor(touchEnabled?: boolean);
  98394. /**
  98395. * Attach the mouse control to the HTML DOM element.
  98396. * @param element Defines the element that listens to the input events.
  98397. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  98398. */
  98399. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  98400. /**
  98401. * Detach the current controls from the specified dom element.
  98402. * @param element Defines the element to stop listening the inputs from
  98403. */
  98404. detachControl(element: Nullable<HTMLElement>): void;
  98405. /**
  98406. * Gets the class name of the current input.
  98407. * @returns the class name.
  98408. */
  98409. getClassName(): string;
  98410. /**
  98411. * Get the friendly name associated with the input class.
  98412. * @returns the input's friendly name.
  98413. */
  98414. getSimpleName(): string;
  98415. private _pointerInput;
  98416. private _onMouseMove;
  98417. /**
  98418. * Rotate camera by mouse offset.
  98419. */
  98420. private rotateCamera;
  98421. }
  98422. }
  98423. declare module BABYLON {
  98424. /**
  98425. * Default Inputs manager for the FlyCamera.
  98426. * It groups all the default supported inputs for ease of use.
  98427. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  98428. */
  98429. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  98430. /**
  98431. * Instantiates a new FlyCameraInputsManager.
  98432. * @param camera Defines the camera the inputs belong to.
  98433. */
  98434. constructor(camera: FlyCamera);
  98435. /**
  98436. * Add keyboard input support to the input manager.
  98437. * @returns the new FlyCameraKeyboardMoveInput().
  98438. */
  98439. addKeyboard(): FlyCameraInputsManager;
  98440. /**
  98441. * Add mouse input support to the input manager.
  98442. * @param touchEnabled Enable touch screen support.
  98443. * @returns the new FlyCameraMouseInput().
  98444. */
  98445. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  98446. }
  98447. }
  98448. declare module BABYLON {
  98449. /**
  98450. * This is a flying camera, designed for 3D movement and rotation in all directions,
  98451. * such as in a 3D Space Shooter or a Flight Simulator.
  98452. */
  98453. export class FlyCamera extends TargetCamera {
  98454. /**
  98455. * Define the collision ellipsoid of the camera.
  98456. * This is helpful for simulating a camera body, like a player's body.
  98457. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  98458. */
  98459. ellipsoid: Vector3;
  98460. /**
  98461. * Define an offset for the position of the ellipsoid around the camera.
  98462. * This can be helpful if the camera is attached away from the player's body center,
  98463. * such as at its head.
  98464. */
  98465. ellipsoidOffset: Vector3;
  98466. /**
  98467. * Enable or disable collisions of the camera with the rest of the scene objects.
  98468. */
  98469. checkCollisions: boolean;
  98470. /**
  98471. * Enable or disable gravity on the camera.
  98472. */
  98473. applyGravity: boolean;
  98474. /**
  98475. * Define the current direction the camera is moving to.
  98476. */
  98477. cameraDirection: Vector3;
  98478. /**
  98479. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  98480. * This overrides and empties cameraRotation.
  98481. */
  98482. rotationQuaternion: Quaternion;
  98483. /**
  98484. * Track Roll to maintain the wanted Rolling when looking around.
  98485. */
  98486. _trackRoll: number;
  98487. /**
  98488. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  98489. */
  98490. rollCorrect: number;
  98491. /**
  98492. * Mimic a banked turn, Rolling the camera when Yawing.
  98493. * It's recommended to use rollCorrect = 10 for faster banking correction.
  98494. */
  98495. bankedTurn: boolean;
  98496. /**
  98497. * Limit in radians for how much Roll banking will add. (Default: 90°)
  98498. */
  98499. bankedTurnLimit: number;
  98500. /**
  98501. * Value of 0 disables the banked Roll.
  98502. * Value of 1 is equal to the Yaw angle in radians.
  98503. */
  98504. bankedTurnMultiplier: number;
  98505. /**
  98506. * The inputs manager loads all the input sources, such as keyboard and mouse.
  98507. */
  98508. inputs: FlyCameraInputsManager;
  98509. /**
  98510. * Gets the input sensibility for mouse input.
  98511. * Higher values reduce sensitivity.
  98512. */
  98513. /**
  98514. * Sets the input sensibility for a mouse input.
  98515. * Higher values reduce sensitivity.
  98516. */
  98517. angularSensibility: number;
  98518. /**
  98519. * Get the keys for camera movement forward.
  98520. */
  98521. /**
  98522. * Set the keys for camera movement forward.
  98523. */
  98524. keysForward: number[];
  98525. /**
  98526. * Get the keys for camera movement backward.
  98527. */
  98528. keysBackward: number[];
  98529. /**
  98530. * Get the keys for camera movement up.
  98531. */
  98532. /**
  98533. * Set the keys for camera movement up.
  98534. */
  98535. keysUp: number[];
  98536. /**
  98537. * Get the keys for camera movement down.
  98538. */
  98539. /**
  98540. * Set the keys for camera movement down.
  98541. */
  98542. keysDown: number[];
  98543. /**
  98544. * Get the keys for camera movement left.
  98545. */
  98546. /**
  98547. * Set the keys for camera movement left.
  98548. */
  98549. keysLeft: number[];
  98550. /**
  98551. * Set the keys for camera movement right.
  98552. */
  98553. /**
  98554. * Set the keys for camera movement right.
  98555. */
  98556. keysRight: number[];
  98557. /**
  98558. * Event raised when the camera collides with a mesh in the scene.
  98559. */
  98560. onCollide: (collidedMesh: AbstractMesh) => void;
  98561. private _collider;
  98562. private _needMoveForGravity;
  98563. private _oldPosition;
  98564. private _diffPosition;
  98565. private _newPosition;
  98566. /** @hidden */
  98567. _localDirection: Vector3;
  98568. /** @hidden */
  98569. _transformedDirection: Vector3;
  98570. /**
  98571. * Instantiates a FlyCamera.
  98572. * This is a flying camera, designed for 3D movement and rotation in all directions,
  98573. * such as in a 3D Space Shooter or a Flight Simulator.
  98574. * @param name Define the name of the camera in the scene.
  98575. * @param position Define the starting position of the camera in the scene.
  98576. * @param scene Define the scene the camera belongs to.
  98577. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  98578. */
  98579. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  98580. /**
  98581. * Attach a control to the HTML DOM element.
  98582. * @param element Defines the element that listens to the input events.
  98583. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  98584. */
  98585. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  98586. /**
  98587. * Detach a control from the HTML DOM element.
  98588. * The camera will stop reacting to that input.
  98589. * @param element Defines the element that listens to the input events.
  98590. */
  98591. detachControl(element: HTMLElement): void;
  98592. private _collisionMask;
  98593. /**
  98594. * Get the mask that the camera ignores in collision events.
  98595. */
  98596. /**
  98597. * Set the mask that the camera ignores in collision events.
  98598. */
  98599. collisionMask: number;
  98600. /** @hidden */
  98601. _collideWithWorld(displacement: Vector3): void;
  98602. /** @hidden */
  98603. private _onCollisionPositionChange;
  98604. /** @hidden */
  98605. _checkInputs(): void;
  98606. /** @hidden */
  98607. _decideIfNeedsToMove(): boolean;
  98608. /** @hidden */
  98609. _updatePosition(): void;
  98610. /**
  98611. * Restore the Roll to its target value at the rate specified.
  98612. * @param rate - Higher means slower restoring.
  98613. * @hidden
  98614. */
  98615. restoreRoll(rate: number): void;
  98616. /**
  98617. * Destroy the camera and release the current resources held by it.
  98618. */
  98619. dispose(): void;
  98620. /**
  98621. * Get the current object class name.
  98622. * @returns the class name.
  98623. */
  98624. getClassName(): string;
  98625. }
  98626. }
  98627. declare module BABYLON {
  98628. /**
  98629. * Listen to keyboard events to control the camera.
  98630. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  98631. */
  98632. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  98633. /**
  98634. * Defines the camera the input is attached to.
  98635. */
  98636. camera: FlyCamera;
  98637. /**
  98638. * The list of keyboard keys used to control the forward move of the camera.
  98639. */
  98640. keysForward: number[];
  98641. /**
  98642. * The list of keyboard keys used to control the backward move of the camera.
  98643. */
  98644. keysBackward: number[];
  98645. /**
  98646. * The list of keyboard keys used to control the forward move of the camera.
  98647. */
  98648. keysUp: number[];
  98649. /**
  98650. * The list of keyboard keys used to control the backward move of the camera.
  98651. */
  98652. keysDown: number[];
  98653. /**
  98654. * The list of keyboard keys used to control the right strafe move of the camera.
  98655. */
  98656. keysRight: number[];
  98657. /**
  98658. * The list of keyboard keys used to control the left strafe move of the camera.
  98659. */
  98660. keysLeft: number[];
  98661. private _keys;
  98662. private _onCanvasBlurObserver;
  98663. private _onKeyboardObserver;
  98664. private _engine;
  98665. private _scene;
  98666. /**
  98667. * Attach the input controls to a specific dom element to get the input from.
  98668. * @param element Defines the element the controls should be listened from
  98669. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  98670. */
  98671. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  98672. /**
  98673. * Detach the current controls from the specified dom element.
  98674. * @param element Defines the element to stop listening the inputs from
  98675. */
  98676. detachControl(element: Nullable<HTMLElement>): void;
  98677. /**
  98678. * Gets the class name of the current intput.
  98679. * @returns the class name
  98680. */
  98681. getClassName(): string;
  98682. /** @hidden */
  98683. _onLostFocus(e: FocusEvent): void;
  98684. /**
  98685. * Get the friendly name associated with the input class.
  98686. * @returns the input friendly name
  98687. */
  98688. getSimpleName(): string;
  98689. /**
  98690. * Update the current camera state depending on the inputs that have been used this frame.
  98691. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  98692. */
  98693. checkInputs(): void;
  98694. }
  98695. }
  98696. declare module BABYLON {
  98697. /**
  98698. * Manage the mouse wheel inputs to control a follow camera.
  98699. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  98700. */
  98701. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  98702. /**
  98703. * Defines the camera the input is attached to.
  98704. */
  98705. camera: FollowCamera;
  98706. /**
  98707. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  98708. */
  98709. axisControlRadius: boolean;
  98710. /**
  98711. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  98712. */
  98713. axisControlHeight: boolean;
  98714. /**
  98715. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  98716. */
  98717. axisControlRotation: boolean;
  98718. /**
  98719. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  98720. * relation to mouseWheel events.
  98721. */
  98722. wheelPrecision: number;
  98723. /**
  98724. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  98725. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  98726. */
  98727. wheelDeltaPercentage: number;
  98728. private _wheel;
  98729. private _observer;
  98730. /**
  98731. * Attach the input controls to a specific dom element to get the input from.
  98732. * @param element Defines the element the controls should be listened from
  98733. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  98734. */
  98735. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  98736. /**
  98737. * Detach the current controls from the specified dom element.
  98738. * @param element Defines the element to stop listening the inputs from
  98739. */
  98740. detachControl(element: Nullable<HTMLElement>): void;
  98741. /**
  98742. * Gets the class name of the current intput.
  98743. * @returns the class name
  98744. */
  98745. getClassName(): string;
  98746. /**
  98747. * Get the friendly name associated with the input class.
  98748. * @returns the input friendly name
  98749. */
  98750. getSimpleName(): string;
  98751. }
  98752. }
  98753. declare module BABYLON {
  98754. /**
  98755. * Manage the pointers inputs to control an follow camera.
  98756. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  98757. */
  98758. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  98759. /**
  98760. * Defines the camera the input is attached to.
  98761. */
  98762. camera: FollowCamera;
  98763. /**
  98764. * Gets the class name of the current input.
  98765. * @returns the class name
  98766. */
  98767. getClassName(): string;
  98768. /**
  98769. * Defines the pointer angular sensibility along the X axis or how fast is
  98770. * the camera rotating.
  98771. * A negative number will reverse the axis direction.
  98772. */
  98773. angularSensibilityX: number;
  98774. /**
  98775. * Defines the pointer angular sensibility along the Y axis or how fast is
  98776. * the camera rotating.
  98777. * A negative number will reverse the axis direction.
  98778. */
  98779. angularSensibilityY: number;
  98780. /**
  98781. * Defines the pointer pinch precision or how fast is the camera zooming.
  98782. * A negative number will reverse the axis direction.
  98783. */
  98784. pinchPrecision: number;
  98785. /**
  98786. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  98787. * from 0.
  98788. * It defines the percentage of current camera.radius to use as delta when
  98789. * pinch zoom is used.
  98790. */
  98791. pinchDeltaPercentage: number;
  98792. /**
  98793. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  98794. */
  98795. axisXControlRadius: boolean;
  98796. /**
  98797. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  98798. */
  98799. axisXControlHeight: boolean;
  98800. /**
  98801. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  98802. */
  98803. axisXControlRotation: boolean;
  98804. /**
  98805. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  98806. */
  98807. axisYControlRadius: boolean;
  98808. /**
  98809. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  98810. */
  98811. axisYControlHeight: boolean;
  98812. /**
  98813. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  98814. */
  98815. axisYControlRotation: boolean;
  98816. /**
  98817. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  98818. */
  98819. axisPinchControlRadius: boolean;
  98820. /**
  98821. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  98822. */
  98823. axisPinchControlHeight: boolean;
  98824. /**
  98825. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  98826. */
  98827. axisPinchControlRotation: boolean;
  98828. /**
  98829. * Log error messages if basic misconfiguration has occurred.
  98830. */
  98831. warningEnable: boolean;
  98832. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  98833. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  98834. private _warningCounter;
  98835. private _warning;
  98836. }
  98837. }
  98838. declare module BABYLON {
  98839. /**
  98840. * Default Inputs manager for the FollowCamera.
  98841. * It groups all the default supported inputs for ease of use.
  98842. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  98843. */
  98844. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  98845. /**
  98846. * Instantiates a new FollowCameraInputsManager.
  98847. * @param camera Defines the camera the inputs belong to
  98848. */
  98849. constructor(camera: FollowCamera);
  98850. /**
  98851. * Add keyboard input support to the input manager.
  98852. * @returns the current input manager
  98853. */
  98854. addKeyboard(): FollowCameraInputsManager;
  98855. /**
  98856. * Add mouse wheel input support to the input manager.
  98857. * @returns the current input manager
  98858. */
  98859. addMouseWheel(): FollowCameraInputsManager;
  98860. /**
  98861. * Add pointers input support to the input manager.
  98862. * @returns the current input manager
  98863. */
  98864. addPointers(): FollowCameraInputsManager;
  98865. /**
  98866. * Add orientation input support to the input manager.
  98867. * @returns the current input manager
  98868. */
  98869. addVRDeviceOrientation(): FollowCameraInputsManager;
  98870. }
  98871. }
  98872. declare module BABYLON {
  98873. /**
  98874. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  98875. * an arc rotate version arcFollowCamera are available.
  98876. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  98877. */
  98878. export class FollowCamera extends TargetCamera {
  98879. /**
  98880. * Distance the follow camera should follow an object at
  98881. */
  98882. radius: number;
  98883. /**
  98884. * Minimum allowed distance of the camera to the axis of rotation
  98885. * (The camera can not get closer).
  98886. * This can help limiting how the Camera is able to move in the scene.
  98887. */
  98888. lowerRadiusLimit: Nullable<number>;
  98889. /**
  98890. * Maximum allowed distance of the camera to the axis of rotation
  98891. * (The camera can not get further).
  98892. * This can help limiting how the Camera is able to move in the scene.
  98893. */
  98894. upperRadiusLimit: Nullable<number>;
  98895. /**
  98896. * Define a rotation offset between the camera and the object it follows
  98897. */
  98898. rotationOffset: number;
  98899. /**
  98900. * Minimum allowed angle to camera position relative to target object.
  98901. * This can help limiting how the Camera is able to move in the scene.
  98902. */
  98903. lowerRotationOffsetLimit: Nullable<number>;
  98904. /**
  98905. * Maximum allowed angle to camera position relative to target object.
  98906. * This can help limiting how the Camera is able to move in the scene.
  98907. */
  98908. upperRotationOffsetLimit: Nullable<number>;
  98909. /**
  98910. * Define a height offset between the camera and the object it follows.
  98911. * It can help following an object from the top (like a car chaing a plane)
  98912. */
  98913. heightOffset: number;
  98914. /**
  98915. * Minimum allowed height of camera position relative to target object.
  98916. * This can help limiting how the Camera is able to move in the scene.
  98917. */
  98918. lowerHeightOffsetLimit: Nullable<number>;
  98919. /**
  98920. * Maximum allowed height of camera position relative to target object.
  98921. * This can help limiting how the Camera is able to move in the scene.
  98922. */
  98923. upperHeightOffsetLimit: Nullable<number>;
  98924. /**
  98925. * Define how fast the camera can accelerate to follow it s target.
  98926. */
  98927. cameraAcceleration: number;
  98928. /**
  98929. * Define the speed limit of the camera following an object.
  98930. */
  98931. maxCameraSpeed: number;
  98932. /**
  98933. * Define the target of the camera.
  98934. */
  98935. lockedTarget: Nullable<AbstractMesh>;
  98936. /**
  98937. * Defines the input associated with the camera.
  98938. */
  98939. inputs: FollowCameraInputsManager;
  98940. /**
  98941. * Instantiates the follow camera.
  98942. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  98943. * @param name Define the name of the camera in the scene
  98944. * @param position Define the position of the camera
  98945. * @param scene Define the scene the camera belong to
  98946. * @param lockedTarget Define the target of the camera
  98947. */
  98948. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  98949. private _follow;
  98950. /**
  98951. * Attached controls to the current camera.
  98952. * @param element Defines the element the controls should be listened from
  98953. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  98954. */
  98955. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  98956. /**
  98957. * Detach the current controls from the camera.
  98958. * The camera will stop reacting to inputs.
  98959. * @param element Defines the element to stop listening the inputs from
  98960. */
  98961. detachControl(element: HTMLElement): void;
  98962. /** @hidden */
  98963. _checkInputs(): void;
  98964. private _checkLimits;
  98965. /**
  98966. * Gets the camera class name.
  98967. * @returns the class name
  98968. */
  98969. getClassName(): string;
  98970. }
  98971. /**
  98972. * Arc Rotate version of the follow camera.
  98973. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  98974. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  98975. */
  98976. export class ArcFollowCamera extends TargetCamera {
  98977. /** The longitudinal angle of the camera */
  98978. alpha: number;
  98979. /** The latitudinal angle of the camera */
  98980. beta: number;
  98981. /** The radius of the camera from its target */
  98982. radius: number;
  98983. /** Define the camera target (the messh it should follow) */
  98984. target: Nullable<AbstractMesh>;
  98985. private _cartesianCoordinates;
  98986. /**
  98987. * Instantiates a new ArcFollowCamera
  98988. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  98989. * @param name Define the name of the camera
  98990. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  98991. * @param beta Define the rotation angle of the camera around the elevation axis
  98992. * @param radius Define the radius of the camera from its target point
  98993. * @param target Define the target of the camera
  98994. * @param scene Define the scene the camera belongs to
  98995. */
  98996. constructor(name: string,
  98997. /** The longitudinal angle of the camera */
  98998. alpha: number,
  98999. /** The latitudinal angle of the camera */
  99000. beta: number,
  99001. /** The radius of the camera from its target */
  99002. radius: number,
  99003. /** Define the camera target (the messh it should follow) */
  99004. target: Nullable<AbstractMesh>, scene: Scene);
  99005. private _follow;
  99006. /** @hidden */
  99007. _checkInputs(): void;
  99008. /**
  99009. * Returns the class name of the object.
  99010. * It is mostly used internally for serialization purposes.
  99011. */
  99012. getClassName(): string;
  99013. }
  99014. }
  99015. declare module BABYLON {
  99016. /**
  99017. * Manage the keyboard inputs to control the movement of a follow camera.
  99018. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99019. */
  99020. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  99021. /**
  99022. * Defines the camera the input is attached to.
  99023. */
  99024. camera: FollowCamera;
  99025. /**
  99026. * Defines the list of key codes associated with the up action (increase heightOffset)
  99027. */
  99028. keysHeightOffsetIncr: number[];
  99029. /**
  99030. * Defines the list of key codes associated with the down action (decrease heightOffset)
  99031. */
  99032. keysHeightOffsetDecr: number[];
  99033. /**
  99034. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  99035. */
  99036. keysHeightOffsetModifierAlt: boolean;
  99037. /**
  99038. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  99039. */
  99040. keysHeightOffsetModifierCtrl: boolean;
  99041. /**
  99042. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  99043. */
  99044. keysHeightOffsetModifierShift: boolean;
  99045. /**
  99046. * Defines the list of key codes associated with the left action (increase rotationOffset)
  99047. */
  99048. keysRotationOffsetIncr: number[];
  99049. /**
  99050. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  99051. */
  99052. keysRotationOffsetDecr: number[];
  99053. /**
  99054. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  99055. */
  99056. keysRotationOffsetModifierAlt: boolean;
  99057. /**
  99058. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  99059. */
  99060. keysRotationOffsetModifierCtrl: boolean;
  99061. /**
  99062. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  99063. */
  99064. keysRotationOffsetModifierShift: boolean;
  99065. /**
  99066. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  99067. */
  99068. keysRadiusIncr: number[];
  99069. /**
  99070. * Defines the list of key codes associated with the zoom-out action (increase radius)
  99071. */
  99072. keysRadiusDecr: number[];
  99073. /**
  99074. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  99075. */
  99076. keysRadiusModifierAlt: boolean;
  99077. /**
  99078. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  99079. */
  99080. keysRadiusModifierCtrl: boolean;
  99081. /**
  99082. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  99083. */
  99084. keysRadiusModifierShift: boolean;
  99085. /**
  99086. * Defines the rate of change of heightOffset.
  99087. */
  99088. heightSensibility: number;
  99089. /**
  99090. * Defines the rate of change of rotationOffset.
  99091. */
  99092. rotationSensibility: number;
  99093. /**
  99094. * Defines the rate of change of radius.
  99095. */
  99096. radiusSensibility: number;
  99097. private _keys;
  99098. private _ctrlPressed;
  99099. private _altPressed;
  99100. private _shiftPressed;
  99101. private _onCanvasBlurObserver;
  99102. private _onKeyboardObserver;
  99103. private _engine;
  99104. private _scene;
  99105. /**
  99106. * Attach the input controls to a specific dom element to get the input from.
  99107. * @param element Defines the element the controls should be listened from
  99108. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99109. */
  99110. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99111. /**
  99112. * Detach the current controls from the specified dom element.
  99113. * @param element Defines the element to stop listening the inputs from
  99114. */
  99115. detachControl(element: Nullable<HTMLElement>): void;
  99116. /**
  99117. * Update the current camera state depending on the inputs that have been used this frame.
  99118. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  99119. */
  99120. checkInputs(): void;
  99121. /**
  99122. * Gets the class name of the current input.
  99123. * @returns the class name
  99124. */
  99125. getClassName(): string;
  99126. /**
  99127. * Get the friendly name associated with the input class.
  99128. * @returns the input friendly name
  99129. */
  99130. getSimpleName(): string;
  99131. /**
  99132. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  99133. * allow modification of the heightOffset value.
  99134. */
  99135. private _modifierHeightOffset;
  99136. /**
  99137. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  99138. * allow modification of the rotationOffset value.
  99139. */
  99140. private _modifierRotationOffset;
  99141. /**
  99142. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  99143. * allow modification of the radius value.
  99144. */
  99145. private _modifierRadius;
  99146. }
  99147. }
  99148. declare module BABYLON {
  99149. interface FreeCameraInputsManager {
  99150. /**
  99151. * @hidden
  99152. */
  99153. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  99154. /**
  99155. * Add orientation input support to the input manager.
  99156. * @returns the current input manager
  99157. */
  99158. addDeviceOrientation(): FreeCameraInputsManager;
  99159. }
  99160. /**
  99161. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  99162. * Screen rotation is taken into account.
  99163. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99164. */
  99165. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  99166. private _camera;
  99167. private _screenOrientationAngle;
  99168. private _constantTranform;
  99169. private _screenQuaternion;
  99170. private _alpha;
  99171. private _beta;
  99172. private _gamma;
  99173. /**
  99174. * @hidden
  99175. */
  99176. _onDeviceOrientationChangedObservable: Observable<void>;
  99177. /**
  99178. * Instantiates a new input
  99179. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99180. */
  99181. constructor();
  99182. /**
  99183. * Define the camera controlled by the input.
  99184. */
  99185. camera: FreeCamera;
  99186. /**
  99187. * Attach the input controls to a specific dom element to get the input from.
  99188. * @param element Defines the element the controls should be listened from
  99189. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99190. */
  99191. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99192. private _orientationChanged;
  99193. private _deviceOrientation;
  99194. /**
  99195. * Detach the current controls from the specified dom element.
  99196. * @param element Defines the element to stop listening the inputs from
  99197. */
  99198. detachControl(element: Nullable<HTMLElement>): void;
  99199. /**
  99200. * Update the current camera state depending on the inputs that have been used this frame.
  99201. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  99202. */
  99203. checkInputs(): void;
  99204. /**
  99205. * Gets the class name of the current intput.
  99206. * @returns the class name
  99207. */
  99208. getClassName(): string;
  99209. /**
  99210. * Get the friendly name associated with the input class.
  99211. * @returns the input friendly name
  99212. */
  99213. getSimpleName(): string;
  99214. }
  99215. }
  99216. declare module BABYLON {
  99217. /**
  99218. * Manage the gamepad inputs to control a free camera.
  99219. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99220. */
  99221. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  99222. /**
  99223. * Define the camera the input is attached to.
  99224. */
  99225. camera: FreeCamera;
  99226. /**
  99227. * Define the Gamepad controlling the input
  99228. */
  99229. gamepad: Nullable<Gamepad>;
  99230. /**
  99231. * Defines the gamepad rotation sensiblity.
  99232. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  99233. */
  99234. gamepadAngularSensibility: number;
  99235. /**
  99236. * Defines the gamepad move sensiblity.
  99237. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  99238. */
  99239. gamepadMoveSensibility: number;
  99240. private _onGamepadConnectedObserver;
  99241. private _onGamepadDisconnectedObserver;
  99242. private _cameraTransform;
  99243. private _deltaTransform;
  99244. private _vector3;
  99245. private _vector2;
  99246. /**
  99247. * Attach the input controls to a specific dom element to get the input from.
  99248. * @param element Defines the element the controls should be listened from
  99249. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99250. */
  99251. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99252. /**
  99253. * Detach the current controls from the specified dom element.
  99254. * @param element Defines the element to stop listening the inputs from
  99255. */
  99256. detachControl(element: Nullable<HTMLElement>): void;
  99257. /**
  99258. * Update the current camera state depending on the inputs that have been used this frame.
  99259. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  99260. */
  99261. checkInputs(): void;
  99262. /**
  99263. * Gets the class name of the current intput.
  99264. * @returns the class name
  99265. */
  99266. getClassName(): string;
  99267. /**
  99268. * Get the friendly name associated with the input class.
  99269. * @returns the input friendly name
  99270. */
  99271. getSimpleName(): string;
  99272. }
  99273. }
  99274. declare module BABYLON {
  99275. /**
  99276. * Defines the potential axis of a Joystick
  99277. */
  99278. export enum JoystickAxis {
  99279. /** X axis */
  99280. X = 0,
  99281. /** Y axis */
  99282. Y = 1,
  99283. /** Z axis */
  99284. Z = 2
  99285. }
  99286. /**
  99287. * Class used to define virtual joystick (used in touch mode)
  99288. */
  99289. export class VirtualJoystick {
  99290. /**
  99291. * Gets or sets a boolean indicating that left and right values must be inverted
  99292. */
  99293. reverseLeftRight: boolean;
  99294. /**
  99295. * Gets or sets a boolean indicating that up and down values must be inverted
  99296. */
  99297. reverseUpDown: boolean;
  99298. /**
  99299. * Gets the offset value for the position (ie. the change of the position value)
  99300. */
  99301. deltaPosition: Vector3;
  99302. /**
  99303. * Gets a boolean indicating if the virtual joystick was pressed
  99304. */
  99305. pressed: boolean;
  99306. /**
  99307. * Canvas the virtual joystick will render onto, default z-index of this is 5
  99308. */
  99309. static Canvas: Nullable<HTMLCanvasElement>;
  99310. private static _globalJoystickIndex;
  99311. private static vjCanvasContext;
  99312. private static vjCanvasWidth;
  99313. private static vjCanvasHeight;
  99314. private static halfWidth;
  99315. private _action;
  99316. private _axisTargetedByLeftAndRight;
  99317. private _axisTargetedByUpAndDown;
  99318. private _joystickSensibility;
  99319. private _inversedSensibility;
  99320. private _joystickPointerID;
  99321. private _joystickColor;
  99322. private _joystickPointerPos;
  99323. private _joystickPreviousPointerPos;
  99324. private _joystickPointerStartPos;
  99325. private _deltaJoystickVector;
  99326. private _leftJoystick;
  99327. private _touches;
  99328. private _onPointerDownHandlerRef;
  99329. private _onPointerMoveHandlerRef;
  99330. private _onPointerUpHandlerRef;
  99331. private _onResize;
  99332. /**
  99333. * Creates a new virtual joystick
  99334. * @param leftJoystick defines that the joystick is for left hand (false by default)
  99335. */
  99336. constructor(leftJoystick?: boolean);
  99337. /**
  99338. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  99339. * @param newJoystickSensibility defines the new sensibility
  99340. */
  99341. setJoystickSensibility(newJoystickSensibility: number): void;
  99342. private _onPointerDown;
  99343. private _onPointerMove;
  99344. private _onPointerUp;
  99345. /**
  99346. * Change the color of the virtual joystick
  99347. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  99348. */
  99349. setJoystickColor(newColor: string): void;
  99350. /**
  99351. * Defines a callback to call when the joystick is touched
  99352. * @param action defines the callback
  99353. */
  99354. setActionOnTouch(action: () => any): void;
  99355. /**
  99356. * Defines which axis you'd like to control for left & right
  99357. * @param axis defines the axis to use
  99358. */
  99359. setAxisForLeftRight(axis: JoystickAxis): void;
  99360. /**
  99361. * Defines which axis you'd like to control for up & down
  99362. * @param axis defines the axis to use
  99363. */
  99364. setAxisForUpDown(axis: JoystickAxis): void;
  99365. private _drawVirtualJoystick;
  99366. /**
  99367. * Release internal HTML canvas
  99368. */
  99369. releaseCanvas(): void;
  99370. }
  99371. }
  99372. declare module BABYLON {
  99373. interface FreeCameraInputsManager {
  99374. /**
  99375. * Add virtual joystick input support to the input manager.
  99376. * @returns the current input manager
  99377. */
  99378. addVirtualJoystick(): FreeCameraInputsManager;
  99379. }
  99380. /**
  99381. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  99382. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99383. */
  99384. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  99385. /**
  99386. * Defines the camera the input is attached to.
  99387. */
  99388. camera: FreeCamera;
  99389. private _leftjoystick;
  99390. private _rightjoystick;
  99391. /**
  99392. * Gets the left stick of the virtual joystick.
  99393. * @returns The virtual Joystick
  99394. */
  99395. getLeftJoystick(): VirtualJoystick;
  99396. /**
  99397. * Gets the right stick of the virtual joystick.
  99398. * @returns The virtual Joystick
  99399. */
  99400. getRightJoystick(): VirtualJoystick;
  99401. /**
  99402. * Update the current camera state depending on the inputs that have been used this frame.
  99403. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  99404. */
  99405. checkInputs(): void;
  99406. /**
  99407. * Attach the input controls to a specific dom element to get the input from.
  99408. * @param element Defines the element the controls should be listened from
  99409. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99410. */
  99411. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99412. /**
  99413. * Detach the current controls from the specified dom element.
  99414. * @param element Defines the element to stop listening the inputs from
  99415. */
  99416. detachControl(element: Nullable<HTMLElement>): void;
  99417. /**
  99418. * Gets the class name of the current intput.
  99419. * @returns the class name
  99420. */
  99421. getClassName(): string;
  99422. /**
  99423. * Get the friendly name associated with the input class.
  99424. * @returns the input friendly name
  99425. */
  99426. getSimpleName(): string;
  99427. }
  99428. }
  99429. declare module BABYLON {
  99430. /**
  99431. * This represents a FPS type of camera controlled by touch.
  99432. * This is like a universal camera minus the Gamepad controls.
  99433. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  99434. */
  99435. export class TouchCamera extends FreeCamera {
  99436. /**
  99437. * Defines the touch sensibility for rotation.
  99438. * The higher the faster.
  99439. */
  99440. touchAngularSensibility: number;
  99441. /**
  99442. * Defines the touch sensibility for move.
  99443. * The higher the faster.
  99444. */
  99445. touchMoveSensibility: number;
  99446. /**
  99447. * Instantiates a new touch camera.
  99448. * This represents a FPS type of camera controlled by touch.
  99449. * This is like a universal camera minus the Gamepad controls.
  99450. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  99451. * @param name Define the name of the camera in the scene
  99452. * @param position Define the start position of the camera in the scene
  99453. * @param scene Define the scene the camera belongs to
  99454. */
  99455. constructor(name: string, position: Vector3, scene: Scene);
  99456. /**
  99457. * Gets the current object class name.
  99458. * @return the class name
  99459. */
  99460. getClassName(): string;
  99461. /** @hidden */
  99462. _setupInputs(): void;
  99463. }
  99464. }
  99465. declare module BABYLON {
  99466. /**
  99467. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  99468. * being tilted forward or back and left or right.
  99469. */
  99470. export class DeviceOrientationCamera extends FreeCamera {
  99471. private _initialQuaternion;
  99472. private _quaternionCache;
  99473. private _tmpDragQuaternion;
  99474. /**
  99475. * Creates a new device orientation camera
  99476. * @param name The name of the camera
  99477. * @param position The start position camera
  99478. * @param scene The scene the camera belongs to
  99479. */
  99480. constructor(name: string, position: Vector3, scene: Scene);
  99481. /**
  99482. * @hidden
  99483. * Disabled pointer input on first orientation sensor update (Default: true)
  99484. */
  99485. _disablePointerInputWhenUsingDeviceOrientation: boolean;
  99486. private _dragFactor;
  99487. /**
  99488. * Enabled turning on the y axis when the orientation sensor is active
  99489. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  99490. */
  99491. enableHorizontalDragging(dragFactor?: number): void;
  99492. /**
  99493. * Gets the current instance class name ("DeviceOrientationCamera").
  99494. * This helps avoiding instanceof at run time.
  99495. * @returns the class name
  99496. */
  99497. getClassName(): string;
  99498. /**
  99499. * @hidden
  99500. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  99501. */
  99502. _checkInputs(): void;
  99503. /**
  99504. * Reset the camera to its default orientation on the specified axis only.
  99505. * @param axis The axis to reset
  99506. */
  99507. resetToCurrentRotation(axis?: Axis): void;
  99508. }
  99509. }
  99510. declare module BABYLON {
  99511. /**
  99512. * Defines supported buttons for XBox360 compatible gamepads
  99513. */
  99514. export enum Xbox360Button {
  99515. /** A */
  99516. A = 0,
  99517. /** B */
  99518. B = 1,
  99519. /** X */
  99520. X = 2,
  99521. /** Y */
  99522. Y = 3,
  99523. /** Start */
  99524. Start = 4,
  99525. /** Back */
  99526. Back = 5,
  99527. /** Left button */
  99528. LB = 6,
  99529. /** Right button */
  99530. RB = 7,
  99531. /** Left stick */
  99532. LeftStick = 8,
  99533. /** Right stick */
  99534. RightStick = 9
  99535. }
  99536. /** Defines values for XBox360 DPad */
  99537. export enum Xbox360Dpad {
  99538. /** Up */
  99539. Up = 0,
  99540. /** Down */
  99541. Down = 1,
  99542. /** Left */
  99543. Left = 2,
  99544. /** Right */
  99545. Right = 3
  99546. }
  99547. /**
  99548. * Defines a XBox360 gamepad
  99549. */
  99550. export class Xbox360Pad extends Gamepad {
  99551. private _leftTrigger;
  99552. private _rightTrigger;
  99553. private _onlefttriggerchanged;
  99554. private _onrighttriggerchanged;
  99555. private _onbuttondown;
  99556. private _onbuttonup;
  99557. private _ondpaddown;
  99558. private _ondpadup;
  99559. /** Observable raised when a button is pressed */
  99560. onButtonDownObservable: Observable<Xbox360Button>;
  99561. /** Observable raised when a button is released */
  99562. onButtonUpObservable: Observable<Xbox360Button>;
  99563. /** Observable raised when a pad is pressed */
  99564. onPadDownObservable: Observable<Xbox360Dpad>;
  99565. /** Observable raised when a pad is released */
  99566. onPadUpObservable: Observable<Xbox360Dpad>;
  99567. private _buttonA;
  99568. private _buttonB;
  99569. private _buttonX;
  99570. private _buttonY;
  99571. private _buttonBack;
  99572. private _buttonStart;
  99573. private _buttonLB;
  99574. private _buttonRB;
  99575. private _buttonLeftStick;
  99576. private _buttonRightStick;
  99577. private _dPadUp;
  99578. private _dPadDown;
  99579. private _dPadLeft;
  99580. private _dPadRight;
  99581. private _isXboxOnePad;
  99582. /**
  99583. * Creates a new XBox360 gamepad object
  99584. * @param id defines the id of this gamepad
  99585. * @param index defines its index
  99586. * @param gamepad defines the internal HTML gamepad object
  99587. * @param xboxOne defines if it is a XBox One gamepad
  99588. */
  99589. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  99590. /**
  99591. * Defines the callback to call when left trigger is pressed
  99592. * @param callback defines the callback to use
  99593. */
  99594. onlefttriggerchanged(callback: (value: number) => void): void;
  99595. /**
  99596. * Defines the callback to call when right trigger is pressed
  99597. * @param callback defines the callback to use
  99598. */
  99599. onrighttriggerchanged(callback: (value: number) => void): void;
  99600. /**
  99601. * Gets the left trigger value
  99602. */
  99603. /**
  99604. * Sets the left trigger value
  99605. */
  99606. leftTrigger: number;
  99607. /**
  99608. * Gets the right trigger value
  99609. */
  99610. /**
  99611. * Sets the right trigger value
  99612. */
  99613. rightTrigger: number;
  99614. /**
  99615. * Defines the callback to call when a button is pressed
  99616. * @param callback defines the callback to use
  99617. */
  99618. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  99619. /**
  99620. * Defines the callback to call when a button is released
  99621. * @param callback defines the callback to use
  99622. */
  99623. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  99624. /**
  99625. * Defines the callback to call when a pad is pressed
  99626. * @param callback defines the callback to use
  99627. */
  99628. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  99629. /**
  99630. * Defines the callback to call when a pad is released
  99631. * @param callback defines the callback to use
  99632. */
  99633. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  99634. private _setButtonValue;
  99635. private _setDPadValue;
  99636. /**
  99637. * Gets the value of the `A` button
  99638. */
  99639. /**
  99640. * Sets the value of the `A` button
  99641. */
  99642. buttonA: number;
  99643. /**
  99644. * Gets the value of the `B` button
  99645. */
  99646. /**
  99647. * Sets the value of the `B` button
  99648. */
  99649. buttonB: number;
  99650. /**
  99651. * Gets the value of the `X` button
  99652. */
  99653. /**
  99654. * Sets the value of the `X` button
  99655. */
  99656. buttonX: number;
  99657. /**
  99658. * Gets the value of the `Y` button
  99659. */
  99660. /**
  99661. * Sets the value of the `Y` button
  99662. */
  99663. buttonY: number;
  99664. /**
  99665. * Gets the value of the `Start` button
  99666. */
  99667. /**
  99668. * Sets the value of the `Start` button
  99669. */
  99670. buttonStart: number;
  99671. /**
  99672. * Gets the value of the `Back` button
  99673. */
  99674. /**
  99675. * Sets the value of the `Back` button
  99676. */
  99677. buttonBack: number;
  99678. /**
  99679. * Gets the value of the `Left` button
  99680. */
  99681. /**
  99682. * Sets the value of the `Left` button
  99683. */
  99684. buttonLB: number;
  99685. /**
  99686. * Gets the value of the `Right` button
  99687. */
  99688. /**
  99689. * Sets the value of the `Right` button
  99690. */
  99691. buttonRB: number;
  99692. /**
  99693. * Gets the value of the Left joystick
  99694. */
  99695. /**
  99696. * Sets the value of the Left joystick
  99697. */
  99698. buttonLeftStick: number;
  99699. /**
  99700. * Gets the value of the Right joystick
  99701. */
  99702. /**
  99703. * Sets the value of the Right joystick
  99704. */
  99705. buttonRightStick: number;
  99706. /**
  99707. * Gets the value of D-pad up
  99708. */
  99709. /**
  99710. * Sets the value of D-pad up
  99711. */
  99712. dPadUp: number;
  99713. /**
  99714. * Gets the value of D-pad down
  99715. */
  99716. /**
  99717. * Sets the value of D-pad down
  99718. */
  99719. dPadDown: number;
  99720. /**
  99721. * Gets the value of D-pad left
  99722. */
  99723. /**
  99724. * Sets the value of D-pad left
  99725. */
  99726. dPadLeft: number;
  99727. /**
  99728. * Gets the value of D-pad right
  99729. */
  99730. /**
  99731. * Sets the value of D-pad right
  99732. */
  99733. dPadRight: number;
  99734. /**
  99735. * Force the gamepad to synchronize with device values
  99736. */
  99737. update(): void;
  99738. /**
  99739. * Disposes the gamepad
  99740. */
  99741. dispose(): void;
  99742. }
  99743. }
  99744. declare module BABYLON {
  99745. /**
  99746. * Manager for handling gamepads
  99747. */
  99748. export class GamepadManager {
  99749. private _scene?;
  99750. private _babylonGamepads;
  99751. private _oneGamepadConnected;
  99752. /** @hidden */
  99753. _isMonitoring: boolean;
  99754. private _gamepadEventSupported;
  99755. private _gamepadSupport;
  99756. /**
  99757. * observable to be triggered when the gamepad controller has been connected
  99758. */
  99759. onGamepadConnectedObservable: Observable<Gamepad>;
  99760. /**
  99761. * observable to be triggered when the gamepad controller has been disconnected
  99762. */
  99763. onGamepadDisconnectedObservable: Observable<Gamepad>;
  99764. private _onGamepadConnectedEvent;
  99765. private _onGamepadDisconnectedEvent;
  99766. /**
  99767. * Initializes the gamepad manager
  99768. * @param _scene BabylonJS scene
  99769. */
  99770. constructor(_scene?: Scene | undefined);
  99771. /**
  99772. * The gamepads in the game pad manager
  99773. */
  99774. readonly gamepads: Gamepad[];
  99775. /**
  99776. * Get the gamepad controllers based on type
  99777. * @param type The type of gamepad controller
  99778. * @returns Nullable gamepad
  99779. */
  99780. getGamepadByType(type?: number): Nullable<Gamepad>;
  99781. /**
  99782. * Disposes the gamepad manager
  99783. */
  99784. dispose(): void;
  99785. private _addNewGamepad;
  99786. private _startMonitoringGamepads;
  99787. private _stopMonitoringGamepads;
  99788. /** @hidden */
  99789. _checkGamepadsStatus(): void;
  99790. private _updateGamepadObjects;
  99791. }
  99792. }
  99793. declare module BABYLON {
  99794. interface Scene {
  99795. /** @hidden */
  99796. _gamepadManager: Nullable<GamepadManager>;
  99797. /**
  99798. * Gets the gamepad manager associated with the scene
  99799. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  99800. */
  99801. gamepadManager: GamepadManager;
  99802. }
  99803. /**
  99804. * Interface representing a free camera inputs manager
  99805. */
  99806. interface FreeCameraInputsManager {
  99807. /**
  99808. * Adds gamepad input support to the FreeCameraInputsManager.
  99809. * @returns the FreeCameraInputsManager
  99810. */
  99811. addGamepad(): FreeCameraInputsManager;
  99812. }
  99813. /**
  99814. * Interface representing an arc rotate camera inputs manager
  99815. */
  99816. interface ArcRotateCameraInputsManager {
  99817. /**
  99818. * Adds gamepad input support to the ArcRotateCamera InputManager.
  99819. * @returns the camera inputs manager
  99820. */
  99821. addGamepad(): ArcRotateCameraInputsManager;
  99822. }
  99823. /**
  99824. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  99825. */
  99826. export class GamepadSystemSceneComponent implements ISceneComponent {
  99827. /**
  99828. * The component name helpfull to identify the component in the list of scene components.
  99829. */
  99830. readonly name: string;
  99831. /**
  99832. * The scene the component belongs to.
  99833. */
  99834. scene: Scene;
  99835. /**
  99836. * Creates a new instance of the component for the given scene
  99837. * @param scene Defines the scene to register the component in
  99838. */
  99839. constructor(scene: Scene);
  99840. /**
  99841. * Registers the component in a given scene
  99842. */
  99843. register(): void;
  99844. /**
  99845. * Rebuilds the elements related to this component in case of
  99846. * context lost for instance.
  99847. */
  99848. rebuild(): void;
  99849. /**
  99850. * Disposes the component and the associated ressources
  99851. */
  99852. dispose(): void;
  99853. private _beforeCameraUpdate;
  99854. }
  99855. }
  99856. declare module BABYLON {
  99857. /**
  99858. * 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,
  99859. * which still works and will still be found in many Playgrounds.
  99860. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  99861. */
  99862. export class UniversalCamera extends TouchCamera {
  99863. /**
  99864. * Defines the gamepad rotation sensiblity.
  99865. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  99866. */
  99867. gamepadAngularSensibility: number;
  99868. /**
  99869. * Defines the gamepad move sensiblity.
  99870. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  99871. */
  99872. gamepadMoveSensibility: number;
  99873. /**
  99874. * 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,
  99875. * which still works and will still be found in many Playgrounds.
  99876. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  99877. * @param name Define the name of the camera in the scene
  99878. * @param position Define the start position of the camera in the scene
  99879. * @param scene Define the scene the camera belongs to
  99880. */
  99881. constructor(name: string, position: Vector3, scene: Scene);
  99882. /**
  99883. * Gets the current object class name.
  99884. * @return the class name
  99885. */
  99886. getClassName(): string;
  99887. }
  99888. }
  99889. declare module BABYLON {
  99890. /**
  99891. * This represents a FPS type of camera. This is only here for back compat purpose.
  99892. * Please use the UniversalCamera instead as both are identical.
  99893. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  99894. */
  99895. export class GamepadCamera extends UniversalCamera {
  99896. /**
  99897. * Instantiates a new Gamepad Camera
  99898. * This represents a FPS type of camera. This is only here for back compat purpose.
  99899. * Please use the UniversalCamera instead as both are identical.
  99900. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  99901. * @param name Define the name of the camera in the scene
  99902. * @param position Define the start position of the camera in the scene
  99903. * @param scene Define the scene the camera belongs to
  99904. */
  99905. constructor(name: string, position: Vector3, scene: Scene);
  99906. /**
  99907. * Gets the current object class name.
  99908. * @return the class name
  99909. */
  99910. getClassName(): string;
  99911. }
  99912. }
  99913. declare module BABYLON {
  99914. /** @hidden */
  99915. export var passPixelShader: {
  99916. name: string;
  99917. shader: string;
  99918. };
  99919. }
  99920. declare module BABYLON {
  99921. /** @hidden */
  99922. export var passCubePixelShader: {
  99923. name: string;
  99924. shader: string;
  99925. };
  99926. }
  99927. declare module BABYLON {
  99928. /**
  99929. * PassPostProcess which produces an output the same as it's input
  99930. */
  99931. export class PassPostProcess extends PostProcess {
  99932. /**
  99933. * Creates the PassPostProcess
  99934. * @param name The name of the effect.
  99935. * @param options The required width/height ratio to downsize to before computing the render pass.
  99936. * @param camera The camera to apply the render pass to.
  99937. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  99938. * @param engine The engine which the post process will be applied. (default: current engine)
  99939. * @param reusable If the post process can be reused on the same frame. (default: false)
  99940. * @param textureType The type of texture to be used when performing the post processing.
  99941. * @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)
  99942. */
  99943. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  99944. }
  99945. /**
  99946. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  99947. */
  99948. export class PassCubePostProcess extends PostProcess {
  99949. private _face;
  99950. /**
  99951. * Gets or sets the cube face to display.
  99952. * * 0 is +X
  99953. * * 1 is -X
  99954. * * 2 is +Y
  99955. * * 3 is -Y
  99956. * * 4 is +Z
  99957. * * 5 is -Z
  99958. */
  99959. face: number;
  99960. /**
  99961. * Creates the PassCubePostProcess
  99962. * @param name The name of the effect.
  99963. * @param options The required width/height ratio to downsize to before computing the render pass.
  99964. * @param camera The camera to apply the render pass to.
  99965. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  99966. * @param engine The engine which the post process will be applied. (default: current engine)
  99967. * @param reusable If the post process can be reused on the same frame. (default: false)
  99968. * @param textureType The type of texture to be used when performing the post processing.
  99969. * @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)
  99970. */
  99971. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  99972. }
  99973. }
  99974. declare module BABYLON {
  99975. /** @hidden */
  99976. export var anaglyphPixelShader: {
  99977. name: string;
  99978. shader: string;
  99979. };
  99980. }
  99981. declare module BABYLON {
  99982. /**
  99983. * Postprocess used to generate anaglyphic rendering
  99984. */
  99985. export class AnaglyphPostProcess extends PostProcess {
  99986. private _passedProcess;
  99987. /**
  99988. * Creates a new AnaglyphPostProcess
  99989. * @param name defines postprocess name
  99990. * @param options defines creation options or target ratio scale
  99991. * @param rigCameras defines cameras using this postprocess
  99992. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  99993. * @param engine defines hosting engine
  99994. * @param reusable defines if the postprocess will be reused multiple times per frame
  99995. */
  99996. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  99997. }
  99998. }
  99999. declare module BABYLON {
  100000. /**
  100001. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  100002. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  100003. */
  100004. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  100005. /**
  100006. * Creates a new AnaglyphArcRotateCamera
  100007. * @param name defines camera name
  100008. * @param alpha defines alpha angle (in radians)
  100009. * @param beta defines beta angle (in radians)
  100010. * @param radius defines radius
  100011. * @param target defines camera target
  100012. * @param interaxialDistance defines distance between each color axis
  100013. * @param scene defines the hosting scene
  100014. */
  100015. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  100016. /**
  100017. * Gets camera class name
  100018. * @returns AnaglyphArcRotateCamera
  100019. */
  100020. getClassName(): string;
  100021. }
  100022. }
  100023. declare module BABYLON {
  100024. /**
  100025. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  100026. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  100027. */
  100028. export class AnaglyphFreeCamera extends FreeCamera {
  100029. /**
  100030. * Creates a new AnaglyphFreeCamera
  100031. * @param name defines camera name
  100032. * @param position defines initial position
  100033. * @param interaxialDistance defines distance between each color axis
  100034. * @param scene defines the hosting scene
  100035. */
  100036. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  100037. /**
  100038. * Gets camera class name
  100039. * @returns AnaglyphFreeCamera
  100040. */
  100041. getClassName(): string;
  100042. }
  100043. }
  100044. declare module BABYLON {
  100045. /**
  100046. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  100047. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  100048. */
  100049. export class AnaglyphGamepadCamera extends GamepadCamera {
  100050. /**
  100051. * Creates a new AnaglyphGamepadCamera
  100052. * @param name defines camera name
  100053. * @param position defines initial position
  100054. * @param interaxialDistance defines distance between each color axis
  100055. * @param scene defines the hosting scene
  100056. */
  100057. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  100058. /**
  100059. * Gets camera class name
  100060. * @returns AnaglyphGamepadCamera
  100061. */
  100062. getClassName(): string;
  100063. }
  100064. }
  100065. declare module BABYLON {
  100066. /**
  100067. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  100068. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  100069. */
  100070. export class AnaglyphUniversalCamera extends UniversalCamera {
  100071. /**
  100072. * Creates a new AnaglyphUniversalCamera
  100073. * @param name defines camera name
  100074. * @param position defines initial position
  100075. * @param interaxialDistance defines distance between each color axis
  100076. * @param scene defines the hosting scene
  100077. */
  100078. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  100079. /**
  100080. * Gets camera class name
  100081. * @returns AnaglyphUniversalCamera
  100082. */
  100083. getClassName(): string;
  100084. }
  100085. }
  100086. declare module BABYLON {
  100087. /** @hidden */
  100088. export var stereoscopicInterlacePixelShader: {
  100089. name: string;
  100090. shader: string;
  100091. };
  100092. }
  100093. declare module BABYLON {
  100094. /**
  100095. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  100096. */
  100097. export class StereoscopicInterlacePostProcess extends PostProcess {
  100098. private _stepSize;
  100099. private _passedProcess;
  100100. /**
  100101. * Initializes a StereoscopicInterlacePostProcess
  100102. * @param name The name of the effect.
  100103. * @param rigCameras The rig cameras to be appled to the post process
  100104. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  100105. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  100106. * @param engine The engine which the post process will be applied. (default: current engine)
  100107. * @param reusable If the post process can be reused on the same frame. (default: false)
  100108. */
  100109. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  100110. }
  100111. }
  100112. declare module BABYLON {
  100113. /**
  100114. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  100115. * @see http://doc.babylonjs.com/features/cameras
  100116. */
  100117. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  100118. /**
  100119. * Creates a new StereoscopicArcRotateCamera
  100120. * @param name defines camera name
  100121. * @param alpha defines alpha angle (in radians)
  100122. * @param beta defines beta angle (in radians)
  100123. * @param radius defines radius
  100124. * @param target defines camera target
  100125. * @param interaxialDistance defines distance between each color axis
  100126. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  100127. * @param scene defines the hosting scene
  100128. */
  100129. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  100130. /**
  100131. * Gets camera class name
  100132. * @returns StereoscopicArcRotateCamera
  100133. */
  100134. getClassName(): string;
  100135. }
  100136. }
  100137. declare module BABYLON {
  100138. /**
  100139. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  100140. * @see http://doc.babylonjs.com/features/cameras
  100141. */
  100142. export class StereoscopicFreeCamera extends FreeCamera {
  100143. /**
  100144. * Creates a new StereoscopicFreeCamera
  100145. * @param name defines camera name
  100146. * @param position defines initial position
  100147. * @param interaxialDistance defines distance between each color axis
  100148. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  100149. * @param scene defines the hosting scene
  100150. */
  100151. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  100152. /**
  100153. * Gets camera class name
  100154. * @returns StereoscopicFreeCamera
  100155. */
  100156. getClassName(): string;
  100157. }
  100158. }
  100159. declare module BABYLON {
  100160. /**
  100161. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  100162. * @see http://doc.babylonjs.com/features/cameras
  100163. */
  100164. export class StereoscopicGamepadCamera extends GamepadCamera {
  100165. /**
  100166. * Creates a new StereoscopicGamepadCamera
  100167. * @param name defines camera name
  100168. * @param position defines initial position
  100169. * @param interaxialDistance defines distance between each color axis
  100170. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  100171. * @param scene defines the hosting scene
  100172. */
  100173. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  100174. /**
  100175. * Gets camera class name
  100176. * @returns StereoscopicGamepadCamera
  100177. */
  100178. getClassName(): string;
  100179. }
  100180. }
  100181. declare module BABYLON {
  100182. /**
  100183. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  100184. * @see http://doc.babylonjs.com/features/cameras
  100185. */
  100186. export class StereoscopicUniversalCamera extends UniversalCamera {
  100187. /**
  100188. * Creates a new StereoscopicUniversalCamera
  100189. * @param name defines camera name
  100190. * @param position defines initial position
  100191. * @param interaxialDistance defines distance between each color axis
  100192. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  100193. * @param scene defines the hosting scene
  100194. */
  100195. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  100196. /**
  100197. * Gets camera class name
  100198. * @returns StereoscopicUniversalCamera
  100199. */
  100200. getClassName(): string;
  100201. }
  100202. }
  100203. declare module BABYLON {
  100204. /**
  100205. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  100206. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  100207. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  100208. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  100209. */
  100210. export class VirtualJoysticksCamera extends FreeCamera {
  100211. /**
  100212. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  100213. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  100214. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  100215. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  100216. * @param name Define the name of the camera in the scene
  100217. * @param position Define the start position of the camera in the scene
  100218. * @param scene Define the scene the camera belongs to
  100219. */
  100220. constructor(name: string, position: Vector3, scene: Scene);
  100221. /**
  100222. * Gets the current object class name.
  100223. * @return the class name
  100224. */
  100225. getClassName(): string;
  100226. }
  100227. }
  100228. declare module BABYLON {
  100229. /**
  100230. * This represents all the required metrics to create a VR camera.
  100231. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  100232. */
  100233. export class VRCameraMetrics {
  100234. /**
  100235. * Define the horizontal resolution off the screen.
  100236. */
  100237. hResolution: number;
  100238. /**
  100239. * Define the vertical resolution off the screen.
  100240. */
  100241. vResolution: number;
  100242. /**
  100243. * Define the horizontal screen size.
  100244. */
  100245. hScreenSize: number;
  100246. /**
  100247. * Define the vertical screen size.
  100248. */
  100249. vScreenSize: number;
  100250. /**
  100251. * Define the vertical screen center position.
  100252. */
  100253. vScreenCenter: number;
  100254. /**
  100255. * Define the distance of the eyes to the screen.
  100256. */
  100257. eyeToScreenDistance: number;
  100258. /**
  100259. * Define the distance between both lenses
  100260. */
  100261. lensSeparationDistance: number;
  100262. /**
  100263. * Define the distance between both viewer's eyes.
  100264. */
  100265. interpupillaryDistance: number;
  100266. /**
  100267. * Define the distortion factor of the VR postprocess.
  100268. * Please, touch with care.
  100269. */
  100270. distortionK: number[];
  100271. /**
  100272. * Define the chromatic aberration correction factors for the VR post process.
  100273. */
  100274. chromaAbCorrection: number[];
  100275. /**
  100276. * Define the scale factor of the post process.
  100277. * The smaller the better but the slower.
  100278. */
  100279. postProcessScaleFactor: number;
  100280. /**
  100281. * Define an offset for the lens center.
  100282. */
  100283. lensCenterOffset: number;
  100284. /**
  100285. * Define if the current vr camera should compensate the distortion of the lense or not.
  100286. */
  100287. compensateDistortion: boolean;
  100288. /**
  100289. * Defines if multiview should be enabled when rendering (Default: false)
  100290. */
  100291. multiviewEnabled: boolean;
  100292. /**
  100293. * Gets the rendering aspect ratio based on the provided resolutions.
  100294. */
  100295. readonly aspectRatio: number;
  100296. /**
  100297. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  100298. */
  100299. readonly aspectRatioFov: number;
  100300. /**
  100301. * @hidden
  100302. */
  100303. readonly leftHMatrix: Matrix;
  100304. /**
  100305. * @hidden
  100306. */
  100307. readonly rightHMatrix: Matrix;
  100308. /**
  100309. * @hidden
  100310. */
  100311. readonly leftPreViewMatrix: Matrix;
  100312. /**
  100313. * @hidden
  100314. */
  100315. readonly rightPreViewMatrix: Matrix;
  100316. /**
  100317. * Get the default VRMetrics based on the most generic setup.
  100318. * @returns the default vr metrics
  100319. */
  100320. static GetDefault(): VRCameraMetrics;
  100321. }
  100322. }
  100323. declare module BABYLON {
  100324. /** @hidden */
  100325. export var vrDistortionCorrectionPixelShader: {
  100326. name: string;
  100327. shader: string;
  100328. };
  100329. }
  100330. declare module BABYLON {
  100331. /**
  100332. * VRDistortionCorrectionPostProcess used for mobile VR
  100333. */
  100334. export class VRDistortionCorrectionPostProcess extends PostProcess {
  100335. private _isRightEye;
  100336. private _distortionFactors;
  100337. private _postProcessScaleFactor;
  100338. private _lensCenterOffset;
  100339. private _scaleIn;
  100340. private _scaleFactor;
  100341. private _lensCenter;
  100342. /**
  100343. * Initializes the VRDistortionCorrectionPostProcess
  100344. * @param name The name of the effect.
  100345. * @param camera The camera to apply the render pass to.
  100346. * @param isRightEye If this is for the right eye distortion
  100347. * @param vrMetrics All the required metrics for the VR camera
  100348. */
  100349. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  100350. }
  100351. }
  100352. declare module BABYLON {
  100353. /**
  100354. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  100355. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  100356. */
  100357. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  100358. /**
  100359. * Creates a new VRDeviceOrientationArcRotateCamera
  100360. * @param name defines camera name
  100361. * @param alpha defines the camera rotation along the logitudinal axis
  100362. * @param beta defines the camera rotation along the latitudinal axis
  100363. * @param radius defines the camera distance from its target
  100364. * @param target defines the camera target
  100365. * @param scene defines the scene the camera belongs to
  100366. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  100367. * @param vrCameraMetrics defines the vr metrics associated to the camera
  100368. */
  100369. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  100370. /**
  100371. * Gets camera class name
  100372. * @returns VRDeviceOrientationArcRotateCamera
  100373. */
  100374. getClassName(): string;
  100375. }
  100376. }
  100377. declare module BABYLON {
  100378. /**
  100379. * Camera used to simulate VR rendering (based on FreeCamera)
  100380. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  100381. */
  100382. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  100383. /**
  100384. * Creates a new VRDeviceOrientationFreeCamera
  100385. * @param name defines camera name
  100386. * @param position defines the start position of the camera
  100387. * @param scene defines the scene the camera belongs to
  100388. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  100389. * @param vrCameraMetrics defines the vr metrics associated to the camera
  100390. */
  100391. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  100392. /**
  100393. * Gets camera class name
  100394. * @returns VRDeviceOrientationFreeCamera
  100395. */
  100396. getClassName(): string;
  100397. }
  100398. }
  100399. declare module BABYLON {
  100400. /**
  100401. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  100402. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  100403. */
  100404. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  100405. /**
  100406. * Creates a new VRDeviceOrientationGamepadCamera
  100407. * @param name defines camera name
  100408. * @param position defines the start position of the camera
  100409. * @param scene defines the scene the camera belongs to
  100410. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  100411. * @param vrCameraMetrics defines the vr metrics associated to the camera
  100412. */
  100413. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  100414. /**
  100415. * Gets camera class name
  100416. * @returns VRDeviceOrientationGamepadCamera
  100417. */
  100418. getClassName(): string;
  100419. }
  100420. }
  100421. declare module BABYLON {
  100422. /**
  100423. * Base class of materials working in push mode in babylon JS
  100424. * @hidden
  100425. */
  100426. export class PushMaterial extends Material {
  100427. protected _activeEffect: Effect;
  100428. protected _normalMatrix: Matrix;
  100429. /**
  100430. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  100431. * This means that the material can keep using a previous shader while a new one is being compiled.
  100432. * This is mostly used when shader parallel compilation is supported (true by default)
  100433. */
  100434. allowShaderHotSwapping: boolean;
  100435. constructor(name: string, scene: Scene);
  100436. getEffect(): Effect;
  100437. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  100438. /**
  100439. * Binds the given world matrix to the active effect
  100440. *
  100441. * @param world the matrix to bind
  100442. */
  100443. bindOnlyWorldMatrix(world: Matrix): void;
  100444. /**
  100445. * Binds the given normal matrix to the active effect
  100446. *
  100447. * @param normalMatrix the matrix to bind
  100448. */
  100449. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  100450. bind(world: Matrix, mesh?: Mesh): void;
  100451. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  100452. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  100453. }
  100454. }
  100455. declare module BABYLON {
  100456. /**
  100457. * This groups all the flags used to control the materials channel.
  100458. */
  100459. export class MaterialFlags {
  100460. private static _DiffuseTextureEnabled;
  100461. /**
  100462. * Are diffuse textures enabled in the application.
  100463. */
  100464. static DiffuseTextureEnabled: boolean;
  100465. private static _AmbientTextureEnabled;
  100466. /**
  100467. * Are ambient textures enabled in the application.
  100468. */
  100469. static AmbientTextureEnabled: boolean;
  100470. private static _OpacityTextureEnabled;
  100471. /**
  100472. * Are opacity textures enabled in the application.
  100473. */
  100474. static OpacityTextureEnabled: boolean;
  100475. private static _ReflectionTextureEnabled;
  100476. /**
  100477. * Are reflection textures enabled in the application.
  100478. */
  100479. static ReflectionTextureEnabled: boolean;
  100480. private static _EmissiveTextureEnabled;
  100481. /**
  100482. * Are emissive textures enabled in the application.
  100483. */
  100484. static EmissiveTextureEnabled: boolean;
  100485. private static _SpecularTextureEnabled;
  100486. /**
  100487. * Are specular textures enabled in the application.
  100488. */
  100489. static SpecularTextureEnabled: boolean;
  100490. private static _BumpTextureEnabled;
  100491. /**
  100492. * Are bump textures enabled in the application.
  100493. */
  100494. static BumpTextureEnabled: boolean;
  100495. private static _LightmapTextureEnabled;
  100496. /**
  100497. * Are lightmap textures enabled in the application.
  100498. */
  100499. static LightmapTextureEnabled: boolean;
  100500. private static _RefractionTextureEnabled;
  100501. /**
  100502. * Are refraction textures enabled in the application.
  100503. */
  100504. static RefractionTextureEnabled: boolean;
  100505. private static _ColorGradingTextureEnabled;
  100506. /**
  100507. * Are color grading textures enabled in the application.
  100508. */
  100509. static ColorGradingTextureEnabled: boolean;
  100510. private static _FresnelEnabled;
  100511. /**
  100512. * Are fresnels enabled in the application.
  100513. */
  100514. static FresnelEnabled: boolean;
  100515. private static _ClearCoatTextureEnabled;
  100516. /**
  100517. * Are clear coat textures enabled in the application.
  100518. */
  100519. static ClearCoatTextureEnabled: boolean;
  100520. private static _ClearCoatBumpTextureEnabled;
  100521. /**
  100522. * Are clear coat bump textures enabled in the application.
  100523. */
  100524. static ClearCoatBumpTextureEnabled: boolean;
  100525. private static _ClearCoatTintTextureEnabled;
  100526. /**
  100527. * Are clear coat tint textures enabled in the application.
  100528. */
  100529. static ClearCoatTintTextureEnabled: boolean;
  100530. private static _SheenTextureEnabled;
  100531. /**
  100532. * Are sheen textures enabled in the application.
  100533. */
  100534. static SheenTextureEnabled: boolean;
  100535. private static _AnisotropicTextureEnabled;
  100536. /**
  100537. * Are anisotropic textures enabled in the application.
  100538. */
  100539. static AnisotropicTextureEnabled: boolean;
  100540. private static _ThicknessTextureEnabled;
  100541. /**
  100542. * Are thickness textures enabled in the application.
  100543. */
  100544. static ThicknessTextureEnabled: boolean;
  100545. }
  100546. }
  100547. declare module BABYLON {
  100548. /** @hidden */
  100549. export var defaultFragmentDeclaration: {
  100550. name: string;
  100551. shader: string;
  100552. };
  100553. }
  100554. declare module BABYLON {
  100555. /** @hidden */
  100556. export var defaultUboDeclaration: {
  100557. name: string;
  100558. shader: string;
  100559. };
  100560. }
  100561. declare module BABYLON {
  100562. /** @hidden */
  100563. export var lightFragmentDeclaration: {
  100564. name: string;
  100565. shader: string;
  100566. };
  100567. }
  100568. declare module BABYLON {
  100569. /** @hidden */
  100570. export var lightUboDeclaration: {
  100571. name: string;
  100572. shader: string;
  100573. };
  100574. }
  100575. declare module BABYLON {
  100576. /** @hidden */
  100577. export var lightsFragmentFunctions: {
  100578. name: string;
  100579. shader: string;
  100580. };
  100581. }
  100582. declare module BABYLON {
  100583. /** @hidden */
  100584. export var shadowsFragmentFunctions: {
  100585. name: string;
  100586. shader: string;
  100587. };
  100588. }
  100589. declare module BABYLON {
  100590. /** @hidden */
  100591. export var fresnelFunction: {
  100592. name: string;
  100593. shader: string;
  100594. };
  100595. }
  100596. declare module BABYLON {
  100597. /** @hidden */
  100598. export var reflectionFunction: {
  100599. name: string;
  100600. shader: string;
  100601. };
  100602. }
  100603. declare module BABYLON {
  100604. /** @hidden */
  100605. export var bumpFragmentFunctions: {
  100606. name: string;
  100607. shader: string;
  100608. };
  100609. }
  100610. declare module BABYLON {
  100611. /** @hidden */
  100612. export var logDepthDeclaration: {
  100613. name: string;
  100614. shader: string;
  100615. };
  100616. }
  100617. declare module BABYLON {
  100618. /** @hidden */
  100619. export var bumpFragment: {
  100620. name: string;
  100621. shader: string;
  100622. };
  100623. }
  100624. declare module BABYLON {
  100625. /** @hidden */
  100626. export var depthPrePass: {
  100627. name: string;
  100628. shader: string;
  100629. };
  100630. }
  100631. declare module BABYLON {
  100632. /** @hidden */
  100633. export var lightFragment: {
  100634. name: string;
  100635. shader: string;
  100636. };
  100637. }
  100638. declare module BABYLON {
  100639. /** @hidden */
  100640. export var logDepthFragment: {
  100641. name: string;
  100642. shader: string;
  100643. };
  100644. }
  100645. declare module BABYLON {
  100646. /** @hidden */
  100647. export var defaultPixelShader: {
  100648. name: string;
  100649. shader: string;
  100650. };
  100651. }
  100652. declare module BABYLON {
  100653. /** @hidden */
  100654. export var defaultVertexDeclaration: {
  100655. name: string;
  100656. shader: string;
  100657. };
  100658. }
  100659. declare module BABYLON {
  100660. /** @hidden */
  100661. export var bumpVertexDeclaration: {
  100662. name: string;
  100663. shader: string;
  100664. };
  100665. }
  100666. declare module BABYLON {
  100667. /** @hidden */
  100668. export var bumpVertex: {
  100669. name: string;
  100670. shader: string;
  100671. };
  100672. }
  100673. declare module BABYLON {
  100674. /** @hidden */
  100675. export var fogVertex: {
  100676. name: string;
  100677. shader: string;
  100678. };
  100679. }
  100680. declare module BABYLON {
  100681. /** @hidden */
  100682. export var shadowsVertex: {
  100683. name: string;
  100684. shader: string;
  100685. };
  100686. }
  100687. declare module BABYLON {
  100688. /** @hidden */
  100689. export var pointCloudVertex: {
  100690. name: string;
  100691. shader: string;
  100692. };
  100693. }
  100694. declare module BABYLON {
  100695. /** @hidden */
  100696. export var logDepthVertex: {
  100697. name: string;
  100698. shader: string;
  100699. };
  100700. }
  100701. declare module BABYLON {
  100702. /** @hidden */
  100703. export var defaultVertexShader: {
  100704. name: string;
  100705. shader: string;
  100706. };
  100707. }
  100708. declare module BABYLON {
  100709. /** @hidden */
  100710. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  100711. MAINUV1: boolean;
  100712. MAINUV2: boolean;
  100713. DIFFUSE: boolean;
  100714. DIFFUSEDIRECTUV: number;
  100715. AMBIENT: boolean;
  100716. AMBIENTDIRECTUV: number;
  100717. OPACITY: boolean;
  100718. OPACITYDIRECTUV: number;
  100719. OPACITYRGB: boolean;
  100720. REFLECTION: boolean;
  100721. EMISSIVE: boolean;
  100722. EMISSIVEDIRECTUV: number;
  100723. SPECULAR: boolean;
  100724. SPECULARDIRECTUV: number;
  100725. BUMP: boolean;
  100726. BUMPDIRECTUV: number;
  100727. PARALLAX: boolean;
  100728. PARALLAXOCCLUSION: boolean;
  100729. SPECULAROVERALPHA: boolean;
  100730. CLIPPLANE: boolean;
  100731. CLIPPLANE2: boolean;
  100732. CLIPPLANE3: boolean;
  100733. CLIPPLANE4: boolean;
  100734. ALPHATEST: boolean;
  100735. DEPTHPREPASS: boolean;
  100736. ALPHAFROMDIFFUSE: boolean;
  100737. POINTSIZE: boolean;
  100738. FOG: boolean;
  100739. SPECULARTERM: boolean;
  100740. DIFFUSEFRESNEL: boolean;
  100741. OPACITYFRESNEL: boolean;
  100742. REFLECTIONFRESNEL: boolean;
  100743. REFRACTIONFRESNEL: boolean;
  100744. EMISSIVEFRESNEL: boolean;
  100745. FRESNEL: boolean;
  100746. NORMAL: boolean;
  100747. UV1: boolean;
  100748. UV2: boolean;
  100749. VERTEXCOLOR: boolean;
  100750. VERTEXALPHA: boolean;
  100751. NUM_BONE_INFLUENCERS: number;
  100752. BonesPerMesh: number;
  100753. BONETEXTURE: boolean;
  100754. INSTANCES: boolean;
  100755. GLOSSINESS: boolean;
  100756. ROUGHNESS: boolean;
  100757. EMISSIVEASILLUMINATION: boolean;
  100758. LINKEMISSIVEWITHDIFFUSE: boolean;
  100759. REFLECTIONFRESNELFROMSPECULAR: boolean;
  100760. LIGHTMAP: boolean;
  100761. LIGHTMAPDIRECTUV: number;
  100762. OBJECTSPACE_NORMALMAP: boolean;
  100763. USELIGHTMAPASSHADOWMAP: boolean;
  100764. REFLECTIONMAP_3D: boolean;
  100765. REFLECTIONMAP_SPHERICAL: boolean;
  100766. REFLECTIONMAP_PLANAR: boolean;
  100767. REFLECTIONMAP_CUBIC: boolean;
  100768. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  100769. REFLECTIONMAP_PROJECTION: boolean;
  100770. REFLECTIONMAP_SKYBOX: boolean;
  100771. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  100772. REFLECTIONMAP_EXPLICIT: boolean;
  100773. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  100774. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  100775. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  100776. INVERTCUBICMAP: boolean;
  100777. LOGARITHMICDEPTH: boolean;
  100778. REFRACTION: boolean;
  100779. REFRACTIONMAP_3D: boolean;
  100780. REFLECTIONOVERALPHA: boolean;
  100781. TWOSIDEDLIGHTING: boolean;
  100782. SHADOWFLOAT: boolean;
  100783. MORPHTARGETS: boolean;
  100784. MORPHTARGETS_NORMAL: boolean;
  100785. MORPHTARGETS_TANGENT: boolean;
  100786. NUM_MORPH_INFLUENCERS: number;
  100787. NONUNIFORMSCALING: boolean;
  100788. PREMULTIPLYALPHA: boolean;
  100789. IMAGEPROCESSING: boolean;
  100790. VIGNETTE: boolean;
  100791. VIGNETTEBLENDMODEMULTIPLY: boolean;
  100792. VIGNETTEBLENDMODEOPAQUE: boolean;
  100793. TONEMAPPING: boolean;
  100794. TONEMAPPING_ACES: boolean;
  100795. CONTRAST: boolean;
  100796. COLORCURVES: boolean;
  100797. COLORGRADING: boolean;
  100798. COLORGRADING3D: boolean;
  100799. SAMPLER3DGREENDEPTH: boolean;
  100800. SAMPLER3DBGRMAP: boolean;
  100801. IMAGEPROCESSINGPOSTPROCESS: boolean;
  100802. MULTIVIEW: boolean;
  100803. /**
  100804. * If the reflection texture on this material is in linear color space
  100805. * @hidden
  100806. */
  100807. IS_REFLECTION_LINEAR: boolean;
  100808. /**
  100809. * If the refraction texture on this material is in linear color space
  100810. * @hidden
  100811. */
  100812. IS_REFRACTION_LINEAR: boolean;
  100813. EXPOSURE: boolean;
  100814. constructor();
  100815. setReflectionMode(modeToEnable: string): void;
  100816. }
  100817. /**
  100818. * This is the default material used in Babylon. It is the best trade off between quality
  100819. * and performances.
  100820. * @see http://doc.babylonjs.com/babylon101/materials
  100821. */
  100822. export class StandardMaterial extends PushMaterial {
  100823. private _diffuseTexture;
  100824. /**
  100825. * The basic texture of the material as viewed under a light.
  100826. */
  100827. diffuseTexture: Nullable<BaseTexture>;
  100828. private _ambientTexture;
  100829. /**
  100830. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  100831. */
  100832. ambientTexture: Nullable<BaseTexture>;
  100833. private _opacityTexture;
  100834. /**
  100835. * Define the transparency of the material from a texture.
  100836. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  100837. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  100838. */
  100839. opacityTexture: Nullable<BaseTexture>;
  100840. private _reflectionTexture;
  100841. /**
  100842. * Define the texture used to display the reflection.
  100843. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  100844. */
  100845. reflectionTexture: Nullable<BaseTexture>;
  100846. private _emissiveTexture;
  100847. /**
  100848. * Define texture of the material as if self lit.
  100849. * This will be mixed in the final result even in the absence of light.
  100850. */
  100851. emissiveTexture: Nullable<BaseTexture>;
  100852. private _specularTexture;
  100853. /**
  100854. * Define how the color and intensity of the highlight given by the light in the material.
  100855. */
  100856. specularTexture: Nullable<BaseTexture>;
  100857. private _bumpTexture;
  100858. /**
  100859. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  100860. * 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.
  100861. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  100862. */
  100863. bumpTexture: Nullable<BaseTexture>;
  100864. private _lightmapTexture;
  100865. /**
  100866. * Complex lighting can be computationally expensive to compute at runtime.
  100867. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  100868. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  100869. */
  100870. lightmapTexture: Nullable<BaseTexture>;
  100871. private _refractionTexture;
  100872. /**
  100873. * Define the texture used to display the refraction.
  100874. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  100875. */
  100876. refractionTexture: Nullable<BaseTexture>;
  100877. /**
  100878. * The color of the material lit by the environmental background lighting.
  100879. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  100880. */
  100881. ambientColor: Color3;
  100882. /**
  100883. * The basic color of the material as viewed under a light.
  100884. */
  100885. diffuseColor: Color3;
  100886. /**
  100887. * Define how the color and intensity of the highlight given by the light in the material.
  100888. */
  100889. specularColor: Color3;
  100890. /**
  100891. * Define the color of the material as if self lit.
  100892. * This will be mixed in the final result even in the absence of light.
  100893. */
  100894. emissiveColor: Color3;
  100895. /**
  100896. * Defines how sharp are the highlights in the material.
  100897. * The bigger the value the sharper giving a more glossy feeling to the result.
  100898. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  100899. */
  100900. specularPower: number;
  100901. private _useAlphaFromDiffuseTexture;
  100902. /**
  100903. * Does the transparency come from the diffuse texture alpha channel.
  100904. */
  100905. useAlphaFromDiffuseTexture: boolean;
  100906. private _useEmissiveAsIllumination;
  100907. /**
  100908. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  100909. */
  100910. useEmissiveAsIllumination: boolean;
  100911. private _linkEmissiveWithDiffuse;
  100912. /**
  100913. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  100914. * the emissive level when the final color is close to one.
  100915. */
  100916. linkEmissiveWithDiffuse: boolean;
  100917. private _useSpecularOverAlpha;
  100918. /**
  100919. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  100920. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  100921. */
  100922. useSpecularOverAlpha: boolean;
  100923. private _useReflectionOverAlpha;
  100924. /**
  100925. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  100926. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  100927. */
  100928. useReflectionOverAlpha: boolean;
  100929. private _disableLighting;
  100930. /**
  100931. * Does lights from the scene impacts this material.
  100932. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  100933. */
  100934. disableLighting: boolean;
  100935. private _useObjectSpaceNormalMap;
  100936. /**
  100937. * Allows using an object space normal map (instead of tangent space).
  100938. */
  100939. useObjectSpaceNormalMap: boolean;
  100940. private _useParallax;
  100941. /**
  100942. * Is parallax enabled or not.
  100943. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  100944. */
  100945. useParallax: boolean;
  100946. private _useParallaxOcclusion;
  100947. /**
  100948. * Is parallax occlusion enabled or not.
  100949. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  100950. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  100951. */
  100952. useParallaxOcclusion: boolean;
  100953. /**
  100954. * 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.
  100955. */
  100956. parallaxScaleBias: number;
  100957. private _roughness;
  100958. /**
  100959. * Helps to define how blurry the reflections should appears in the material.
  100960. */
  100961. roughness: number;
  100962. /**
  100963. * In case of refraction, define the value of the indice of refraction.
  100964. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  100965. */
  100966. indexOfRefraction: number;
  100967. /**
  100968. * Invert the refraction texture alongside the y axis.
  100969. * It can be useful with procedural textures or probe for instance.
  100970. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  100971. */
  100972. invertRefractionY: boolean;
  100973. /**
  100974. * Defines the alpha limits in alpha test mode.
  100975. */
  100976. alphaCutOff: number;
  100977. private _useLightmapAsShadowmap;
  100978. /**
  100979. * In case of light mapping, define whether the map contains light or shadow informations.
  100980. */
  100981. useLightmapAsShadowmap: boolean;
  100982. private _diffuseFresnelParameters;
  100983. /**
  100984. * Define the diffuse fresnel parameters of the material.
  100985. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  100986. */
  100987. diffuseFresnelParameters: FresnelParameters;
  100988. private _opacityFresnelParameters;
  100989. /**
  100990. * Define the opacity fresnel parameters of the material.
  100991. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  100992. */
  100993. opacityFresnelParameters: FresnelParameters;
  100994. private _reflectionFresnelParameters;
  100995. /**
  100996. * Define the reflection fresnel parameters of the material.
  100997. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  100998. */
  100999. reflectionFresnelParameters: FresnelParameters;
  101000. private _refractionFresnelParameters;
  101001. /**
  101002. * Define the refraction fresnel parameters of the material.
  101003. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  101004. */
  101005. refractionFresnelParameters: FresnelParameters;
  101006. private _emissiveFresnelParameters;
  101007. /**
  101008. * Define the emissive fresnel parameters of the material.
  101009. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  101010. */
  101011. emissiveFresnelParameters: FresnelParameters;
  101012. private _useReflectionFresnelFromSpecular;
  101013. /**
  101014. * If true automatically deducts the fresnels values from the material specularity.
  101015. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  101016. */
  101017. useReflectionFresnelFromSpecular: boolean;
  101018. private _useGlossinessFromSpecularMapAlpha;
  101019. /**
  101020. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  101021. */
  101022. useGlossinessFromSpecularMapAlpha: boolean;
  101023. private _maxSimultaneousLights;
  101024. /**
  101025. * Defines the maximum number of lights that can be used in the material
  101026. */
  101027. maxSimultaneousLights: number;
  101028. private _invertNormalMapX;
  101029. /**
  101030. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  101031. */
  101032. invertNormalMapX: boolean;
  101033. private _invertNormalMapY;
  101034. /**
  101035. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  101036. */
  101037. invertNormalMapY: boolean;
  101038. private _twoSidedLighting;
  101039. /**
  101040. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  101041. */
  101042. twoSidedLighting: boolean;
  101043. /**
  101044. * Default configuration related to image processing available in the standard Material.
  101045. */
  101046. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  101047. /**
  101048. * Gets the image processing configuration used either in this material.
  101049. */
  101050. /**
  101051. * Sets the Default image processing configuration used either in the this material.
  101052. *
  101053. * If sets to null, the scene one is in use.
  101054. */
  101055. imageProcessingConfiguration: ImageProcessingConfiguration;
  101056. /**
  101057. * Keep track of the image processing observer to allow dispose and replace.
  101058. */
  101059. private _imageProcessingObserver;
  101060. /**
  101061. * Attaches a new image processing configuration to the Standard Material.
  101062. * @param configuration
  101063. */
  101064. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  101065. /**
  101066. * Gets wether the color curves effect is enabled.
  101067. */
  101068. /**
  101069. * Sets wether the color curves effect is enabled.
  101070. */
  101071. cameraColorCurvesEnabled: boolean;
  101072. /**
  101073. * Gets wether the color grading effect is enabled.
  101074. */
  101075. /**
  101076. * Gets wether the color grading effect is enabled.
  101077. */
  101078. cameraColorGradingEnabled: boolean;
  101079. /**
  101080. * Gets wether tonemapping is enabled or not.
  101081. */
  101082. /**
  101083. * Sets wether tonemapping is enabled or not
  101084. */
  101085. cameraToneMappingEnabled: boolean;
  101086. /**
  101087. * The camera exposure used on this material.
  101088. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  101089. * This corresponds to a photographic exposure.
  101090. */
  101091. /**
  101092. * The camera exposure used on this material.
  101093. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  101094. * This corresponds to a photographic exposure.
  101095. */
  101096. cameraExposure: number;
  101097. /**
  101098. * Gets The camera contrast used on this material.
  101099. */
  101100. /**
  101101. * Sets The camera contrast used on this material.
  101102. */
  101103. cameraContrast: number;
  101104. /**
  101105. * Gets the Color Grading 2D Lookup Texture.
  101106. */
  101107. /**
  101108. * Sets the Color Grading 2D Lookup Texture.
  101109. */
  101110. cameraColorGradingTexture: Nullable<BaseTexture>;
  101111. /**
  101112. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  101113. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  101114. * 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;
  101115. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  101116. */
  101117. /**
  101118. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  101119. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  101120. * 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;
  101121. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  101122. */
  101123. cameraColorCurves: Nullable<ColorCurves>;
  101124. /**
  101125. * Custom callback helping to override the default shader used in the material.
  101126. */
  101127. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  101128. protected _renderTargets: SmartArray<RenderTargetTexture>;
  101129. protected _worldViewProjectionMatrix: Matrix;
  101130. protected _globalAmbientColor: Color3;
  101131. protected _useLogarithmicDepth: boolean;
  101132. /**
  101133. * Instantiates a new standard material.
  101134. * This is the default material used in Babylon. It is the best trade off between quality
  101135. * and performances.
  101136. * @see http://doc.babylonjs.com/babylon101/materials
  101137. * @param name Define the name of the material in the scene
  101138. * @param scene Define the scene the material belong to
  101139. */
  101140. constructor(name: string, scene: Scene);
  101141. /**
  101142. * Gets a boolean indicating that current material needs to register RTT
  101143. */
  101144. readonly hasRenderTargetTextures: boolean;
  101145. /**
  101146. * Gets the current class name of the material e.g. "StandardMaterial"
  101147. * Mainly use in serialization.
  101148. * @returns the class name
  101149. */
  101150. getClassName(): string;
  101151. /**
  101152. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  101153. * You can try switching to logarithmic depth.
  101154. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  101155. */
  101156. useLogarithmicDepth: boolean;
  101157. /**
  101158. * Specifies if the material will require alpha blending
  101159. * @returns a boolean specifying if alpha blending is needed
  101160. */
  101161. needAlphaBlending(): boolean;
  101162. /**
  101163. * Specifies if this material should be rendered in alpha test mode
  101164. * @returns a boolean specifying if an alpha test is needed.
  101165. */
  101166. needAlphaTesting(): boolean;
  101167. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  101168. /**
  101169. * Get the texture used for alpha test purpose.
  101170. * @returns the diffuse texture in case of the standard material.
  101171. */
  101172. getAlphaTestTexture(): Nullable<BaseTexture>;
  101173. /**
  101174. * Get if the submesh is ready to be used and all its information available.
  101175. * Child classes can use it to update shaders
  101176. * @param mesh defines the mesh to check
  101177. * @param subMesh defines which submesh to check
  101178. * @param useInstances specifies that instances should be used
  101179. * @returns a boolean indicating that the submesh is ready or not
  101180. */
  101181. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  101182. /**
  101183. * Builds the material UBO layouts.
  101184. * Used internally during the effect preparation.
  101185. */
  101186. buildUniformLayout(): void;
  101187. /**
  101188. * Unbinds the material from the mesh
  101189. */
  101190. unbind(): void;
  101191. /**
  101192. * Binds the submesh to this material by preparing the effect and shader to draw
  101193. * @param world defines the world transformation matrix
  101194. * @param mesh defines the mesh containing the submesh
  101195. * @param subMesh defines the submesh to bind the material to
  101196. */
  101197. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  101198. /**
  101199. * Get the list of animatables in the material.
  101200. * @returns the list of animatables object used in the material
  101201. */
  101202. getAnimatables(): IAnimatable[];
  101203. /**
  101204. * Gets the active textures from the material
  101205. * @returns an array of textures
  101206. */
  101207. getActiveTextures(): BaseTexture[];
  101208. /**
  101209. * Specifies if the material uses a texture
  101210. * @param texture defines the texture to check against the material
  101211. * @returns a boolean specifying if the material uses the texture
  101212. */
  101213. hasTexture(texture: BaseTexture): boolean;
  101214. /**
  101215. * Disposes the material
  101216. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  101217. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  101218. */
  101219. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  101220. /**
  101221. * Makes a duplicate of the material, and gives it a new name
  101222. * @param name defines the new name for the duplicated material
  101223. * @returns the cloned material
  101224. */
  101225. clone(name: string): StandardMaterial;
  101226. /**
  101227. * Serializes this material in a JSON representation
  101228. * @returns the serialized material object
  101229. */
  101230. serialize(): any;
  101231. /**
  101232. * Creates a standard material from parsed material data
  101233. * @param source defines the JSON representation of the material
  101234. * @param scene defines the hosting scene
  101235. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  101236. * @returns a new standard material
  101237. */
  101238. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  101239. /**
  101240. * Are diffuse textures enabled in the application.
  101241. */
  101242. static DiffuseTextureEnabled: boolean;
  101243. /**
  101244. * Are ambient textures enabled in the application.
  101245. */
  101246. static AmbientTextureEnabled: boolean;
  101247. /**
  101248. * Are opacity textures enabled in the application.
  101249. */
  101250. static OpacityTextureEnabled: boolean;
  101251. /**
  101252. * Are reflection textures enabled in the application.
  101253. */
  101254. static ReflectionTextureEnabled: boolean;
  101255. /**
  101256. * Are emissive textures enabled in the application.
  101257. */
  101258. static EmissiveTextureEnabled: boolean;
  101259. /**
  101260. * Are specular textures enabled in the application.
  101261. */
  101262. static SpecularTextureEnabled: boolean;
  101263. /**
  101264. * Are bump textures enabled in the application.
  101265. */
  101266. static BumpTextureEnabled: boolean;
  101267. /**
  101268. * Are lightmap textures enabled in the application.
  101269. */
  101270. static LightmapTextureEnabled: boolean;
  101271. /**
  101272. * Are refraction textures enabled in the application.
  101273. */
  101274. static RefractionTextureEnabled: boolean;
  101275. /**
  101276. * Are color grading textures enabled in the application.
  101277. */
  101278. static ColorGradingTextureEnabled: boolean;
  101279. /**
  101280. * Are fresnels enabled in the application.
  101281. */
  101282. static FresnelEnabled: boolean;
  101283. }
  101284. }
  101285. declare module BABYLON {
  101286. /**
  101287. * A class extending Texture allowing drawing on a texture
  101288. * @see http://doc.babylonjs.com/how_to/dynamictexture
  101289. */
  101290. export class DynamicTexture extends Texture {
  101291. private _generateMipMaps;
  101292. private _canvas;
  101293. private _context;
  101294. private _engine;
  101295. /**
  101296. * Creates a DynamicTexture
  101297. * @param name defines the name of the texture
  101298. * @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
  101299. * @param scene defines the scene where you want the texture
  101300. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  101301. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  101302. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  101303. */
  101304. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  101305. /**
  101306. * Get the current class name of the texture useful for serialization or dynamic coding.
  101307. * @returns "DynamicTexture"
  101308. */
  101309. getClassName(): string;
  101310. /**
  101311. * Gets the current state of canRescale
  101312. */
  101313. readonly canRescale: boolean;
  101314. private _recreate;
  101315. /**
  101316. * Scales the texture
  101317. * @param ratio the scale factor to apply to both width and height
  101318. */
  101319. scale(ratio: number): void;
  101320. /**
  101321. * Resizes the texture
  101322. * @param width the new width
  101323. * @param height the new height
  101324. */
  101325. scaleTo(width: number, height: number): void;
  101326. /**
  101327. * Gets the context of the canvas used by the texture
  101328. * @returns the canvas context of the dynamic texture
  101329. */
  101330. getContext(): CanvasRenderingContext2D;
  101331. /**
  101332. * Clears the texture
  101333. */
  101334. clear(): void;
  101335. /**
  101336. * Updates the texture
  101337. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  101338. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  101339. */
  101340. update(invertY?: boolean, premulAlpha?: boolean): void;
  101341. /**
  101342. * Draws text onto the texture
  101343. * @param text defines the text to be drawn
  101344. * @param x defines the placement of the text from the left
  101345. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  101346. * @param font defines the font to be used with font-style, font-size, font-name
  101347. * @param color defines the color used for the text
  101348. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  101349. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  101350. * @param update defines whether texture is immediately update (default is true)
  101351. */
  101352. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  101353. /**
  101354. * Clones the texture
  101355. * @returns the clone of the texture.
  101356. */
  101357. clone(): DynamicTexture;
  101358. /**
  101359. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  101360. * @returns a serialized dynamic texture object
  101361. */
  101362. serialize(): any;
  101363. /** @hidden */
  101364. _rebuild(): void;
  101365. }
  101366. }
  101367. declare module BABYLON {
  101368. /** @hidden */
  101369. export var imageProcessingPixelShader: {
  101370. name: string;
  101371. shader: string;
  101372. };
  101373. }
  101374. declare module BABYLON {
  101375. /**
  101376. * ImageProcessingPostProcess
  101377. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  101378. */
  101379. export class ImageProcessingPostProcess extends PostProcess {
  101380. /**
  101381. * Default configuration related to image processing available in the PBR Material.
  101382. */
  101383. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  101384. /**
  101385. * Gets the image processing configuration used either in this material.
  101386. */
  101387. /**
  101388. * Sets the Default image processing configuration used either in the this material.
  101389. *
  101390. * If sets to null, the scene one is in use.
  101391. */
  101392. imageProcessingConfiguration: ImageProcessingConfiguration;
  101393. /**
  101394. * Keep track of the image processing observer to allow dispose and replace.
  101395. */
  101396. private _imageProcessingObserver;
  101397. /**
  101398. * Attaches a new image processing configuration to the PBR Material.
  101399. * @param configuration
  101400. */
  101401. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  101402. /**
  101403. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  101404. */
  101405. /**
  101406. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  101407. */
  101408. colorCurves: Nullable<ColorCurves>;
  101409. /**
  101410. * Gets wether the color curves effect is enabled.
  101411. */
  101412. /**
  101413. * Sets wether the color curves effect is enabled.
  101414. */
  101415. colorCurvesEnabled: boolean;
  101416. /**
  101417. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  101418. */
  101419. /**
  101420. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  101421. */
  101422. colorGradingTexture: Nullable<BaseTexture>;
  101423. /**
  101424. * Gets wether the color grading effect is enabled.
  101425. */
  101426. /**
  101427. * Gets wether the color grading effect is enabled.
  101428. */
  101429. colorGradingEnabled: boolean;
  101430. /**
  101431. * Gets exposure used in the effect.
  101432. */
  101433. /**
  101434. * Sets exposure used in the effect.
  101435. */
  101436. exposure: number;
  101437. /**
  101438. * Gets wether tonemapping is enabled or not.
  101439. */
  101440. /**
  101441. * Sets wether tonemapping is enabled or not
  101442. */
  101443. toneMappingEnabled: boolean;
  101444. /**
  101445. * Gets the type of tone mapping effect.
  101446. */
  101447. /**
  101448. * Sets the type of tone mapping effect.
  101449. */
  101450. toneMappingType: number;
  101451. /**
  101452. * Gets contrast used in the effect.
  101453. */
  101454. /**
  101455. * Sets contrast used in the effect.
  101456. */
  101457. contrast: number;
  101458. /**
  101459. * Gets Vignette stretch size.
  101460. */
  101461. /**
  101462. * Sets Vignette stretch size.
  101463. */
  101464. vignetteStretch: number;
  101465. /**
  101466. * Gets Vignette centre X Offset.
  101467. */
  101468. /**
  101469. * Sets Vignette centre X Offset.
  101470. */
  101471. vignetteCentreX: number;
  101472. /**
  101473. * Gets Vignette centre Y Offset.
  101474. */
  101475. /**
  101476. * Sets Vignette centre Y Offset.
  101477. */
  101478. vignetteCentreY: number;
  101479. /**
  101480. * Gets Vignette weight or intensity of the vignette effect.
  101481. */
  101482. /**
  101483. * Sets Vignette weight or intensity of the vignette effect.
  101484. */
  101485. vignetteWeight: number;
  101486. /**
  101487. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  101488. * if vignetteEnabled is set to true.
  101489. */
  101490. /**
  101491. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  101492. * if vignetteEnabled is set to true.
  101493. */
  101494. vignetteColor: Color4;
  101495. /**
  101496. * Gets Camera field of view used by the Vignette effect.
  101497. */
  101498. /**
  101499. * Sets Camera field of view used by the Vignette effect.
  101500. */
  101501. vignetteCameraFov: number;
  101502. /**
  101503. * Gets the vignette blend mode allowing different kind of effect.
  101504. */
  101505. /**
  101506. * Sets the vignette blend mode allowing different kind of effect.
  101507. */
  101508. vignetteBlendMode: number;
  101509. /**
  101510. * Gets wether the vignette effect is enabled.
  101511. */
  101512. /**
  101513. * Sets wether the vignette effect is enabled.
  101514. */
  101515. vignetteEnabled: boolean;
  101516. private _fromLinearSpace;
  101517. /**
  101518. * Gets wether the input of the processing is in Gamma or Linear Space.
  101519. */
  101520. /**
  101521. * Sets wether the input of the processing is in Gamma or Linear Space.
  101522. */
  101523. fromLinearSpace: boolean;
  101524. /**
  101525. * Defines cache preventing GC.
  101526. */
  101527. private _defines;
  101528. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  101529. /**
  101530. * "ImageProcessingPostProcess"
  101531. * @returns "ImageProcessingPostProcess"
  101532. */
  101533. getClassName(): string;
  101534. protected _updateParameters(): void;
  101535. dispose(camera?: Camera): void;
  101536. }
  101537. }
  101538. declare module BABYLON {
  101539. /**
  101540. * Class containing static functions to help procedurally build meshes
  101541. */
  101542. export class GroundBuilder {
  101543. /**
  101544. * Creates a ground mesh
  101545. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  101546. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  101547. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  101548. * @param name defines the name of the mesh
  101549. * @param options defines the options used to create the mesh
  101550. * @param scene defines the hosting scene
  101551. * @returns the ground mesh
  101552. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  101553. */
  101554. static CreateGround(name: string, options: {
  101555. width?: number;
  101556. height?: number;
  101557. subdivisions?: number;
  101558. subdivisionsX?: number;
  101559. subdivisionsY?: number;
  101560. updatable?: boolean;
  101561. }, scene: any): Mesh;
  101562. /**
  101563. * Creates a tiled ground mesh
  101564. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  101565. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  101566. * * 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
  101567. * * 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
  101568. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  101569. * @param name defines the name of the mesh
  101570. * @param options defines the options used to create the mesh
  101571. * @param scene defines the hosting scene
  101572. * @returns the tiled ground mesh
  101573. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  101574. */
  101575. static CreateTiledGround(name: string, options: {
  101576. xmin: number;
  101577. zmin: number;
  101578. xmax: number;
  101579. zmax: number;
  101580. subdivisions?: {
  101581. w: number;
  101582. h: number;
  101583. };
  101584. precision?: {
  101585. w: number;
  101586. h: number;
  101587. };
  101588. updatable?: boolean;
  101589. }, scene?: Nullable<Scene>): Mesh;
  101590. /**
  101591. * Creates a ground mesh from a height map
  101592. * * The parameter `url` sets the URL of the height map image resource.
  101593. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  101594. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  101595. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  101596. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  101597. * * 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.
  101598. * * 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).
  101599. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  101600. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  101601. * @param name defines the name of the mesh
  101602. * @param url defines the url to the height map
  101603. * @param options defines the options used to create the mesh
  101604. * @param scene defines the hosting scene
  101605. * @returns the ground mesh
  101606. * @see https://doc.babylonjs.com/babylon101/height_map
  101607. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  101608. */
  101609. static CreateGroundFromHeightMap(name: string, url: string, options: {
  101610. width?: number;
  101611. height?: number;
  101612. subdivisions?: number;
  101613. minHeight?: number;
  101614. maxHeight?: number;
  101615. colorFilter?: Color3;
  101616. alphaFilter?: number;
  101617. updatable?: boolean;
  101618. onReady?: (mesh: GroundMesh) => void;
  101619. }, scene?: Nullable<Scene>): GroundMesh;
  101620. }
  101621. }
  101622. declare module BABYLON {
  101623. /**
  101624. * Class containing static functions to help procedurally build meshes
  101625. */
  101626. export class TorusBuilder {
  101627. /**
  101628. * Creates a torus mesh
  101629. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  101630. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  101631. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  101632. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  101633. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  101634. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  101635. * @param name defines the name of the mesh
  101636. * @param options defines the options used to create the mesh
  101637. * @param scene defines the hosting scene
  101638. * @returns the torus mesh
  101639. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  101640. */
  101641. static CreateTorus(name: string, options: {
  101642. diameter?: number;
  101643. thickness?: number;
  101644. tessellation?: number;
  101645. updatable?: boolean;
  101646. sideOrientation?: number;
  101647. frontUVs?: Vector4;
  101648. backUVs?: Vector4;
  101649. }, scene: any): Mesh;
  101650. }
  101651. }
  101652. declare module BABYLON {
  101653. /**
  101654. * Class containing static functions to help procedurally build meshes
  101655. */
  101656. export class CylinderBuilder {
  101657. /**
  101658. * Creates a cylinder or a cone mesh
  101659. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  101660. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  101661. * * 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.
  101662. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  101663. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  101664. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  101665. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  101666. * * 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).
  101667. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  101668. * * 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).
  101669. * * 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
  101670. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  101671. * * 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
  101672. * * 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.
  101673. * * If `enclose` is false, a ring surface is one element.
  101674. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  101675. * * 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
  101676. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  101677. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  101678. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  101679. * @param name defines the name of the mesh
  101680. * @param options defines the options used to create the mesh
  101681. * @param scene defines the hosting scene
  101682. * @returns the cylinder mesh
  101683. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  101684. */
  101685. static CreateCylinder(name: string, options: {
  101686. height?: number;
  101687. diameterTop?: number;
  101688. diameterBottom?: number;
  101689. diameter?: number;
  101690. tessellation?: number;
  101691. subdivisions?: number;
  101692. arc?: number;
  101693. faceColors?: Color4[];
  101694. faceUV?: Vector4[];
  101695. updatable?: boolean;
  101696. hasRings?: boolean;
  101697. enclose?: boolean;
  101698. cap?: number;
  101699. sideOrientation?: number;
  101700. frontUVs?: Vector4;
  101701. backUVs?: Vector4;
  101702. }, scene: any): Mesh;
  101703. }
  101704. }
  101705. declare module BABYLON {
  101706. /**
  101707. * Options to modify the vr teleportation behavior.
  101708. */
  101709. export interface VRTeleportationOptions {
  101710. /**
  101711. * The name of the mesh which should be used as the teleportation floor. (default: null)
  101712. */
  101713. floorMeshName?: string;
  101714. /**
  101715. * A list of meshes to be used as the teleportation floor. (default: empty)
  101716. */
  101717. floorMeshes?: Mesh[];
  101718. }
  101719. /**
  101720. * Options to modify the vr experience helper's behavior.
  101721. */
  101722. export interface VRExperienceHelperOptions extends WebVROptions {
  101723. /**
  101724. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  101725. */
  101726. createDeviceOrientationCamera?: boolean;
  101727. /**
  101728. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  101729. */
  101730. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  101731. /**
  101732. * Uses the main button on the controller to toggle the laser casted. (default: true)
  101733. */
  101734. laserToggle?: boolean;
  101735. /**
  101736. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  101737. */
  101738. floorMeshes?: Mesh[];
  101739. /**
  101740. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  101741. */
  101742. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  101743. }
  101744. /**
  101745. * Event containing information after VR has been entered
  101746. */
  101747. export class OnAfterEnteringVRObservableEvent {
  101748. /**
  101749. * If entering vr was successful
  101750. */
  101751. success: boolean;
  101752. }
  101753. /**
  101754. * Helps to quickly add VR support to an existing scene.
  101755. * See http://doc.babylonjs.com/how_to/webvr_helper
  101756. */
  101757. export class VRExperienceHelper {
  101758. /** Options to modify the vr experience helper's behavior. */
  101759. webVROptions: VRExperienceHelperOptions;
  101760. private _scene;
  101761. private _position;
  101762. private _btnVR;
  101763. private _btnVRDisplayed;
  101764. private _webVRsupported;
  101765. private _webVRready;
  101766. private _webVRrequesting;
  101767. private _webVRpresenting;
  101768. private _hasEnteredVR;
  101769. private _fullscreenVRpresenting;
  101770. private _canvas;
  101771. private _webVRCamera;
  101772. private _vrDeviceOrientationCamera;
  101773. private _deviceOrientationCamera;
  101774. private _existingCamera;
  101775. private _onKeyDown;
  101776. private _onVrDisplayPresentChange;
  101777. private _onVRDisplayChanged;
  101778. private _onVRRequestPresentStart;
  101779. private _onVRRequestPresentComplete;
  101780. /**
  101781. * Observable raised right before entering VR.
  101782. */
  101783. onEnteringVRObservable: Observable<VRExperienceHelper>;
  101784. /**
  101785. * Observable raised when entering VR has completed.
  101786. */
  101787. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  101788. /**
  101789. * Observable raised when exiting VR.
  101790. */
  101791. onExitingVRObservable: Observable<VRExperienceHelper>;
  101792. /**
  101793. * Observable raised when controller mesh is loaded.
  101794. */
  101795. onControllerMeshLoadedObservable: Observable<WebVRController>;
  101796. /** Return this.onEnteringVRObservable
  101797. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  101798. */
  101799. readonly onEnteringVR: Observable<VRExperienceHelper>;
  101800. /** Return this.onExitingVRObservable
  101801. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  101802. */
  101803. readonly onExitingVR: Observable<VRExperienceHelper>;
  101804. /** Return this.onControllerMeshLoadedObservable
  101805. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  101806. */
  101807. readonly onControllerMeshLoaded: Observable<WebVRController>;
  101808. private _rayLength;
  101809. private _useCustomVRButton;
  101810. private _teleportationRequested;
  101811. private _teleportActive;
  101812. private _floorMeshName;
  101813. private _floorMeshesCollection;
  101814. private _rotationAllowed;
  101815. private _teleportBackwardsVector;
  101816. private _teleportationTarget;
  101817. private _isDefaultTeleportationTarget;
  101818. private _postProcessMove;
  101819. private _teleportationFillColor;
  101820. private _teleportationBorderColor;
  101821. private _rotationAngle;
  101822. private _haloCenter;
  101823. private _cameraGazer;
  101824. private _padSensibilityUp;
  101825. private _padSensibilityDown;
  101826. private _leftController;
  101827. private _rightController;
  101828. /**
  101829. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  101830. */
  101831. onNewMeshSelected: Observable<AbstractMesh>;
  101832. /**
  101833. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  101834. */
  101835. onNewMeshPicked: Observable<PickingInfo>;
  101836. private _circleEase;
  101837. /**
  101838. * Observable raised before camera teleportation
  101839. */
  101840. onBeforeCameraTeleport: Observable<Vector3>;
  101841. /**
  101842. * Observable raised after camera teleportation
  101843. */
  101844. onAfterCameraTeleport: Observable<Vector3>;
  101845. /**
  101846. * Observable raised when current selected mesh gets unselected
  101847. */
  101848. onSelectedMeshUnselected: Observable<AbstractMesh>;
  101849. private _raySelectionPredicate;
  101850. /**
  101851. * To be optionaly changed by user to define custom ray selection
  101852. */
  101853. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  101854. /**
  101855. * To be optionaly changed by user to define custom selection logic (after ray selection)
  101856. */
  101857. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  101858. /**
  101859. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  101860. */
  101861. teleportationEnabled: boolean;
  101862. private _defaultHeight;
  101863. private _teleportationInitialized;
  101864. private _interactionsEnabled;
  101865. private _interactionsRequested;
  101866. private _displayGaze;
  101867. private _displayLaserPointer;
  101868. /**
  101869. * The mesh used to display where the user is going to teleport.
  101870. */
  101871. /**
  101872. * Sets the mesh to be used to display where the user is going to teleport.
  101873. */
  101874. teleportationTarget: Mesh;
  101875. /**
  101876. * 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
  101877. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  101878. * See http://doc.babylonjs.com/resources/baking_transformations
  101879. */
  101880. gazeTrackerMesh: Mesh;
  101881. /**
  101882. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  101883. */
  101884. updateGazeTrackerScale: boolean;
  101885. /**
  101886. * If the gaze trackers color should be updated when selecting meshes
  101887. */
  101888. updateGazeTrackerColor: boolean;
  101889. /**
  101890. * The gaze tracking mesh corresponding to the left controller
  101891. */
  101892. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  101893. /**
  101894. * The gaze tracking mesh corresponding to the right controller
  101895. */
  101896. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  101897. /**
  101898. * If the ray of the gaze should be displayed.
  101899. */
  101900. /**
  101901. * Sets if the ray of the gaze should be displayed.
  101902. */
  101903. displayGaze: boolean;
  101904. /**
  101905. * If the ray of the LaserPointer should be displayed.
  101906. */
  101907. /**
  101908. * Sets if the ray of the LaserPointer should be displayed.
  101909. */
  101910. displayLaserPointer: boolean;
  101911. /**
  101912. * The deviceOrientationCamera used as the camera when not in VR.
  101913. */
  101914. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  101915. /**
  101916. * Based on the current WebVR support, returns the current VR camera used.
  101917. */
  101918. readonly currentVRCamera: Nullable<Camera>;
  101919. /**
  101920. * The webVRCamera which is used when in VR.
  101921. */
  101922. readonly webVRCamera: WebVRFreeCamera;
  101923. /**
  101924. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  101925. */
  101926. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  101927. private readonly _teleportationRequestInitiated;
  101928. /**
  101929. * Defines wether or not Pointer lock should be requested when switching to
  101930. * full screen.
  101931. */
  101932. requestPointerLockOnFullScreen: boolean;
  101933. /**
  101934. * Instantiates a VRExperienceHelper.
  101935. * Helps to quickly add VR support to an existing scene.
  101936. * @param scene The scene the VRExperienceHelper belongs to.
  101937. * @param webVROptions Options to modify the vr experience helper's behavior.
  101938. */
  101939. constructor(scene: Scene,
  101940. /** Options to modify the vr experience helper's behavior. */
  101941. webVROptions?: VRExperienceHelperOptions);
  101942. private _onDefaultMeshLoaded;
  101943. private _onResize;
  101944. private _onFullscreenChange;
  101945. /**
  101946. * Gets a value indicating if we are currently in VR mode.
  101947. */
  101948. readonly isInVRMode: boolean;
  101949. private onVrDisplayPresentChange;
  101950. private onVRDisplayChanged;
  101951. private moveButtonToBottomRight;
  101952. private displayVRButton;
  101953. private updateButtonVisibility;
  101954. private _cachedAngularSensibility;
  101955. /**
  101956. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  101957. * Otherwise, will use the fullscreen API.
  101958. */
  101959. enterVR(): void;
  101960. /**
  101961. * Attempt to exit VR, or fullscreen.
  101962. */
  101963. exitVR(): void;
  101964. /**
  101965. * The position of the vr experience helper.
  101966. */
  101967. /**
  101968. * Sets the position of the vr experience helper.
  101969. */
  101970. position: Vector3;
  101971. /**
  101972. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  101973. */
  101974. enableInteractions(): void;
  101975. private readonly _noControllerIsActive;
  101976. private beforeRender;
  101977. private _isTeleportationFloor;
  101978. /**
  101979. * Adds a floor mesh to be used for teleportation.
  101980. * @param floorMesh the mesh to be used for teleportation.
  101981. */
  101982. addFloorMesh(floorMesh: Mesh): void;
  101983. /**
  101984. * Removes a floor mesh from being used for teleportation.
  101985. * @param floorMesh the mesh to be removed.
  101986. */
  101987. removeFloorMesh(floorMesh: Mesh): void;
  101988. /**
  101989. * Enables interactions and teleportation using the VR controllers and gaze.
  101990. * @param vrTeleportationOptions options to modify teleportation behavior.
  101991. */
  101992. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  101993. private _onNewGamepadConnected;
  101994. private _tryEnableInteractionOnController;
  101995. private _onNewGamepadDisconnected;
  101996. private _enableInteractionOnController;
  101997. private _checkTeleportWithRay;
  101998. private _checkRotate;
  101999. private _checkTeleportBackwards;
  102000. private _enableTeleportationOnController;
  102001. private _createTeleportationCircles;
  102002. private _displayTeleportationTarget;
  102003. private _hideTeleportationTarget;
  102004. private _rotateCamera;
  102005. private _moveTeleportationSelectorTo;
  102006. private _workingVector;
  102007. private _workingQuaternion;
  102008. private _workingMatrix;
  102009. /**
  102010. * Teleports the users feet to the desired location
  102011. * @param location The location where the user's feet should be placed
  102012. */
  102013. teleportCamera(location: Vector3): void;
  102014. private _convertNormalToDirectionOfRay;
  102015. private _castRayAndSelectObject;
  102016. private _notifySelectedMeshUnselected;
  102017. /**
  102018. * Sets the color of the laser ray from the vr controllers.
  102019. * @param color new color for the ray.
  102020. */
  102021. changeLaserColor(color: Color3): void;
  102022. /**
  102023. * Sets the color of the ray from the vr headsets gaze.
  102024. * @param color new color for the ray.
  102025. */
  102026. changeGazeColor(color: Color3): void;
  102027. /**
  102028. * Exits VR and disposes of the vr experience helper
  102029. */
  102030. dispose(): void;
  102031. /**
  102032. * Gets the name of the VRExperienceHelper class
  102033. * @returns "VRExperienceHelper"
  102034. */
  102035. getClassName(): string;
  102036. }
  102037. }
  102038. declare module BABYLON {
  102039. /**
  102040. * Manages an XRSession
  102041. * @see https://doc.babylonjs.com/how_to/webxr
  102042. */
  102043. export class WebXRSessionManager implements IDisposable {
  102044. private scene;
  102045. /**
  102046. * Fires every time a new xrFrame arrives which can be used to update the camera
  102047. */
  102048. onXRFrameObservable: Observable<any>;
  102049. /**
  102050. * Fires when the xr session is ended either by the device or manually done
  102051. */
  102052. onXRSessionEnded: Observable<any>;
  102053. /** @hidden */
  102054. _xrSession: XRSession;
  102055. /** @hidden */
  102056. _frameOfReference: XRFrameOfReference;
  102057. /** @hidden */
  102058. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  102059. /** @hidden */
  102060. _currentXRFrame: Nullable<XRFrame>;
  102061. private _xrNavigator;
  102062. private _xrDevice;
  102063. private _tmpMatrix;
  102064. /**
  102065. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  102066. * @param scene The scene which the session should be created for
  102067. */
  102068. constructor(scene: Scene);
  102069. /**
  102070. * Initializes the manager
  102071. * After initialization enterXR can be called to start an XR session
  102072. * @returns Promise which resolves after it is initialized
  102073. */
  102074. initializeAsync(): Promise<void>;
  102075. /**
  102076. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  102077. * @param sessionCreationOptions xr options to create the session with
  102078. * @param frameOfReferenceType option to configure how the xr pose is expressed
  102079. * @returns Promise which resolves after it enters XR
  102080. */
  102081. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  102082. /**
  102083. * Stops the xrSession and restores the renderloop
  102084. * @returns Promise which resolves after it exits XR
  102085. */
  102086. exitXRAsync(): Promise<void>;
  102087. /**
  102088. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  102089. * @param ray ray to cast into the environment
  102090. * @returns Promise which resolves with a collision point in the environment if it exists
  102091. */
  102092. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  102093. /**
  102094. * Checks if a session would be supported for the creation options specified
  102095. * @param options creation options to check if they are supported
  102096. * @returns true if supported
  102097. */
  102098. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  102099. /**
  102100. * @hidden
  102101. * Converts the render layer of xrSession to a render target
  102102. * @param session session to create render target for
  102103. * @param scene scene the new render target should be created for
  102104. */
  102105. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  102106. /**
  102107. * Disposes of the session manager
  102108. */
  102109. dispose(): void;
  102110. }
  102111. }
  102112. declare module BABYLON {
  102113. /**
  102114. * WebXR Camera which holds the views for the xrSession
  102115. * @see https://doc.babylonjs.com/how_to/webxr
  102116. */
  102117. export class WebXRCamera extends FreeCamera {
  102118. private static _TmpMatrix;
  102119. /**
  102120. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  102121. * @param name the name of the camera
  102122. * @param scene the scene to add the camera to
  102123. */
  102124. constructor(name: string, scene: Scene);
  102125. private _updateNumberOfRigCameras;
  102126. /** @hidden */
  102127. _updateForDualEyeDebugging(pupilDistance?: number): void;
  102128. /**
  102129. * Updates the cameras position from the current pose information of the XR session
  102130. * @param xrSessionManager the session containing pose information
  102131. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  102132. */
  102133. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  102134. }
  102135. }
  102136. declare module BABYLON {
  102137. /**
  102138. * States of the webXR experience
  102139. */
  102140. export enum WebXRState {
  102141. /**
  102142. * Transitioning to being in XR mode
  102143. */
  102144. ENTERING_XR = 0,
  102145. /**
  102146. * Transitioning to non XR mode
  102147. */
  102148. EXITING_XR = 1,
  102149. /**
  102150. * In XR mode and presenting
  102151. */
  102152. IN_XR = 2,
  102153. /**
  102154. * Not entered XR mode
  102155. */
  102156. NOT_IN_XR = 3
  102157. }
  102158. /**
  102159. * Helper class used to enable XR
  102160. * @see https://doc.babylonjs.com/how_to/webxr
  102161. */
  102162. export class WebXRExperienceHelper implements IDisposable {
  102163. private scene;
  102164. /**
  102165. * 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
  102166. */
  102167. container: AbstractMesh;
  102168. /**
  102169. * Camera used to render xr content
  102170. */
  102171. camera: WebXRCamera;
  102172. /**
  102173. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  102174. */
  102175. state: WebXRState;
  102176. private _setState;
  102177. private static _TmpVector;
  102178. /**
  102179. * Fires when the state of the experience helper has changed
  102180. */
  102181. onStateChangedObservable: Observable<WebXRState>;
  102182. /** @hidden */
  102183. _sessionManager: WebXRSessionManager;
  102184. private _nonVRCamera;
  102185. private _originalSceneAutoClear;
  102186. private _supported;
  102187. /**
  102188. * Creates the experience helper
  102189. * @param scene the scene to attach the experience helper to
  102190. * @returns a promise for the experience helper
  102191. */
  102192. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  102193. /**
  102194. * Creates a WebXRExperienceHelper
  102195. * @param scene The scene the helper should be created in
  102196. */
  102197. private constructor();
  102198. /**
  102199. * Exits XR mode and returns the scene to its original state
  102200. * @returns promise that resolves after xr mode has exited
  102201. */
  102202. exitXRAsync(): Promise<void>;
  102203. /**
  102204. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  102205. * @param sessionCreationOptions options for the XR session
  102206. * @param frameOfReference frame of reference of the XR session
  102207. * @returns promise that resolves after xr mode has entered
  102208. */
  102209. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  102210. /**
  102211. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  102212. * @param ray ray to cast into the environment
  102213. * @returns Promise which resolves with a collision point in the environment if it exists
  102214. */
  102215. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  102216. /**
  102217. * Updates the global position of the camera by moving the camera's container
  102218. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  102219. * @param position The desired global position of the camera
  102220. */
  102221. setPositionOfCameraUsingContainer(position: Vector3): void;
  102222. /**
  102223. * Rotates the xr camera by rotating the camera's container around the camera's position
  102224. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  102225. * @param rotation the desired quaternion rotation to apply to the camera
  102226. */
  102227. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  102228. /**
  102229. * Checks if the creation options are supported by the xr session
  102230. * @param options creation options
  102231. * @returns true if supported
  102232. */
  102233. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  102234. /**
  102235. * Disposes of the experience helper
  102236. */
  102237. dispose(): void;
  102238. }
  102239. }
  102240. declare module BABYLON {
  102241. /**
  102242. * Button which can be used to enter a different mode of XR
  102243. */
  102244. export class WebXREnterExitUIButton {
  102245. /** button element */
  102246. element: HTMLElement;
  102247. /** XR initialization options for the button */
  102248. initializationOptions: XRSessionCreationOptions;
  102249. /**
  102250. * Creates a WebXREnterExitUIButton
  102251. * @param element button element
  102252. * @param initializationOptions XR initialization options for the button
  102253. */
  102254. constructor(
  102255. /** button element */
  102256. element: HTMLElement,
  102257. /** XR initialization options for the button */
  102258. initializationOptions: XRSessionCreationOptions);
  102259. /**
  102260. * Overwritable function which can be used to update the button's visuals when the state changes
  102261. * @param activeButton the current active button in the UI
  102262. */
  102263. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  102264. }
  102265. /**
  102266. * Options to create the webXR UI
  102267. */
  102268. export class WebXREnterExitUIOptions {
  102269. /**
  102270. * Context to enter xr with
  102271. */
  102272. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  102273. /**
  102274. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  102275. */
  102276. customButtons?: Array<WebXREnterExitUIButton>;
  102277. }
  102278. /**
  102279. * UI to allow the user to enter/exit XR mode
  102280. */
  102281. export class WebXREnterExitUI implements IDisposable {
  102282. private scene;
  102283. private _overlay;
  102284. private _buttons;
  102285. private _activeButton;
  102286. /**
  102287. * Fired every time the active button is changed.
  102288. *
  102289. * When xr is entered via a button that launches xr that button will be the callback parameter
  102290. *
  102291. * When exiting xr the callback parameter will be null)
  102292. */
  102293. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  102294. /**
  102295. * Creates UI to allow the user to enter/exit XR mode
  102296. * @param scene the scene to add the ui to
  102297. * @param helper the xr experience helper to enter/exit xr with
  102298. * @param options options to configure the UI
  102299. * @returns the created ui
  102300. */
  102301. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  102302. private constructor();
  102303. private _updateButtons;
  102304. /**
  102305. * Disposes of the object
  102306. */
  102307. dispose(): void;
  102308. }
  102309. }
  102310. declare module BABYLON {
  102311. /**
  102312. * Represents an XR input
  102313. */
  102314. export class WebXRController {
  102315. /**
  102316. * 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
  102317. */
  102318. grip?: AbstractMesh;
  102319. /**
  102320. * Pointer which can be used to select objects or attach a visible laser to
  102321. */
  102322. pointer: AbstractMesh;
  102323. /**
  102324. * Creates the controller
  102325. * @see https://doc.babylonjs.com/how_to/webxr
  102326. * @param scene the scene which the controller should be associated to
  102327. */
  102328. constructor(scene: Scene);
  102329. /**
  102330. * Disposes of the object
  102331. */
  102332. dispose(): void;
  102333. }
  102334. /**
  102335. * XR input used to track XR inputs such as controllers/rays
  102336. */
  102337. export class WebXRInput implements IDisposable {
  102338. private helper;
  102339. /**
  102340. * XR controllers being tracked
  102341. */
  102342. controllers: Array<WebXRController>;
  102343. private _tmpMatrix;
  102344. private _frameObserver;
  102345. /**
  102346. * Initializes the WebXRInput
  102347. * @param helper experience helper which the input should be created for
  102348. */
  102349. constructor(helper: WebXRExperienceHelper);
  102350. /**
  102351. * Disposes of the object
  102352. */
  102353. dispose(): void;
  102354. }
  102355. }
  102356. declare module BABYLON {
  102357. /**
  102358. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  102359. */
  102360. export class WebXRManagedOutputCanvas implements IDisposable {
  102361. private _canvas;
  102362. /**
  102363. * xrpresent context of the canvas which can be used to display/mirror xr content
  102364. */
  102365. canvasContext: Nullable<WebGLRenderingContext>;
  102366. /**
  102367. * Initializes the canvas to be added/removed upon entering/exiting xr
  102368. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  102369. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  102370. */
  102371. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  102372. /**
  102373. * Disposes of the object
  102374. */
  102375. dispose(): void;
  102376. private _setManagedOutputCanvas;
  102377. private _addCanvas;
  102378. private _removeCanvas;
  102379. }
  102380. }
  102381. declare module BABYLON {
  102382. /**
  102383. * Contains an array of blocks representing the octree
  102384. */
  102385. export interface IOctreeContainer<T> {
  102386. /**
  102387. * Blocks within the octree
  102388. */
  102389. blocks: Array<OctreeBlock<T>>;
  102390. }
  102391. /**
  102392. * Class used to store a cell in an octree
  102393. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  102394. */
  102395. export class OctreeBlock<T> {
  102396. /**
  102397. * Gets the content of the current block
  102398. */
  102399. entries: T[];
  102400. /**
  102401. * Gets the list of block children
  102402. */
  102403. blocks: Array<OctreeBlock<T>>;
  102404. private _depth;
  102405. private _maxDepth;
  102406. private _capacity;
  102407. private _minPoint;
  102408. private _maxPoint;
  102409. private _boundingVectors;
  102410. private _creationFunc;
  102411. /**
  102412. * Creates a new block
  102413. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  102414. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  102415. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  102416. * @param depth defines the current depth of this block in the octree
  102417. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  102418. * @param creationFunc defines a callback to call when an element is added to the block
  102419. */
  102420. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  102421. /**
  102422. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  102423. */
  102424. readonly capacity: number;
  102425. /**
  102426. * Gets the minimum vector (in world space) of the block's bounding box
  102427. */
  102428. readonly minPoint: Vector3;
  102429. /**
  102430. * Gets the maximum vector (in world space) of the block's bounding box
  102431. */
  102432. readonly maxPoint: Vector3;
  102433. /**
  102434. * Add a new element to this block
  102435. * @param entry defines the element to add
  102436. */
  102437. addEntry(entry: T): void;
  102438. /**
  102439. * Remove an element from this block
  102440. * @param entry defines the element to remove
  102441. */
  102442. removeEntry(entry: T): void;
  102443. /**
  102444. * Add an array of elements to this block
  102445. * @param entries defines the array of elements to add
  102446. */
  102447. addEntries(entries: T[]): void;
  102448. /**
  102449. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  102450. * @param frustumPlanes defines the frustum planes to test
  102451. * @param selection defines the array to store current content if selection is positive
  102452. * @param allowDuplicate defines if the selection array can contains duplicated entries
  102453. */
  102454. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  102455. /**
  102456. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  102457. * @param sphereCenter defines the bounding sphere center
  102458. * @param sphereRadius defines the bounding sphere radius
  102459. * @param selection defines the array to store current content if selection is positive
  102460. * @param allowDuplicate defines if the selection array can contains duplicated entries
  102461. */
  102462. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  102463. /**
  102464. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  102465. * @param ray defines the ray to test with
  102466. * @param selection defines the array to store current content if selection is positive
  102467. */
  102468. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  102469. /**
  102470. * Subdivide the content into child blocks (this block will then be empty)
  102471. */
  102472. createInnerBlocks(): void;
  102473. /**
  102474. * @hidden
  102475. */
  102476. 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;
  102477. }
  102478. }
  102479. declare module BABYLON {
  102480. /**
  102481. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  102482. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  102483. */
  102484. export class Octree<T> {
  102485. /** 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.) */
  102486. maxDepth: number;
  102487. /**
  102488. * Blocks within the octree containing objects
  102489. */
  102490. blocks: Array<OctreeBlock<T>>;
  102491. /**
  102492. * Content stored in the octree
  102493. */
  102494. dynamicContent: T[];
  102495. private _maxBlockCapacity;
  102496. private _selectionContent;
  102497. private _creationFunc;
  102498. /**
  102499. * Creates a octree
  102500. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  102501. * @param creationFunc function to be used to instatiate the octree
  102502. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  102503. * @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.)
  102504. */
  102505. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  102506. /** 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.) */
  102507. maxDepth?: number);
  102508. /**
  102509. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  102510. * @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);
  102511. * @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);
  102512. * @param entries meshes to be added to the octree blocks
  102513. */
  102514. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  102515. /**
  102516. * Adds a mesh to the octree
  102517. * @param entry Mesh to add to the octree
  102518. */
  102519. addMesh(entry: T): void;
  102520. /**
  102521. * Remove an element from the octree
  102522. * @param entry defines the element to remove
  102523. */
  102524. removeMesh(entry: T): void;
  102525. /**
  102526. * Selects an array of meshes within the frustum
  102527. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  102528. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  102529. * @returns array of meshes within the frustum
  102530. */
  102531. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  102532. /**
  102533. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  102534. * @param sphereCenter defines the bounding sphere center
  102535. * @param sphereRadius defines the bounding sphere radius
  102536. * @param allowDuplicate defines if the selection array can contains duplicated entries
  102537. * @returns an array of objects that intersect the sphere
  102538. */
  102539. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  102540. /**
  102541. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  102542. * @param ray defines the ray to test with
  102543. * @returns array of intersected objects
  102544. */
  102545. intersectsRay(ray: Ray): SmartArray<T>;
  102546. /**
  102547. * Adds a mesh into the octree block if it intersects the block
  102548. */
  102549. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  102550. /**
  102551. * Adds a submesh into the octree block if it intersects the block
  102552. */
  102553. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  102554. }
  102555. }
  102556. declare module BABYLON {
  102557. interface Scene {
  102558. /**
  102559. * @hidden
  102560. * Backing Filed
  102561. */
  102562. _selectionOctree: Octree<AbstractMesh>;
  102563. /**
  102564. * Gets the octree used to boost mesh selection (picking)
  102565. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  102566. */
  102567. selectionOctree: Octree<AbstractMesh>;
  102568. /**
  102569. * Creates or updates the octree used to boost selection (picking)
  102570. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  102571. * @param maxCapacity defines the maximum capacity per leaf
  102572. * @param maxDepth defines the maximum depth of the octree
  102573. * @returns an octree of AbstractMesh
  102574. */
  102575. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  102576. }
  102577. interface AbstractMesh {
  102578. /**
  102579. * @hidden
  102580. * Backing Field
  102581. */
  102582. _submeshesOctree: Octree<SubMesh>;
  102583. /**
  102584. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  102585. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  102586. * @param maxCapacity defines the maximum size of each block (64 by default)
  102587. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  102588. * @returns the new octree
  102589. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  102590. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  102591. */
  102592. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  102593. }
  102594. /**
  102595. * Defines the octree scene component responsible to manage any octrees
  102596. * in a given scene.
  102597. */
  102598. export class OctreeSceneComponent {
  102599. /**
  102600. * The component name help to identify the component in the list of scene components.
  102601. */
  102602. readonly name: string;
  102603. /**
  102604. * The scene the component belongs to.
  102605. */
  102606. scene: Scene;
  102607. /**
  102608. * Indicates if the meshes have been checked to make sure they are isEnabled()
  102609. */
  102610. readonly checksIsEnabled: boolean;
  102611. /**
  102612. * Creates a new instance of the component for the given scene
  102613. * @param scene Defines the scene to register the component in
  102614. */
  102615. constructor(scene: Scene);
  102616. /**
  102617. * Registers the component in a given scene
  102618. */
  102619. register(): void;
  102620. /**
  102621. * Return the list of active meshes
  102622. * @returns the list of active meshes
  102623. */
  102624. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  102625. /**
  102626. * Return the list of active sub meshes
  102627. * @param mesh The mesh to get the candidates sub meshes from
  102628. * @returns the list of active sub meshes
  102629. */
  102630. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  102631. private _tempRay;
  102632. /**
  102633. * Return the list of sub meshes intersecting with a given local ray
  102634. * @param mesh defines the mesh to find the submesh for
  102635. * @param localRay defines the ray in local space
  102636. * @returns the list of intersecting sub meshes
  102637. */
  102638. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  102639. /**
  102640. * Return the list of sub meshes colliding with a collider
  102641. * @param mesh defines the mesh to find the submesh for
  102642. * @param collider defines the collider to evaluate the collision against
  102643. * @returns the list of colliding sub meshes
  102644. */
  102645. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  102646. /**
  102647. * Rebuilds the elements related to this component in case of
  102648. * context lost for instance.
  102649. */
  102650. rebuild(): void;
  102651. /**
  102652. * Disposes the component and the associated ressources.
  102653. */
  102654. dispose(): void;
  102655. }
  102656. }
  102657. declare module BABYLON {
  102658. /**
  102659. * Renders a layer on top of an existing scene
  102660. */
  102661. export class UtilityLayerRenderer implements IDisposable {
  102662. /** the original scene that will be rendered on top of */
  102663. originalScene: Scene;
  102664. private _pointerCaptures;
  102665. private _lastPointerEvents;
  102666. private static _DefaultUtilityLayer;
  102667. private static _DefaultKeepDepthUtilityLayer;
  102668. private _sharedGizmoLight;
  102669. /**
  102670. * @hidden
  102671. * Light which used by gizmos to get light shading
  102672. */
  102673. _getSharedGizmoLight(): HemisphericLight;
  102674. /**
  102675. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  102676. */
  102677. pickUtilitySceneFirst: boolean;
  102678. /**
  102679. * 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)
  102680. */
  102681. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  102682. /**
  102683. * 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)
  102684. */
  102685. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  102686. /**
  102687. * The scene that is rendered on top of the original scene
  102688. */
  102689. utilityLayerScene: Scene;
  102690. /**
  102691. * If the utility layer should automatically be rendered on top of existing scene
  102692. */
  102693. shouldRender: boolean;
  102694. /**
  102695. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  102696. */
  102697. onlyCheckPointerDownEvents: boolean;
  102698. /**
  102699. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  102700. */
  102701. processAllEvents: boolean;
  102702. /**
  102703. * Observable raised when the pointer move from the utility layer scene to the main scene
  102704. */
  102705. onPointerOutObservable: Observable<number>;
  102706. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  102707. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  102708. private _afterRenderObserver;
  102709. private _sceneDisposeObserver;
  102710. private _originalPointerObserver;
  102711. /**
  102712. * Instantiates a UtilityLayerRenderer
  102713. * @param originalScene the original scene that will be rendered on top of
  102714. * @param handleEvents boolean indicating if the utility layer should handle events
  102715. */
  102716. constructor(
  102717. /** the original scene that will be rendered on top of */
  102718. originalScene: Scene, handleEvents?: boolean);
  102719. private _notifyObservers;
  102720. /**
  102721. * Renders the utility layers scene on top of the original scene
  102722. */
  102723. render(): void;
  102724. /**
  102725. * Disposes of the renderer
  102726. */
  102727. dispose(): void;
  102728. private _updateCamera;
  102729. }
  102730. }
  102731. declare module BABYLON {
  102732. /**
  102733. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  102734. */
  102735. export class Gizmo implements IDisposable {
  102736. /** The utility layer the gizmo will be added to */
  102737. gizmoLayer: UtilityLayerRenderer;
  102738. /**
  102739. * The root mesh of the gizmo
  102740. */
  102741. _rootMesh: Mesh;
  102742. private _attachedMesh;
  102743. /**
  102744. * Ratio for the scale of the gizmo (Default: 1)
  102745. */
  102746. scaleRatio: number;
  102747. /**
  102748. * If a custom mesh has been set (Default: false)
  102749. */
  102750. protected _customMeshSet: boolean;
  102751. /**
  102752. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  102753. * * When set, interactions will be enabled
  102754. */
  102755. attachedMesh: Nullable<AbstractMesh>;
  102756. /**
  102757. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  102758. * @param mesh The mesh to replace the default mesh of the gizmo
  102759. */
  102760. setCustomMesh(mesh: Mesh): void;
  102761. /**
  102762. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  102763. */
  102764. updateGizmoRotationToMatchAttachedMesh: boolean;
  102765. /**
  102766. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  102767. */
  102768. updateGizmoPositionToMatchAttachedMesh: boolean;
  102769. /**
  102770. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  102771. */
  102772. protected _updateScale: boolean;
  102773. protected _interactionsEnabled: boolean;
  102774. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  102775. private _beforeRenderObserver;
  102776. private _tempVector;
  102777. /**
  102778. * Creates a gizmo
  102779. * @param gizmoLayer The utility layer the gizmo will be added to
  102780. */
  102781. constructor(
  102782. /** The utility layer the gizmo will be added to */
  102783. gizmoLayer?: UtilityLayerRenderer);
  102784. /**
  102785. * Updates the gizmo to match the attached mesh's position/rotation
  102786. */
  102787. protected _update(): void;
  102788. /**
  102789. * Disposes of the gizmo
  102790. */
  102791. dispose(): void;
  102792. }
  102793. }
  102794. declare module BABYLON {
  102795. /**
  102796. * Single axis drag gizmo
  102797. */
  102798. export class AxisDragGizmo extends Gizmo {
  102799. /**
  102800. * Drag behavior responsible for the gizmos dragging interactions
  102801. */
  102802. dragBehavior: PointerDragBehavior;
  102803. private _pointerObserver;
  102804. /**
  102805. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  102806. */
  102807. snapDistance: number;
  102808. /**
  102809. * Event that fires each time the gizmo snaps to a new location.
  102810. * * snapDistance is the the change in distance
  102811. */
  102812. onSnapObservable: Observable<{
  102813. snapDistance: number;
  102814. }>;
  102815. /** @hidden */
  102816. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  102817. /** @hidden */
  102818. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  102819. /**
  102820. * Creates an AxisDragGizmo
  102821. * @param gizmoLayer The utility layer the gizmo will be added to
  102822. * @param dragAxis The axis which the gizmo will be able to drag on
  102823. * @param color The color of the gizmo
  102824. */
  102825. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  102826. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  102827. /**
  102828. * Disposes of the gizmo
  102829. */
  102830. dispose(): void;
  102831. }
  102832. }
  102833. declare module BABYLON.Debug {
  102834. /**
  102835. * The Axes viewer will show 3 axes in a specific point in space
  102836. */
  102837. export class AxesViewer {
  102838. private _xAxis;
  102839. private _yAxis;
  102840. private _zAxis;
  102841. private _scaleLinesFactor;
  102842. private _instanced;
  102843. /**
  102844. * Gets the hosting scene
  102845. */
  102846. scene: Scene;
  102847. /**
  102848. * Gets or sets a number used to scale line length
  102849. */
  102850. scaleLines: number;
  102851. /** Gets the node hierarchy used to render x-axis */
  102852. readonly xAxis: TransformNode;
  102853. /** Gets the node hierarchy used to render y-axis */
  102854. readonly yAxis: TransformNode;
  102855. /** Gets the node hierarchy used to render z-axis */
  102856. readonly zAxis: TransformNode;
  102857. /**
  102858. * Creates a new AxesViewer
  102859. * @param scene defines the hosting scene
  102860. * @param scaleLines defines a number used to scale line length (1 by default)
  102861. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  102862. * @param xAxis defines the node hierarchy used to render the x-axis
  102863. * @param yAxis defines the node hierarchy used to render the y-axis
  102864. * @param zAxis defines the node hierarchy used to render the z-axis
  102865. */
  102866. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  102867. /**
  102868. * Force the viewer to update
  102869. * @param position defines the position of the viewer
  102870. * @param xaxis defines the x axis of the viewer
  102871. * @param yaxis defines the y axis of the viewer
  102872. * @param zaxis defines the z axis of the viewer
  102873. */
  102874. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  102875. /**
  102876. * Creates an instance of this axes viewer.
  102877. * @returns a new axes viewer with instanced meshes
  102878. */
  102879. createInstance(): AxesViewer;
  102880. /** Releases resources */
  102881. dispose(): void;
  102882. private static _SetRenderingGroupId;
  102883. }
  102884. }
  102885. declare module BABYLON.Debug {
  102886. /**
  102887. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  102888. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  102889. */
  102890. export class BoneAxesViewer extends AxesViewer {
  102891. /**
  102892. * Gets or sets the target mesh where to display the axes viewer
  102893. */
  102894. mesh: Nullable<Mesh>;
  102895. /**
  102896. * Gets or sets the target bone where to display the axes viewer
  102897. */
  102898. bone: Nullable<Bone>;
  102899. /** Gets current position */
  102900. pos: Vector3;
  102901. /** Gets direction of X axis */
  102902. xaxis: Vector3;
  102903. /** Gets direction of Y axis */
  102904. yaxis: Vector3;
  102905. /** Gets direction of Z axis */
  102906. zaxis: Vector3;
  102907. /**
  102908. * Creates a new BoneAxesViewer
  102909. * @param scene defines the hosting scene
  102910. * @param bone defines the target bone
  102911. * @param mesh defines the target mesh
  102912. * @param scaleLines defines a scaling factor for line length (1 by default)
  102913. */
  102914. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  102915. /**
  102916. * Force the viewer to update
  102917. */
  102918. update(): void;
  102919. /** Releases resources */
  102920. dispose(): void;
  102921. }
  102922. }
  102923. declare module BABYLON {
  102924. /**
  102925. * Interface used to define scene explorer extensibility option
  102926. */
  102927. export interface IExplorerExtensibilityOption {
  102928. /**
  102929. * Define the option label
  102930. */
  102931. label: string;
  102932. /**
  102933. * Defines the action to execute on click
  102934. */
  102935. action: (entity: any) => void;
  102936. }
  102937. /**
  102938. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  102939. */
  102940. export interface IExplorerExtensibilityGroup {
  102941. /**
  102942. * Defines a predicate to test if a given type mut be extended
  102943. */
  102944. predicate: (entity: any) => boolean;
  102945. /**
  102946. * Gets the list of options added to a type
  102947. */
  102948. entries: IExplorerExtensibilityOption[];
  102949. }
  102950. /**
  102951. * Interface used to define the options to use to create the Inspector
  102952. */
  102953. export interface IInspectorOptions {
  102954. /**
  102955. * Display in overlay mode (default: false)
  102956. */
  102957. overlay?: boolean;
  102958. /**
  102959. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  102960. */
  102961. globalRoot?: HTMLElement;
  102962. /**
  102963. * Display the Scene explorer
  102964. */
  102965. showExplorer?: boolean;
  102966. /**
  102967. * Display the property inspector
  102968. */
  102969. showInspector?: boolean;
  102970. /**
  102971. * Display in embed mode (both panes on the right)
  102972. */
  102973. embedMode?: boolean;
  102974. /**
  102975. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  102976. */
  102977. handleResize?: boolean;
  102978. /**
  102979. * Allow the panes to popup (default: true)
  102980. */
  102981. enablePopup?: boolean;
  102982. /**
  102983. * Allow the panes to be closed by users (default: true)
  102984. */
  102985. enableClose?: boolean;
  102986. /**
  102987. * Optional list of extensibility entries
  102988. */
  102989. explorerExtensibility?: IExplorerExtensibilityGroup[];
  102990. /**
  102991. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  102992. */
  102993. inspectorURL?: string;
  102994. }
  102995. interface Scene {
  102996. /**
  102997. * @hidden
  102998. * Backing field
  102999. */
  103000. _debugLayer: DebugLayer;
  103001. /**
  103002. * Gets the debug layer (aka Inspector) associated with the scene
  103003. * @see http://doc.babylonjs.com/features/playground_debuglayer
  103004. */
  103005. debugLayer: DebugLayer;
  103006. }
  103007. /**
  103008. * The debug layer (aka Inspector) is the go to tool in order to better understand
  103009. * what is happening in your scene
  103010. * @see http://doc.babylonjs.com/features/playground_debuglayer
  103011. */
  103012. export class DebugLayer {
  103013. /**
  103014. * Define the url to get the inspector script from.
  103015. * By default it uses the babylonjs CDN.
  103016. * @ignoreNaming
  103017. */
  103018. static InspectorURL: string;
  103019. private _scene;
  103020. private BJSINSPECTOR;
  103021. /**
  103022. * Observable triggered when a property is changed through the inspector.
  103023. */
  103024. onPropertyChangedObservable: Observable<{
  103025. object: any;
  103026. property: string;
  103027. value: any;
  103028. initialValue: any;
  103029. }>;
  103030. /**
  103031. * Instantiates a new debug layer.
  103032. * The debug layer (aka Inspector) is the go to tool in order to better understand
  103033. * what is happening in your scene
  103034. * @see http://doc.babylonjs.com/features/playground_debuglayer
  103035. * @param scene Defines the scene to inspect
  103036. */
  103037. constructor(scene: Scene);
  103038. /** Creates the inspector window. */
  103039. private _createInspector;
  103040. /**
  103041. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  103042. * @param entity defines the entity to select
  103043. * @param lineContainerTitle defines the specific block to highlight
  103044. */
  103045. select(entity: any, lineContainerTitle?: string): void;
  103046. /** Get the inspector from bundle or global */
  103047. private _getGlobalInspector;
  103048. /**
  103049. * Get if the inspector is visible or not.
  103050. * @returns true if visible otherwise, false
  103051. */
  103052. isVisible(): boolean;
  103053. /**
  103054. * Hide the inspector and close its window.
  103055. */
  103056. hide(): void;
  103057. /**
  103058. * Launch the debugLayer.
  103059. * @param config Define the configuration of the inspector
  103060. * @return a promise fulfilled when the debug layer is visible
  103061. */
  103062. show(config?: IInspectorOptions): Promise<DebugLayer>;
  103063. }
  103064. }
  103065. declare module BABYLON {
  103066. /**
  103067. * Class containing static functions to help procedurally build meshes
  103068. */
  103069. export class BoxBuilder {
  103070. /**
  103071. * Creates a box mesh
  103072. * * The parameter `size` sets the size (float) of each box side (default 1)
  103073. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  103074. * * 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)
  103075. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  103076. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  103077. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  103078. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  103079. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  103080. * @param name defines the name of the mesh
  103081. * @param options defines the options used to create the mesh
  103082. * @param scene defines the hosting scene
  103083. * @returns the box mesh
  103084. */
  103085. static CreateBox(name: string, options: {
  103086. size?: number;
  103087. width?: number;
  103088. height?: number;
  103089. depth?: number;
  103090. faceUV?: Vector4[];
  103091. faceColors?: Color4[];
  103092. sideOrientation?: number;
  103093. frontUVs?: Vector4;
  103094. backUVs?: Vector4;
  103095. wrap?: boolean;
  103096. topBaseAt?: number;
  103097. bottomBaseAt?: number;
  103098. updatable?: boolean;
  103099. }, scene?: Nullable<Scene>): Mesh;
  103100. }
  103101. }
  103102. declare module BABYLON {
  103103. /**
  103104. * Class containing static functions to help procedurally build meshes
  103105. */
  103106. export class SphereBuilder {
  103107. /**
  103108. * Creates a sphere mesh
  103109. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  103110. * * 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`)
  103111. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  103112. * * 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
  103113. * * 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)
  103114. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  103115. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  103116. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  103117. * @param name defines the name of the mesh
  103118. * @param options defines the options used to create the mesh
  103119. * @param scene defines the hosting scene
  103120. * @returns the sphere mesh
  103121. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  103122. */
  103123. static CreateSphere(name: string, options: {
  103124. segments?: number;
  103125. diameter?: number;
  103126. diameterX?: number;
  103127. diameterY?: number;
  103128. diameterZ?: number;
  103129. arc?: number;
  103130. slice?: number;
  103131. sideOrientation?: number;
  103132. frontUVs?: Vector4;
  103133. backUVs?: Vector4;
  103134. updatable?: boolean;
  103135. }, scene: any): Mesh;
  103136. }
  103137. }
  103138. declare module BABYLON.Debug {
  103139. /**
  103140. * Used to show the physics impostor around the specific mesh
  103141. */
  103142. export class PhysicsViewer {
  103143. /** @hidden */
  103144. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  103145. /** @hidden */
  103146. protected _meshes: Array<Nullable<AbstractMesh>>;
  103147. /** @hidden */
  103148. protected _scene: Nullable<Scene>;
  103149. /** @hidden */
  103150. protected _numMeshes: number;
  103151. /** @hidden */
  103152. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  103153. private _renderFunction;
  103154. private _utilityLayer;
  103155. private _debugBoxMesh;
  103156. private _debugSphereMesh;
  103157. private _debugCylinderMesh;
  103158. private _debugMaterial;
  103159. private _debugMeshMeshes;
  103160. /**
  103161. * Creates a new PhysicsViewer
  103162. * @param scene defines the hosting scene
  103163. */
  103164. constructor(scene: Scene);
  103165. /** @hidden */
  103166. protected _updateDebugMeshes(): void;
  103167. /**
  103168. * Renders a specified physic impostor
  103169. * @param impostor defines the impostor to render
  103170. * @param targetMesh defines the mesh represented by the impostor
  103171. * @returns the new debug mesh used to render the impostor
  103172. */
  103173. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  103174. /**
  103175. * Hides a specified physic impostor
  103176. * @param impostor defines the impostor to hide
  103177. */
  103178. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  103179. private _getDebugMaterial;
  103180. private _getDebugBoxMesh;
  103181. private _getDebugSphereMesh;
  103182. private _getDebugCylinderMesh;
  103183. private _getDebugMeshMesh;
  103184. private _getDebugMesh;
  103185. /** Releases all resources */
  103186. dispose(): void;
  103187. }
  103188. }
  103189. declare module BABYLON {
  103190. /**
  103191. * Class containing static functions to help procedurally build meshes
  103192. */
  103193. export class LinesBuilder {
  103194. /**
  103195. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  103196. * * 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
  103197. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  103198. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  103199. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  103200. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  103201. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  103202. * * 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
  103203. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  103204. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  103205. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  103206. * @param name defines the name of the new line system
  103207. * @param options defines the options used to create the line system
  103208. * @param scene defines the hosting scene
  103209. * @returns a new line system mesh
  103210. */
  103211. static CreateLineSystem(name: string, options: {
  103212. lines: Vector3[][];
  103213. updatable?: boolean;
  103214. instance?: Nullable<LinesMesh>;
  103215. colors?: Nullable<Color4[][]>;
  103216. useVertexAlpha?: boolean;
  103217. }, scene: Nullable<Scene>): LinesMesh;
  103218. /**
  103219. * Creates a line mesh
  103220. * 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
  103221. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  103222. * * The parameter `points` is an array successive Vector3
  103223. * * 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
  103224. * * The optional parameter `colors` is an array of successive Color4, one per line point
  103225. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  103226. * * When updating an instance, remember that only point positions can change, not the number of points
  103227. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  103228. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  103229. * @param name defines the name of the new line system
  103230. * @param options defines the options used to create the line system
  103231. * @param scene defines the hosting scene
  103232. * @returns a new line mesh
  103233. */
  103234. static CreateLines(name: string, options: {
  103235. points: Vector3[];
  103236. updatable?: boolean;
  103237. instance?: Nullable<LinesMesh>;
  103238. colors?: Color4[];
  103239. useVertexAlpha?: boolean;
  103240. }, scene?: Nullable<Scene>): LinesMesh;
  103241. /**
  103242. * Creates a dashed line mesh
  103243. * * 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
  103244. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  103245. * * The parameter `points` is an array successive Vector3
  103246. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  103247. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  103248. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  103249. * * 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
  103250. * * When updating an instance, remember that only point positions can change, not the number of points
  103251. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  103252. * @param name defines the name of the mesh
  103253. * @param options defines the options used to create the mesh
  103254. * @param scene defines the hosting scene
  103255. * @returns the dashed line mesh
  103256. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  103257. */
  103258. static CreateDashedLines(name: string, options: {
  103259. points: Vector3[];
  103260. dashSize?: number;
  103261. gapSize?: number;
  103262. dashNb?: number;
  103263. updatable?: boolean;
  103264. instance?: LinesMesh;
  103265. }, scene?: Nullable<Scene>): LinesMesh;
  103266. }
  103267. }
  103268. declare module BABYLON {
  103269. /**
  103270. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  103271. * in order to better appreciate the issue one might have.
  103272. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  103273. */
  103274. export class RayHelper {
  103275. /**
  103276. * Defines the ray we are currently tryin to visualize.
  103277. */
  103278. ray: Nullable<Ray>;
  103279. private _renderPoints;
  103280. private _renderLine;
  103281. private _renderFunction;
  103282. private _scene;
  103283. private _updateToMeshFunction;
  103284. private _attachedToMesh;
  103285. private _meshSpaceDirection;
  103286. private _meshSpaceOrigin;
  103287. /**
  103288. * Helper function to create a colored helper in a scene in one line.
  103289. * @param ray Defines the ray we are currently tryin to visualize
  103290. * @param scene Defines the scene the ray is used in
  103291. * @param color Defines the color we want to see the ray in
  103292. * @returns The newly created ray helper.
  103293. */
  103294. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  103295. /**
  103296. * Instantiate a new ray helper.
  103297. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  103298. * in order to better appreciate the issue one might have.
  103299. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  103300. * @param ray Defines the ray we are currently tryin to visualize
  103301. */
  103302. constructor(ray: Ray);
  103303. /**
  103304. * Shows the ray we are willing to debug.
  103305. * @param scene Defines the scene the ray needs to be rendered in
  103306. * @param color Defines the color the ray needs to be rendered in
  103307. */
  103308. show(scene: Scene, color?: Color3): void;
  103309. /**
  103310. * Hides the ray we are debugging.
  103311. */
  103312. hide(): void;
  103313. private _render;
  103314. /**
  103315. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  103316. * @param mesh Defines the mesh we want the helper attached to
  103317. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  103318. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  103319. * @param length Defines the length of the ray
  103320. */
  103321. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  103322. /**
  103323. * Detach the ray helper from the mesh it has previously been attached to.
  103324. */
  103325. detachFromMesh(): void;
  103326. private _updateToMesh;
  103327. /**
  103328. * Dispose the helper and release its associated resources.
  103329. */
  103330. dispose(): void;
  103331. }
  103332. }
  103333. declare module BABYLON.Debug {
  103334. /**
  103335. * Class used to render a debug view of a given skeleton
  103336. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  103337. */
  103338. export class SkeletonViewer {
  103339. /** defines the skeleton to render */
  103340. skeleton: Skeleton;
  103341. /** defines the mesh attached to the skeleton */
  103342. mesh: AbstractMesh;
  103343. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  103344. autoUpdateBonesMatrices: boolean;
  103345. /** defines the rendering group id to use with the viewer */
  103346. renderingGroupId: number;
  103347. /** Gets or sets the color used to render the skeleton */
  103348. color: Color3;
  103349. private _scene;
  103350. private _debugLines;
  103351. private _debugMesh;
  103352. private _isEnabled;
  103353. private _renderFunction;
  103354. private _utilityLayer;
  103355. /**
  103356. * Returns the mesh used to render the bones
  103357. */
  103358. readonly debugMesh: Nullable<LinesMesh>;
  103359. /**
  103360. * Creates a new SkeletonViewer
  103361. * @param skeleton defines the skeleton to render
  103362. * @param mesh defines the mesh attached to the skeleton
  103363. * @param scene defines the hosting scene
  103364. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  103365. * @param renderingGroupId defines the rendering group id to use with the viewer
  103366. */
  103367. constructor(
  103368. /** defines the skeleton to render */
  103369. skeleton: Skeleton,
  103370. /** defines the mesh attached to the skeleton */
  103371. mesh: AbstractMesh, scene: Scene,
  103372. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  103373. autoUpdateBonesMatrices?: boolean,
  103374. /** defines the rendering group id to use with the viewer */
  103375. renderingGroupId?: number);
  103376. /** Gets or sets a boolean indicating if the viewer is enabled */
  103377. isEnabled: boolean;
  103378. private _getBonePosition;
  103379. private _getLinesForBonesWithLength;
  103380. private _getLinesForBonesNoLength;
  103381. /** Update the viewer to sync with current skeleton state */
  103382. update(): void;
  103383. /** Release associated resources */
  103384. dispose(): void;
  103385. }
  103386. }
  103387. declare module BABYLON {
  103388. /**
  103389. * Options to create the null engine
  103390. */
  103391. export class NullEngineOptions {
  103392. /**
  103393. * Render width (Default: 512)
  103394. */
  103395. renderWidth: number;
  103396. /**
  103397. * Render height (Default: 256)
  103398. */
  103399. renderHeight: number;
  103400. /**
  103401. * Texture size (Default: 512)
  103402. */
  103403. textureSize: number;
  103404. /**
  103405. * If delta time between frames should be constant
  103406. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  103407. */
  103408. deterministicLockstep: boolean;
  103409. /**
  103410. * Maximum about of steps between frames (Default: 4)
  103411. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  103412. */
  103413. lockstepMaxSteps: number;
  103414. }
  103415. /**
  103416. * The null engine class provides support for headless version of babylon.js.
  103417. * This can be used in server side scenario or for testing purposes
  103418. */
  103419. export class NullEngine extends Engine {
  103420. private _options;
  103421. /**
  103422. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  103423. */
  103424. isDeterministicLockStep(): boolean;
  103425. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  103426. getLockstepMaxSteps(): number;
  103427. /**
  103428. * Sets hardware scaling, used to save performance if needed
  103429. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  103430. */
  103431. getHardwareScalingLevel(): number;
  103432. constructor(options?: NullEngineOptions);
  103433. createVertexBuffer(vertices: FloatArray): DataBuffer;
  103434. createIndexBuffer(indices: IndicesArray): DataBuffer;
  103435. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  103436. getRenderWidth(useScreen?: boolean): number;
  103437. getRenderHeight(useScreen?: boolean): number;
  103438. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  103439. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  103440. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  103441. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  103442. bindSamplers(effect: Effect): void;
  103443. enableEffect(effect: Effect): void;
  103444. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  103445. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  103446. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  103447. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  103448. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  103449. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  103450. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  103451. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  103452. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  103453. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  103454. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  103455. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  103456. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  103457. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  103458. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  103459. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  103460. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  103461. setFloat(uniform: WebGLUniformLocation, value: number): void;
  103462. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  103463. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  103464. setBool(uniform: WebGLUniformLocation, bool: number): void;
  103465. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  103466. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  103467. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  103468. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  103469. bindBuffers(vertexBuffers: {
  103470. [key: string]: VertexBuffer;
  103471. }, indexBuffer: DataBuffer, effect: Effect): void;
  103472. wipeCaches(bruteForce?: boolean): void;
  103473. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  103474. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  103475. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  103476. /** @hidden */
  103477. _createTexture(): WebGLTexture;
  103478. /** @hidden */
  103479. _releaseTexture(texture: InternalTexture): void;
  103480. 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;
  103481. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  103482. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  103483. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  103484. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  103485. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  103486. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  103487. areAllEffectsReady(): boolean;
  103488. /**
  103489. * @hidden
  103490. * Get the current error code of the webGL context
  103491. * @returns the error code
  103492. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  103493. */
  103494. getError(): number;
  103495. /** @hidden */
  103496. _getUnpackAlignement(): number;
  103497. /** @hidden */
  103498. _unpackFlipY(value: boolean): void;
  103499. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  103500. /**
  103501. * Updates a dynamic vertex buffer.
  103502. * @param vertexBuffer the vertex buffer to update
  103503. * @param data the data used to update the vertex buffer
  103504. * @param byteOffset the byte offset of the data (optional)
  103505. * @param byteLength the byte length of the data (optional)
  103506. */
  103507. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  103508. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  103509. /** @hidden */
  103510. _bindTexture(channel: number, texture: InternalTexture): void;
  103511. /** @hidden */
  103512. _releaseBuffer(buffer: DataBuffer): boolean;
  103513. releaseEffects(): void;
  103514. displayLoadingUI(): void;
  103515. hideLoadingUI(): void;
  103516. /** @hidden */
  103517. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  103518. /** @hidden */
  103519. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  103520. /** @hidden */
  103521. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  103522. /** @hidden */
  103523. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  103524. }
  103525. }
  103526. declare module BABYLON {
  103527. /** @hidden */
  103528. export class _OcclusionDataStorage {
  103529. /** @hidden */
  103530. occlusionInternalRetryCounter: number;
  103531. /** @hidden */
  103532. isOcclusionQueryInProgress: boolean;
  103533. /** @hidden */
  103534. isOccluded: boolean;
  103535. /** @hidden */
  103536. occlusionRetryCount: number;
  103537. /** @hidden */
  103538. occlusionType: number;
  103539. /** @hidden */
  103540. occlusionQueryAlgorithmType: number;
  103541. }
  103542. interface Engine {
  103543. /**
  103544. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  103545. * @return the new query
  103546. */
  103547. createQuery(): WebGLQuery;
  103548. /**
  103549. * Delete and release a webGL query
  103550. * @param query defines the query to delete
  103551. * @return the current engine
  103552. */
  103553. deleteQuery(query: WebGLQuery): Engine;
  103554. /**
  103555. * Check if a given query has resolved and got its value
  103556. * @param query defines the query to check
  103557. * @returns true if the query got its value
  103558. */
  103559. isQueryResultAvailable(query: WebGLQuery): boolean;
  103560. /**
  103561. * Gets the value of a given query
  103562. * @param query defines the query to check
  103563. * @returns the value of the query
  103564. */
  103565. getQueryResult(query: WebGLQuery): number;
  103566. /**
  103567. * Initiates an occlusion query
  103568. * @param algorithmType defines the algorithm to use
  103569. * @param query defines the query to use
  103570. * @returns the current engine
  103571. * @see http://doc.babylonjs.com/features/occlusionquery
  103572. */
  103573. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  103574. /**
  103575. * Ends an occlusion query
  103576. * @see http://doc.babylonjs.com/features/occlusionquery
  103577. * @param algorithmType defines the algorithm to use
  103578. * @returns the current engine
  103579. */
  103580. endOcclusionQuery(algorithmType: number): Engine;
  103581. /**
  103582. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  103583. * Please note that only one query can be issued at a time
  103584. * @returns a time token used to track the time span
  103585. */
  103586. startTimeQuery(): Nullable<_TimeToken>;
  103587. /**
  103588. * Ends a time query
  103589. * @param token defines the token used to measure the time span
  103590. * @returns the time spent (in ns)
  103591. */
  103592. endTimeQuery(token: _TimeToken): int;
  103593. /** @hidden */
  103594. _currentNonTimestampToken: Nullable<_TimeToken>;
  103595. /** @hidden */
  103596. _createTimeQuery(): WebGLQuery;
  103597. /** @hidden */
  103598. _deleteTimeQuery(query: WebGLQuery): void;
  103599. /** @hidden */
  103600. _getGlAlgorithmType(algorithmType: number): number;
  103601. /** @hidden */
  103602. _getTimeQueryResult(query: WebGLQuery): any;
  103603. /** @hidden */
  103604. _getTimeQueryAvailability(query: WebGLQuery): any;
  103605. }
  103606. interface AbstractMesh {
  103607. /**
  103608. * Backing filed
  103609. * @hidden
  103610. */
  103611. __occlusionDataStorage: _OcclusionDataStorage;
  103612. /**
  103613. * Access property
  103614. * @hidden
  103615. */
  103616. _occlusionDataStorage: _OcclusionDataStorage;
  103617. /**
  103618. * 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.
  103619. * The default value is -1 which means don't break the query and wait till the result
  103620. * @see http://doc.babylonjs.com/features/occlusionquery
  103621. */
  103622. occlusionRetryCount: number;
  103623. /**
  103624. * 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:
  103625. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  103626. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  103627. * * 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.
  103628. * @see http://doc.babylonjs.com/features/occlusionquery
  103629. */
  103630. occlusionType: number;
  103631. /**
  103632. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  103633. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  103634. * * 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.
  103635. * @see http://doc.babylonjs.com/features/occlusionquery
  103636. */
  103637. occlusionQueryAlgorithmType: number;
  103638. /**
  103639. * 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
  103640. * @see http://doc.babylonjs.com/features/occlusionquery
  103641. */
  103642. isOccluded: boolean;
  103643. /**
  103644. * Flag to check the progress status of the query
  103645. * @see http://doc.babylonjs.com/features/occlusionquery
  103646. */
  103647. isOcclusionQueryInProgress: boolean;
  103648. }
  103649. }
  103650. declare module BABYLON {
  103651. /** @hidden */
  103652. export var _forceTransformFeedbackToBundle: boolean;
  103653. interface Engine {
  103654. /**
  103655. * Creates a webGL transform feedback object
  103656. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  103657. * @returns the webGL transform feedback object
  103658. */
  103659. createTransformFeedback(): WebGLTransformFeedback;
  103660. /**
  103661. * Delete a webGL transform feedback object
  103662. * @param value defines the webGL transform feedback object to delete
  103663. */
  103664. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  103665. /**
  103666. * Bind a webGL transform feedback object to the webgl context
  103667. * @param value defines the webGL transform feedback object to bind
  103668. */
  103669. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  103670. /**
  103671. * Begins a transform feedback operation
  103672. * @param usePoints defines if points or triangles must be used
  103673. */
  103674. beginTransformFeedback(usePoints: boolean): void;
  103675. /**
  103676. * Ends a transform feedback operation
  103677. */
  103678. endTransformFeedback(): void;
  103679. /**
  103680. * Specify the varyings to use with transform feedback
  103681. * @param program defines the associated webGL program
  103682. * @param value defines the list of strings representing the varying names
  103683. */
  103684. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  103685. /**
  103686. * Bind a webGL buffer for a transform feedback operation
  103687. * @param value defines the webGL buffer to bind
  103688. */
  103689. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  103690. }
  103691. }
  103692. declare module BABYLON {
  103693. /**
  103694. * Creation options of the multi render target texture.
  103695. */
  103696. export interface IMultiRenderTargetOptions {
  103697. /**
  103698. * Define if the texture needs to create mip maps after render.
  103699. */
  103700. generateMipMaps?: boolean;
  103701. /**
  103702. * Define the types of all the draw buffers we want to create
  103703. */
  103704. types?: number[];
  103705. /**
  103706. * Define the sampling modes of all the draw buffers we want to create
  103707. */
  103708. samplingModes?: number[];
  103709. /**
  103710. * Define if a depth buffer is required
  103711. */
  103712. generateDepthBuffer?: boolean;
  103713. /**
  103714. * Define if a stencil buffer is required
  103715. */
  103716. generateStencilBuffer?: boolean;
  103717. /**
  103718. * Define if a depth texture is required instead of a depth buffer
  103719. */
  103720. generateDepthTexture?: boolean;
  103721. /**
  103722. * Define the number of desired draw buffers
  103723. */
  103724. textureCount?: number;
  103725. /**
  103726. * Define if aspect ratio should be adapted to the texture or stay the scene one
  103727. */
  103728. doNotChangeAspectRatio?: boolean;
  103729. /**
  103730. * Define the default type of the buffers we are creating
  103731. */
  103732. defaultType?: number;
  103733. }
  103734. /**
  103735. * A multi render target, like a render target provides the ability to render to a texture.
  103736. * Unlike the render target, it can render to several draw buffers in one draw.
  103737. * This is specially interesting in deferred rendering or for any effects requiring more than
  103738. * just one color from a single pass.
  103739. */
  103740. export class MultiRenderTarget extends RenderTargetTexture {
  103741. private _internalTextures;
  103742. private _textures;
  103743. private _multiRenderTargetOptions;
  103744. /**
  103745. * Get if draw buffers are currently supported by the used hardware and browser.
  103746. */
  103747. readonly isSupported: boolean;
  103748. /**
  103749. * Get the list of textures generated by the multi render target.
  103750. */
  103751. readonly textures: Texture[];
  103752. /**
  103753. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  103754. */
  103755. readonly depthTexture: Texture;
  103756. /**
  103757. * Set the wrapping mode on U of all the textures we are rendering to.
  103758. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  103759. */
  103760. wrapU: number;
  103761. /**
  103762. * Set the wrapping mode on V of all the textures we are rendering to.
  103763. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  103764. */
  103765. wrapV: number;
  103766. /**
  103767. * Instantiate a new multi render target texture.
  103768. * A multi render target, like a render target provides the ability to render to a texture.
  103769. * Unlike the render target, it can render to several draw buffers in one draw.
  103770. * This is specially interesting in deferred rendering or for any effects requiring more than
  103771. * just one color from a single pass.
  103772. * @param name Define the name of the texture
  103773. * @param size Define the size of the buffers to render to
  103774. * @param count Define the number of target we are rendering into
  103775. * @param scene Define the scene the texture belongs to
  103776. * @param options Define the options used to create the multi render target
  103777. */
  103778. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  103779. /** @hidden */
  103780. _rebuild(): void;
  103781. private _createInternalTextures;
  103782. private _createTextures;
  103783. /**
  103784. * Define the number of samples used if MSAA is enabled.
  103785. */
  103786. samples: number;
  103787. /**
  103788. * Resize all the textures in the multi render target.
  103789. * Be carrefull as it will recreate all the data in the new texture.
  103790. * @param size Define the new size
  103791. */
  103792. resize(size: any): void;
  103793. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  103794. /**
  103795. * Dispose the render targets and their associated resources
  103796. */
  103797. dispose(): void;
  103798. /**
  103799. * Release all the underlying texture used as draw buffers.
  103800. */
  103801. releaseInternalTextures(): void;
  103802. }
  103803. }
  103804. declare module BABYLON {
  103805. interface Engine {
  103806. /**
  103807. * Unbind a list of render target textures from the webGL context
  103808. * This is used only when drawBuffer extension or webGL2 are active
  103809. * @param textures defines the render target textures to unbind
  103810. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  103811. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  103812. */
  103813. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  103814. /**
  103815. * Create a multi render target texture
  103816. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  103817. * @param size defines the size of the texture
  103818. * @param options defines the creation options
  103819. * @returns the cube texture as an InternalTexture
  103820. */
  103821. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  103822. /**
  103823. * Update the sample count for a given multiple render target texture
  103824. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  103825. * @param textures defines the textures to update
  103826. * @param samples defines the sample count to set
  103827. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  103828. */
  103829. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  103830. }
  103831. }
  103832. declare module BABYLON {
  103833. /**
  103834. * Gather the list of clipboard event types as constants.
  103835. */
  103836. export class ClipboardEventTypes {
  103837. /**
  103838. * The clipboard event is fired when a copy command is active (pressed).
  103839. */
  103840. static readonly COPY: number;
  103841. /**
  103842. * The clipboard event is fired when a cut command is active (pressed).
  103843. */
  103844. static readonly CUT: number;
  103845. /**
  103846. * The clipboard event is fired when a paste command is active (pressed).
  103847. */
  103848. static readonly PASTE: number;
  103849. }
  103850. /**
  103851. * This class is used to store clipboard related info for the onClipboardObservable event.
  103852. */
  103853. export class ClipboardInfo {
  103854. /**
  103855. * Defines the type of event (BABYLON.ClipboardEventTypes)
  103856. */
  103857. type: number;
  103858. /**
  103859. * Defines the related dom event
  103860. */
  103861. event: ClipboardEvent;
  103862. /**
  103863. *Creates an instance of ClipboardInfo.
  103864. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  103865. * @param event Defines the related dom event
  103866. */
  103867. constructor(
  103868. /**
  103869. * Defines the type of event (BABYLON.ClipboardEventTypes)
  103870. */
  103871. type: number,
  103872. /**
  103873. * Defines the related dom event
  103874. */
  103875. event: ClipboardEvent);
  103876. /**
  103877. * Get the clipboard event's type from the keycode.
  103878. * @param keyCode Defines the keyCode for the current keyboard event.
  103879. * @return {number}
  103880. */
  103881. static GetTypeFromCharacter(keyCode: number): number;
  103882. }
  103883. }
  103884. declare module BABYLON {
  103885. /**
  103886. * Class used to represent data loading progression
  103887. */
  103888. export class SceneLoaderProgressEvent {
  103889. /** defines if data length to load can be evaluated */
  103890. readonly lengthComputable: boolean;
  103891. /** defines the loaded data length */
  103892. readonly loaded: number;
  103893. /** defines the data length to load */
  103894. readonly total: number;
  103895. /**
  103896. * Create a new progress event
  103897. * @param lengthComputable defines if data length to load can be evaluated
  103898. * @param loaded defines the loaded data length
  103899. * @param total defines the data length to load
  103900. */
  103901. constructor(
  103902. /** defines if data length to load can be evaluated */
  103903. lengthComputable: boolean,
  103904. /** defines the loaded data length */
  103905. loaded: number,
  103906. /** defines the data length to load */
  103907. total: number);
  103908. /**
  103909. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  103910. * @param event defines the source event
  103911. * @returns a new SceneLoaderProgressEvent
  103912. */
  103913. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  103914. }
  103915. /**
  103916. * Interface used by SceneLoader plugins to define supported file extensions
  103917. */
  103918. export interface ISceneLoaderPluginExtensions {
  103919. /**
  103920. * Defines the list of supported extensions
  103921. */
  103922. [extension: string]: {
  103923. isBinary: boolean;
  103924. };
  103925. }
  103926. /**
  103927. * Interface used by SceneLoader plugin factory
  103928. */
  103929. export interface ISceneLoaderPluginFactory {
  103930. /**
  103931. * Defines the name of the factory
  103932. */
  103933. name: string;
  103934. /**
  103935. * Function called to create a new plugin
  103936. * @return the new plugin
  103937. */
  103938. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  103939. /**
  103940. * Boolean indicating if the plugin can direct load specific data
  103941. */
  103942. canDirectLoad?: (data: string) => boolean;
  103943. }
  103944. /**
  103945. * Interface used to define a SceneLoader plugin
  103946. */
  103947. export interface ISceneLoaderPlugin {
  103948. /**
  103949. * The friendly name of this plugin.
  103950. */
  103951. name: string;
  103952. /**
  103953. * The file extensions supported by this plugin.
  103954. */
  103955. extensions: string | ISceneLoaderPluginExtensions;
  103956. /**
  103957. * Import meshes into a scene.
  103958. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  103959. * @param scene The scene to import into
  103960. * @param data The data to import
  103961. * @param rootUrl The root url for scene and resources
  103962. * @param meshes The meshes array to import into
  103963. * @param particleSystems The particle systems array to import into
  103964. * @param skeletons The skeletons array to import into
  103965. * @param onError The callback when import fails
  103966. * @returns True if successful or false otherwise
  103967. */
  103968. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  103969. /**
  103970. * Load into a scene.
  103971. * @param scene The scene to load into
  103972. * @param data The data to import
  103973. * @param rootUrl The root url for scene and resources
  103974. * @param onError The callback when import fails
  103975. * @returns true if successful or false otherwise
  103976. */
  103977. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  103978. /**
  103979. * The callback that returns true if the data can be directly loaded.
  103980. */
  103981. canDirectLoad?: (data: string) => boolean;
  103982. /**
  103983. * The callback that allows custom handling of the root url based on the response url.
  103984. */
  103985. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  103986. /**
  103987. * Load into an asset container.
  103988. * @param scene The scene to load into
  103989. * @param data The data to import
  103990. * @param rootUrl The root url for scene and resources
  103991. * @param onError The callback when import fails
  103992. * @returns The loaded asset container
  103993. */
  103994. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  103995. }
  103996. /**
  103997. * Interface used to define an async SceneLoader plugin
  103998. */
  103999. export interface ISceneLoaderPluginAsync {
  104000. /**
  104001. * The friendly name of this plugin.
  104002. */
  104003. name: string;
  104004. /**
  104005. * The file extensions supported by this plugin.
  104006. */
  104007. extensions: string | ISceneLoaderPluginExtensions;
  104008. /**
  104009. * Import meshes into a scene.
  104010. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  104011. * @param scene The scene to import into
  104012. * @param data The data to import
  104013. * @param rootUrl The root url for scene and resources
  104014. * @param onProgress The callback when the load progresses
  104015. * @param fileName Defines the name of the file to load
  104016. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  104017. */
  104018. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  104019. meshes: AbstractMesh[];
  104020. particleSystems: IParticleSystem[];
  104021. skeletons: Skeleton[];
  104022. animationGroups: AnimationGroup[];
  104023. }>;
  104024. /**
  104025. * Load into a scene.
  104026. * @param scene The scene to load into
  104027. * @param data The data to import
  104028. * @param rootUrl The root url for scene and resources
  104029. * @param onProgress The callback when the load progresses
  104030. * @param fileName Defines the name of the file to load
  104031. * @returns Nothing
  104032. */
  104033. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  104034. /**
  104035. * The callback that returns true if the data can be directly loaded.
  104036. */
  104037. canDirectLoad?: (data: string) => boolean;
  104038. /**
  104039. * The callback that allows custom handling of the root url based on the response url.
  104040. */
  104041. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  104042. /**
  104043. * Load into an asset container.
  104044. * @param scene The scene to load into
  104045. * @param data The data to import
  104046. * @param rootUrl The root url for scene and resources
  104047. * @param onProgress The callback when the load progresses
  104048. * @param fileName Defines the name of the file to load
  104049. * @returns The loaded asset container
  104050. */
  104051. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  104052. }
  104053. /**
  104054. * Class used to load scene from various file formats using registered plugins
  104055. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  104056. */
  104057. export class SceneLoader {
  104058. /**
  104059. * No logging while loading
  104060. */
  104061. static readonly NO_LOGGING: number;
  104062. /**
  104063. * Minimal logging while loading
  104064. */
  104065. static readonly MINIMAL_LOGGING: number;
  104066. /**
  104067. * Summary logging while loading
  104068. */
  104069. static readonly SUMMARY_LOGGING: number;
  104070. /**
  104071. * Detailled logging while loading
  104072. */
  104073. static readonly DETAILED_LOGGING: number;
  104074. /**
  104075. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  104076. */
  104077. static ForceFullSceneLoadingForIncremental: boolean;
  104078. /**
  104079. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  104080. */
  104081. static ShowLoadingScreen: boolean;
  104082. /**
  104083. * Defines the current logging level (while loading the scene)
  104084. * @ignorenaming
  104085. */
  104086. static loggingLevel: number;
  104087. /**
  104088. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  104089. */
  104090. static CleanBoneMatrixWeights: boolean;
  104091. /**
  104092. * Event raised when a plugin is used to load a scene
  104093. */
  104094. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  104095. private static _registeredPlugins;
  104096. private static _getDefaultPlugin;
  104097. private static _getPluginForExtension;
  104098. private static _getPluginForDirectLoad;
  104099. private static _getPluginForFilename;
  104100. private static _getDirectLoad;
  104101. private static _loadData;
  104102. private static _getFileInfo;
  104103. /**
  104104. * Gets a plugin that can load the given extension
  104105. * @param extension defines the extension to load
  104106. * @returns a plugin or null if none works
  104107. */
  104108. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  104109. /**
  104110. * Gets a boolean indicating that the given extension can be loaded
  104111. * @param extension defines the extension to load
  104112. * @returns true if the extension is supported
  104113. */
  104114. static IsPluginForExtensionAvailable(extension: string): boolean;
  104115. /**
  104116. * Adds a new plugin to the list of registered plugins
  104117. * @param plugin defines the plugin to add
  104118. */
  104119. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  104120. /**
  104121. * Import meshes into a scene
  104122. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  104123. * @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)
  104124. * @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)
  104125. * @param scene the instance of BABYLON.Scene to append to
  104126. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  104127. * @param onProgress a callback with a progress event for each file being loaded
  104128. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  104129. * @param pluginExtension the extension used to determine the plugin
  104130. * @returns The loaded plugin
  104131. */
  104132. 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>;
  104133. /**
  104134. * Import meshes into a scene
  104135. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  104136. * @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)
  104137. * @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)
  104138. * @param scene the instance of BABYLON.Scene to append to
  104139. * @param onProgress a callback with a progress event for each file being loaded
  104140. * @param pluginExtension the extension used to determine the plugin
  104141. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  104142. */
  104143. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  104144. meshes: AbstractMesh[];
  104145. particleSystems: IParticleSystem[];
  104146. skeletons: Skeleton[];
  104147. animationGroups: AnimationGroup[];
  104148. }>;
  104149. /**
  104150. * Load a scene
  104151. * @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)
  104152. * @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)
  104153. * @param engine is the instance of BABYLON.Engine to use to create the scene
  104154. * @param onSuccess a callback with the scene when import succeeds
  104155. * @param onProgress a callback with a progress event for each file being loaded
  104156. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  104157. * @param pluginExtension the extension used to determine the plugin
  104158. * @returns The loaded plugin
  104159. */
  104160. 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>;
  104161. /**
  104162. * Load a scene
  104163. * @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)
  104164. * @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)
  104165. * @param engine is the instance of BABYLON.Engine to use to create the scene
  104166. * @param onProgress a callback with a progress event for each file being loaded
  104167. * @param pluginExtension the extension used to determine the plugin
  104168. * @returns The loaded scene
  104169. */
  104170. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  104171. /**
  104172. * Append a scene
  104173. * @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)
  104174. * @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)
  104175. * @param scene is the instance of BABYLON.Scene to append to
  104176. * @param onSuccess a callback with the scene when import succeeds
  104177. * @param onProgress a callback with a progress event for each file being loaded
  104178. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  104179. * @param pluginExtension the extension used to determine the plugin
  104180. * @returns The loaded plugin
  104181. */
  104182. 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>;
  104183. /**
  104184. * Append a scene
  104185. * @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)
  104186. * @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)
  104187. * @param scene is the instance of BABYLON.Scene to append to
  104188. * @param onProgress a callback with a progress event for each file being loaded
  104189. * @param pluginExtension the extension used to determine the plugin
  104190. * @returns The given scene
  104191. */
  104192. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  104193. /**
  104194. * Load a scene into an asset container
  104195. * @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)
  104196. * @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)
  104197. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  104198. * @param onSuccess a callback with the scene when import succeeds
  104199. * @param onProgress a callback with a progress event for each file being loaded
  104200. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  104201. * @param pluginExtension the extension used to determine the plugin
  104202. * @returns The loaded plugin
  104203. */
  104204. 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>;
  104205. /**
  104206. * Load a scene into an asset container
  104207. * @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)
  104208. * @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)
  104209. * @param scene is the instance of Scene to append to
  104210. * @param onProgress a callback with a progress event for each file being loaded
  104211. * @param pluginExtension the extension used to determine the plugin
  104212. * @returns The loaded asset container
  104213. */
  104214. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  104215. }
  104216. }
  104217. declare module BABYLON {
  104218. /**
  104219. * Google Daydream controller
  104220. */
  104221. export class DaydreamController extends WebVRController {
  104222. /**
  104223. * Base Url for the controller model.
  104224. */
  104225. static MODEL_BASE_URL: string;
  104226. /**
  104227. * File name for the controller model.
  104228. */
  104229. static MODEL_FILENAME: string;
  104230. /**
  104231. * Gamepad Id prefix used to identify Daydream Controller.
  104232. */
  104233. static readonly GAMEPAD_ID_PREFIX: string;
  104234. /**
  104235. * Creates a new DaydreamController from a gamepad
  104236. * @param vrGamepad the gamepad that the controller should be created from
  104237. */
  104238. constructor(vrGamepad: any);
  104239. /**
  104240. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  104241. * @param scene scene in which to add meshes
  104242. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  104243. */
  104244. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  104245. /**
  104246. * Called once for each button that changed state since the last frame
  104247. * @param buttonIdx Which button index changed
  104248. * @param state New state of the button
  104249. * @param changes Which properties on the state changed since last frame
  104250. */
  104251. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  104252. }
  104253. }
  104254. declare module BABYLON {
  104255. /**
  104256. * Gear VR Controller
  104257. */
  104258. export class GearVRController extends WebVRController {
  104259. /**
  104260. * Base Url for the controller model.
  104261. */
  104262. static MODEL_BASE_URL: string;
  104263. /**
  104264. * File name for the controller model.
  104265. */
  104266. static MODEL_FILENAME: string;
  104267. /**
  104268. * Gamepad Id prefix used to identify this controller.
  104269. */
  104270. static readonly GAMEPAD_ID_PREFIX: string;
  104271. private readonly _buttonIndexToObservableNameMap;
  104272. /**
  104273. * Creates a new GearVRController from a gamepad
  104274. * @param vrGamepad the gamepad that the controller should be created from
  104275. */
  104276. constructor(vrGamepad: any);
  104277. /**
  104278. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  104279. * @param scene scene in which to add meshes
  104280. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  104281. */
  104282. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  104283. /**
  104284. * Called once for each button that changed state since the last frame
  104285. * @param buttonIdx Which button index changed
  104286. * @param state New state of the button
  104287. * @param changes Which properties on the state changed since last frame
  104288. */
  104289. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  104290. }
  104291. }
  104292. declare module BABYLON {
  104293. /**
  104294. * Generic Controller
  104295. */
  104296. export class GenericController extends WebVRController {
  104297. /**
  104298. * Base Url for the controller model.
  104299. */
  104300. static readonly MODEL_BASE_URL: string;
  104301. /**
  104302. * File name for the controller model.
  104303. */
  104304. static readonly MODEL_FILENAME: string;
  104305. /**
  104306. * Creates a new GenericController from a gamepad
  104307. * @param vrGamepad the gamepad that the controller should be created from
  104308. */
  104309. constructor(vrGamepad: any);
  104310. /**
  104311. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  104312. * @param scene scene in which to add meshes
  104313. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  104314. */
  104315. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  104316. /**
  104317. * Called once for each button that changed state since the last frame
  104318. * @param buttonIdx Which button index changed
  104319. * @param state New state of the button
  104320. * @param changes Which properties on the state changed since last frame
  104321. */
  104322. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  104323. }
  104324. }
  104325. declare module BABYLON {
  104326. /**
  104327. * Oculus Touch Controller
  104328. */
  104329. export class OculusTouchController extends WebVRController {
  104330. /**
  104331. * Base Url for the controller model.
  104332. */
  104333. static MODEL_BASE_URL: string;
  104334. /**
  104335. * File name for the left controller model.
  104336. */
  104337. static MODEL_LEFT_FILENAME: string;
  104338. /**
  104339. * File name for the right controller model.
  104340. */
  104341. static MODEL_RIGHT_FILENAME: string;
  104342. /**
  104343. * Fired when the secondary trigger on this controller is modified
  104344. */
  104345. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  104346. /**
  104347. * Fired when the thumb rest on this controller is modified
  104348. */
  104349. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  104350. /**
  104351. * Creates a new OculusTouchController from a gamepad
  104352. * @param vrGamepad the gamepad that the controller should be created from
  104353. */
  104354. constructor(vrGamepad: any);
  104355. /**
  104356. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  104357. * @param scene scene in which to add meshes
  104358. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  104359. */
  104360. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  104361. /**
  104362. * Fired when the A button on this controller is modified
  104363. */
  104364. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  104365. /**
  104366. * Fired when the B button on this controller is modified
  104367. */
  104368. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  104369. /**
  104370. * Fired when the X button on this controller is modified
  104371. */
  104372. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  104373. /**
  104374. * Fired when the Y button on this controller is modified
  104375. */
  104376. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  104377. /**
  104378. * Called once for each button that changed state since the last frame
  104379. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  104380. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  104381. * 2) secondary trigger (same)
  104382. * 3) A (right) X (left), touch, pressed = value
  104383. * 4) B / Y
  104384. * 5) thumb rest
  104385. * @param buttonIdx Which button index changed
  104386. * @param state New state of the button
  104387. * @param changes Which properties on the state changed since last frame
  104388. */
  104389. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  104390. }
  104391. }
  104392. declare module BABYLON {
  104393. /**
  104394. * Vive Controller
  104395. */
  104396. export class ViveController extends WebVRController {
  104397. /**
  104398. * Base Url for the controller model.
  104399. */
  104400. static MODEL_BASE_URL: string;
  104401. /**
  104402. * File name for the controller model.
  104403. */
  104404. static MODEL_FILENAME: string;
  104405. /**
  104406. * Creates a new ViveController from a gamepad
  104407. * @param vrGamepad the gamepad that the controller should be created from
  104408. */
  104409. constructor(vrGamepad: any);
  104410. /**
  104411. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  104412. * @param scene scene in which to add meshes
  104413. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  104414. */
  104415. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  104416. /**
  104417. * Fired when the left button on this controller is modified
  104418. */
  104419. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  104420. /**
  104421. * Fired when the right button on this controller is modified
  104422. */
  104423. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  104424. /**
  104425. * Fired when the menu button on this controller is modified
  104426. */
  104427. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  104428. /**
  104429. * Called once for each button that changed state since the last frame
  104430. * Vive mapping:
  104431. * 0: touchpad
  104432. * 1: trigger
  104433. * 2: left AND right buttons
  104434. * 3: menu button
  104435. * @param buttonIdx Which button index changed
  104436. * @param state New state of the button
  104437. * @param changes Which properties on the state changed since last frame
  104438. */
  104439. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  104440. }
  104441. }
  104442. declare module BABYLON {
  104443. /**
  104444. * Defines the WindowsMotionController object that the state of the windows motion controller
  104445. */
  104446. export class WindowsMotionController extends WebVRController {
  104447. /**
  104448. * The base url used to load the left and right controller models
  104449. */
  104450. static MODEL_BASE_URL: string;
  104451. /**
  104452. * The name of the left controller model file
  104453. */
  104454. static MODEL_LEFT_FILENAME: string;
  104455. /**
  104456. * The name of the right controller model file
  104457. */
  104458. static MODEL_RIGHT_FILENAME: string;
  104459. /**
  104460. * The controller name prefix for this controller type
  104461. */
  104462. static readonly GAMEPAD_ID_PREFIX: string;
  104463. /**
  104464. * The controller id pattern for this controller type
  104465. */
  104466. private static readonly GAMEPAD_ID_PATTERN;
  104467. private _loadedMeshInfo;
  104468. private readonly _mapping;
  104469. /**
  104470. * Fired when the trackpad on this controller is clicked
  104471. */
  104472. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  104473. /**
  104474. * Fired when the trackpad on this controller is modified
  104475. */
  104476. onTrackpadValuesChangedObservable: Observable<StickValues>;
  104477. /**
  104478. * The current x and y values of this controller's trackpad
  104479. */
  104480. trackpad: StickValues;
  104481. /**
  104482. * Creates a new WindowsMotionController from a gamepad
  104483. * @param vrGamepad the gamepad that the controller should be created from
  104484. */
  104485. constructor(vrGamepad: any);
  104486. /**
  104487. * Fired when the trigger on this controller is modified
  104488. */
  104489. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  104490. /**
  104491. * Fired when the menu button on this controller is modified
  104492. */
  104493. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  104494. /**
  104495. * Fired when the grip button on this controller is modified
  104496. */
  104497. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  104498. /**
  104499. * Fired when the thumbstick button on this controller is modified
  104500. */
  104501. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  104502. /**
  104503. * Fired when the touchpad button on this controller is modified
  104504. */
  104505. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  104506. /**
  104507. * Fired when the touchpad values on this controller are modified
  104508. */
  104509. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  104510. private _updateTrackpad;
  104511. /**
  104512. * Called once per frame by the engine.
  104513. */
  104514. update(): void;
  104515. /**
  104516. * Called once for each button that changed state since the last frame
  104517. * @param buttonIdx Which button index changed
  104518. * @param state New state of the button
  104519. * @param changes Which properties on the state changed since last frame
  104520. */
  104521. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  104522. /**
  104523. * Moves the buttons on the controller mesh based on their current state
  104524. * @param buttonName the name of the button to move
  104525. * @param buttonValue the value of the button which determines the buttons new position
  104526. */
  104527. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  104528. /**
  104529. * Moves the axis on the controller mesh based on its current state
  104530. * @param axis the index of the axis
  104531. * @param axisValue the value of the axis which determines the meshes new position
  104532. * @hidden
  104533. */
  104534. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  104535. /**
  104536. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  104537. * @param scene scene in which to add meshes
  104538. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  104539. */
  104540. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  104541. /**
  104542. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  104543. * can be transformed by button presses and axes values, based on this._mapping.
  104544. *
  104545. * @param scene scene in which the meshes exist
  104546. * @param meshes list of meshes that make up the controller model to process
  104547. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  104548. */
  104549. private processModel;
  104550. private createMeshInfo;
  104551. /**
  104552. * Gets the ray of the controller in the direction the controller is pointing
  104553. * @param length the length the resulting ray should be
  104554. * @returns a ray in the direction the controller is pointing
  104555. */
  104556. getForwardRay(length?: number): Ray;
  104557. /**
  104558. * Disposes of the controller
  104559. */
  104560. dispose(): void;
  104561. }
  104562. }
  104563. declare module BABYLON {
  104564. /**
  104565. * Single axis scale gizmo
  104566. */
  104567. export class AxisScaleGizmo extends Gizmo {
  104568. private _coloredMaterial;
  104569. /**
  104570. * Drag behavior responsible for the gizmos dragging interactions
  104571. */
  104572. dragBehavior: PointerDragBehavior;
  104573. private _pointerObserver;
  104574. /**
  104575. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  104576. */
  104577. snapDistance: number;
  104578. /**
  104579. * Event that fires each time the gizmo snaps to a new location.
  104580. * * snapDistance is the the change in distance
  104581. */
  104582. onSnapObservable: Observable<{
  104583. snapDistance: number;
  104584. }>;
  104585. /**
  104586. * If the scaling operation should be done on all axis (default: false)
  104587. */
  104588. uniformScaling: boolean;
  104589. /**
  104590. * Creates an AxisScaleGizmo
  104591. * @param gizmoLayer The utility layer the gizmo will be added to
  104592. * @param dragAxis The axis which the gizmo will be able to scale on
  104593. * @param color The color of the gizmo
  104594. */
  104595. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  104596. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  104597. /**
  104598. * Disposes of the gizmo
  104599. */
  104600. dispose(): void;
  104601. /**
  104602. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  104603. * @param mesh The mesh to replace the default mesh of the gizmo
  104604. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  104605. */
  104606. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  104607. }
  104608. }
  104609. declare module BABYLON {
  104610. /**
  104611. * Bounding box gizmo
  104612. */
  104613. export class BoundingBoxGizmo extends Gizmo {
  104614. private _lineBoundingBox;
  104615. private _rotateSpheresParent;
  104616. private _scaleBoxesParent;
  104617. private _boundingDimensions;
  104618. private _renderObserver;
  104619. private _pointerObserver;
  104620. private _scaleDragSpeed;
  104621. private _tmpQuaternion;
  104622. private _tmpVector;
  104623. private _tmpRotationMatrix;
  104624. /**
  104625. * 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)
  104626. */
  104627. ignoreChildren: boolean;
  104628. /**
  104629. * 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)
  104630. */
  104631. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  104632. /**
  104633. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  104634. */
  104635. rotationSphereSize: number;
  104636. /**
  104637. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  104638. */
  104639. scaleBoxSize: number;
  104640. /**
  104641. * 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)
  104642. */
  104643. fixedDragMeshScreenSize: boolean;
  104644. /**
  104645. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  104646. */
  104647. fixedDragMeshScreenSizeDistanceFactor: number;
  104648. /**
  104649. * Fired when a rotation sphere or scale box is dragged
  104650. */
  104651. onDragStartObservable: Observable<{}>;
  104652. /**
  104653. * Fired when a scale box is dragged
  104654. */
  104655. onScaleBoxDragObservable: Observable<{}>;
  104656. /**
  104657. * Fired when a scale box drag is ended
  104658. */
  104659. onScaleBoxDragEndObservable: Observable<{}>;
  104660. /**
  104661. * Fired when a rotation sphere is dragged
  104662. */
  104663. onRotationSphereDragObservable: Observable<{}>;
  104664. /**
  104665. * Fired when a rotation sphere drag is ended
  104666. */
  104667. onRotationSphereDragEndObservable: Observable<{}>;
  104668. /**
  104669. * 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)
  104670. */
  104671. scalePivot: Nullable<Vector3>;
  104672. /**
  104673. * Mesh used as a pivot to rotate the attached mesh
  104674. */
  104675. private _anchorMesh;
  104676. private _existingMeshScale;
  104677. private _dragMesh;
  104678. private pointerDragBehavior;
  104679. private coloredMaterial;
  104680. private hoverColoredMaterial;
  104681. /**
  104682. * Sets the color of the bounding box gizmo
  104683. * @param color the color to set
  104684. */
  104685. setColor(color: Color3): void;
  104686. /**
  104687. * Creates an BoundingBoxGizmo
  104688. * @param gizmoLayer The utility layer the gizmo will be added to
  104689. * @param color The color of the gizmo
  104690. */
  104691. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  104692. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  104693. private _selectNode;
  104694. /**
  104695. * Updates the bounding box information for the Gizmo
  104696. */
  104697. updateBoundingBox(): void;
  104698. private _updateRotationSpheres;
  104699. private _updateScaleBoxes;
  104700. /**
  104701. * Enables rotation on the specified axis and disables rotation on the others
  104702. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  104703. */
  104704. setEnabledRotationAxis(axis: string): void;
  104705. /**
  104706. * Enables/disables scaling
  104707. * @param enable if scaling should be enabled
  104708. */
  104709. setEnabledScaling(enable: boolean): void;
  104710. private _updateDummy;
  104711. /**
  104712. * Enables a pointer drag behavior on the bounding box of the gizmo
  104713. */
  104714. enableDragBehavior(): void;
  104715. /**
  104716. * Disposes of the gizmo
  104717. */
  104718. dispose(): void;
  104719. /**
  104720. * 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)
  104721. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  104722. * @returns the bounding box mesh with the passed in mesh as a child
  104723. */
  104724. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  104725. /**
  104726. * CustomMeshes are not supported by this gizmo
  104727. * @param mesh The mesh to replace the default mesh of the gizmo
  104728. */
  104729. setCustomMesh(mesh: Mesh): void;
  104730. }
  104731. }
  104732. declare module BABYLON {
  104733. /**
  104734. * Single plane rotation gizmo
  104735. */
  104736. export class PlaneRotationGizmo extends Gizmo {
  104737. /**
  104738. * Drag behavior responsible for the gizmos dragging interactions
  104739. */
  104740. dragBehavior: PointerDragBehavior;
  104741. private _pointerObserver;
  104742. /**
  104743. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  104744. */
  104745. snapDistance: number;
  104746. /**
  104747. * Event that fires each time the gizmo snaps to a new location.
  104748. * * snapDistance is the the change in distance
  104749. */
  104750. onSnapObservable: Observable<{
  104751. snapDistance: number;
  104752. }>;
  104753. /**
  104754. * Creates a PlaneRotationGizmo
  104755. * @param gizmoLayer The utility layer the gizmo will be added to
  104756. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  104757. * @param color The color of the gizmo
  104758. * @param tessellation Amount of tessellation to be used when creating rotation circles
  104759. */
  104760. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  104761. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  104762. /**
  104763. * Disposes of the gizmo
  104764. */
  104765. dispose(): void;
  104766. }
  104767. }
  104768. declare module BABYLON {
  104769. /**
  104770. * Gizmo that enables rotating a mesh along 3 axis
  104771. */
  104772. export class RotationGizmo extends Gizmo {
  104773. /**
  104774. * Internal gizmo used for interactions on the x axis
  104775. */
  104776. xGizmo: PlaneRotationGizmo;
  104777. /**
  104778. * Internal gizmo used for interactions on the y axis
  104779. */
  104780. yGizmo: PlaneRotationGizmo;
  104781. /**
  104782. * Internal gizmo used for interactions on the z axis
  104783. */
  104784. zGizmo: PlaneRotationGizmo;
  104785. /** Fires an event when any of it's sub gizmos are dragged */
  104786. onDragStartObservable: Observable<{}>;
  104787. /** Fires an event when any of it's sub gizmos are released from dragging */
  104788. onDragEndObservable: Observable<{}>;
  104789. attachedMesh: Nullable<AbstractMesh>;
  104790. /**
  104791. * Creates a RotationGizmo
  104792. * @param gizmoLayer The utility layer the gizmo will be added to
  104793. * @param tessellation Amount of tessellation to be used when creating rotation circles
  104794. */
  104795. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  104796. updateGizmoRotationToMatchAttachedMesh: boolean;
  104797. /**
  104798. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  104799. */
  104800. snapDistance: number;
  104801. /**
  104802. * Ratio for the scale of the gizmo (Default: 1)
  104803. */
  104804. scaleRatio: number;
  104805. /**
  104806. * Disposes of the gizmo
  104807. */
  104808. dispose(): void;
  104809. /**
  104810. * CustomMeshes are not supported by this gizmo
  104811. * @param mesh The mesh to replace the default mesh of the gizmo
  104812. */
  104813. setCustomMesh(mesh: Mesh): void;
  104814. }
  104815. }
  104816. declare module BABYLON {
  104817. /**
  104818. * Gizmo that enables dragging a mesh along 3 axis
  104819. */
  104820. export class PositionGizmo extends Gizmo {
  104821. /**
  104822. * Internal gizmo used for interactions on the x axis
  104823. */
  104824. xGizmo: AxisDragGizmo;
  104825. /**
  104826. * Internal gizmo used for interactions on the y axis
  104827. */
  104828. yGizmo: AxisDragGizmo;
  104829. /**
  104830. * Internal gizmo used for interactions on the z axis
  104831. */
  104832. zGizmo: AxisDragGizmo;
  104833. /** Fires an event when any of it's sub gizmos are dragged */
  104834. onDragStartObservable: Observable<{}>;
  104835. /** Fires an event when any of it's sub gizmos are released from dragging */
  104836. onDragEndObservable: Observable<{}>;
  104837. attachedMesh: Nullable<AbstractMesh>;
  104838. /**
  104839. * Creates a PositionGizmo
  104840. * @param gizmoLayer The utility layer the gizmo will be added to
  104841. */
  104842. constructor(gizmoLayer?: UtilityLayerRenderer);
  104843. updateGizmoRotationToMatchAttachedMesh: boolean;
  104844. /**
  104845. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  104846. */
  104847. snapDistance: number;
  104848. /**
  104849. * Ratio for the scale of the gizmo (Default: 1)
  104850. */
  104851. scaleRatio: number;
  104852. /**
  104853. * Disposes of the gizmo
  104854. */
  104855. dispose(): void;
  104856. /**
  104857. * CustomMeshes are not supported by this gizmo
  104858. * @param mesh The mesh to replace the default mesh of the gizmo
  104859. */
  104860. setCustomMesh(mesh: Mesh): void;
  104861. }
  104862. }
  104863. declare module BABYLON {
  104864. /**
  104865. * Class containing static functions to help procedurally build meshes
  104866. */
  104867. export class PolyhedronBuilder {
  104868. /**
  104869. * Creates a polyhedron mesh
  104870. * * 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
  104871. * * The parameter `size` (positive float, default 1) sets the polygon size
  104872. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  104873. * * 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`
  104874. * * 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
  104875. * * 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)`)
  104876. * * 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
  104877. * * 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
  104878. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  104879. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  104880. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104881. * @param name defines the name of the mesh
  104882. * @param options defines the options used to create the mesh
  104883. * @param scene defines the hosting scene
  104884. * @returns the polyhedron mesh
  104885. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  104886. */
  104887. static CreatePolyhedron(name: string, options: {
  104888. type?: number;
  104889. size?: number;
  104890. sizeX?: number;
  104891. sizeY?: number;
  104892. sizeZ?: number;
  104893. custom?: any;
  104894. faceUV?: Vector4[];
  104895. faceColors?: Color4[];
  104896. flat?: boolean;
  104897. updatable?: boolean;
  104898. sideOrientation?: number;
  104899. frontUVs?: Vector4;
  104900. backUVs?: Vector4;
  104901. }, scene?: Nullable<Scene>): Mesh;
  104902. }
  104903. }
  104904. declare module BABYLON {
  104905. /**
  104906. * Gizmo that enables scaling a mesh along 3 axis
  104907. */
  104908. export class ScaleGizmo extends Gizmo {
  104909. /**
  104910. * Internal gizmo used for interactions on the x axis
  104911. */
  104912. xGizmo: AxisScaleGizmo;
  104913. /**
  104914. * Internal gizmo used for interactions on the y axis
  104915. */
  104916. yGizmo: AxisScaleGizmo;
  104917. /**
  104918. * Internal gizmo used for interactions on the z axis
  104919. */
  104920. zGizmo: AxisScaleGizmo;
  104921. /**
  104922. * Internal gizmo used to scale all axis equally
  104923. */
  104924. uniformScaleGizmo: AxisScaleGizmo;
  104925. /** Fires an event when any of it's sub gizmos are dragged */
  104926. onDragStartObservable: Observable<{}>;
  104927. /** Fires an event when any of it's sub gizmos are released from dragging */
  104928. onDragEndObservable: Observable<{}>;
  104929. attachedMesh: Nullable<AbstractMesh>;
  104930. /**
  104931. * Creates a ScaleGizmo
  104932. * @param gizmoLayer The utility layer the gizmo will be added to
  104933. */
  104934. constructor(gizmoLayer?: UtilityLayerRenderer);
  104935. updateGizmoRotationToMatchAttachedMesh: boolean;
  104936. /**
  104937. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  104938. */
  104939. snapDistance: number;
  104940. /**
  104941. * Ratio for the scale of the gizmo (Default: 1)
  104942. */
  104943. scaleRatio: number;
  104944. /**
  104945. * Disposes of the gizmo
  104946. */
  104947. dispose(): void;
  104948. }
  104949. }
  104950. declare module BABYLON {
  104951. /**
  104952. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  104953. */
  104954. export class GizmoManager implements IDisposable {
  104955. private scene;
  104956. /**
  104957. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  104958. */
  104959. gizmos: {
  104960. positionGizmo: Nullable<PositionGizmo>;
  104961. rotationGizmo: Nullable<RotationGizmo>;
  104962. scaleGizmo: Nullable<ScaleGizmo>;
  104963. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  104964. };
  104965. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  104966. clearGizmoOnEmptyPointerEvent: boolean;
  104967. /** Fires an event when the manager is attached to a mesh */
  104968. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  104969. private _gizmosEnabled;
  104970. private _pointerObserver;
  104971. private _attachedMesh;
  104972. private _boundingBoxColor;
  104973. private _defaultUtilityLayer;
  104974. private _defaultKeepDepthUtilityLayer;
  104975. /**
  104976. * When bounding box gizmo is enabled, this can be used to track drag/end events
  104977. */
  104978. boundingBoxDragBehavior: SixDofDragBehavior;
  104979. /**
  104980. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  104981. */
  104982. attachableMeshes: Nullable<Array<AbstractMesh>>;
  104983. /**
  104984. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  104985. */
  104986. usePointerToAttachGizmos: boolean;
  104987. /**
  104988. * Instatiates a gizmo manager
  104989. * @param scene the scene to overlay the gizmos on top of
  104990. */
  104991. constructor(scene: Scene);
  104992. /**
  104993. * Attaches a set of gizmos to the specified mesh
  104994. * @param mesh The mesh the gizmo's should be attached to
  104995. */
  104996. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  104997. /**
  104998. * If the position gizmo is enabled
  104999. */
  105000. positionGizmoEnabled: boolean;
  105001. /**
  105002. * If the rotation gizmo is enabled
  105003. */
  105004. rotationGizmoEnabled: boolean;
  105005. /**
  105006. * If the scale gizmo is enabled
  105007. */
  105008. scaleGizmoEnabled: boolean;
  105009. /**
  105010. * If the boundingBox gizmo is enabled
  105011. */
  105012. boundingBoxGizmoEnabled: boolean;
  105013. /**
  105014. * Disposes of the gizmo manager
  105015. */
  105016. dispose(): void;
  105017. }
  105018. }
  105019. declare module BABYLON {
  105020. /**
  105021. * A directional light is defined by a direction (what a surprise!).
  105022. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  105023. * 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.
  105024. * Documentation: https://doc.babylonjs.com/babylon101/lights
  105025. */
  105026. export class DirectionalLight extends ShadowLight {
  105027. private _shadowFrustumSize;
  105028. /**
  105029. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  105030. */
  105031. /**
  105032. * Specifies a fix frustum size for the shadow generation.
  105033. */
  105034. shadowFrustumSize: number;
  105035. private _shadowOrthoScale;
  105036. /**
  105037. * Gets the shadow projection scale against the optimal computed one.
  105038. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  105039. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  105040. */
  105041. /**
  105042. * Sets the shadow projection scale against the optimal computed one.
  105043. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  105044. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  105045. */
  105046. shadowOrthoScale: number;
  105047. /**
  105048. * Automatically compute the projection matrix to best fit (including all the casters)
  105049. * on each frame.
  105050. */
  105051. autoUpdateExtends: boolean;
  105052. private _orthoLeft;
  105053. private _orthoRight;
  105054. private _orthoTop;
  105055. private _orthoBottom;
  105056. /**
  105057. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  105058. * The directional light is emitted from everywhere in the given direction.
  105059. * It can cast shadows.
  105060. * Documentation : https://doc.babylonjs.com/babylon101/lights
  105061. * @param name The friendly name of the light
  105062. * @param direction The direction of the light
  105063. * @param scene The scene the light belongs to
  105064. */
  105065. constructor(name: string, direction: Vector3, scene: Scene);
  105066. /**
  105067. * Returns the string "DirectionalLight".
  105068. * @return The class name
  105069. */
  105070. getClassName(): string;
  105071. /**
  105072. * Returns the integer 1.
  105073. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  105074. */
  105075. getTypeID(): number;
  105076. /**
  105077. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  105078. * Returns the DirectionalLight Shadow projection matrix.
  105079. */
  105080. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  105081. /**
  105082. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  105083. * Returns the DirectionalLight Shadow projection matrix.
  105084. */
  105085. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  105086. /**
  105087. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  105088. * Returns the DirectionalLight Shadow projection matrix.
  105089. */
  105090. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  105091. protected _buildUniformLayout(): void;
  105092. /**
  105093. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  105094. * @param effect The effect to update
  105095. * @param lightIndex The index of the light in the effect to update
  105096. * @returns The directional light
  105097. */
  105098. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  105099. /**
  105100. * Gets the minZ used for shadow according to both the scene and the light.
  105101. *
  105102. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  105103. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  105104. * @param activeCamera The camera we are returning the min for
  105105. * @returns the depth min z
  105106. */
  105107. getDepthMinZ(activeCamera: Camera): number;
  105108. /**
  105109. * Gets the maxZ used for shadow according to both the scene and the light.
  105110. *
  105111. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  105112. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  105113. * @param activeCamera The camera we are returning the max for
  105114. * @returns the depth max z
  105115. */
  105116. getDepthMaxZ(activeCamera: Camera): number;
  105117. /**
  105118. * Prepares the list of defines specific to the light type.
  105119. * @param defines the list of defines
  105120. * @param lightIndex defines the index of the light for the effect
  105121. */
  105122. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  105123. }
  105124. }
  105125. declare module BABYLON {
  105126. /**
  105127. * Class containing static functions to help procedurally build meshes
  105128. */
  105129. export class HemisphereBuilder {
  105130. /**
  105131. * Creates a hemisphere mesh
  105132. * @param name defines the name of the mesh
  105133. * @param options defines the options used to create the mesh
  105134. * @param scene defines the hosting scene
  105135. * @returns the hemisphere mesh
  105136. */
  105137. static CreateHemisphere(name: string, options: {
  105138. segments?: number;
  105139. diameter?: number;
  105140. sideOrientation?: number;
  105141. }, scene: any): Mesh;
  105142. }
  105143. }
  105144. declare module BABYLON {
  105145. /**
  105146. * A spot light is defined by a position, a direction, an angle, and an exponent.
  105147. * These values define a cone of light starting from the position, emitting toward the direction.
  105148. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  105149. * and the exponent defines the speed of the decay of the light with distance (reach).
  105150. * Documentation: https://doc.babylonjs.com/babylon101/lights
  105151. */
  105152. export class SpotLight extends ShadowLight {
  105153. private _angle;
  105154. private _innerAngle;
  105155. private _cosHalfAngle;
  105156. private _lightAngleScale;
  105157. private _lightAngleOffset;
  105158. /**
  105159. * Gets the cone angle of the spot light in Radians.
  105160. */
  105161. /**
  105162. * Sets the cone angle of the spot light in Radians.
  105163. */
  105164. angle: number;
  105165. /**
  105166. * Only used in gltf falloff mode, this defines the angle where
  105167. * the directional falloff will start before cutting at angle which could be seen
  105168. * as outer angle.
  105169. */
  105170. /**
  105171. * Only used in gltf falloff mode, this defines the angle where
  105172. * the directional falloff will start before cutting at angle which could be seen
  105173. * as outer angle.
  105174. */
  105175. innerAngle: number;
  105176. private _shadowAngleScale;
  105177. /**
  105178. * Allows scaling the angle of the light for shadow generation only.
  105179. */
  105180. /**
  105181. * Allows scaling the angle of the light for shadow generation only.
  105182. */
  105183. shadowAngleScale: number;
  105184. /**
  105185. * The light decay speed with the distance from the emission spot.
  105186. */
  105187. exponent: number;
  105188. private _projectionTextureMatrix;
  105189. /**
  105190. * Allows reading the projecton texture
  105191. */
  105192. readonly projectionTextureMatrix: Matrix;
  105193. protected _projectionTextureLightNear: number;
  105194. /**
  105195. * Gets the near clip of the Spotlight for texture projection.
  105196. */
  105197. /**
  105198. * Sets the near clip of the Spotlight for texture projection.
  105199. */
  105200. projectionTextureLightNear: number;
  105201. protected _projectionTextureLightFar: number;
  105202. /**
  105203. * Gets the far clip of the Spotlight for texture projection.
  105204. */
  105205. /**
  105206. * Sets the far clip of the Spotlight for texture projection.
  105207. */
  105208. projectionTextureLightFar: number;
  105209. protected _projectionTextureUpDirection: Vector3;
  105210. /**
  105211. * Gets the Up vector of the Spotlight for texture projection.
  105212. */
  105213. /**
  105214. * Sets the Up vector of the Spotlight for texture projection.
  105215. */
  105216. projectionTextureUpDirection: Vector3;
  105217. private _projectionTexture;
  105218. /**
  105219. * Gets the projection texture of the light.
  105220. */
  105221. /**
  105222. * Sets the projection texture of the light.
  105223. */
  105224. projectionTexture: Nullable<BaseTexture>;
  105225. private _projectionTextureViewLightDirty;
  105226. private _projectionTextureProjectionLightDirty;
  105227. private _projectionTextureDirty;
  105228. private _projectionTextureViewTargetVector;
  105229. private _projectionTextureViewLightMatrix;
  105230. private _projectionTextureProjectionLightMatrix;
  105231. private _projectionTextureScalingMatrix;
  105232. /**
  105233. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  105234. * It can cast shadows.
  105235. * Documentation : https://doc.babylonjs.com/babylon101/lights
  105236. * @param name The light friendly name
  105237. * @param position The position of the spot light in the scene
  105238. * @param direction The direction of the light in the scene
  105239. * @param angle The cone angle of the light in Radians
  105240. * @param exponent The light decay speed with the distance from the emission spot
  105241. * @param scene The scene the lights belongs to
  105242. */
  105243. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  105244. /**
  105245. * Returns the string "SpotLight".
  105246. * @returns the class name
  105247. */
  105248. getClassName(): string;
  105249. /**
  105250. * Returns the integer 2.
  105251. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  105252. */
  105253. getTypeID(): number;
  105254. /**
  105255. * Overrides the direction setter to recompute the projection texture view light Matrix.
  105256. */
  105257. protected _setDirection(value: Vector3): void;
  105258. /**
  105259. * Overrides the position setter to recompute the projection texture view light Matrix.
  105260. */
  105261. protected _setPosition(value: Vector3): void;
  105262. /**
  105263. * 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.
  105264. * Returns the SpotLight.
  105265. */
  105266. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  105267. protected _computeProjectionTextureViewLightMatrix(): void;
  105268. protected _computeProjectionTextureProjectionLightMatrix(): void;
  105269. /**
  105270. * Main function for light texture projection matrix computing.
  105271. */
  105272. protected _computeProjectionTextureMatrix(): void;
  105273. protected _buildUniformLayout(): void;
  105274. private _computeAngleValues;
  105275. /**
  105276. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  105277. * @param effect The effect to update
  105278. * @param lightIndex The index of the light in the effect to update
  105279. * @returns The spot light
  105280. */
  105281. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  105282. /**
  105283. * Disposes the light and the associated resources.
  105284. */
  105285. dispose(): void;
  105286. /**
  105287. * Prepares the list of defines specific to the light type.
  105288. * @param defines the list of defines
  105289. * @param lightIndex defines the index of the light for the effect
  105290. */
  105291. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  105292. }
  105293. }
  105294. declare module BABYLON {
  105295. /**
  105296. * Gizmo that enables viewing a light
  105297. */
  105298. export class LightGizmo extends Gizmo {
  105299. private _lightMesh;
  105300. private _material;
  105301. private cachedPosition;
  105302. private cachedForward;
  105303. /**
  105304. * Creates a LightGizmo
  105305. * @param gizmoLayer The utility layer the gizmo will be added to
  105306. */
  105307. constructor(gizmoLayer?: UtilityLayerRenderer);
  105308. private _light;
  105309. /**
  105310. * The light that the gizmo is attached to
  105311. */
  105312. light: Nullable<Light>;
  105313. /**
  105314. * @hidden
  105315. * Updates the gizmo to match the attached mesh's position/rotation
  105316. */
  105317. protected _update(): void;
  105318. private static _Scale;
  105319. /**
  105320. * Creates the lines for a light mesh
  105321. */
  105322. private static _createLightLines;
  105323. /**
  105324. * Disposes of the light gizmo
  105325. */
  105326. dispose(): void;
  105327. private static _CreateHemisphericLightMesh;
  105328. private static _CreatePointLightMesh;
  105329. private static _CreateSpotLightMesh;
  105330. private static _CreateDirectionalLightMesh;
  105331. }
  105332. }
  105333. declare module BABYLON {
  105334. /** @hidden */
  105335. export var backgroundFragmentDeclaration: {
  105336. name: string;
  105337. shader: string;
  105338. };
  105339. }
  105340. declare module BABYLON {
  105341. /** @hidden */
  105342. export var backgroundUboDeclaration: {
  105343. name: string;
  105344. shader: string;
  105345. };
  105346. }
  105347. declare module BABYLON {
  105348. /** @hidden */
  105349. export var backgroundPixelShader: {
  105350. name: string;
  105351. shader: string;
  105352. };
  105353. }
  105354. declare module BABYLON {
  105355. /** @hidden */
  105356. export var backgroundVertexDeclaration: {
  105357. name: string;
  105358. shader: string;
  105359. };
  105360. }
  105361. declare module BABYLON {
  105362. /** @hidden */
  105363. export var backgroundVertexShader: {
  105364. name: string;
  105365. shader: string;
  105366. };
  105367. }
  105368. declare module BABYLON {
  105369. /**
  105370. * Background material used to create an efficient environement around your scene.
  105371. */
  105372. export class BackgroundMaterial extends PushMaterial {
  105373. /**
  105374. * Standard reflectance value at parallel view angle.
  105375. */
  105376. static StandardReflectance0: number;
  105377. /**
  105378. * Standard reflectance value at grazing angle.
  105379. */
  105380. static StandardReflectance90: number;
  105381. protected _primaryColor: Color3;
  105382. /**
  105383. * Key light Color (multiply against the environement texture)
  105384. */
  105385. primaryColor: Color3;
  105386. protected __perceptualColor: Nullable<Color3>;
  105387. /**
  105388. * Experimental Internal Use Only.
  105389. *
  105390. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  105391. * This acts as a helper to set the primary color to a more "human friendly" value.
  105392. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  105393. * output color as close as possible from the chosen value.
  105394. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  105395. * part of lighting setup.)
  105396. */
  105397. _perceptualColor: Nullable<Color3>;
  105398. protected _primaryColorShadowLevel: float;
  105399. /**
  105400. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  105401. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  105402. */
  105403. primaryColorShadowLevel: float;
  105404. protected _primaryColorHighlightLevel: float;
  105405. /**
  105406. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  105407. * The primary color is used at the level chosen to define what the white area would look.
  105408. */
  105409. primaryColorHighlightLevel: float;
  105410. protected _reflectionTexture: Nullable<BaseTexture>;
  105411. /**
  105412. * Reflection Texture used in the material.
  105413. * Should be author in a specific way for the best result (refer to the documentation).
  105414. */
  105415. reflectionTexture: Nullable<BaseTexture>;
  105416. protected _reflectionBlur: float;
  105417. /**
  105418. * Reflection Texture level of blur.
  105419. *
  105420. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  105421. * texture twice.
  105422. */
  105423. reflectionBlur: float;
  105424. protected _diffuseTexture: Nullable<BaseTexture>;
  105425. /**
  105426. * Diffuse Texture used in the material.
  105427. * Should be author in a specific way for the best result (refer to the documentation).
  105428. */
  105429. diffuseTexture: Nullable<BaseTexture>;
  105430. protected _shadowLights: Nullable<IShadowLight[]>;
  105431. /**
  105432. * Specify the list of lights casting shadow on the material.
  105433. * All scene shadow lights will be included if null.
  105434. */
  105435. shadowLights: Nullable<IShadowLight[]>;
  105436. protected _shadowLevel: float;
  105437. /**
  105438. * Helps adjusting the shadow to a softer level if required.
  105439. * 0 means black shadows and 1 means no shadows.
  105440. */
  105441. shadowLevel: float;
  105442. protected _sceneCenter: Vector3;
  105443. /**
  105444. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  105445. * It is usually zero but might be interesting to modify according to your setup.
  105446. */
  105447. sceneCenter: Vector3;
  105448. protected _opacityFresnel: boolean;
  105449. /**
  105450. * This helps specifying that the material is falling off to the sky box at grazing angle.
  105451. * This helps ensuring a nice transition when the camera goes under the ground.
  105452. */
  105453. opacityFresnel: boolean;
  105454. protected _reflectionFresnel: boolean;
  105455. /**
  105456. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  105457. * This helps adding a mirror texture on the ground.
  105458. */
  105459. reflectionFresnel: boolean;
  105460. protected _reflectionFalloffDistance: number;
  105461. /**
  105462. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  105463. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  105464. */
  105465. reflectionFalloffDistance: number;
  105466. protected _reflectionAmount: number;
  105467. /**
  105468. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  105469. */
  105470. reflectionAmount: number;
  105471. protected _reflectionReflectance0: number;
  105472. /**
  105473. * This specifies the weight of the reflection at grazing angle.
  105474. */
  105475. reflectionReflectance0: number;
  105476. protected _reflectionReflectance90: number;
  105477. /**
  105478. * This specifies the weight of the reflection at a perpendicular point of view.
  105479. */
  105480. reflectionReflectance90: number;
  105481. /**
  105482. * Sets the reflection reflectance fresnel values according to the default standard
  105483. * empirically know to work well :-)
  105484. */
  105485. reflectionStandardFresnelWeight: number;
  105486. protected _useRGBColor: boolean;
  105487. /**
  105488. * Helps to directly use the maps channels instead of their level.
  105489. */
  105490. useRGBColor: boolean;
  105491. protected _enableNoise: boolean;
  105492. /**
  105493. * This helps reducing the banding effect that could occur on the background.
  105494. */
  105495. enableNoise: boolean;
  105496. /**
  105497. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  105498. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  105499. * Recommended to be keep at 1.0 except for special cases.
  105500. */
  105501. fovMultiplier: number;
  105502. private _fovMultiplier;
  105503. /**
  105504. * Enable the FOV adjustment feature controlled by fovMultiplier.
  105505. */
  105506. useEquirectangularFOV: boolean;
  105507. private _maxSimultaneousLights;
  105508. /**
  105509. * Number of Simultaneous lights allowed on the material.
  105510. */
  105511. maxSimultaneousLights: int;
  105512. /**
  105513. * Default configuration related to image processing available in the Background Material.
  105514. */
  105515. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  105516. /**
  105517. * Keep track of the image processing observer to allow dispose and replace.
  105518. */
  105519. private _imageProcessingObserver;
  105520. /**
  105521. * Attaches a new image processing configuration to the PBR Material.
  105522. * @param configuration (if null the scene configuration will be use)
  105523. */
  105524. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  105525. /**
  105526. * Gets the image processing configuration used either in this material.
  105527. */
  105528. /**
  105529. * Sets the Default image processing configuration used either in the this material.
  105530. *
  105531. * If sets to null, the scene one is in use.
  105532. */
  105533. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  105534. /**
  105535. * Gets wether the color curves effect is enabled.
  105536. */
  105537. /**
  105538. * Sets wether the color curves effect is enabled.
  105539. */
  105540. cameraColorCurvesEnabled: boolean;
  105541. /**
  105542. * Gets wether the color grading effect is enabled.
  105543. */
  105544. /**
  105545. * Gets wether the color grading effect is enabled.
  105546. */
  105547. cameraColorGradingEnabled: boolean;
  105548. /**
  105549. * Gets wether tonemapping is enabled or not.
  105550. */
  105551. /**
  105552. * Sets wether tonemapping is enabled or not
  105553. */
  105554. cameraToneMappingEnabled: boolean;
  105555. /**
  105556. * The camera exposure used on this material.
  105557. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  105558. * This corresponds to a photographic exposure.
  105559. */
  105560. /**
  105561. * The camera exposure used on this material.
  105562. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  105563. * This corresponds to a photographic exposure.
  105564. */
  105565. cameraExposure: float;
  105566. /**
  105567. * Gets The camera contrast used on this material.
  105568. */
  105569. /**
  105570. * Sets The camera contrast used on this material.
  105571. */
  105572. cameraContrast: float;
  105573. /**
  105574. * Gets the Color Grading 2D Lookup Texture.
  105575. */
  105576. /**
  105577. * Sets the Color Grading 2D Lookup Texture.
  105578. */
  105579. cameraColorGradingTexture: Nullable<BaseTexture>;
  105580. /**
  105581. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  105582. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  105583. * 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;
  105584. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  105585. */
  105586. /**
  105587. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  105588. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  105589. * 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;
  105590. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  105591. */
  105592. cameraColorCurves: Nullable<ColorCurves>;
  105593. /**
  105594. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  105595. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  105596. */
  105597. switchToBGR: boolean;
  105598. private _renderTargets;
  105599. private _reflectionControls;
  105600. private _white;
  105601. private _primaryShadowColor;
  105602. private _primaryHighlightColor;
  105603. /**
  105604. * Instantiates a Background Material in the given scene
  105605. * @param name The friendly name of the material
  105606. * @param scene The scene to add the material to
  105607. */
  105608. constructor(name: string, scene: Scene);
  105609. /**
  105610. * Gets a boolean indicating that current material needs to register RTT
  105611. */
  105612. readonly hasRenderTargetTextures: boolean;
  105613. /**
  105614. * The entire material has been created in order to prevent overdraw.
  105615. * @returns false
  105616. */
  105617. needAlphaTesting(): boolean;
  105618. /**
  105619. * The entire material has been created in order to prevent overdraw.
  105620. * @returns true if blending is enable
  105621. */
  105622. needAlphaBlending(): boolean;
  105623. /**
  105624. * Checks wether the material is ready to be rendered for a given mesh.
  105625. * @param mesh The mesh to render
  105626. * @param subMesh The submesh to check against
  105627. * @param useInstances Specify wether or not the material is used with instances
  105628. * @returns true if all the dependencies are ready (Textures, Effects...)
  105629. */
  105630. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  105631. /**
  105632. * Compute the primary color according to the chosen perceptual color.
  105633. */
  105634. private _computePrimaryColorFromPerceptualColor;
  105635. /**
  105636. * Compute the highlights and shadow colors according to their chosen levels.
  105637. */
  105638. private _computePrimaryColors;
  105639. /**
  105640. * Build the uniform buffer used in the material.
  105641. */
  105642. buildUniformLayout(): void;
  105643. /**
  105644. * Unbind the material.
  105645. */
  105646. unbind(): void;
  105647. /**
  105648. * Bind only the world matrix to the material.
  105649. * @param world The world matrix to bind.
  105650. */
  105651. bindOnlyWorldMatrix(world: Matrix): void;
  105652. /**
  105653. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  105654. * @param world The world matrix to bind.
  105655. * @param subMesh The submesh to bind for.
  105656. */
  105657. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  105658. /**
  105659. * Dispose the material.
  105660. * @param forceDisposeEffect Force disposal of the associated effect.
  105661. * @param forceDisposeTextures Force disposal of the associated textures.
  105662. */
  105663. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  105664. /**
  105665. * Clones the material.
  105666. * @param name The cloned name.
  105667. * @returns The cloned material.
  105668. */
  105669. clone(name: string): BackgroundMaterial;
  105670. /**
  105671. * Serializes the current material to its JSON representation.
  105672. * @returns The JSON representation.
  105673. */
  105674. serialize(): any;
  105675. /**
  105676. * Gets the class name of the material
  105677. * @returns "BackgroundMaterial"
  105678. */
  105679. getClassName(): string;
  105680. /**
  105681. * Parse a JSON input to create back a background material.
  105682. * @param source The JSON data to parse
  105683. * @param scene The scene to create the parsed material in
  105684. * @param rootUrl The root url of the assets the material depends upon
  105685. * @returns the instantiated BackgroundMaterial.
  105686. */
  105687. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  105688. }
  105689. }
  105690. declare module BABYLON {
  105691. /**
  105692. * Represents the different options available during the creation of
  105693. * a Environment helper.
  105694. *
  105695. * This can control the default ground, skybox and image processing setup of your scene.
  105696. */
  105697. export interface IEnvironmentHelperOptions {
  105698. /**
  105699. * Specifies wether or not to create a ground.
  105700. * True by default.
  105701. */
  105702. createGround: boolean;
  105703. /**
  105704. * Specifies the ground size.
  105705. * 15 by default.
  105706. */
  105707. groundSize: number;
  105708. /**
  105709. * The texture used on the ground for the main color.
  105710. * Comes from the BabylonJS CDN by default.
  105711. *
  105712. * Remarks: Can be either a texture or a url.
  105713. */
  105714. groundTexture: string | BaseTexture;
  105715. /**
  105716. * The color mixed in the ground texture by default.
  105717. * BabylonJS clearColor by default.
  105718. */
  105719. groundColor: Color3;
  105720. /**
  105721. * Specifies the ground opacity.
  105722. * 1 by default.
  105723. */
  105724. groundOpacity: number;
  105725. /**
  105726. * Enables the ground to receive shadows.
  105727. * True by default.
  105728. */
  105729. enableGroundShadow: boolean;
  105730. /**
  105731. * Helps preventing the shadow to be fully black on the ground.
  105732. * 0.5 by default.
  105733. */
  105734. groundShadowLevel: number;
  105735. /**
  105736. * Creates a mirror texture attach to the ground.
  105737. * false by default.
  105738. */
  105739. enableGroundMirror: boolean;
  105740. /**
  105741. * Specifies the ground mirror size ratio.
  105742. * 0.3 by default as the default kernel is 64.
  105743. */
  105744. groundMirrorSizeRatio: number;
  105745. /**
  105746. * Specifies the ground mirror blur kernel size.
  105747. * 64 by default.
  105748. */
  105749. groundMirrorBlurKernel: number;
  105750. /**
  105751. * Specifies the ground mirror visibility amount.
  105752. * 1 by default
  105753. */
  105754. groundMirrorAmount: number;
  105755. /**
  105756. * Specifies the ground mirror reflectance weight.
  105757. * This uses the standard weight of the background material to setup the fresnel effect
  105758. * of the mirror.
  105759. * 1 by default.
  105760. */
  105761. groundMirrorFresnelWeight: number;
  105762. /**
  105763. * Specifies the ground mirror Falloff distance.
  105764. * This can helps reducing the size of the reflection.
  105765. * 0 by Default.
  105766. */
  105767. groundMirrorFallOffDistance: number;
  105768. /**
  105769. * Specifies the ground mirror texture type.
  105770. * Unsigned Int by Default.
  105771. */
  105772. groundMirrorTextureType: number;
  105773. /**
  105774. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  105775. * the shown objects.
  105776. */
  105777. groundYBias: number;
  105778. /**
  105779. * Specifies wether or not to create a skybox.
  105780. * True by default.
  105781. */
  105782. createSkybox: boolean;
  105783. /**
  105784. * Specifies the skybox size.
  105785. * 20 by default.
  105786. */
  105787. skyboxSize: number;
  105788. /**
  105789. * The texture used on the skybox for the main color.
  105790. * Comes from the BabylonJS CDN by default.
  105791. *
  105792. * Remarks: Can be either a texture or a url.
  105793. */
  105794. skyboxTexture: string | BaseTexture;
  105795. /**
  105796. * The color mixed in the skybox texture by default.
  105797. * BabylonJS clearColor by default.
  105798. */
  105799. skyboxColor: Color3;
  105800. /**
  105801. * The background rotation around the Y axis of the scene.
  105802. * This helps aligning the key lights of your scene with the background.
  105803. * 0 by default.
  105804. */
  105805. backgroundYRotation: number;
  105806. /**
  105807. * Compute automatically the size of the elements to best fit with the scene.
  105808. */
  105809. sizeAuto: boolean;
  105810. /**
  105811. * Default position of the rootMesh if autoSize is not true.
  105812. */
  105813. rootPosition: Vector3;
  105814. /**
  105815. * Sets up the image processing in the scene.
  105816. * true by default.
  105817. */
  105818. setupImageProcessing: boolean;
  105819. /**
  105820. * The texture used as your environment texture in the scene.
  105821. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  105822. *
  105823. * Remarks: Can be either a texture or a url.
  105824. */
  105825. environmentTexture: string | BaseTexture;
  105826. /**
  105827. * The value of the exposure to apply to the scene.
  105828. * 0.6 by default if setupImageProcessing is true.
  105829. */
  105830. cameraExposure: number;
  105831. /**
  105832. * The value of the contrast to apply to the scene.
  105833. * 1.6 by default if setupImageProcessing is true.
  105834. */
  105835. cameraContrast: number;
  105836. /**
  105837. * Specifies wether or not tonemapping should be enabled in the scene.
  105838. * true by default if setupImageProcessing is true.
  105839. */
  105840. toneMappingEnabled: boolean;
  105841. }
  105842. /**
  105843. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  105844. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  105845. * It also helps with the default setup of your imageProcessing configuration.
  105846. */
  105847. export class EnvironmentHelper {
  105848. /**
  105849. * Default ground texture URL.
  105850. */
  105851. private static _groundTextureCDNUrl;
  105852. /**
  105853. * Default skybox texture URL.
  105854. */
  105855. private static _skyboxTextureCDNUrl;
  105856. /**
  105857. * Default environment texture URL.
  105858. */
  105859. private static _environmentTextureCDNUrl;
  105860. /**
  105861. * Creates the default options for the helper.
  105862. */
  105863. private static _getDefaultOptions;
  105864. private _rootMesh;
  105865. /**
  105866. * Gets the root mesh created by the helper.
  105867. */
  105868. readonly rootMesh: Mesh;
  105869. private _skybox;
  105870. /**
  105871. * Gets the skybox created by the helper.
  105872. */
  105873. readonly skybox: Nullable<Mesh>;
  105874. private _skyboxTexture;
  105875. /**
  105876. * Gets the skybox texture created by the helper.
  105877. */
  105878. readonly skyboxTexture: Nullable<BaseTexture>;
  105879. private _skyboxMaterial;
  105880. /**
  105881. * Gets the skybox material created by the helper.
  105882. */
  105883. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  105884. private _ground;
  105885. /**
  105886. * Gets the ground mesh created by the helper.
  105887. */
  105888. readonly ground: Nullable<Mesh>;
  105889. private _groundTexture;
  105890. /**
  105891. * Gets the ground texture created by the helper.
  105892. */
  105893. readonly groundTexture: Nullable<BaseTexture>;
  105894. private _groundMirror;
  105895. /**
  105896. * Gets the ground mirror created by the helper.
  105897. */
  105898. readonly groundMirror: Nullable<MirrorTexture>;
  105899. /**
  105900. * Gets the ground mirror render list to helps pushing the meshes
  105901. * you wish in the ground reflection.
  105902. */
  105903. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  105904. private _groundMaterial;
  105905. /**
  105906. * Gets the ground material created by the helper.
  105907. */
  105908. readonly groundMaterial: Nullable<BackgroundMaterial>;
  105909. /**
  105910. * Stores the creation options.
  105911. */
  105912. private readonly _scene;
  105913. private _options;
  105914. /**
  105915. * This observable will be notified with any error during the creation of the environment,
  105916. * mainly texture creation errors.
  105917. */
  105918. onErrorObservable: Observable<{
  105919. message?: string;
  105920. exception?: any;
  105921. }>;
  105922. /**
  105923. * constructor
  105924. * @param options Defines the options we want to customize the helper
  105925. * @param scene The scene to add the material to
  105926. */
  105927. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  105928. /**
  105929. * Updates the background according to the new options
  105930. * @param options
  105931. */
  105932. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  105933. /**
  105934. * Sets the primary color of all the available elements.
  105935. * @param color the main color to affect to the ground and the background
  105936. */
  105937. setMainColor(color: Color3): void;
  105938. /**
  105939. * Setup the image processing according to the specified options.
  105940. */
  105941. private _setupImageProcessing;
  105942. /**
  105943. * Setup the environment texture according to the specified options.
  105944. */
  105945. private _setupEnvironmentTexture;
  105946. /**
  105947. * Setup the background according to the specified options.
  105948. */
  105949. private _setupBackground;
  105950. /**
  105951. * Get the scene sizes according to the setup.
  105952. */
  105953. private _getSceneSize;
  105954. /**
  105955. * Setup the ground according to the specified options.
  105956. */
  105957. private _setupGround;
  105958. /**
  105959. * Setup the ground material according to the specified options.
  105960. */
  105961. private _setupGroundMaterial;
  105962. /**
  105963. * Setup the ground diffuse texture according to the specified options.
  105964. */
  105965. private _setupGroundDiffuseTexture;
  105966. /**
  105967. * Setup the ground mirror texture according to the specified options.
  105968. */
  105969. private _setupGroundMirrorTexture;
  105970. /**
  105971. * Setup the ground to receive the mirror texture.
  105972. */
  105973. private _setupMirrorInGroundMaterial;
  105974. /**
  105975. * Setup the skybox according to the specified options.
  105976. */
  105977. private _setupSkybox;
  105978. /**
  105979. * Setup the skybox material according to the specified options.
  105980. */
  105981. private _setupSkyboxMaterial;
  105982. /**
  105983. * Setup the skybox reflection texture according to the specified options.
  105984. */
  105985. private _setupSkyboxReflectionTexture;
  105986. private _errorHandler;
  105987. /**
  105988. * Dispose all the elements created by the Helper.
  105989. */
  105990. dispose(): void;
  105991. }
  105992. }
  105993. declare module BABYLON {
  105994. /**
  105995. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  105996. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  105997. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  105998. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  105999. */
  106000. export class PhotoDome extends TransformNode {
  106001. private _useDirectMapping;
  106002. /**
  106003. * The texture being displayed on the sphere
  106004. */
  106005. protected _photoTexture: Texture;
  106006. /**
  106007. * Gets or sets the texture being displayed on the sphere
  106008. */
  106009. photoTexture: Texture;
  106010. /**
  106011. * Observable raised when an error occured while loading the 360 image
  106012. */
  106013. onLoadErrorObservable: Observable<string>;
  106014. /**
  106015. * The skybox material
  106016. */
  106017. protected _material: BackgroundMaterial;
  106018. /**
  106019. * The surface used for the skybox
  106020. */
  106021. protected _mesh: Mesh;
  106022. /**
  106023. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  106024. * Also see the options.resolution property.
  106025. */
  106026. fovMultiplier: number;
  106027. /**
  106028. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  106029. * @param name Element's name, child elements will append suffixes for their own names.
  106030. * @param urlsOfPhoto defines the url of the photo to display
  106031. * @param options defines an object containing optional or exposed sub element properties
  106032. * @param onError defines a callback called when an error occured while loading the texture
  106033. */
  106034. constructor(name: string, urlOfPhoto: string, options: {
  106035. resolution?: number;
  106036. size?: number;
  106037. useDirectMapping?: boolean;
  106038. faceForward?: boolean;
  106039. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  106040. /**
  106041. * Releases resources associated with this node.
  106042. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  106043. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  106044. */
  106045. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  106046. }
  106047. }
  106048. declare module BABYLON {
  106049. /** @hidden */
  106050. export var rgbdDecodePixelShader: {
  106051. name: string;
  106052. shader: string;
  106053. };
  106054. }
  106055. declare module BABYLON {
  106056. /**
  106057. * Class used to host texture specific utilities
  106058. */
  106059. export class BRDFTextureTools {
  106060. /**
  106061. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  106062. * @param texture the texture to expand.
  106063. */
  106064. private static _ExpandDefaultBRDFTexture;
  106065. /**
  106066. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  106067. * @param scene defines the hosting scene
  106068. * @returns the environment BRDF texture
  106069. */
  106070. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  106071. private static _environmentBRDFBase64Texture;
  106072. }
  106073. }
  106074. declare module BABYLON {
  106075. /**
  106076. * @hidden
  106077. */
  106078. export interface IMaterialClearCoatDefines {
  106079. CLEARCOAT: boolean;
  106080. CLEARCOAT_DEFAULTIOR: boolean;
  106081. CLEARCOAT_TEXTURE: boolean;
  106082. CLEARCOAT_TEXTUREDIRECTUV: number;
  106083. CLEARCOAT_BUMP: boolean;
  106084. CLEARCOAT_BUMPDIRECTUV: number;
  106085. CLEARCOAT_TINT: boolean;
  106086. CLEARCOAT_TINT_TEXTURE: boolean;
  106087. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  106088. /** @hidden */
  106089. _areTexturesDirty: boolean;
  106090. }
  106091. /**
  106092. * Define the code related to the clear coat parameters of the pbr material.
  106093. */
  106094. export class PBRClearCoatConfiguration {
  106095. /**
  106096. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  106097. * The default fits with a polyurethane material.
  106098. */
  106099. private static readonly _DefaultIndiceOfRefraction;
  106100. private _isEnabled;
  106101. /**
  106102. * Defines if the clear coat is enabled in the material.
  106103. */
  106104. isEnabled: boolean;
  106105. /**
  106106. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  106107. */
  106108. intensity: number;
  106109. /**
  106110. * Defines the clear coat layer roughness.
  106111. */
  106112. roughness: number;
  106113. private _indiceOfRefraction;
  106114. /**
  106115. * Defines the indice of refraction of the clear coat.
  106116. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  106117. * The default fits with a polyurethane material.
  106118. * Changing the default value is more performance intensive.
  106119. */
  106120. indiceOfRefraction: number;
  106121. private _texture;
  106122. /**
  106123. * Stores the clear coat values in a texture.
  106124. */
  106125. texture: Nullable<BaseTexture>;
  106126. private _bumpTexture;
  106127. /**
  106128. * Define the clear coat specific bump texture.
  106129. */
  106130. bumpTexture: Nullable<BaseTexture>;
  106131. private _isTintEnabled;
  106132. /**
  106133. * Defines if the clear coat tint is enabled in the material.
  106134. */
  106135. isTintEnabled: boolean;
  106136. /**
  106137. * Defines the clear coat tint of the material.
  106138. * This is only use if tint is enabled
  106139. */
  106140. tintColor: Color3;
  106141. /**
  106142. * Defines the distance at which the tint color should be found in the
  106143. * clear coat media.
  106144. * This is only use if tint is enabled
  106145. */
  106146. tintColorAtDistance: number;
  106147. /**
  106148. * Defines the clear coat layer thickness.
  106149. * This is only use if tint is enabled
  106150. */
  106151. tintThickness: number;
  106152. private _tintTexture;
  106153. /**
  106154. * Stores the clear tint values in a texture.
  106155. * rgb is tint
  106156. * a is a thickness factor
  106157. */
  106158. tintTexture: Nullable<BaseTexture>;
  106159. /** @hidden */
  106160. private _internalMarkAllSubMeshesAsTexturesDirty;
  106161. /** @hidden */
  106162. _markAllSubMeshesAsTexturesDirty(): void;
  106163. /**
  106164. * Instantiate a new istance of clear coat configuration.
  106165. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  106166. */
  106167. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  106168. /**
  106169. * Gets wehter the submesh is ready to be used or not.
  106170. * @param defines the list of "defines" to update.
  106171. * @param scene defines the scene the material belongs to.
  106172. * @param engine defines the engine the material belongs to.
  106173. * @param disableBumpMap defines wether the material disables bump or not.
  106174. * @returns - boolean indicating that the submesh is ready or not.
  106175. */
  106176. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  106177. /**
  106178. * Checks to see if a texture is used in the material.
  106179. * @param defines the list of "defines" to update.
  106180. * @param scene defines the scene to the material belongs to.
  106181. */
  106182. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  106183. /**
  106184. * Binds the material data.
  106185. * @param uniformBuffer defines the Uniform buffer to fill in.
  106186. * @param scene defines the scene the material belongs to.
  106187. * @param engine defines the engine the material belongs to.
  106188. * @param disableBumpMap defines wether the material disables bump or not.
  106189. * @param isFrozen defines wether the material is frozen or not.
  106190. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  106191. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  106192. */
  106193. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  106194. /**
  106195. * Checks to see if a texture is used in the material.
  106196. * @param texture - Base texture to use.
  106197. * @returns - Boolean specifying if a texture is used in the material.
  106198. */
  106199. hasTexture(texture: BaseTexture): boolean;
  106200. /**
  106201. * Returns an array of the actively used textures.
  106202. * @param activeTextures Array of BaseTextures
  106203. */
  106204. getActiveTextures(activeTextures: BaseTexture[]): void;
  106205. /**
  106206. * Returns the animatable textures.
  106207. * @param animatables Array of animatable textures.
  106208. */
  106209. getAnimatables(animatables: IAnimatable[]): void;
  106210. /**
  106211. * Disposes the resources of the material.
  106212. * @param forceDisposeTextures - Forces the disposal of all textures.
  106213. */
  106214. dispose(forceDisposeTextures?: boolean): void;
  106215. /**
  106216. * Get the current class name of the texture useful for serialization or dynamic coding.
  106217. * @returns "PBRClearCoatConfiguration"
  106218. */
  106219. getClassName(): string;
  106220. /**
  106221. * Add fallbacks to the effect fallbacks list.
  106222. * @param defines defines the Base texture to use.
  106223. * @param fallbacks defines the current fallback list.
  106224. * @param currentRank defines the current fallback rank.
  106225. * @returns the new fallback rank.
  106226. */
  106227. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  106228. /**
  106229. * Add the required uniforms to the current list.
  106230. * @param uniforms defines the current uniform list.
  106231. */
  106232. static AddUniforms(uniforms: string[]): void;
  106233. /**
  106234. * Add the required samplers to the current list.
  106235. * @param samplers defines the current sampler list.
  106236. */
  106237. static AddSamplers(samplers: string[]): void;
  106238. /**
  106239. * Add the required uniforms to the current buffer.
  106240. * @param uniformBuffer defines the current uniform buffer.
  106241. */
  106242. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  106243. /**
  106244. * Makes a duplicate of the current configuration into another one.
  106245. * @param clearCoatConfiguration define the config where to copy the info
  106246. */
  106247. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  106248. /**
  106249. * Serializes this clear coat configuration.
  106250. * @returns - An object with the serialized config.
  106251. */
  106252. serialize(): any;
  106253. /**
  106254. * Parses a Clear Coat Configuration from a serialized object.
  106255. * @param source - Serialized object.
  106256. */
  106257. parse(source: any): void;
  106258. }
  106259. }
  106260. declare module BABYLON {
  106261. /**
  106262. * @hidden
  106263. */
  106264. export interface IMaterialAnisotropicDefines {
  106265. ANISOTROPIC: boolean;
  106266. ANISOTROPIC_TEXTURE: boolean;
  106267. ANISOTROPIC_TEXTUREDIRECTUV: number;
  106268. MAINUV1: boolean;
  106269. _areTexturesDirty: boolean;
  106270. _needUVs: boolean;
  106271. }
  106272. /**
  106273. * Define the code related to the anisotropic parameters of the pbr material.
  106274. */
  106275. export class PBRAnisotropicConfiguration {
  106276. private _isEnabled;
  106277. /**
  106278. * Defines if the anisotropy is enabled in the material.
  106279. */
  106280. isEnabled: boolean;
  106281. /**
  106282. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  106283. */
  106284. intensity: number;
  106285. /**
  106286. * Defines if the effect is along the tangents, bitangents or in between.
  106287. * By default, the effect is "strectching" the highlights along the tangents.
  106288. */
  106289. direction: Vector2;
  106290. private _texture;
  106291. /**
  106292. * Stores the anisotropy values in a texture.
  106293. * rg is direction (like normal from -1 to 1)
  106294. * b is a intensity
  106295. */
  106296. texture: Nullable<BaseTexture>;
  106297. /** @hidden */
  106298. private _internalMarkAllSubMeshesAsTexturesDirty;
  106299. /** @hidden */
  106300. _markAllSubMeshesAsTexturesDirty(): void;
  106301. /**
  106302. * Instantiate a new istance of anisotropy configuration.
  106303. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  106304. */
  106305. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  106306. /**
  106307. * Specifies that the submesh is ready to be used.
  106308. * @param defines the list of "defines" to update.
  106309. * @param scene defines the scene the material belongs to.
  106310. * @returns - boolean indicating that the submesh is ready or not.
  106311. */
  106312. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  106313. /**
  106314. * Checks to see if a texture is used in the material.
  106315. * @param defines the list of "defines" to update.
  106316. * @param mesh the mesh we are preparing the defines for.
  106317. * @param scene defines the scene the material belongs to.
  106318. */
  106319. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  106320. /**
  106321. * Binds the material data.
  106322. * @param uniformBuffer defines the Uniform buffer to fill in.
  106323. * @param scene defines the scene the material belongs to.
  106324. * @param isFrozen defines wether the material is frozen or not.
  106325. */
  106326. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  106327. /**
  106328. * Checks to see if a texture is used in the material.
  106329. * @param texture - Base texture to use.
  106330. * @returns - Boolean specifying if a texture is used in the material.
  106331. */
  106332. hasTexture(texture: BaseTexture): boolean;
  106333. /**
  106334. * Returns an array of the actively used textures.
  106335. * @param activeTextures Array of BaseTextures
  106336. */
  106337. getActiveTextures(activeTextures: BaseTexture[]): void;
  106338. /**
  106339. * Returns the animatable textures.
  106340. * @param animatables Array of animatable textures.
  106341. */
  106342. getAnimatables(animatables: IAnimatable[]): void;
  106343. /**
  106344. * Disposes the resources of the material.
  106345. * @param forceDisposeTextures - Forces the disposal of all textures.
  106346. */
  106347. dispose(forceDisposeTextures?: boolean): void;
  106348. /**
  106349. * Get the current class name of the texture useful for serialization or dynamic coding.
  106350. * @returns "PBRAnisotropicConfiguration"
  106351. */
  106352. getClassName(): string;
  106353. /**
  106354. * Add fallbacks to the effect fallbacks list.
  106355. * @param defines defines the Base texture to use.
  106356. * @param fallbacks defines the current fallback list.
  106357. * @param currentRank defines the current fallback rank.
  106358. * @returns the new fallback rank.
  106359. */
  106360. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  106361. /**
  106362. * Add the required uniforms to the current list.
  106363. * @param uniforms defines the current uniform list.
  106364. */
  106365. static AddUniforms(uniforms: string[]): void;
  106366. /**
  106367. * Add the required uniforms to the current buffer.
  106368. * @param uniformBuffer defines the current uniform buffer.
  106369. */
  106370. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  106371. /**
  106372. * Add the required samplers to the current list.
  106373. * @param samplers defines the current sampler list.
  106374. */
  106375. static AddSamplers(samplers: string[]): void;
  106376. /**
  106377. * Makes a duplicate of the current configuration into another one.
  106378. * @param anisotropicConfiguration define the config where to copy the info
  106379. */
  106380. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  106381. /**
  106382. * Serializes this anisotropy configuration.
  106383. * @returns - An object with the serialized config.
  106384. */
  106385. serialize(): any;
  106386. /**
  106387. * Parses a anisotropy Configuration from a serialized object.
  106388. * @param source - Serialized object.
  106389. */
  106390. parse(source: any): void;
  106391. }
  106392. }
  106393. declare module BABYLON {
  106394. /**
  106395. * @hidden
  106396. */
  106397. export interface IMaterialBRDFDefines {
  106398. BRDF_V_HEIGHT_CORRELATED: boolean;
  106399. MS_BRDF_ENERGY_CONSERVATION: boolean;
  106400. SPHERICAL_HARMONICS: boolean;
  106401. /** @hidden */
  106402. _areMiscDirty: boolean;
  106403. }
  106404. /**
  106405. * Define the code related to the BRDF parameters of the pbr material.
  106406. */
  106407. export class PBRBRDFConfiguration {
  106408. /**
  106409. * Default value used for the energy conservation.
  106410. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  106411. */
  106412. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  106413. /**
  106414. * Default value used for the Smith Visibility Height Correlated mode.
  106415. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  106416. */
  106417. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  106418. /**
  106419. * Default value used for the IBL diffuse part.
  106420. * This can help switching back to the polynomials mode globally which is a tiny bit
  106421. * less GPU intensive at the drawback of a lower quality.
  106422. */
  106423. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  106424. private _useEnergyConservation;
  106425. /**
  106426. * Defines if the material uses energy conservation.
  106427. */
  106428. useEnergyConservation: boolean;
  106429. private _useSmithVisibilityHeightCorrelated;
  106430. /**
  106431. * LEGACY Mode set to false
  106432. * Defines if the material uses height smith correlated visibility term.
  106433. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  106434. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  106435. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  106436. * Not relying on height correlated will also disable energy conservation.
  106437. */
  106438. useSmithVisibilityHeightCorrelated: boolean;
  106439. private _useSphericalHarmonics;
  106440. /**
  106441. * LEGACY Mode set to false
  106442. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  106443. * diffuse part of the IBL.
  106444. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  106445. * to the ground truth.
  106446. */
  106447. useSphericalHarmonics: boolean;
  106448. /** @hidden */
  106449. private _internalMarkAllSubMeshesAsMiscDirty;
  106450. /** @hidden */
  106451. _markAllSubMeshesAsMiscDirty(): void;
  106452. /**
  106453. * Instantiate a new istance of clear coat configuration.
  106454. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  106455. */
  106456. constructor(markAllSubMeshesAsMiscDirty: () => void);
  106457. /**
  106458. * Checks to see if a texture is used in the material.
  106459. * @param defines the list of "defines" to update.
  106460. */
  106461. prepareDefines(defines: IMaterialBRDFDefines): void;
  106462. /**
  106463. * Get the current class name of the texture useful for serialization or dynamic coding.
  106464. * @returns "PBRClearCoatConfiguration"
  106465. */
  106466. getClassName(): string;
  106467. /**
  106468. * Makes a duplicate of the current configuration into another one.
  106469. * @param brdfConfiguration define the config where to copy the info
  106470. */
  106471. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  106472. /**
  106473. * Serializes this BRDF configuration.
  106474. * @returns - An object with the serialized config.
  106475. */
  106476. serialize(): any;
  106477. /**
  106478. * Parses a BRDF Configuration from a serialized object.
  106479. * @param source - Serialized object.
  106480. */
  106481. parse(source: any): void;
  106482. }
  106483. }
  106484. declare module BABYLON {
  106485. /**
  106486. * @hidden
  106487. */
  106488. export interface IMaterialSheenDefines {
  106489. SHEEN: boolean;
  106490. SHEEN_TEXTURE: boolean;
  106491. SHEEN_TEXTUREDIRECTUV: number;
  106492. SHEEN_LINKWITHALBEDO: boolean;
  106493. /** @hidden */
  106494. _areTexturesDirty: boolean;
  106495. }
  106496. /**
  106497. * Define the code related to the Sheen parameters of the pbr material.
  106498. */
  106499. export class PBRSheenConfiguration {
  106500. private _isEnabled;
  106501. /**
  106502. * Defines if the material uses sheen.
  106503. */
  106504. isEnabled: boolean;
  106505. private _linkSheenWithAlbedo;
  106506. /**
  106507. * Defines if the sheen is linked to the sheen color.
  106508. */
  106509. linkSheenWithAlbedo: boolean;
  106510. /**
  106511. * Defines the sheen intensity.
  106512. */
  106513. intensity: number;
  106514. /**
  106515. * Defines the sheen color.
  106516. */
  106517. color: Color3;
  106518. private _texture;
  106519. /**
  106520. * Stores the sheen tint values in a texture.
  106521. * rgb is tint
  106522. * a is a intensity
  106523. */
  106524. texture: Nullable<BaseTexture>;
  106525. /** @hidden */
  106526. private _internalMarkAllSubMeshesAsTexturesDirty;
  106527. /** @hidden */
  106528. _markAllSubMeshesAsTexturesDirty(): void;
  106529. /**
  106530. * Instantiate a new istance of clear coat configuration.
  106531. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  106532. */
  106533. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  106534. /**
  106535. * Specifies that the submesh is ready to be used.
  106536. * @param defines the list of "defines" to update.
  106537. * @param scene defines the scene the material belongs to.
  106538. * @returns - boolean indicating that the submesh is ready or not.
  106539. */
  106540. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  106541. /**
  106542. * Checks to see if a texture is used in the material.
  106543. * @param defines the list of "defines" to update.
  106544. * @param scene defines the scene the material belongs to.
  106545. */
  106546. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  106547. /**
  106548. * Binds the material data.
  106549. * @param uniformBuffer defines the Uniform buffer to fill in.
  106550. * @param scene defines the scene the material belongs to.
  106551. * @param isFrozen defines wether the material is frozen or not.
  106552. */
  106553. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  106554. /**
  106555. * Checks to see if a texture is used in the material.
  106556. * @param texture - Base texture to use.
  106557. * @returns - Boolean specifying if a texture is used in the material.
  106558. */
  106559. hasTexture(texture: BaseTexture): boolean;
  106560. /**
  106561. * Returns an array of the actively used textures.
  106562. * @param activeTextures Array of BaseTextures
  106563. */
  106564. getActiveTextures(activeTextures: BaseTexture[]): void;
  106565. /**
  106566. * Returns the animatable textures.
  106567. * @param animatables Array of animatable textures.
  106568. */
  106569. getAnimatables(animatables: IAnimatable[]): void;
  106570. /**
  106571. * Disposes the resources of the material.
  106572. * @param forceDisposeTextures - Forces the disposal of all textures.
  106573. */
  106574. dispose(forceDisposeTextures?: boolean): void;
  106575. /**
  106576. * Get the current class name of the texture useful for serialization or dynamic coding.
  106577. * @returns "PBRSheenConfiguration"
  106578. */
  106579. getClassName(): string;
  106580. /**
  106581. * Add fallbacks to the effect fallbacks list.
  106582. * @param defines defines the Base texture to use.
  106583. * @param fallbacks defines the current fallback list.
  106584. * @param currentRank defines the current fallback rank.
  106585. * @returns the new fallback rank.
  106586. */
  106587. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  106588. /**
  106589. * Add the required uniforms to the current list.
  106590. * @param uniforms defines the current uniform list.
  106591. */
  106592. static AddUniforms(uniforms: string[]): void;
  106593. /**
  106594. * Add the required uniforms to the current buffer.
  106595. * @param uniformBuffer defines the current uniform buffer.
  106596. */
  106597. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  106598. /**
  106599. * Add the required samplers to the current list.
  106600. * @param samplers defines the current sampler list.
  106601. */
  106602. static AddSamplers(samplers: string[]): void;
  106603. /**
  106604. * Makes a duplicate of the current configuration into another one.
  106605. * @param sheenConfiguration define the config where to copy the info
  106606. */
  106607. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  106608. /**
  106609. * Serializes this BRDF configuration.
  106610. * @returns - An object with the serialized config.
  106611. */
  106612. serialize(): any;
  106613. /**
  106614. * Parses a Sheen Configuration from a serialized object.
  106615. * @param source - Serialized object.
  106616. */
  106617. parse(source: any): void;
  106618. }
  106619. }
  106620. declare module BABYLON {
  106621. /**
  106622. * @hidden
  106623. */
  106624. export interface IMaterialSubSurfaceDefines {
  106625. SUBSURFACE: boolean;
  106626. SS_REFRACTION: boolean;
  106627. SS_TRANSLUCENCY: boolean;
  106628. SS_SCATERRING: boolean;
  106629. SS_THICKNESSANDMASK_TEXTURE: boolean;
  106630. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  106631. SS_REFRACTIONMAP_3D: boolean;
  106632. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  106633. SS_LODINREFRACTIONALPHA: boolean;
  106634. SS_GAMMAREFRACTION: boolean;
  106635. SS_RGBDREFRACTION: boolean;
  106636. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  106637. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  106638. /** @hidden */
  106639. _areTexturesDirty: boolean;
  106640. }
  106641. /**
  106642. * Define the code related to the sub surface parameters of the pbr material.
  106643. */
  106644. export class PBRSubSurfaceConfiguration {
  106645. private _isRefractionEnabled;
  106646. /**
  106647. * Defines if the refraction is enabled in the material.
  106648. */
  106649. isRefractionEnabled: boolean;
  106650. private _isTranslucencyEnabled;
  106651. /**
  106652. * Defines if the translucency is enabled in the material.
  106653. */
  106654. isTranslucencyEnabled: boolean;
  106655. private _isScatteringEnabled;
  106656. /**
  106657. * Defines the refraction intensity of the material.
  106658. * The refraction when enabled replaces the Diffuse part of the material.
  106659. * The intensity helps transitionning between diffuse and refraction.
  106660. */
  106661. refractionIntensity: number;
  106662. /**
  106663. * Defines the translucency intensity of the material.
  106664. * When translucency has been enabled, this defines how much of the "translucency"
  106665. * is addded to the diffuse part of the material.
  106666. */
  106667. translucencyIntensity: number;
  106668. /**
  106669. * Defines the scattering intensity of the material.
  106670. * When scattering has been enabled, this defines how much of the "scattered light"
  106671. * is addded to the diffuse part of the material.
  106672. */
  106673. scatteringIntensity: number;
  106674. private _thicknessTexture;
  106675. /**
  106676. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  106677. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  106678. * 0 would mean minimumThickness
  106679. * 1 would mean maximumThickness
  106680. * The other channels might be use as a mask to vary the different effects intensity.
  106681. */
  106682. thicknessTexture: Nullable<BaseTexture>;
  106683. private _refractionTexture;
  106684. /**
  106685. * Defines the texture to use for refraction.
  106686. */
  106687. refractionTexture: Nullable<BaseTexture>;
  106688. private _indexOfRefraction;
  106689. /**
  106690. * Defines the indice of refraction used in the material.
  106691. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  106692. */
  106693. indexOfRefraction: number;
  106694. private _invertRefractionY;
  106695. /**
  106696. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  106697. */
  106698. invertRefractionY: boolean;
  106699. private _linkRefractionWithTransparency;
  106700. /**
  106701. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  106702. * Materials half opaque for instance using refraction could benefit from this control.
  106703. */
  106704. linkRefractionWithTransparency: boolean;
  106705. /**
  106706. * Defines the minimum thickness stored in the thickness map.
  106707. * If no thickness map is defined, this value will be used to simulate thickness.
  106708. */
  106709. minimumThickness: number;
  106710. /**
  106711. * Defines the maximum thickness stored in the thickness map.
  106712. */
  106713. maximumThickness: number;
  106714. /**
  106715. * Defines the volume tint of the material.
  106716. * This is used for both translucency and scattering.
  106717. */
  106718. tintColor: Color3;
  106719. /**
  106720. * Defines the distance at which the tint color should be found in the media.
  106721. * This is used for refraction only.
  106722. */
  106723. tintColorAtDistance: number;
  106724. /**
  106725. * Defines how far each channel transmit through the media.
  106726. * It is defined as a color to simplify it selection.
  106727. */
  106728. diffusionDistance: Color3;
  106729. private _useMaskFromThicknessTexture;
  106730. /**
  106731. * Stores the intensity of the different subsurface effects in the thickness texture.
  106732. * * the green channel is the translucency intensity.
  106733. * * the blue channel is the scattering intensity.
  106734. * * the alpha channel is the refraction intensity.
  106735. */
  106736. useMaskFromThicknessTexture: boolean;
  106737. /** @hidden */
  106738. private _internalMarkAllSubMeshesAsTexturesDirty;
  106739. /** @hidden */
  106740. _markAllSubMeshesAsTexturesDirty(): void;
  106741. /**
  106742. * Instantiate a new istance of sub surface configuration.
  106743. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  106744. */
  106745. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  106746. /**
  106747. * Gets wehter the submesh is ready to be used or not.
  106748. * @param defines the list of "defines" to update.
  106749. * @param scene defines the scene the material belongs to.
  106750. * @returns - boolean indicating that the submesh is ready or not.
  106751. */
  106752. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  106753. /**
  106754. * Checks to see if a texture is used in the material.
  106755. * @param defines the list of "defines" to update.
  106756. * @param scene defines the scene to the material belongs to.
  106757. */
  106758. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  106759. /**
  106760. * Binds the material data.
  106761. * @param uniformBuffer defines the Uniform buffer to fill in.
  106762. * @param scene defines the scene the material belongs to.
  106763. * @param engine defines the engine the material belongs to.
  106764. * @param isFrozen defines wether the material is frozen or not.
  106765. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  106766. */
  106767. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  106768. /**
  106769. * Unbinds the material from the mesh.
  106770. * @param activeEffect defines the effect that should be unbound from.
  106771. * @returns true if unbound, otherwise false
  106772. */
  106773. unbind(activeEffect: Effect): boolean;
  106774. /**
  106775. * Returns the texture used for refraction or null if none is used.
  106776. * @param scene defines the scene the material belongs to.
  106777. * @returns - Refraction texture if present. If no refraction texture and refraction
  106778. * is linked with transparency, returns environment texture. Otherwise, returns null.
  106779. */
  106780. private _getRefractionTexture;
  106781. /**
  106782. * Returns true if alpha blending should be disabled.
  106783. */
  106784. readonly disableAlphaBlending: boolean;
  106785. /**
  106786. * Fills the list of render target textures.
  106787. * @param renderTargets the list of render targets to update
  106788. */
  106789. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  106790. /**
  106791. * Checks to see if a texture is used in the material.
  106792. * @param texture - Base texture to use.
  106793. * @returns - Boolean specifying if a texture is used in the material.
  106794. */
  106795. hasTexture(texture: BaseTexture): boolean;
  106796. /**
  106797. * Gets a boolean indicating that current material needs to register RTT
  106798. * @returns true if this uses a render target otherwise false.
  106799. */
  106800. hasRenderTargetTextures(): boolean;
  106801. /**
  106802. * Returns an array of the actively used textures.
  106803. * @param activeTextures Array of BaseTextures
  106804. */
  106805. getActiveTextures(activeTextures: BaseTexture[]): void;
  106806. /**
  106807. * Returns the animatable textures.
  106808. * @param animatables Array of animatable textures.
  106809. */
  106810. getAnimatables(animatables: IAnimatable[]): void;
  106811. /**
  106812. * Disposes the resources of the material.
  106813. * @param forceDisposeTextures - Forces the disposal of all textures.
  106814. */
  106815. dispose(forceDisposeTextures?: boolean): void;
  106816. /**
  106817. * Get the current class name of the texture useful for serialization or dynamic coding.
  106818. * @returns "PBRSubSurfaceConfiguration"
  106819. */
  106820. getClassName(): string;
  106821. /**
  106822. * Add fallbacks to the effect fallbacks list.
  106823. * @param defines defines the Base texture to use.
  106824. * @param fallbacks defines the current fallback list.
  106825. * @param currentRank defines the current fallback rank.
  106826. * @returns the new fallback rank.
  106827. */
  106828. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  106829. /**
  106830. * Add the required uniforms to the current list.
  106831. * @param uniforms defines the current uniform list.
  106832. */
  106833. static AddUniforms(uniforms: string[]): void;
  106834. /**
  106835. * Add the required samplers to the current list.
  106836. * @param samplers defines the current sampler list.
  106837. */
  106838. static AddSamplers(samplers: string[]): void;
  106839. /**
  106840. * Add the required uniforms to the current buffer.
  106841. * @param uniformBuffer defines the current uniform buffer.
  106842. */
  106843. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  106844. /**
  106845. * Makes a duplicate of the current configuration into another one.
  106846. * @param configuration define the config where to copy the info
  106847. */
  106848. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  106849. /**
  106850. * Serializes this Sub Surface configuration.
  106851. * @returns - An object with the serialized config.
  106852. */
  106853. serialize(): any;
  106854. /**
  106855. * Parses a Sub Surface Configuration from a serialized object.
  106856. * @param source - Serialized object.
  106857. */
  106858. parse(source: any): void;
  106859. }
  106860. }
  106861. declare module BABYLON {
  106862. /** @hidden */
  106863. export var pbrFragmentDeclaration: {
  106864. name: string;
  106865. shader: string;
  106866. };
  106867. }
  106868. declare module BABYLON {
  106869. /** @hidden */
  106870. export var pbrUboDeclaration: {
  106871. name: string;
  106872. shader: string;
  106873. };
  106874. }
  106875. declare module BABYLON {
  106876. /** @hidden */
  106877. export var pbrFragmentExtraDeclaration: {
  106878. name: string;
  106879. shader: string;
  106880. };
  106881. }
  106882. declare module BABYLON {
  106883. /** @hidden */
  106884. export var pbrFragmentSamplersDeclaration: {
  106885. name: string;
  106886. shader: string;
  106887. };
  106888. }
  106889. declare module BABYLON {
  106890. /** @hidden */
  106891. export var pbrHelperFunctions: {
  106892. name: string;
  106893. shader: string;
  106894. };
  106895. }
  106896. declare module BABYLON {
  106897. /** @hidden */
  106898. export var harmonicsFunctions: {
  106899. name: string;
  106900. shader: string;
  106901. };
  106902. }
  106903. declare module BABYLON {
  106904. /** @hidden */
  106905. export var pbrDirectLightingSetupFunctions: {
  106906. name: string;
  106907. shader: string;
  106908. };
  106909. }
  106910. declare module BABYLON {
  106911. /** @hidden */
  106912. export var pbrDirectLightingFalloffFunctions: {
  106913. name: string;
  106914. shader: string;
  106915. };
  106916. }
  106917. declare module BABYLON {
  106918. /** @hidden */
  106919. export var pbrBRDFFunctions: {
  106920. name: string;
  106921. shader: string;
  106922. };
  106923. }
  106924. declare module BABYLON {
  106925. /** @hidden */
  106926. export var pbrDirectLightingFunctions: {
  106927. name: string;
  106928. shader: string;
  106929. };
  106930. }
  106931. declare module BABYLON {
  106932. /** @hidden */
  106933. export var pbrIBLFunctions: {
  106934. name: string;
  106935. shader: string;
  106936. };
  106937. }
  106938. declare module BABYLON {
  106939. /** @hidden */
  106940. export var pbrDebug: {
  106941. name: string;
  106942. shader: string;
  106943. };
  106944. }
  106945. declare module BABYLON {
  106946. /** @hidden */
  106947. export var pbrPixelShader: {
  106948. name: string;
  106949. shader: string;
  106950. };
  106951. }
  106952. declare module BABYLON {
  106953. /** @hidden */
  106954. export var pbrVertexDeclaration: {
  106955. name: string;
  106956. shader: string;
  106957. };
  106958. }
  106959. declare module BABYLON {
  106960. /** @hidden */
  106961. export var pbrVertexShader: {
  106962. name: string;
  106963. shader: string;
  106964. };
  106965. }
  106966. declare module BABYLON {
  106967. /**
  106968. * Manages the defines for the PBR Material.
  106969. * @hidden
  106970. */
  106971. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  106972. PBR: boolean;
  106973. MAINUV1: boolean;
  106974. MAINUV2: boolean;
  106975. UV1: boolean;
  106976. UV2: boolean;
  106977. ALBEDO: boolean;
  106978. ALBEDODIRECTUV: number;
  106979. VERTEXCOLOR: boolean;
  106980. AMBIENT: boolean;
  106981. AMBIENTDIRECTUV: number;
  106982. AMBIENTINGRAYSCALE: boolean;
  106983. OPACITY: boolean;
  106984. VERTEXALPHA: boolean;
  106985. OPACITYDIRECTUV: number;
  106986. OPACITYRGB: boolean;
  106987. ALPHATEST: boolean;
  106988. DEPTHPREPASS: boolean;
  106989. ALPHABLEND: boolean;
  106990. ALPHAFROMALBEDO: boolean;
  106991. ALPHATESTVALUE: string;
  106992. SPECULAROVERALPHA: boolean;
  106993. RADIANCEOVERALPHA: boolean;
  106994. ALPHAFRESNEL: boolean;
  106995. LINEARALPHAFRESNEL: boolean;
  106996. PREMULTIPLYALPHA: boolean;
  106997. EMISSIVE: boolean;
  106998. EMISSIVEDIRECTUV: number;
  106999. REFLECTIVITY: boolean;
  107000. REFLECTIVITYDIRECTUV: number;
  107001. SPECULARTERM: boolean;
  107002. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  107003. MICROSURFACEAUTOMATIC: boolean;
  107004. LODBASEDMICROSFURACE: boolean;
  107005. MICROSURFACEMAP: boolean;
  107006. MICROSURFACEMAPDIRECTUV: number;
  107007. METALLICWORKFLOW: boolean;
  107008. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  107009. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  107010. METALLNESSSTOREINMETALMAPBLUE: boolean;
  107011. AOSTOREINMETALMAPRED: boolean;
  107012. ENVIRONMENTBRDF: boolean;
  107013. ENVIRONMENTBRDF_RGBD: boolean;
  107014. NORMAL: boolean;
  107015. TANGENT: boolean;
  107016. BUMP: boolean;
  107017. BUMPDIRECTUV: number;
  107018. OBJECTSPACE_NORMALMAP: boolean;
  107019. PARALLAX: boolean;
  107020. PARALLAXOCCLUSION: boolean;
  107021. NORMALXYSCALE: boolean;
  107022. LIGHTMAP: boolean;
  107023. LIGHTMAPDIRECTUV: number;
  107024. USELIGHTMAPASSHADOWMAP: boolean;
  107025. GAMMALIGHTMAP: boolean;
  107026. REFLECTION: boolean;
  107027. REFLECTIONMAP_3D: boolean;
  107028. REFLECTIONMAP_SPHERICAL: boolean;
  107029. REFLECTIONMAP_PLANAR: boolean;
  107030. REFLECTIONMAP_CUBIC: boolean;
  107031. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  107032. REFLECTIONMAP_PROJECTION: boolean;
  107033. REFLECTIONMAP_SKYBOX: boolean;
  107034. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  107035. REFLECTIONMAP_EXPLICIT: boolean;
  107036. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  107037. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  107038. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  107039. INVERTCUBICMAP: boolean;
  107040. USESPHERICALFROMREFLECTIONMAP: boolean;
  107041. SPHERICAL_HARMONICS: boolean;
  107042. USESPHERICALINVERTEX: boolean;
  107043. REFLECTIONMAP_OPPOSITEZ: boolean;
  107044. LODINREFLECTIONALPHA: boolean;
  107045. GAMMAREFLECTION: boolean;
  107046. RGBDREFLECTION: boolean;
  107047. RADIANCEOCCLUSION: boolean;
  107048. HORIZONOCCLUSION: boolean;
  107049. INSTANCES: boolean;
  107050. NUM_BONE_INFLUENCERS: number;
  107051. BonesPerMesh: number;
  107052. BONETEXTURE: boolean;
  107053. NONUNIFORMSCALING: boolean;
  107054. MORPHTARGETS: boolean;
  107055. MORPHTARGETS_NORMAL: boolean;
  107056. MORPHTARGETS_TANGENT: boolean;
  107057. NUM_MORPH_INFLUENCERS: number;
  107058. IMAGEPROCESSING: boolean;
  107059. VIGNETTE: boolean;
  107060. VIGNETTEBLENDMODEMULTIPLY: boolean;
  107061. VIGNETTEBLENDMODEOPAQUE: boolean;
  107062. TONEMAPPING: boolean;
  107063. TONEMAPPING_ACES: boolean;
  107064. CONTRAST: boolean;
  107065. COLORCURVES: boolean;
  107066. COLORGRADING: boolean;
  107067. COLORGRADING3D: boolean;
  107068. SAMPLER3DGREENDEPTH: boolean;
  107069. SAMPLER3DBGRMAP: boolean;
  107070. IMAGEPROCESSINGPOSTPROCESS: boolean;
  107071. EXPOSURE: boolean;
  107072. MULTIVIEW: boolean;
  107073. USEPHYSICALLIGHTFALLOFF: boolean;
  107074. USEGLTFLIGHTFALLOFF: boolean;
  107075. TWOSIDEDLIGHTING: boolean;
  107076. SHADOWFLOAT: boolean;
  107077. CLIPPLANE: boolean;
  107078. CLIPPLANE2: boolean;
  107079. CLIPPLANE3: boolean;
  107080. CLIPPLANE4: boolean;
  107081. POINTSIZE: boolean;
  107082. FOG: boolean;
  107083. LOGARITHMICDEPTH: boolean;
  107084. FORCENORMALFORWARD: boolean;
  107085. SPECULARAA: boolean;
  107086. CLEARCOAT: boolean;
  107087. CLEARCOAT_DEFAULTIOR: boolean;
  107088. CLEARCOAT_TEXTURE: boolean;
  107089. CLEARCOAT_TEXTUREDIRECTUV: number;
  107090. CLEARCOAT_BUMP: boolean;
  107091. CLEARCOAT_BUMPDIRECTUV: number;
  107092. CLEARCOAT_TINT: boolean;
  107093. CLEARCOAT_TINT_TEXTURE: boolean;
  107094. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  107095. ANISOTROPIC: boolean;
  107096. ANISOTROPIC_TEXTURE: boolean;
  107097. ANISOTROPIC_TEXTUREDIRECTUV: number;
  107098. BRDF_V_HEIGHT_CORRELATED: boolean;
  107099. MS_BRDF_ENERGY_CONSERVATION: boolean;
  107100. SHEEN: boolean;
  107101. SHEEN_TEXTURE: boolean;
  107102. SHEEN_TEXTUREDIRECTUV: number;
  107103. SHEEN_LINKWITHALBEDO: boolean;
  107104. SUBSURFACE: boolean;
  107105. SS_REFRACTION: boolean;
  107106. SS_TRANSLUCENCY: boolean;
  107107. SS_SCATERRING: boolean;
  107108. SS_THICKNESSANDMASK_TEXTURE: boolean;
  107109. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  107110. SS_REFRACTIONMAP_3D: boolean;
  107111. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  107112. SS_LODINREFRACTIONALPHA: boolean;
  107113. SS_GAMMAREFRACTION: boolean;
  107114. SS_RGBDREFRACTION: boolean;
  107115. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  107116. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  107117. UNLIT: boolean;
  107118. DEBUGMODE: number;
  107119. /**
  107120. * Initializes the PBR Material defines.
  107121. */
  107122. constructor();
  107123. /**
  107124. * Resets the PBR Material defines.
  107125. */
  107126. reset(): void;
  107127. }
  107128. /**
  107129. * The Physically based material base class of BJS.
  107130. *
  107131. * This offers the main features of a standard PBR material.
  107132. * For more information, please refer to the documentation :
  107133. * https://doc.babylonjs.com/how_to/physically_based_rendering
  107134. */
  107135. export abstract class PBRBaseMaterial extends PushMaterial {
  107136. /**
  107137. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  107138. */
  107139. static readonly PBRMATERIAL_OPAQUE: number;
  107140. /**
  107141. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  107142. */
  107143. static readonly PBRMATERIAL_ALPHATEST: number;
  107144. /**
  107145. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  107146. */
  107147. static readonly PBRMATERIAL_ALPHABLEND: number;
  107148. /**
  107149. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  107150. * They are also discarded below the alpha cutoff threshold to improve performances.
  107151. */
  107152. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  107153. /**
  107154. * Defines the default value of how much AO map is occluding the analytical lights
  107155. * (point spot...).
  107156. */
  107157. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  107158. /**
  107159. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  107160. */
  107161. static readonly LIGHTFALLOFF_PHYSICAL: number;
  107162. /**
  107163. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  107164. * to enhance interoperability with other engines.
  107165. */
  107166. static readonly LIGHTFALLOFF_GLTF: number;
  107167. /**
  107168. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  107169. * to enhance interoperability with other materials.
  107170. */
  107171. static readonly LIGHTFALLOFF_STANDARD: number;
  107172. /**
  107173. * Intensity of the direct lights e.g. the four lights available in your scene.
  107174. * This impacts both the direct diffuse and specular highlights.
  107175. */
  107176. protected _directIntensity: number;
  107177. /**
  107178. * Intensity of the emissive part of the material.
  107179. * This helps controlling the emissive effect without modifying the emissive color.
  107180. */
  107181. protected _emissiveIntensity: number;
  107182. /**
  107183. * Intensity of the environment e.g. how much the environment will light the object
  107184. * either through harmonics for rough material or through the refelction for shiny ones.
  107185. */
  107186. protected _environmentIntensity: number;
  107187. /**
  107188. * This is a special control allowing the reduction of the specular highlights coming from the
  107189. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  107190. */
  107191. protected _specularIntensity: number;
  107192. /**
  107193. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  107194. */
  107195. private _lightingInfos;
  107196. /**
  107197. * Debug Control allowing disabling the bump map on this material.
  107198. */
  107199. protected _disableBumpMap: boolean;
  107200. /**
  107201. * AKA Diffuse Texture in standard nomenclature.
  107202. */
  107203. protected _albedoTexture: Nullable<BaseTexture>;
  107204. /**
  107205. * AKA Occlusion Texture in other nomenclature.
  107206. */
  107207. protected _ambientTexture: Nullable<BaseTexture>;
  107208. /**
  107209. * AKA Occlusion Texture Intensity in other nomenclature.
  107210. */
  107211. protected _ambientTextureStrength: number;
  107212. /**
  107213. * Defines how much the AO map is occluding the analytical lights (point spot...).
  107214. * 1 means it completely occludes it
  107215. * 0 mean it has no impact
  107216. */
  107217. protected _ambientTextureImpactOnAnalyticalLights: number;
  107218. /**
  107219. * Stores the alpha values in a texture.
  107220. */
  107221. protected _opacityTexture: Nullable<BaseTexture>;
  107222. /**
  107223. * Stores the reflection values in a texture.
  107224. */
  107225. protected _reflectionTexture: Nullable<BaseTexture>;
  107226. /**
  107227. * Stores the emissive values in a texture.
  107228. */
  107229. protected _emissiveTexture: Nullable<BaseTexture>;
  107230. /**
  107231. * AKA Specular texture in other nomenclature.
  107232. */
  107233. protected _reflectivityTexture: Nullable<BaseTexture>;
  107234. /**
  107235. * Used to switch from specular/glossiness to metallic/roughness workflow.
  107236. */
  107237. protected _metallicTexture: Nullable<BaseTexture>;
  107238. /**
  107239. * Specifies the metallic scalar of the metallic/roughness workflow.
  107240. * Can also be used to scale the metalness values of the metallic texture.
  107241. */
  107242. protected _metallic: Nullable<number>;
  107243. /**
  107244. * Specifies the roughness scalar of the metallic/roughness workflow.
  107245. * Can also be used to scale the roughness values of the metallic texture.
  107246. */
  107247. protected _roughness: Nullable<number>;
  107248. /**
  107249. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  107250. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  107251. */
  107252. protected _microSurfaceTexture: Nullable<BaseTexture>;
  107253. /**
  107254. * Stores surface normal data used to displace a mesh in a texture.
  107255. */
  107256. protected _bumpTexture: Nullable<BaseTexture>;
  107257. /**
  107258. * Stores the pre-calculated light information of a mesh in a texture.
  107259. */
  107260. protected _lightmapTexture: Nullable<BaseTexture>;
  107261. /**
  107262. * The color of a material in ambient lighting.
  107263. */
  107264. protected _ambientColor: Color3;
  107265. /**
  107266. * AKA Diffuse Color in other nomenclature.
  107267. */
  107268. protected _albedoColor: Color3;
  107269. /**
  107270. * AKA Specular Color in other nomenclature.
  107271. */
  107272. protected _reflectivityColor: Color3;
  107273. /**
  107274. * The color applied when light is reflected from a material.
  107275. */
  107276. protected _reflectionColor: Color3;
  107277. /**
  107278. * The color applied when light is emitted from a material.
  107279. */
  107280. protected _emissiveColor: Color3;
  107281. /**
  107282. * AKA Glossiness in other nomenclature.
  107283. */
  107284. protected _microSurface: number;
  107285. /**
  107286. * Specifies that the material will use the light map as a show map.
  107287. */
  107288. protected _useLightmapAsShadowmap: boolean;
  107289. /**
  107290. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  107291. * makes the reflect vector face the model (under horizon).
  107292. */
  107293. protected _useHorizonOcclusion: boolean;
  107294. /**
  107295. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  107296. * too much the area relying on ambient texture to define their ambient occlusion.
  107297. */
  107298. protected _useRadianceOcclusion: boolean;
  107299. /**
  107300. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  107301. */
  107302. protected _useAlphaFromAlbedoTexture: boolean;
  107303. /**
  107304. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  107305. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  107306. */
  107307. protected _useSpecularOverAlpha: boolean;
  107308. /**
  107309. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  107310. */
  107311. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  107312. /**
  107313. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  107314. */
  107315. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  107316. /**
  107317. * Specifies if the metallic texture contains the roughness information in its green channel.
  107318. */
  107319. protected _useRoughnessFromMetallicTextureGreen: boolean;
  107320. /**
  107321. * Specifies if the metallic texture contains the metallness information in its blue channel.
  107322. */
  107323. protected _useMetallnessFromMetallicTextureBlue: boolean;
  107324. /**
  107325. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  107326. */
  107327. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  107328. /**
  107329. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  107330. */
  107331. protected _useAmbientInGrayScale: boolean;
  107332. /**
  107333. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  107334. * The material will try to infer what glossiness each pixel should be.
  107335. */
  107336. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  107337. /**
  107338. * Defines the falloff type used in this material.
  107339. * It by default is Physical.
  107340. */
  107341. protected _lightFalloff: number;
  107342. /**
  107343. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  107344. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  107345. */
  107346. protected _useRadianceOverAlpha: boolean;
  107347. /**
  107348. * Allows using an object space normal map (instead of tangent space).
  107349. */
  107350. protected _useObjectSpaceNormalMap: boolean;
  107351. /**
  107352. * Allows using the bump map in parallax mode.
  107353. */
  107354. protected _useParallax: boolean;
  107355. /**
  107356. * Allows using the bump map in parallax occlusion mode.
  107357. */
  107358. protected _useParallaxOcclusion: boolean;
  107359. /**
  107360. * Controls the scale bias of the parallax mode.
  107361. */
  107362. protected _parallaxScaleBias: number;
  107363. /**
  107364. * If sets to true, disables all the lights affecting the material.
  107365. */
  107366. protected _disableLighting: boolean;
  107367. /**
  107368. * Number of Simultaneous lights allowed on the material.
  107369. */
  107370. protected _maxSimultaneousLights: number;
  107371. /**
  107372. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  107373. */
  107374. protected _invertNormalMapX: boolean;
  107375. /**
  107376. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  107377. */
  107378. protected _invertNormalMapY: boolean;
  107379. /**
  107380. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  107381. */
  107382. protected _twoSidedLighting: boolean;
  107383. /**
  107384. * Defines the alpha limits in alpha test mode.
  107385. */
  107386. protected _alphaCutOff: number;
  107387. /**
  107388. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  107389. */
  107390. protected _forceAlphaTest: boolean;
  107391. /**
  107392. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  107393. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  107394. */
  107395. protected _useAlphaFresnel: boolean;
  107396. /**
  107397. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  107398. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  107399. */
  107400. protected _useLinearAlphaFresnel: boolean;
  107401. /**
  107402. * The transparency mode of the material.
  107403. */
  107404. protected _transparencyMode: Nullable<number>;
  107405. /**
  107406. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  107407. * from cos thetav and roughness:
  107408. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  107409. */
  107410. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  107411. /**
  107412. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  107413. */
  107414. protected _forceIrradianceInFragment: boolean;
  107415. /**
  107416. * Force normal to face away from face.
  107417. */
  107418. protected _forceNormalForward: boolean;
  107419. /**
  107420. * Enables specular anti aliasing in the PBR shader.
  107421. * It will both interacts on the Geometry for analytical and IBL lighting.
  107422. * It also prefilter the roughness map based on the bump values.
  107423. */
  107424. protected _enableSpecularAntiAliasing: boolean;
  107425. /**
  107426. * Default configuration related to image processing available in the PBR Material.
  107427. */
  107428. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  107429. /**
  107430. * Keep track of the image processing observer to allow dispose and replace.
  107431. */
  107432. private _imageProcessingObserver;
  107433. /**
  107434. * Attaches a new image processing configuration to the PBR Material.
  107435. * @param configuration
  107436. */
  107437. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  107438. /**
  107439. * Stores the available render targets.
  107440. */
  107441. private _renderTargets;
  107442. /**
  107443. * Sets the global ambient color for the material used in lighting calculations.
  107444. */
  107445. private _globalAmbientColor;
  107446. /**
  107447. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  107448. */
  107449. private _useLogarithmicDepth;
  107450. /**
  107451. * If set to true, no lighting calculations will be applied.
  107452. */
  107453. private _unlit;
  107454. private _debugMode;
  107455. /**
  107456. * @hidden
  107457. * This is reserved for the inspector.
  107458. * Defines the material debug mode.
  107459. * It helps seeing only some components of the material while troubleshooting.
  107460. */
  107461. debugMode: number;
  107462. /**
  107463. * @hidden
  107464. * This is reserved for the inspector.
  107465. * Specify from where on screen the debug mode should start.
  107466. * The value goes from -1 (full screen) to 1 (not visible)
  107467. * It helps with side by side comparison against the final render
  107468. * This defaults to -1
  107469. */
  107470. private debugLimit;
  107471. /**
  107472. * @hidden
  107473. * This is reserved for the inspector.
  107474. * As the default viewing range might not be enough (if the ambient is really small for instance)
  107475. * You can use the factor to better multiply the final value.
  107476. */
  107477. private debugFactor;
  107478. /**
  107479. * Defines the clear coat layer parameters for the material.
  107480. */
  107481. readonly clearCoat: PBRClearCoatConfiguration;
  107482. /**
  107483. * Defines the anisotropic parameters for the material.
  107484. */
  107485. readonly anisotropy: PBRAnisotropicConfiguration;
  107486. /**
  107487. * Defines the BRDF parameters for the material.
  107488. */
  107489. readonly brdf: PBRBRDFConfiguration;
  107490. /**
  107491. * Defines the Sheen parameters for the material.
  107492. */
  107493. readonly sheen: PBRSheenConfiguration;
  107494. /**
  107495. * Defines the SubSurface parameters for the material.
  107496. */
  107497. readonly subSurface: PBRSubSurfaceConfiguration;
  107498. /**
  107499. * Custom callback helping to override the default shader used in the material.
  107500. */
  107501. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  107502. /**
  107503. * Instantiates a new PBRMaterial instance.
  107504. *
  107505. * @param name The material name
  107506. * @param scene The scene the material will be use in.
  107507. */
  107508. constructor(name: string, scene: Scene);
  107509. /**
  107510. * Gets a boolean indicating that current material needs to register RTT
  107511. */
  107512. readonly hasRenderTargetTextures: boolean;
  107513. /**
  107514. * Gets the name of the material class.
  107515. */
  107516. getClassName(): string;
  107517. /**
  107518. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  107519. */
  107520. /**
  107521. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  107522. */
  107523. useLogarithmicDepth: boolean;
  107524. /**
  107525. * Gets the current transparency mode.
  107526. */
  107527. /**
  107528. * Sets the transparency mode of the material.
  107529. *
  107530. * | Value | Type | Description |
  107531. * | ----- | ----------------------------------- | ----------- |
  107532. * | 0 | OPAQUE | |
  107533. * | 1 | ALPHATEST | |
  107534. * | 2 | ALPHABLEND | |
  107535. * | 3 | ALPHATESTANDBLEND | |
  107536. *
  107537. */
  107538. transparencyMode: Nullable<number>;
  107539. /**
  107540. * Returns true if alpha blending should be disabled.
  107541. */
  107542. private readonly _disableAlphaBlending;
  107543. /**
  107544. * Specifies whether or not this material should be rendered in alpha blend mode.
  107545. */
  107546. needAlphaBlending(): boolean;
  107547. /**
  107548. * Specifies if the mesh will require alpha blending.
  107549. * @param mesh - BJS mesh.
  107550. */
  107551. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  107552. /**
  107553. * Specifies whether or not this material should be rendered in alpha test mode.
  107554. */
  107555. needAlphaTesting(): boolean;
  107556. /**
  107557. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  107558. */
  107559. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  107560. /**
  107561. * Gets the texture used for the alpha test.
  107562. */
  107563. getAlphaTestTexture(): Nullable<BaseTexture>;
  107564. /**
  107565. * Specifies that the submesh is ready to be used.
  107566. * @param mesh - BJS mesh.
  107567. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  107568. * @param useInstances - Specifies that instances should be used.
  107569. * @returns - boolean indicating that the submesh is ready or not.
  107570. */
  107571. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  107572. /**
  107573. * Specifies if the material uses metallic roughness workflow.
  107574. * @returns boolean specifiying if the material uses metallic roughness workflow.
  107575. */
  107576. isMetallicWorkflow(): boolean;
  107577. private _prepareEffect;
  107578. private _prepareDefines;
  107579. /**
  107580. * Force shader compilation
  107581. */
  107582. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  107583. clipPlane: boolean;
  107584. }>): void;
  107585. /**
  107586. * Initializes the uniform buffer layout for the shader.
  107587. */
  107588. buildUniformLayout(): void;
  107589. /**
  107590. * Unbinds the material from the mesh
  107591. */
  107592. unbind(): void;
  107593. /**
  107594. * Binds the submesh data.
  107595. * @param world - The world matrix.
  107596. * @param mesh - The BJS mesh.
  107597. * @param subMesh - A submesh of the BJS mesh.
  107598. */
  107599. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  107600. /**
  107601. * Returns the animatable textures.
  107602. * @returns - Array of animatable textures.
  107603. */
  107604. getAnimatables(): IAnimatable[];
  107605. /**
  107606. * Returns the texture used for reflections.
  107607. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  107608. */
  107609. private _getReflectionTexture;
  107610. /**
  107611. * Returns an array of the actively used textures.
  107612. * @returns - Array of BaseTextures
  107613. */
  107614. getActiveTextures(): BaseTexture[];
  107615. /**
  107616. * Checks to see if a texture is used in the material.
  107617. * @param texture - Base texture to use.
  107618. * @returns - Boolean specifying if a texture is used in the material.
  107619. */
  107620. hasTexture(texture: BaseTexture): boolean;
  107621. /**
  107622. * Disposes the resources of the material.
  107623. * @param forceDisposeEffect - Forces the disposal of effects.
  107624. * @param forceDisposeTextures - Forces the disposal of all textures.
  107625. */
  107626. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  107627. }
  107628. }
  107629. declare module BABYLON {
  107630. /**
  107631. * The Physically based material of BJS.
  107632. *
  107633. * This offers the main features of a standard PBR material.
  107634. * For more information, please refer to the documentation :
  107635. * https://doc.babylonjs.com/how_to/physically_based_rendering
  107636. */
  107637. export class PBRMaterial extends PBRBaseMaterial {
  107638. /**
  107639. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  107640. */
  107641. static readonly PBRMATERIAL_OPAQUE: number;
  107642. /**
  107643. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  107644. */
  107645. static readonly PBRMATERIAL_ALPHATEST: number;
  107646. /**
  107647. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  107648. */
  107649. static readonly PBRMATERIAL_ALPHABLEND: number;
  107650. /**
  107651. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  107652. * They are also discarded below the alpha cutoff threshold to improve performances.
  107653. */
  107654. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  107655. /**
  107656. * Defines the default value of how much AO map is occluding the analytical lights
  107657. * (point spot...).
  107658. */
  107659. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  107660. /**
  107661. * Intensity of the direct lights e.g. the four lights available in your scene.
  107662. * This impacts both the direct diffuse and specular highlights.
  107663. */
  107664. directIntensity: number;
  107665. /**
  107666. * Intensity of the emissive part of the material.
  107667. * This helps controlling the emissive effect without modifying the emissive color.
  107668. */
  107669. emissiveIntensity: number;
  107670. /**
  107671. * Intensity of the environment e.g. how much the environment will light the object
  107672. * either through harmonics for rough material or through the refelction for shiny ones.
  107673. */
  107674. environmentIntensity: number;
  107675. /**
  107676. * This is a special control allowing the reduction of the specular highlights coming from the
  107677. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  107678. */
  107679. specularIntensity: number;
  107680. /**
  107681. * Debug Control allowing disabling the bump map on this material.
  107682. */
  107683. disableBumpMap: boolean;
  107684. /**
  107685. * AKA Diffuse Texture in standard nomenclature.
  107686. */
  107687. albedoTexture: BaseTexture;
  107688. /**
  107689. * AKA Occlusion Texture in other nomenclature.
  107690. */
  107691. ambientTexture: BaseTexture;
  107692. /**
  107693. * AKA Occlusion Texture Intensity in other nomenclature.
  107694. */
  107695. ambientTextureStrength: number;
  107696. /**
  107697. * Defines how much the AO map is occluding the analytical lights (point spot...).
  107698. * 1 means it completely occludes it
  107699. * 0 mean it has no impact
  107700. */
  107701. ambientTextureImpactOnAnalyticalLights: number;
  107702. /**
  107703. * Stores the alpha values in a texture.
  107704. */
  107705. opacityTexture: BaseTexture;
  107706. /**
  107707. * Stores the reflection values in a texture.
  107708. */
  107709. reflectionTexture: Nullable<BaseTexture>;
  107710. /**
  107711. * Stores the emissive values in a texture.
  107712. */
  107713. emissiveTexture: BaseTexture;
  107714. /**
  107715. * AKA Specular texture in other nomenclature.
  107716. */
  107717. reflectivityTexture: BaseTexture;
  107718. /**
  107719. * Used to switch from specular/glossiness to metallic/roughness workflow.
  107720. */
  107721. metallicTexture: BaseTexture;
  107722. /**
  107723. * Specifies the metallic scalar of the metallic/roughness workflow.
  107724. * Can also be used to scale the metalness values of the metallic texture.
  107725. */
  107726. metallic: Nullable<number>;
  107727. /**
  107728. * Specifies the roughness scalar of the metallic/roughness workflow.
  107729. * Can also be used to scale the roughness values of the metallic texture.
  107730. */
  107731. roughness: Nullable<number>;
  107732. /**
  107733. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  107734. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  107735. */
  107736. microSurfaceTexture: BaseTexture;
  107737. /**
  107738. * Stores surface normal data used to displace a mesh in a texture.
  107739. */
  107740. bumpTexture: BaseTexture;
  107741. /**
  107742. * Stores the pre-calculated light information of a mesh in a texture.
  107743. */
  107744. lightmapTexture: BaseTexture;
  107745. /**
  107746. * Stores the refracted light information in a texture.
  107747. */
  107748. refractionTexture: Nullable<BaseTexture>;
  107749. /**
  107750. * The color of a material in ambient lighting.
  107751. */
  107752. ambientColor: Color3;
  107753. /**
  107754. * AKA Diffuse Color in other nomenclature.
  107755. */
  107756. albedoColor: Color3;
  107757. /**
  107758. * AKA Specular Color in other nomenclature.
  107759. */
  107760. reflectivityColor: Color3;
  107761. /**
  107762. * The color reflected from the material.
  107763. */
  107764. reflectionColor: Color3;
  107765. /**
  107766. * The color emitted from the material.
  107767. */
  107768. emissiveColor: Color3;
  107769. /**
  107770. * AKA Glossiness in other nomenclature.
  107771. */
  107772. microSurface: number;
  107773. /**
  107774. * source material index of refraction (IOR)' / 'destination material IOR.
  107775. */
  107776. indexOfRefraction: number;
  107777. /**
  107778. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  107779. */
  107780. invertRefractionY: boolean;
  107781. /**
  107782. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  107783. * Materials half opaque for instance using refraction could benefit from this control.
  107784. */
  107785. linkRefractionWithTransparency: boolean;
  107786. /**
  107787. * If true, the light map contains occlusion information instead of lighting info.
  107788. */
  107789. useLightmapAsShadowmap: boolean;
  107790. /**
  107791. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  107792. */
  107793. useAlphaFromAlbedoTexture: boolean;
  107794. /**
  107795. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  107796. */
  107797. forceAlphaTest: boolean;
  107798. /**
  107799. * Defines the alpha limits in alpha test mode.
  107800. */
  107801. alphaCutOff: number;
  107802. /**
  107803. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  107804. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  107805. */
  107806. useSpecularOverAlpha: boolean;
  107807. /**
  107808. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  107809. */
  107810. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  107811. /**
  107812. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  107813. */
  107814. useRoughnessFromMetallicTextureAlpha: boolean;
  107815. /**
  107816. * Specifies if the metallic texture contains the roughness information in its green channel.
  107817. */
  107818. useRoughnessFromMetallicTextureGreen: boolean;
  107819. /**
  107820. * Specifies if the metallic texture contains the metallness information in its blue channel.
  107821. */
  107822. useMetallnessFromMetallicTextureBlue: boolean;
  107823. /**
  107824. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  107825. */
  107826. useAmbientOcclusionFromMetallicTextureRed: boolean;
  107827. /**
  107828. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  107829. */
  107830. useAmbientInGrayScale: boolean;
  107831. /**
  107832. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  107833. * The material will try to infer what glossiness each pixel should be.
  107834. */
  107835. useAutoMicroSurfaceFromReflectivityMap: boolean;
  107836. /**
  107837. * BJS is using an harcoded light falloff based on a manually sets up range.
  107838. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  107839. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  107840. */
  107841. /**
  107842. * BJS is using an harcoded light falloff based on a manually sets up range.
  107843. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  107844. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  107845. */
  107846. usePhysicalLightFalloff: boolean;
  107847. /**
  107848. * In order to support the falloff compatibility with gltf, a special mode has been added
  107849. * to reproduce the gltf light falloff.
  107850. */
  107851. /**
  107852. * In order to support the falloff compatibility with gltf, a special mode has been added
  107853. * to reproduce the gltf light falloff.
  107854. */
  107855. useGLTFLightFalloff: boolean;
  107856. /**
  107857. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  107858. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  107859. */
  107860. useRadianceOverAlpha: boolean;
  107861. /**
  107862. * Allows using an object space normal map (instead of tangent space).
  107863. */
  107864. useObjectSpaceNormalMap: boolean;
  107865. /**
  107866. * Allows using the bump map in parallax mode.
  107867. */
  107868. useParallax: boolean;
  107869. /**
  107870. * Allows using the bump map in parallax occlusion mode.
  107871. */
  107872. useParallaxOcclusion: boolean;
  107873. /**
  107874. * Controls the scale bias of the parallax mode.
  107875. */
  107876. parallaxScaleBias: number;
  107877. /**
  107878. * If sets to true, disables all the lights affecting the material.
  107879. */
  107880. disableLighting: boolean;
  107881. /**
  107882. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  107883. */
  107884. forceIrradianceInFragment: boolean;
  107885. /**
  107886. * Number of Simultaneous lights allowed on the material.
  107887. */
  107888. maxSimultaneousLights: number;
  107889. /**
  107890. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  107891. */
  107892. invertNormalMapX: boolean;
  107893. /**
  107894. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  107895. */
  107896. invertNormalMapY: boolean;
  107897. /**
  107898. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  107899. */
  107900. twoSidedLighting: boolean;
  107901. /**
  107902. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  107903. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  107904. */
  107905. useAlphaFresnel: boolean;
  107906. /**
  107907. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  107908. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  107909. */
  107910. useLinearAlphaFresnel: boolean;
  107911. /**
  107912. * Let user defines the brdf lookup texture used for IBL.
  107913. * A default 8bit version is embedded but you could point at :
  107914. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  107915. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  107916. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  107917. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  107918. */
  107919. environmentBRDFTexture: Nullable<BaseTexture>;
  107920. /**
  107921. * Force normal to face away from face.
  107922. */
  107923. forceNormalForward: boolean;
  107924. /**
  107925. * Enables specular anti aliasing in the PBR shader.
  107926. * It will both interacts on the Geometry for analytical and IBL lighting.
  107927. * It also prefilter the roughness map based on the bump values.
  107928. */
  107929. enableSpecularAntiAliasing: boolean;
  107930. /**
  107931. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  107932. * makes the reflect vector face the model (under horizon).
  107933. */
  107934. useHorizonOcclusion: boolean;
  107935. /**
  107936. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  107937. * too much the area relying on ambient texture to define their ambient occlusion.
  107938. */
  107939. useRadianceOcclusion: boolean;
  107940. /**
  107941. * If set to true, no lighting calculations will be applied.
  107942. */
  107943. unlit: boolean;
  107944. /**
  107945. * Gets the image processing configuration used either in this material.
  107946. */
  107947. /**
  107948. * Sets the Default image processing configuration used either in the this material.
  107949. *
  107950. * If sets to null, the scene one is in use.
  107951. */
  107952. imageProcessingConfiguration: ImageProcessingConfiguration;
  107953. /**
  107954. * Gets wether the color curves effect is enabled.
  107955. */
  107956. /**
  107957. * Sets wether the color curves effect is enabled.
  107958. */
  107959. cameraColorCurvesEnabled: boolean;
  107960. /**
  107961. * Gets wether the color grading effect is enabled.
  107962. */
  107963. /**
  107964. * Gets wether the color grading effect is enabled.
  107965. */
  107966. cameraColorGradingEnabled: boolean;
  107967. /**
  107968. * Gets wether tonemapping is enabled or not.
  107969. */
  107970. /**
  107971. * Sets wether tonemapping is enabled or not
  107972. */
  107973. cameraToneMappingEnabled: boolean;
  107974. /**
  107975. * The camera exposure used on this material.
  107976. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  107977. * This corresponds to a photographic exposure.
  107978. */
  107979. /**
  107980. * The camera exposure used on this material.
  107981. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  107982. * This corresponds to a photographic exposure.
  107983. */
  107984. cameraExposure: number;
  107985. /**
  107986. * Gets The camera contrast used on this material.
  107987. */
  107988. /**
  107989. * Sets The camera contrast used on this material.
  107990. */
  107991. cameraContrast: number;
  107992. /**
  107993. * Gets the Color Grading 2D Lookup Texture.
  107994. */
  107995. /**
  107996. * Sets the Color Grading 2D Lookup Texture.
  107997. */
  107998. cameraColorGradingTexture: Nullable<BaseTexture>;
  107999. /**
  108000. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  108001. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  108002. * 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;
  108003. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  108004. */
  108005. /**
  108006. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  108007. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  108008. * 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;
  108009. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  108010. */
  108011. cameraColorCurves: Nullable<ColorCurves>;
  108012. /**
  108013. * Instantiates a new PBRMaterial instance.
  108014. *
  108015. * @param name The material name
  108016. * @param scene The scene the material will be use in.
  108017. */
  108018. constructor(name: string, scene: Scene);
  108019. /**
  108020. * Returns the name of this material class.
  108021. */
  108022. getClassName(): string;
  108023. /**
  108024. * Makes a duplicate of the current material.
  108025. * @param name - name to use for the new material.
  108026. */
  108027. clone(name: string): PBRMaterial;
  108028. /**
  108029. * Serializes this PBR Material.
  108030. * @returns - An object with the serialized material.
  108031. */
  108032. serialize(): any;
  108033. /**
  108034. * Parses a PBR Material from a serialized object.
  108035. * @param source - Serialized object.
  108036. * @param scene - BJS scene instance.
  108037. * @param rootUrl - url for the scene object
  108038. * @returns - PBRMaterial
  108039. */
  108040. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  108041. }
  108042. }
  108043. declare module BABYLON {
  108044. /**
  108045. * Direct draw surface info
  108046. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  108047. */
  108048. export interface DDSInfo {
  108049. /**
  108050. * Width of the texture
  108051. */
  108052. width: number;
  108053. /**
  108054. * Width of the texture
  108055. */
  108056. height: number;
  108057. /**
  108058. * Number of Mipmaps for the texture
  108059. * @see https://en.wikipedia.org/wiki/Mipmap
  108060. */
  108061. mipmapCount: number;
  108062. /**
  108063. * If the textures format is a known fourCC format
  108064. * @see https://www.fourcc.org/
  108065. */
  108066. isFourCC: boolean;
  108067. /**
  108068. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  108069. */
  108070. isRGB: boolean;
  108071. /**
  108072. * If the texture is a lumincance format
  108073. */
  108074. isLuminance: boolean;
  108075. /**
  108076. * If this is a cube texture
  108077. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  108078. */
  108079. isCube: boolean;
  108080. /**
  108081. * If the texture is a compressed format eg. FOURCC_DXT1
  108082. */
  108083. isCompressed: boolean;
  108084. /**
  108085. * The dxgiFormat of the texture
  108086. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  108087. */
  108088. dxgiFormat: number;
  108089. /**
  108090. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  108091. */
  108092. textureType: number;
  108093. /**
  108094. * Sphericle polynomial created for the dds texture
  108095. */
  108096. sphericalPolynomial?: SphericalPolynomial;
  108097. }
  108098. /**
  108099. * Class used to provide DDS decompression tools
  108100. */
  108101. export class DDSTools {
  108102. /**
  108103. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  108104. */
  108105. static StoreLODInAlphaChannel: boolean;
  108106. /**
  108107. * Gets DDS information from an array buffer
  108108. * @param arrayBuffer defines the array buffer to read data from
  108109. * @returns the DDS information
  108110. */
  108111. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  108112. private static _FloatView;
  108113. private static _Int32View;
  108114. private static _ToHalfFloat;
  108115. private static _FromHalfFloat;
  108116. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  108117. private static _GetHalfFloatRGBAArrayBuffer;
  108118. private static _GetFloatRGBAArrayBuffer;
  108119. private static _GetFloatAsUIntRGBAArrayBuffer;
  108120. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  108121. private static _GetRGBAArrayBuffer;
  108122. private static _ExtractLongWordOrder;
  108123. private static _GetRGBArrayBuffer;
  108124. private static _GetLuminanceArrayBuffer;
  108125. /**
  108126. * Uploads DDS Levels to a Babylon Texture
  108127. * @hidden
  108128. */
  108129. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  108130. }
  108131. interface Engine {
  108132. /**
  108133. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  108134. * @param rootUrl defines the url where the file to load is located
  108135. * @param scene defines the current scene
  108136. * @param lodScale defines scale to apply to the mip map selection
  108137. * @param lodOffset defines offset to apply to the mip map selection
  108138. * @param onLoad defines an optional callback raised when the texture is loaded
  108139. * @param onError defines an optional callback raised if there is an issue to load the texture
  108140. * @param format defines the format of the data
  108141. * @param forcedExtension defines the extension to use to pick the right loader
  108142. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  108143. * @returns the cube texture as an InternalTexture
  108144. */
  108145. 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;
  108146. }
  108147. }
  108148. declare module BABYLON {
  108149. /**
  108150. * Implementation of the DDS Texture Loader.
  108151. * @hidden
  108152. */
  108153. export class _DDSTextureLoader implements IInternalTextureLoader {
  108154. /**
  108155. * Defines wether the loader supports cascade loading the different faces.
  108156. */
  108157. readonly supportCascades: boolean;
  108158. /**
  108159. * This returns if the loader support the current file information.
  108160. * @param extension defines the file extension of the file being loaded
  108161. * @param textureFormatInUse defines the current compressed format in use iun the engine
  108162. * @param fallback defines the fallback internal texture if any
  108163. * @param isBase64 defines whether the texture is encoded as a base64
  108164. * @param isBuffer defines whether the texture data are stored as a buffer
  108165. * @returns true if the loader can load the specified file
  108166. */
  108167. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  108168. /**
  108169. * Transform the url before loading if required.
  108170. * @param rootUrl the url of the texture
  108171. * @param textureFormatInUse defines the current compressed format in use iun the engine
  108172. * @returns the transformed texture
  108173. */
  108174. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  108175. /**
  108176. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  108177. * @param rootUrl the url of the texture
  108178. * @param textureFormatInUse defines the current compressed format in use iun the engine
  108179. * @returns the fallback texture
  108180. */
  108181. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  108182. /**
  108183. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  108184. * @param data contains the texture data
  108185. * @param texture defines the BabylonJS internal texture
  108186. * @param createPolynomials will be true if polynomials have been requested
  108187. * @param onLoad defines the callback to trigger once the texture is ready
  108188. * @param onError defines the callback to trigger in case of error
  108189. */
  108190. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  108191. /**
  108192. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  108193. * @param data contains the texture data
  108194. * @param texture defines the BabylonJS internal texture
  108195. * @param callback defines the method to call once ready to upload
  108196. */
  108197. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  108198. }
  108199. }
  108200. declare module BABYLON {
  108201. /** @hidden */
  108202. export var rgbdEncodePixelShader: {
  108203. name: string;
  108204. shader: string;
  108205. };
  108206. }
  108207. declare module BABYLON {
  108208. /**
  108209. * Raw texture data and descriptor sufficient for WebGL texture upload
  108210. */
  108211. export interface EnvironmentTextureInfo {
  108212. /**
  108213. * Version of the environment map
  108214. */
  108215. version: number;
  108216. /**
  108217. * Width of image
  108218. */
  108219. width: number;
  108220. /**
  108221. * Irradiance information stored in the file.
  108222. */
  108223. irradiance: any;
  108224. /**
  108225. * Specular information stored in the file.
  108226. */
  108227. specular: any;
  108228. }
  108229. /**
  108230. * Sets of helpers addressing the serialization and deserialization of environment texture
  108231. * stored in a BabylonJS env file.
  108232. * Those files are usually stored as .env files.
  108233. */
  108234. export class EnvironmentTextureTools {
  108235. /**
  108236. * Magic number identifying the env file.
  108237. */
  108238. private static _MagicBytes;
  108239. /**
  108240. * Gets the environment info from an env file.
  108241. * @param data The array buffer containing the .env bytes.
  108242. * @returns the environment file info (the json header) if successfully parsed.
  108243. */
  108244. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  108245. /**
  108246. * Creates an environment texture from a loaded cube texture.
  108247. * @param texture defines the cube texture to convert in env file
  108248. * @return a promise containing the environment data if succesfull.
  108249. */
  108250. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  108251. /**
  108252. * Creates a JSON representation of the spherical data.
  108253. * @param texture defines the texture containing the polynomials
  108254. * @return the JSON representation of the spherical info
  108255. */
  108256. private static _CreateEnvTextureIrradiance;
  108257. /**
  108258. * Uploads the texture info contained in the env file to the GPU.
  108259. * @param texture defines the internal texture to upload to
  108260. * @param arrayBuffer defines the buffer cotaining the data to load
  108261. * @param info defines the texture info retrieved through the GetEnvInfo method
  108262. * @returns a promise
  108263. */
  108264. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  108265. /**
  108266. * Uploads the levels of image data to the GPU.
  108267. * @param texture defines the internal texture to upload to
  108268. * @param imageData defines the array buffer views of image data [mipmap][face]
  108269. * @returns a promise
  108270. */
  108271. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  108272. /**
  108273. * Uploads spherical polynomials information to the texture.
  108274. * @param texture defines the texture we are trying to upload the information to
  108275. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  108276. */
  108277. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  108278. /** @hidden */
  108279. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  108280. }
  108281. }
  108282. declare module BABYLON {
  108283. /**
  108284. * Implementation of the ENV Texture Loader.
  108285. * @hidden
  108286. */
  108287. export class _ENVTextureLoader implements IInternalTextureLoader {
  108288. /**
  108289. * Defines wether the loader supports cascade loading the different faces.
  108290. */
  108291. readonly supportCascades: boolean;
  108292. /**
  108293. * This returns if the loader support the current file information.
  108294. * @param extension defines the file extension of the file being loaded
  108295. * @param textureFormatInUse defines the current compressed format in use iun the engine
  108296. * @param fallback defines the fallback internal texture if any
  108297. * @param isBase64 defines whether the texture is encoded as a base64
  108298. * @param isBuffer defines whether the texture data are stored as a buffer
  108299. * @returns true if the loader can load the specified file
  108300. */
  108301. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  108302. /**
  108303. * Transform the url before loading if required.
  108304. * @param rootUrl the url of the texture
  108305. * @param textureFormatInUse defines the current compressed format in use iun the engine
  108306. * @returns the transformed texture
  108307. */
  108308. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  108309. /**
  108310. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  108311. * @param rootUrl the url of the texture
  108312. * @param textureFormatInUse defines the current compressed format in use iun the engine
  108313. * @returns the fallback texture
  108314. */
  108315. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  108316. /**
  108317. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  108318. * @param data contains the texture data
  108319. * @param texture defines the BabylonJS internal texture
  108320. * @param createPolynomials will be true if polynomials have been requested
  108321. * @param onLoad defines the callback to trigger once the texture is ready
  108322. * @param onError defines the callback to trigger in case of error
  108323. */
  108324. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  108325. /**
  108326. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  108327. * @param data contains the texture data
  108328. * @param texture defines the BabylonJS internal texture
  108329. * @param callback defines the method to call once ready to upload
  108330. */
  108331. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  108332. }
  108333. }
  108334. declare module BABYLON {
  108335. /**
  108336. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  108337. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  108338. */
  108339. export class KhronosTextureContainer {
  108340. /** contents of the KTX container file */
  108341. arrayBuffer: any;
  108342. private static HEADER_LEN;
  108343. private static COMPRESSED_2D;
  108344. private static COMPRESSED_3D;
  108345. private static TEX_2D;
  108346. private static TEX_3D;
  108347. /**
  108348. * Gets the openGL type
  108349. */
  108350. glType: number;
  108351. /**
  108352. * Gets the openGL type size
  108353. */
  108354. glTypeSize: number;
  108355. /**
  108356. * Gets the openGL format
  108357. */
  108358. glFormat: number;
  108359. /**
  108360. * Gets the openGL internal format
  108361. */
  108362. glInternalFormat: number;
  108363. /**
  108364. * Gets the base internal format
  108365. */
  108366. glBaseInternalFormat: number;
  108367. /**
  108368. * Gets image width in pixel
  108369. */
  108370. pixelWidth: number;
  108371. /**
  108372. * Gets image height in pixel
  108373. */
  108374. pixelHeight: number;
  108375. /**
  108376. * Gets image depth in pixels
  108377. */
  108378. pixelDepth: number;
  108379. /**
  108380. * Gets the number of array elements
  108381. */
  108382. numberOfArrayElements: number;
  108383. /**
  108384. * Gets the number of faces
  108385. */
  108386. numberOfFaces: number;
  108387. /**
  108388. * Gets the number of mipmap levels
  108389. */
  108390. numberOfMipmapLevels: number;
  108391. /**
  108392. * Gets the bytes of key value data
  108393. */
  108394. bytesOfKeyValueData: number;
  108395. /**
  108396. * Gets the load type
  108397. */
  108398. loadType: number;
  108399. /**
  108400. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  108401. */
  108402. isInvalid: boolean;
  108403. /**
  108404. * Creates a new KhronosTextureContainer
  108405. * @param arrayBuffer contents of the KTX container file
  108406. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  108407. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  108408. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  108409. */
  108410. constructor(
  108411. /** contents of the KTX container file */
  108412. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  108413. /**
  108414. * Uploads KTX content to a Babylon Texture.
  108415. * It is assumed that the texture has already been created & is currently bound
  108416. * @hidden
  108417. */
  108418. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  108419. private _upload2DCompressedLevels;
  108420. }
  108421. }
  108422. declare module BABYLON {
  108423. /**
  108424. * Implementation of the KTX Texture Loader.
  108425. * @hidden
  108426. */
  108427. export class _KTXTextureLoader implements IInternalTextureLoader {
  108428. /**
  108429. * Defines wether the loader supports cascade loading the different faces.
  108430. */
  108431. readonly supportCascades: boolean;
  108432. /**
  108433. * This returns if the loader support the current file information.
  108434. * @param extension defines the file extension of the file being loaded
  108435. * @param textureFormatInUse defines the current compressed format in use iun the engine
  108436. * @param fallback defines the fallback internal texture if any
  108437. * @param isBase64 defines whether the texture is encoded as a base64
  108438. * @param isBuffer defines whether the texture data are stored as a buffer
  108439. * @returns true if the loader can load the specified file
  108440. */
  108441. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  108442. /**
  108443. * Transform the url before loading if required.
  108444. * @param rootUrl the url of the texture
  108445. * @param textureFormatInUse defines the current compressed format in use iun the engine
  108446. * @returns the transformed texture
  108447. */
  108448. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  108449. /**
  108450. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  108451. * @param rootUrl the url of the texture
  108452. * @param textureFormatInUse defines the current compressed format in use iun the engine
  108453. * @returns the fallback texture
  108454. */
  108455. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  108456. /**
  108457. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  108458. * @param data contains the texture data
  108459. * @param texture defines the BabylonJS internal texture
  108460. * @param createPolynomials will be true if polynomials have been requested
  108461. * @param onLoad defines the callback to trigger once the texture is ready
  108462. * @param onError defines the callback to trigger in case of error
  108463. */
  108464. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  108465. /**
  108466. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  108467. * @param data contains the texture data
  108468. * @param texture defines the BabylonJS internal texture
  108469. * @param callback defines the method to call once ready to upload
  108470. */
  108471. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  108472. }
  108473. }
  108474. declare module BABYLON {
  108475. /** @hidden */
  108476. export var _forceSceneHelpersToBundle: boolean;
  108477. interface Scene {
  108478. /**
  108479. * Creates a default light for the scene.
  108480. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  108481. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  108482. */
  108483. createDefaultLight(replace?: boolean): void;
  108484. /**
  108485. * Creates a default camera for the scene.
  108486. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  108487. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  108488. * @param replace has default false, when true replaces the active camera in the scene
  108489. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  108490. */
  108491. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  108492. /**
  108493. * Creates a default camera and a default light.
  108494. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  108495. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  108496. * @param replace has the default false, when true replaces the active camera/light in the scene
  108497. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  108498. */
  108499. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  108500. /**
  108501. * Creates a new sky box
  108502. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  108503. * @param environmentTexture defines the texture to use as environment texture
  108504. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  108505. * @param scale defines the overall scale of the skybox
  108506. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  108507. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  108508. * @returns a new mesh holding the sky box
  108509. */
  108510. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  108511. /**
  108512. * Creates a new environment
  108513. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  108514. * @param options defines the options you can use to configure the environment
  108515. * @returns the new EnvironmentHelper
  108516. */
  108517. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  108518. /**
  108519. * Creates a new VREXperienceHelper
  108520. * @see http://doc.babylonjs.com/how_to/webvr_helper
  108521. * @param webVROptions defines the options used to create the new VREXperienceHelper
  108522. * @returns a new VREXperienceHelper
  108523. */
  108524. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  108525. /**
  108526. * Creates a new XREXperienceHelper
  108527. * @see http://doc.babylonjs.com/how_to/webxr
  108528. * @returns a promise for a new XREXperienceHelper
  108529. */
  108530. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  108531. }
  108532. }
  108533. declare module BABYLON {
  108534. /**
  108535. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  108536. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  108537. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  108538. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  108539. */
  108540. export class VideoDome extends TransformNode {
  108541. /**
  108542. * Define the video source as a Monoscopic panoramic 360 video.
  108543. */
  108544. static readonly MODE_MONOSCOPIC: number;
  108545. /**
  108546. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  108547. */
  108548. static readonly MODE_TOPBOTTOM: number;
  108549. /**
  108550. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  108551. */
  108552. static readonly MODE_SIDEBYSIDE: number;
  108553. private _useDirectMapping;
  108554. /**
  108555. * The video texture being displayed on the sphere
  108556. */
  108557. protected _videoTexture: VideoTexture;
  108558. /**
  108559. * Gets the video texture being displayed on the sphere
  108560. */
  108561. readonly videoTexture: VideoTexture;
  108562. /**
  108563. * The skybox material
  108564. */
  108565. protected _material: BackgroundMaterial;
  108566. /**
  108567. * The surface used for the skybox
  108568. */
  108569. protected _mesh: Mesh;
  108570. /**
  108571. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  108572. * Also see the options.resolution property.
  108573. */
  108574. fovMultiplier: number;
  108575. private _videoMode;
  108576. /**
  108577. * Gets or set the current video mode for the video. It can be:
  108578. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  108579. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  108580. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  108581. */
  108582. videoMode: number;
  108583. /**
  108584. * Oberserver used in Stereoscopic VR Mode.
  108585. */
  108586. private _onBeforeCameraRenderObserver;
  108587. /**
  108588. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  108589. * @param name Element's name, child elements will append suffixes for their own names.
  108590. * @param urlsOrVideo defines the url(s) or the video element to use
  108591. * @param options An object containing optional or exposed sub element properties
  108592. */
  108593. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  108594. resolution?: number;
  108595. clickToPlay?: boolean;
  108596. autoPlay?: boolean;
  108597. loop?: boolean;
  108598. size?: number;
  108599. poster?: string;
  108600. faceForward?: boolean;
  108601. useDirectMapping?: boolean;
  108602. }, scene: Scene);
  108603. private _changeVideoMode;
  108604. /**
  108605. * Releases resources associated with this node.
  108606. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  108607. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  108608. */
  108609. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  108610. }
  108611. }
  108612. declare module BABYLON {
  108613. /**
  108614. * This class can be used to get instrumentation data from a Babylon engine
  108615. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  108616. */
  108617. export class EngineInstrumentation implements IDisposable {
  108618. /**
  108619. * Define the instrumented engine.
  108620. */
  108621. engine: Engine;
  108622. private _captureGPUFrameTime;
  108623. private _gpuFrameTimeToken;
  108624. private _gpuFrameTime;
  108625. private _captureShaderCompilationTime;
  108626. private _shaderCompilationTime;
  108627. private _onBeginFrameObserver;
  108628. private _onEndFrameObserver;
  108629. private _onBeforeShaderCompilationObserver;
  108630. private _onAfterShaderCompilationObserver;
  108631. /**
  108632. * Gets the perf counter used for GPU frame time
  108633. */
  108634. readonly gpuFrameTimeCounter: PerfCounter;
  108635. /**
  108636. * Gets the GPU frame time capture status
  108637. */
  108638. /**
  108639. * Enable or disable the GPU frame time capture
  108640. */
  108641. captureGPUFrameTime: boolean;
  108642. /**
  108643. * Gets the perf counter used for shader compilation time
  108644. */
  108645. readonly shaderCompilationTimeCounter: PerfCounter;
  108646. /**
  108647. * Gets the shader compilation time capture status
  108648. */
  108649. /**
  108650. * Enable or disable the shader compilation time capture
  108651. */
  108652. captureShaderCompilationTime: boolean;
  108653. /**
  108654. * Instantiates a new engine instrumentation.
  108655. * This class can be used to get instrumentation data from a Babylon engine
  108656. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  108657. * @param engine Defines the engine to instrument
  108658. */
  108659. constructor(
  108660. /**
  108661. * Define the instrumented engine.
  108662. */
  108663. engine: Engine);
  108664. /**
  108665. * Dispose and release associated resources.
  108666. */
  108667. dispose(): void;
  108668. }
  108669. }
  108670. declare module BABYLON {
  108671. /**
  108672. * This class can be used to get instrumentation data from a Babylon engine
  108673. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  108674. */
  108675. export class SceneInstrumentation implements IDisposable {
  108676. /**
  108677. * Defines the scene to instrument
  108678. */
  108679. scene: Scene;
  108680. private _captureActiveMeshesEvaluationTime;
  108681. private _activeMeshesEvaluationTime;
  108682. private _captureRenderTargetsRenderTime;
  108683. private _renderTargetsRenderTime;
  108684. private _captureFrameTime;
  108685. private _frameTime;
  108686. private _captureRenderTime;
  108687. private _renderTime;
  108688. private _captureInterFrameTime;
  108689. private _interFrameTime;
  108690. private _captureParticlesRenderTime;
  108691. private _particlesRenderTime;
  108692. private _captureSpritesRenderTime;
  108693. private _spritesRenderTime;
  108694. private _capturePhysicsTime;
  108695. private _physicsTime;
  108696. private _captureAnimationsTime;
  108697. private _animationsTime;
  108698. private _captureCameraRenderTime;
  108699. private _cameraRenderTime;
  108700. private _onBeforeActiveMeshesEvaluationObserver;
  108701. private _onAfterActiveMeshesEvaluationObserver;
  108702. private _onBeforeRenderTargetsRenderObserver;
  108703. private _onAfterRenderTargetsRenderObserver;
  108704. private _onAfterRenderObserver;
  108705. private _onBeforeDrawPhaseObserver;
  108706. private _onAfterDrawPhaseObserver;
  108707. private _onBeforeAnimationsObserver;
  108708. private _onBeforeParticlesRenderingObserver;
  108709. private _onAfterParticlesRenderingObserver;
  108710. private _onBeforeSpritesRenderingObserver;
  108711. private _onAfterSpritesRenderingObserver;
  108712. private _onBeforePhysicsObserver;
  108713. private _onAfterPhysicsObserver;
  108714. private _onAfterAnimationsObserver;
  108715. private _onBeforeCameraRenderObserver;
  108716. private _onAfterCameraRenderObserver;
  108717. /**
  108718. * Gets the perf counter used for active meshes evaluation time
  108719. */
  108720. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  108721. /**
  108722. * Gets the active meshes evaluation time capture status
  108723. */
  108724. /**
  108725. * Enable or disable the active meshes evaluation time capture
  108726. */
  108727. captureActiveMeshesEvaluationTime: boolean;
  108728. /**
  108729. * Gets the perf counter used for render targets render time
  108730. */
  108731. readonly renderTargetsRenderTimeCounter: PerfCounter;
  108732. /**
  108733. * Gets the render targets render time capture status
  108734. */
  108735. /**
  108736. * Enable or disable the render targets render time capture
  108737. */
  108738. captureRenderTargetsRenderTime: boolean;
  108739. /**
  108740. * Gets the perf counter used for particles render time
  108741. */
  108742. readonly particlesRenderTimeCounter: PerfCounter;
  108743. /**
  108744. * Gets the particles render time capture status
  108745. */
  108746. /**
  108747. * Enable or disable the particles render time capture
  108748. */
  108749. captureParticlesRenderTime: boolean;
  108750. /**
  108751. * Gets the perf counter used for sprites render time
  108752. */
  108753. readonly spritesRenderTimeCounter: PerfCounter;
  108754. /**
  108755. * Gets the sprites render time capture status
  108756. */
  108757. /**
  108758. * Enable or disable the sprites render time capture
  108759. */
  108760. captureSpritesRenderTime: boolean;
  108761. /**
  108762. * Gets the perf counter used for physics time
  108763. */
  108764. readonly physicsTimeCounter: PerfCounter;
  108765. /**
  108766. * Gets the physics time capture status
  108767. */
  108768. /**
  108769. * Enable or disable the physics time capture
  108770. */
  108771. capturePhysicsTime: boolean;
  108772. /**
  108773. * Gets the perf counter used for animations time
  108774. */
  108775. readonly animationsTimeCounter: PerfCounter;
  108776. /**
  108777. * Gets the animations time capture status
  108778. */
  108779. /**
  108780. * Enable or disable the animations time capture
  108781. */
  108782. captureAnimationsTime: boolean;
  108783. /**
  108784. * Gets the perf counter used for frame time capture
  108785. */
  108786. readonly frameTimeCounter: PerfCounter;
  108787. /**
  108788. * Gets the frame time capture status
  108789. */
  108790. /**
  108791. * Enable or disable the frame time capture
  108792. */
  108793. captureFrameTime: boolean;
  108794. /**
  108795. * Gets the perf counter used for inter-frames time capture
  108796. */
  108797. readonly interFrameTimeCounter: PerfCounter;
  108798. /**
  108799. * Gets the inter-frames time capture status
  108800. */
  108801. /**
  108802. * Enable or disable the inter-frames time capture
  108803. */
  108804. captureInterFrameTime: boolean;
  108805. /**
  108806. * Gets the perf counter used for render time capture
  108807. */
  108808. readonly renderTimeCounter: PerfCounter;
  108809. /**
  108810. * Gets the render time capture status
  108811. */
  108812. /**
  108813. * Enable or disable the render time capture
  108814. */
  108815. captureRenderTime: boolean;
  108816. /**
  108817. * Gets the perf counter used for camera render time capture
  108818. */
  108819. readonly cameraRenderTimeCounter: PerfCounter;
  108820. /**
  108821. * Gets the camera render time capture status
  108822. */
  108823. /**
  108824. * Enable or disable the camera render time capture
  108825. */
  108826. captureCameraRenderTime: boolean;
  108827. /**
  108828. * Gets the perf counter used for draw calls
  108829. */
  108830. readonly drawCallsCounter: PerfCounter;
  108831. /**
  108832. * Instantiates a new scene instrumentation.
  108833. * This class can be used to get instrumentation data from a Babylon engine
  108834. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  108835. * @param scene Defines the scene to instrument
  108836. */
  108837. constructor(
  108838. /**
  108839. * Defines the scene to instrument
  108840. */
  108841. scene: Scene);
  108842. /**
  108843. * Dispose and release associated resources.
  108844. */
  108845. dispose(): void;
  108846. }
  108847. }
  108848. declare module BABYLON {
  108849. /** @hidden */
  108850. export var glowMapGenerationPixelShader: {
  108851. name: string;
  108852. shader: string;
  108853. };
  108854. }
  108855. declare module BABYLON {
  108856. /** @hidden */
  108857. export var glowMapGenerationVertexShader: {
  108858. name: string;
  108859. shader: string;
  108860. };
  108861. }
  108862. declare module BABYLON {
  108863. /**
  108864. * Effect layer options. This helps customizing the behaviour
  108865. * of the effect layer.
  108866. */
  108867. export interface IEffectLayerOptions {
  108868. /**
  108869. * Multiplication factor apply to the canvas size to compute the render target size
  108870. * used to generated the objects (the smaller the faster).
  108871. */
  108872. mainTextureRatio: number;
  108873. /**
  108874. * Enforces a fixed size texture to ensure effect stability across devices.
  108875. */
  108876. mainTextureFixedSize?: number;
  108877. /**
  108878. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  108879. */
  108880. alphaBlendingMode: number;
  108881. /**
  108882. * The camera attached to the layer.
  108883. */
  108884. camera: Nullable<Camera>;
  108885. /**
  108886. * The rendering group to draw the layer in.
  108887. */
  108888. renderingGroupId: number;
  108889. }
  108890. /**
  108891. * The effect layer Helps adding post process effect blended with the main pass.
  108892. *
  108893. * This can be for instance use to generate glow or higlight effects on the scene.
  108894. *
  108895. * The effect layer class can not be used directly and is intented to inherited from to be
  108896. * customized per effects.
  108897. */
  108898. export abstract class EffectLayer {
  108899. private _vertexBuffers;
  108900. private _indexBuffer;
  108901. private _cachedDefines;
  108902. private _effectLayerMapGenerationEffect;
  108903. private _effectLayerOptions;
  108904. private _mergeEffect;
  108905. protected _scene: Scene;
  108906. protected _engine: Engine;
  108907. protected _maxSize: number;
  108908. protected _mainTextureDesiredSize: ISize;
  108909. protected _mainTexture: RenderTargetTexture;
  108910. protected _shouldRender: boolean;
  108911. protected _postProcesses: PostProcess[];
  108912. protected _textures: BaseTexture[];
  108913. protected _emissiveTextureAndColor: {
  108914. texture: Nullable<BaseTexture>;
  108915. color: Color4;
  108916. };
  108917. /**
  108918. * The name of the layer
  108919. */
  108920. name: string;
  108921. /**
  108922. * The clear color of the texture used to generate the glow map.
  108923. */
  108924. neutralColor: Color4;
  108925. /**
  108926. * Specifies wether the highlight layer is enabled or not.
  108927. */
  108928. isEnabled: boolean;
  108929. /**
  108930. * Gets the camera attached to the layer.
  108931. */
  108932. readonly camera: Nullable<Camera>;
  108933. /**
  108934. * Gets the rendering group id the layer should render in.
  108935. */
  108936. readonly renderingGroupId: number;
  108937. /**
  108938. * An event triggered when the effect layer has been disposed.
  108939. */
  108940. onDisposeObservable: Observable<EffectLayer>;
  108941. /**
  108942. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  108943. */
  108944. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  108945. /**
  108946. * An event triggered when the generated texture is being merged in the scene.
  108947. */
  108948. onBeforeComposeObservable: Observable<EffectLayer>;
  108949. /**
  108950. * An event triggered when the generated texture has been merged in the scene.
  108951. */
  108952. onAfterComposeObservable: Observable<EffectLayer>;
  108953. /**
  108954. * An event triggered when the efffect layer changes its size.
  108955. */
  108956. onSizeChangedObservable: Observable<EffectLayer>;
  108957. /** @hidden */
  108958. static _SceneComponentInitialization: (scene: Scene) => void;
  108959. /**
  108960. * Instantiates a new effect Layer and references it in the scene.
  108961. * @param name The name of the layer
  108962. * @param scene The scene to use the layer in
  108963. */
  108964. constructor(
  108965. /** The Friendly of the effect in the scene */
  108966. name: string, scene: Scene);
  108967. /**
  108968. * Get the effect name of the layer.
  108969. * @return The effect name
  108970. */
  108971. abstract getEffectName(): string;
  108972. /**
  108973. * Checks for the readiness of the element composing the layer.
  108974. * @param subMesh the mesh to check for
  108975. * @param useInstances specify wether or not to use instances to render the mesh
  108976. * @return true if ready otherwise, false
  108977. */
  108978. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  108979. /**
  108980. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  108981. * @returns true if the effect requires stencil during the main canvas render pass.
  108982. */
  108983. abstract needStencil(): boolean;
  108984. /**
  108985. * Create the merge effect. This is the shader use to blit the information back
  108986. * to the main canvas at the end of the scene rendering.
  108987. * @returns The effect containing the shader used to merge the effect on the main canvas
  108988. */
  108989. protected abstract _createMergeEffect(): Effect;
  108990. /**
  108991. * Creates the render target textures and post processes used in the effect layer.
  108992. */
  108993. protected abstract _createTextureAndPostProcesses(): void;
  108994. /**
  108995. * Implementation specific of rendering the generating effect on the main canvas.
  108996. * @param effect The effect used to render through
  108997. */
  108998. protected abstract _internalRender(effect: Effect): void;
  108999. /**
  109000. * Sets the required values for both the emissive texture and and the main color.
  109001. */
  109002. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  109003. /**
  109004. * Free any resources and references associated to a mesh.
  109005. * Internal use
  109006. * @param mesh The mesh to free.
  109007. */
  109008. abstract _disposeMesh(mesh: Mesh): void;
  109009. /**
  109010. * Serializes this layer (Glow or Highlight for example)
  109011. * @returns a serialized layer object
  109012. */
  109013. abstract serialize?(): any;
  109014. /**
  109015. * Initializes the effect layer with the required options.
  109016. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  109017. */
  109018. protected _init(options: Partial<IEffectLayerOptions>): void;
  109019. /**
  109020. * Generates the index buffer of the full screen quad blending to the main canvas.
  109021. */
  109022. private _generateIndexBuffer;
  109023. /**
  109024. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  109025. */
  109026. private _generateVertexBuffer;
  109027. /**
  109028. * Sets the main texture desired size which is the closest power of two
  109029. * of the engine canvas size.
  109030. */
  109031. private _setMainTextureSize;
  109032. /**
  109033. * Creates the main texture for the effect layer.
  109034. */
  109035. protected _createMainTexture(): void;
  109036. /**
  109037. * Adds specific effects defines.
  109038. * @param defines The defines to add specifics to.
  109039. */
  109040. protected _addCustomEffectDefines(defines: string[]): void;
  109041. /**
  109042. * Checks for the readiness of the element composing the layer.
  109043. * @param subMesh the mesh to check for
  109044. * @param useInstances specify wether or not to use instances to render the mesh
  109045. * @param emissiveTexture the associated emissive texture used to generate the glow
  109046. * @return true if ready otherwise, false
  109047. */
  109048. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  109049. /**
  109050. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  109051. */
  109052. render(): void;
  109053. /**
  109054. * Determine if a given mesh will be used in the current effect.
  109055. * @param mesh mesh to test
  109056. * @returns true if the mesh will be used
  109057. */
  109058. hasMesh(mesh: AbstractMesh): boolean;
  109059. /**
  109060. * Returns true if the layer contains information to display, otherwise false.
  109061. * @returns true if the glow layer should be rendered
  109062. */
  109063. shouldRender(): boolean;
  109064. /**
  109065. * Returns true if the mesh should render, otherwise false.
  109066. * @param mesh The mesh to render
  109067. * @returns true if it should render otherwise false
  109068. */
  109069. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  109070. /**
  109071. * Returns true if the mesh can be rendered, otherwise false.
  109072. * @param mesh The mesh to render
  109073. * @param material The material used on the mesh
  109074. * @returns true if it can be rendered otherwise false
  109075. */
  109076. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  109077. /**
  109078. * Returns true if the mesh should render, otherwise false.
  109079. * @param mesh The mesh to render
  109080. * @returns true if it should render otherwise false
  109081. */
  109082. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  109083. /**
  109084. * Renders the submesh passed in parameter to the generation map.
  109085. */
  109086. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  109087. /**
  109088. * Rebuild the required buffers.
  109089. * @hidden Internal use only.
  109090. */
  109091. _rebuild(): void;
  109092. /**
  109093. * Dispose only the render target textures and post process.
  109094. */
  109095. private _disposeTextureAndPostProcesses;
  109096. /**
  109097. * Dispose the highlight layer and free resources.
  109098. */
  109099. dispose(): void;
  109100. /**
  109101. * Gets the class name of the effect layer
  109102. * @returns the string with the class name of the effect layer
  109103. */
  109104. getClassName(): string;
  109105. /**
  109106. * Creates an effect layer from parsed effect layer data
  109107. * @param parsedEffectLayer defines effect layer data
  109108. * @param scene defines the current scene
  109109. * @param rootUrl defines the root URL containing the effect layer information
  109110. * @returns a parsed effect Layer
  109111. */
  109112. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  109113. }
  109114. }
  109115. declare module BABYLON {
  109116. interface AbstractScene {
  109117. /**
  109118. * The list of effect layers (highlights/glow) added to the scene
  109119. * @see http://doc.babylonjs.com/how_to/highlight_layer
  109120. * @see http://doc.babylonjs.com/how_to/glow_layer
  109121. */
  109122. effectLayers: Array<EffectLayer>;
  109123. /**
  109124. * Removes the given effect layer from this scene.
  109125. * @param toRemove defines the effect layer to remove
  109126. * @returns the index of the removed effect layer
  109127. */
  109128. removeEffectLayer(toRemove: EffectLayer): number;
  109129. /**
  109130. * Adds the given effect layer to this scene
  109131. * @param newEffectLayer defines the effect layer to add
  109132. */
  109133. addEffectLayer(newEffectLayer: EffectLayer): void;
  109134. }
  109135. /**
  109136. * Defines the layer scene component responsible to manage any effect layers
  109137. * in a given scene.
  109138. */
  109139. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  109140. /**
  109141. * The component name helpfull to identify the component in the list of scene components.
  109142. */
  109143. readonly name: string;
  109144. /**
  109145. * The scene the component belongs to.
  109146. */
  109147. scene: Scene;
  109148. private _engine;
  109149. private _renderEffects;
  109150. private _needStencil;
  109151. private _previousStencilState;
  109152. /**
  109153. * Creates a new instance of the component for the given scene
  109154. * @param scene Defines the scene to register the component in
  109155. */
  109156. constructor(scene: Scene);
  109157. /**
  109158. * Registers the component in a given scene
  109159. */
  109160. register(): void;
  109161. /**
  109162. * Rebuilds the elements related to this component in case of
  109163. * context lost for instance.
  109164. */
  109165. rebuild(): void;
  109166. /**
  109167. * Serializes the component data to the specified json object
  109168. * @param serializationObject The object to serialize to
  109169. */
  109170. serialize(serializationObject: any): void;
  109171. /**
  109172. * Adds all the elements from the container to the scene
  109173. * @param container the container holding the elements
  109174. */
  109175. addFromContainer(container: AbstractScene): void;
  109176. /**
  109177. * Removes all the elements in the container from the scene
  109178. * @param container contains the elements to remove
  109179. * @param dispose if the removed element should be disposed (default: false)
  109180. */
  109181. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  109182. /**
  109183. * Disposes the component and the associated ressources.
  109184. */
  109185. dispose(): void;
  109186. private _isReadyForMesh;
  109187. private _renderMainTexture;
  109188. private _setStencil;
  109189. private _setStencilBack;
  109190. private _draw;
  109191. private _drawCamera;
  109192. private _drawRenderingGroup;
  109193. }
  109194. }
  109195. declare module BABYLON {
  109196. /** @hidden */
  109197. export var glowMapMergePixelShader: {
  109198. name: string;
  109199. shader: string;
  109200. };
  109201. }
  109202. declare module BABYLON {
  109203. /** @hidden */
  109204. export var glowMapMergeVertexShader: {
  109205. name: string;
  109206. shader: string;
  109207. };
  109208. }
  109209. declare module BABYLON {
  109210. interface AbstractScene {
  109211. /**
  109212. * Return a the first highlight layer of the scene with a given name.
  109213. * @param name The name of the highlight layer to look for.
  109214. * @return The highlight layer if found otherwise null.
  109215. */
  109216. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  109217. }
  109218. /**
  109219. * Glow layer options. This helps customizing the behaviour
  109220. * of the glow layer.
  109221. */
  109222. export interface IGlowLayerOptions {
  109223. /**
  109224. * Multiplication factor apply to the canvas size to compute the render target size
  109225. * used to generated the glowing objects (the smaller the faster).
  109226. */
  109227. mainTextureRatio: number;
  109228. /**
  109229. * Enforces a fixed size texture to ensure resize independant blur.
  109230. */
  109231. mainTextureFixedSize?: number;
  109232. /**
  109233. * How big is the kernel of the blur texture.
  109234. */
  109235. blurKernelSize: number;
  109236. /**
  109237. * The camera attached to the layer.
  109238. */
  109239. camera: Nullable<Camera>;
  109240. /**
  109241. * Enable MSAA by chosing the number of samples.
  109242. */
  109243. mainTextureSamples?: number;
  109244. /**
  109245. * The rendering group to draw the layer in.
  109246. */
  109247. renderingGroupId: number;
  109248. }
  109249. /**
  109250. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  109251. *
  109252. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  109253. * glowy meshes to your scene.
  109254. *
  109255. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  109256. */
  109257. export class GlowLayer extends EffectLayer {
  109258. /**
  109259. * Effect Name of the layer.
  109260. */
  109261. static readonly EffectName: string;
  109262. /**
  109263. * The default blur kernel size used for the glow.
  109264. */
  109265. static DefaultBlurKernelSize: number;
  109266. /**
  109267. * The default texture size ratio used for the glow.
  109268. */
  109269. static DefaultTextureRatio: number;
  109270. /**
  109271. * Sets the kernel size of the blur.
  109272. */
  109273. /**
  109274. * Gets the kernel size of the blur.
  109275. */
  109276. blurKernelSize: number;
  109277. /**
  109278. * Sets the glow intensity.
  109279. */
  109280. /**
  109281. * Gets the glow intensity.
  109282. */
  109283. intensity: number;
  109284. private _options;
  109285. private _intensity;
  109286. private _horizontalBlurPostprocess1;
  109287. private _verticalBlurPostprocess1;
  109288. private _horizontalBlurPostprocess2;
  109289. private _verticalBlurPostprocess2;
  109290. private _blurTexture1;
  109291. private _blurTexture2;
  109292. private _postProcesses1;
  109293. private _postProcesses2;
  109294. private _includedOnlyMeshes;
  109295. private _excludedMeshes;
  109296. /**
  109297. * Callback used to let the user override the color selection on a per mesh basis
  109298. */
  109299. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  109300. /**
  109301. * Callback used to let the user override the texture selection on a per mesh basis
  109302. */
  109303. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  109304. /**
  109305. * Instantiates a new glow Layer and references it to the scene.
  109306. * @param name The name of the layer
  109307. * @param scene The scene to use the layer in
  109308. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  109309. */
  109310. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  109311. /**
  109312. * Get the effect name of the layer.
  109313. * @return The effect name
  109314. */
  109315. getEffectName(): string;
  109316. /**
  109317. * Create the merge effect. This is the shader use to blit the information back
  109318. * to the main canvas at the end of the scene rendering.
  109319. */
  109320. protected _createMergeEffect(): Effect;
  109321. /**
  109322. * Creates the render target textures and post processes used in the glow layer.
  109323. */
  109324. protected _createTextureAndPostProcesses(): void;
  109325. /**
  109326. * Checks for the readiness of the element composing the layer.
  109327. * @param subMesh the mesh to check for
  109328. * @param useInstances specify wether or not to use instances to render the mesh
  109329. * @param emissiveTexture the associated emissive texture used to generate the glow
  109330. * @return true if ready otherwise, false
  109331. */
  109332. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  109333. /**
  109334. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  109335. */
  109336. needStencil(): boolean;
  109337. /**
  109338. * Returns true if the mesh can be rendered, otherwise false.
  109339. * @param mesh The mesh to render
  109340. * @param material The material used on the mesh
  109341. * @returns true if it can be rendered otherwise false
  109342. */
  109343. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  109344. /**
  109345. * Implementation specific of rendering the generating effect on the main canvas.
  109346. * @param effect The effect used to render through
  109347. */
  109348. protected _internalRender(effect: Effect): void;
  109349. /**
  109350. * Sets the required values for both the emissive texture and and the main color.
  109351. */
  109352. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  109353. /**
  109354. * Returns true if the mesh should render, otherwise false.
  109355. * @param mesh The mesh to render
  109356. * @returns true if it should render otherwise false
  109357. */
  109358. protected _shouldRenderMesh(mesh: Mesh): boolean;
  109359. /**
  109360. * Adds specific effects defines.
  109361. * @param defines The defines to add specifics to.
  109362. */
  109363. protected _addCustomEffectDefines(defines: string[]): void;
  109364. /**
  109365. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  109366. * @param mesh The mesh to exclude from the glow layer
  109367. */
  109368. addExcludedMesh(mesh: Mesh): void;
  109369. /**
  109370. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  109371. * @param mesh The mesh to remove
  109372. */
  109373. removeExcludedMesh(mesh: Mesh): void;
  109374. /**
  109375. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  109376. * @param mesh The mesh to include in the glow layer
  109377. */
  109378. addIncludedOnlyMesh(mesh: Mesh): void;
  109379. /**
  109380. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  109381. * @param mesh The mesh to remove
  109382. */
  109383. removeIncludedOnlyMesh(mesh: Mesh): void;
  109384. /**
  109385. * Determine if a given mesh will be used in the glow layer
  109386. * @param mesh The mesh to test
  109387. * @returns true if the mesh will be highlighted by the current glow layer
  109388. */
  109389. hasMesh(mesh: AbstractMesh): boolean;
  109390. /**
  109391. * Free any resources and references associated to a mesh.
  109392. * Internal use
  109393. * @param mesh The mesh to free.
  109394. * @hidden
  109395. */
  109396. _disposeMesh(mesh: Mesh): void;
  109397. /**
  109398. * Gets the class name of the effect layer
  109399. * @returns the string with the class name of the effect layer
  109400. */
  109401. getClassName(): string;
  109402. /**
  109403. * Serializes this glow layer
  109404. * @returns a serialized glow layer object
  109405. */
  109406. serialize(): any;
  109407. /**
  109408. * Creates a Glow Layer from parsed glow layer data
  109409. * @param parsedGlowLayer defines glow layer data
  109410. * @param scene defines the current scene
  109411. * @param rootUrl defines the root URL containing the glow layer information
  109412. * @returns a parsed Glow Layer
  109413. */
  109414. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  109415. }
  109416. }
  109417. declare module BABYLON {
  109418. /** @hidden */
  109419. export var glowBlurPostProcessPixelShader: {
  109420. name: string;
  109421. shader: string;
  109422. };
  109423. }
  109424. declare module BABYLON {
  109425. interface AbstractScene {
  109426. /**
  109427. * Return a the first highlight layer of the scene with a given name.
  109428. * @param name The name of the highlight layer to look for.
  109429. * @return The highlight layer if found otherwise null.
  109430. */
  109431. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  109432. }
  109433. /**
  109434. * Highlight layer options. This helps customizing the behaviour
  109435. * of the highlight layer.
  109436. */
  109437. export interface IHighlightLayerOptions {
  109438. /**
  109439. * Multiplication factor apply to the canvas size to compute the render target size
  109440. * used to generated the glowing objects (the smaller the faster).
  109441. */
  109442. mainTextureRatio: number;
  109443. /**
  109444. * Enforces a fixed size texture to ensure resize independant blur.
  109445. */
  109446. mainTextureFixedSize?: number;
  109447. /**
  109448. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  109449. * of the picture to blur (the smaller the faster).
  109450. */
  109451. blurTextureSizeRatio: number;
  109452. /**
  109453. * How big in texel of the blur texture is the vertical blur.
  109454. */
  109455. blurVerticalSize: number;
  109456. /**
  109457. * How big in texel of the blur texture is the horizontal blur.
  109458. */
  109459. blurHorizontalSize: number;
  109460. /**
  109461. * Alpha blending mode used to apply the blur. Default is combine.
  109462. */
  109463. alphaBlendingMode: number;
  109464. /**
  109465. * The camera attached to the layer.
  109466. */
  109467. camera: Nullable<Camera>;
  109468. /**
  109469. * Should we display highlight as a solid stroke?
  109470. */
  109471. isStroke?: boolean;
  109472. /**
  109473. * The rendering group to draw the layer in.
  109474. */
  109475. renderingGroupId: number;
  109476. }
  109477. /**
  109478. * The highlight layer Helps adding a glow effect around a mesh.
  109479. *
  109480. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  109481. * glowy meshes to your scene.
  109482. *
  109483. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  109484. */
  109485. export class HighlightLayer extends EffectLayer {
  109486. name: string;
  109487. /**
  109488. * Effect Name of the highlight layer.
  109489. */
  109490. static readonly EffectName: string;
  109491. /**
  109492. * The neutral color used during the preparation of the glow effect.
  109493. * This is black by default as the blend operation is a blend operation.
  109494. */
  109495. static NeutralColor: Color4;
  109496. /**
  109497. * Stencil value used for glowing meshes.
  109498. */
  109499. static GlowingMeshStencilReference: number;
  109500. /**
  109501. * Stencil value used for the other meshes in the scene.
  109502. */
  109503. static NormalMeshStencilReference: number;
  109504. /**
  109505. * Specifies whether or not the inner glow is ACTIVE in the layer.
  109506. */
  109507. innerGlow: boolean;
  109508. /**
  109509. * Specifies whether or not the outer glow is ACTIVE in the layer.
  109510. */
  109511. outerGlow: boolean;
  109512. /**
  109513. * Specifies the horizontal size of the blur.
  109514. */
  109515. /**
  109516. * Gets the horizontal size of the blur.
  109517. */
  109518. blurHorizontalSize: number;
  109519. /**
  109520. * Specifies the vertical size of the blur.
  109521. */
  109522. /**
  109523. * Gets the vertical size of the blur.
  109524. */
  109525. blurVerticalSize: number;
  109526. /**
  109527. * An event triggered when the highlight layer is being blurred.
  109528. */
  109529. onBeforeBlurObservable: Observable<HighlightLayer>;
  109530. /**
  109531. * An event triggered when the highlight layer has been blurred.
  109532. */
  109533. onAfterBlurObservable: Observable<HighlightLayer>;
  109534. private _instanceGlowingMeshStencilReference;
  109535. private _options;
  109536. private _downSamplePostprocess;
  109537. private _horizontalBlurPostprocess;
  109538. private _verticalBlurPostprocess;
  109539. private _blurTexture;
  109540. private _meshes;
  109541. private _excludedMeshes;
  109542. /**
  109543. * Instantiates a new highlight Layer and references it to the scene..
  109544. * @param name The name of the layer
  109545. * @param scene The scene to use the layer in
  109546. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  109547. */
  109548. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  109549. /**
  109550. * Get the effect name of the layer.
  109551. * @return The effect name
  109552. */
  109553. getEffectName(): string;
  109554. /**
  109555. * Create the merge effect. This is the shader use to blit the information back
  109556. * to the main canvas at the end of the scene rendering.
  109557. */
  109558. protected _createMergeEffect(): Effect;
  109559. /**
  109560. * Creates the render target textures and post processes used in the highlight layer.
  109561. */
  109562. protected _createTextureAndPostProcesses(): void;
  109563. /**
  109564. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  109565. */
  109566. needStencil(): boolean;
  109567. /**
  109568. * Checks for the readiness of the element composing the layer.
  109569. * @param subMesh the mesh to check for
  109570. * @param useInstances specify wether or not to use instances to render the mesh
  109571. * @param emissiveTexture the associated emissive texture used to generate the glow
  109572. * @return true if ready otherwise, false
  109573. */
  109574. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  109575. /**
  109576. * Implementation specific of rendering the generating effect on the main canvas.
  109577. * @param effect The effect used to render through
  109578. */
  109579. protected _internalRender(effect: Effect): void;
  109580. /**
  109581. * Returns true if the layer contains information to display, otherwise false.
  109582. */
  109583. shouldRender(): boolean;
  109584. /**
  109585. * Returns true if the mesh should render, otherwise false.
  109586. * @param mesh The mesh to render
  109587. * @returns true if it should render otherwise false
  109588. */
  109589. protected _shouldRenderMesh(mesh: Mesh): boolean;
  109590. /**
  109591. * Sets the required values for both the emissive texture and and the main color.
  109592. */
  109593. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  109594. /**
  109595. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  109596. * @param mesh The mesh to exclude from the highlight layer
  109597. */
  109598. addExcludedMesh(mesh: Mesh): void;
  109599. /**
  109600. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  109601. * @param mesh The mesh to highlight
  109602. */
  109603. removeExcludedMesh(mesh: Mesh): void;
  109604. /**
  109605. * Determine if a given mesh will be highlighted by the current HighlightLayer
  109606. * @param mesh mesh to test
  109607. * @returns true if the mesh will be highlighted by the current HighlightLayer
  109608. */
  109609. hasMesh(mesh: AbstractMesh): boolean;
  109610. /**
  109611. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  109612. * @param mesh The mesh to highlight
  109613. * @param color The color of the highlight
  109614. * @param glowEmissiveOnly Extract the glow from the emissive texture
  109615. */
  109616. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  109617. /**
  109618. * Remove a mesh from the highlight layer in order to make it stop glowing.
  109619. * @param mesh The mesh to highlight
  109620. */
  109621. removeMesh(mesh: Mesh): void;
  109622. /**
  109623. * Force the stencil to the normal expected value for none glowing parts
  109624. */
  109625. private _defaultStencilReference;
  109626. /**
  109627. * Free any resources and references associated to a mesh.
  109628. * Internal use
  109629. * @param mesh The mesh to free.
  109630. * @hidden
  109631. */
  109632. _disposeMesh(mesh: Mesh): void;
  109633. /**
  109634. * Dispose the highlight layer and free resources.
  109635. */
  109636. dispose(): void;
  109637. /**
  109638. * Gets the class name of the effect layer
  109639. * @returns the string with the class name of the effect layer
  109640. */
  109641. getClassName(): string;
  109642. /**
  109643. * Serializes this Highlight layer
  109644. * @returns a serialized Highlight layer object
  109645. */
  109646. serialize(): any;
  109647. /**
  109648. * Creates a Highlight layer from parsed Highlight layer data
  109649. * @param parsedHightlightLayer defines the Highlight layer data
  109650. * @param scene defines the current scene
  109651. * @param rootUrl defines the root URL containing the Highlight layer information
  109652. * @returns a parsed Highlight layer
  109653. */
  109654. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  109655. }
  109656. }
  109657. declare module BABYLON {
  109658. interface AbstractScene {
  109659. /**
  109660. * The list of layers (background and foreground) of the scene
  109661. */
  109662. layers: Array<Layer>;
  109663. }
  109664. /**
  109665. * Defines the layer scene component responsible to manage any layers
  109666. * in a given scene.
  109667. */
  109668. export class LayerSceneComponent implements ISceneComponent {
  109669. /**
  109670. * The component name helpfull to identify the component in the list of scene components.
  109671. */
  109672. readonly name: string;
  109673. /**
  109674. * The scene the component belongs to.
  109675. */
  109676. scene: Scene;
  109677. private _engine;
  109678. /**
  109679. * Creates a new instance of the component for the given scene
  109680. * @param scene Defines the scene to register the component in
  109681. */
  109682. constructor(scene: Scene);
  109683. /**
  109684. * Registers the component in a given scene
  109685. */
  109686. register(): void;
  109687. /**
  109688. * Rebuilds the elements related to this component in case of
  109689. * context lost for instance.
  109690. */
  109691. rebuild(): void;
  109692. /**
  109693. * Disposes the component and the associated ressources.
  109694. */
  109695. dispose(): void;
  109696. private _draw;
  109697. private _drawCameraPredicate;
  109698. private _drawCameraBackground;
  109699. private _drawCameraForeground;
  109700. private _drawRenderTargetPredicate;
  109701. private _drawRenderTargetBackground;
  109702. private _drawRenderTargetForeground;
  109703. /**
  109704. * Adds all the elements from the container to the scene
  109705. * @param container the container holding the elements
  109706. */
  109707. addFromContainer(container: AbstractScene): void;
  109708. /**
  109709. * Removes all the elements in the container from the scene
  109710. * @param container contains the elements to remove
  109711. * @param dispose if the removed element should be disposed (default: false)
  109712. */
  109713. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  109714. }
  109715. }
  109716. declare module BABYLON {
  109717. /** @hidden */
  109718. export var layerPixelShader: {
  109719. name: string;
  109720. shader: string;
  109721. };
  109722. }
  109723. declare module BABYLON {
  109724. /** @hidden */
  109725. export var layerVertexShader: {
  109726. name: string;
  109727. shader: string;
  109728. };
  109729. }
  109730. declare module BABYLON {
  109731. /**
  109732. * This represents a full screen 2d layer.
  109733. * This can be useful to display a picture in the background of your scene for instance.
  109734. * @see https://www.babylonjs-playground.com/#08A2BS#1
  109735. */
  109736. export class Layer {
  109737. /**
  109738. * Define the name of the layer.
  109739. */
  109740. name: string;
  109741. /**
  109742. * Define the texture the layer should display.
  109743. */
  109744. texture: Nullable<Texture>;
  109745. /**
  109746. * Is the layer in background or foreground.
  109747. */
  109748. isBackground: boolean;
  109749. /**
  109750. * Define the color of the layer (instead of texture).
  109751. */
  109752. color: Color4;
  109753. /**
  109754. * Define the scale of the layer in order to zoom in out of the texture.
  109755. */
  109756. scale: Vector2;
  109757. /**
  109758. * Define an offset for the layer in order to shift the texture.
  109759. */
  109760. offset: Vector2;
  109761. /**
  109762. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  109763. */
  109764. alphaBlendingMode: number;
  109765. /**
  109766. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  109767. * Alpha test will not mix with the background color in case of transparency.
  109768. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  109769. */
  109770. alphaTest: boolean;
  109771. /**
  109772. * Define a mask to restrict the layer to only some of the scene cameras.
  109773. */
  109774. layerMask: number;
  109775. /**
  109776. * Define the list of render target the layer is visible into.
  109777. */
  109778. renderTargetTextures: RenderTargetTexture[];
  109779. /**
  109780. * Define if the layer is only used in renderTarget or if it also
  109781. * renders in the main frame buffer of the canvas.
  109782. */
  109783. renderOnlyInRenderTargetTextures: boolean;
  109784. private _scene;
  109785. private _vertexBuffers;
  109786. private _indexBuffer;
  109787. private _effect;
  109788. private _alphaTestEffect;
  109789. /**
  109790. * An event triggered when the layer is disposed.
  109791. */
  109792. onDisposeObservable: Observable<Layer>;
  109793. private _onDisposeObserver;
  109794. /**
  109795. * Back compatibility with callback before the onDisposeObservable existed.
  109796. * The set callback will be triggered when the layer has been disposed.
  109797. */
  109798. onDispose: () => void;
  109799. /**
  109800. * An event triggered before rendering the scene
  109801. */
  109802. onBeforeRenderObservable: Observable<Layer>;
  109803. private _onBeforeRenderObserver;
  109804. /**
  109805. * Back compatibility with callback before the onBeforeRenderObservable existed.
  109806. * The set callback will be triggered just before rendering the layer.
  109807. */
  109808. onBeforeRender: () => void;
  109809. /**
  109810. * An event triggered after rendering the scene
  109811. */
  109812. onAfterRenderObservable: Observable<Layer>;
  109813. private _onAfterRenderObserver;
  109814. /**
  109815. * Back compatibility with callback before the onAfterRenderObservable existed.
  109816. * The set callback will be triggered just after rendering the layer.
  109817. */
  109818. onAfterRender: () => void;
  109819. /**
  109820. * Instantiates a new layer.
  109821. * This represents a full screen 2d layer.
  109822. * This can be useful to display a picture in the background of your scene for instance.
  109823. * @see https://www.babylonjs-playground.com/#08A2BS#1
  109824. * @param name Define the name of the layer in the scene
  109825. * @param imgUrl Define the url of the texture to display in the layer
  109826. * @param scene Define the scene the layer belongs to
  109827. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  109828. * @param color Defines a color for the layer
  109829. */
  109830. constructor(
  109831. /**
  109832. * Define the name of the layer.
  109833. */
  109834. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  109835. private _createIndexBuffer;
  109836. /** @hidden */
  109837. _rebuild(): void;
  109838. /**
  109839. * Renders the layer in the scene.
  109840. */
  109841. render(): void;
  109842. /**
  109843. * Disposes and releases the associated ressources.
  109844. */
  109845. dispose(): void;
  109846. }
  109847. }
  109848. declare module BABYLON {
  109849. /** @hidden */
  109850. export var lensFlarePixelShader: {
  109851. name: string;
  109852. shader: string;
  109853. };
  109854. }
  109855. declare module BABYLON {
  109856. /** @hidden */
  109857. export var lensFlareVertexShader: {
  109858. name: string;
  109859. shader: string;
  109860. };
  109861. }
  109862. declare module BABYLON {
  109863. /**
  109864. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  109865. * It is usually composed of several `lensFlare`.
  109866. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  109867. */
  109868. export class LensFlareSystem {
  109869. /**
  109870. * Define the name of the lens flare system
  109871. */
  109872. name: string;
  109873. /**
  109874. * List of lens flares used in this system.
  109875. */
  109876. lensFlares: LensFlare[];
  109877. /**
  109878. * Define a limit from the border the lens flare can be visible.
  109879. */
  109880. borderLimit: number;
  109881. /**
  109882. * Define a viewport border we do not want to see the lens flare in.
  109883. */
  109884. viewportBorder: number;
  109885. /**
  109886. * Define a predicate which could limit the list of meshes able to occlude the effect.
  109887. */
  109888. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  109889. /**
  109890. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  109891. */
  109892. layerMask: number;
  109893. /**
  109894. * Define the id of the lens flare system in the scene.
  109895. * (equal to name by default)
  109896. */
  109897. id: string;
  109898. private _scene;
  109899. private _emitter;
  109900. private _vertexBuffers;
  109901. private _indexBuffer;
  109902. private _effect;
  109903. private _positionX;
  109904. private _positionY;
  109905. private _isEnabled;
  109906. /** @hidden */
  109907. static _SceneComponentInitialization: (scene: Scene) => void;
  109908. /**
  109909. * Instantiates a lens flare system.
  109910. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  109911. * It is usually composed of several `lensFlare`.
  109912. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  109913. * @param name Define the name of the lens flare system in the scene
  109914. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  109915. * @param scene Define the scene the lens flare system belongs to
  109916. */
  109917. constructor(
  109918. /**
  109919. * Define the name of the lens flare system
  109920. */
  109921. name: string, emitter: any, scene: Scene);
  109922. /**
  109923. * Define if the lens flare system is enabled.
  109924. */
  109925. isEnabled: boolean;
  109926. /**
  109927. * Get the scene the effects belongs to.
  109928. * @returns the scene holding the lens flare system
  109929. */
  109930. getScene(): Scene;
  109931. /**
  109932. * Get the emitter of the lens flare system.
  109933. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  109934. * @returns the emitter of the lens flare system
  109935. */
  109936. getEmitter(): any;
  109937. /**
  109938. * Set the emitter of the lens flare system.
  109939. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  109940. * @param newEmitter Define the new emitter of the system
  109941. */
  109942. setEmitter(newEmitter: any): void;
  109943. /**
  109944. * Get the lens flare system emitter position.
  109945. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  109946. * @returns the position
  109947. */
  109948. getEmitterPosition(): Vector3;
  109949. /**
  109950. * @hidden
  109951. */
  109952. computeEffectivePosition(globalViewport: Viewport): boolean;
  109953. /** @hidden */
  109954. _isVisible(): boolean;
  109955. /**
  109956. * @hidden
  109957. */
  109958. render(): boolean;
  109959. /**
  109960. * Dispose and release the lens flare with its associated resources.
  109961. */
  109962. dispose(): void;
  109963. /**
  109964. * Parse a lens flare system from a JSON repressentation
  109965. * @param parsedLensFlareSystem Define the JSON to parse
  109966. * @param scene Define the scene the parsed system should be instantiated in
  109967. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  109968. * @returns the parsed system
  109969. */
  109970. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  109971. /**
  109972. * Serialize the current Lens Flare System into a JSON representation.
  109973. * @returns the serialized JSON
  109974. */
  109975. serialize(): any;
  109976. }
  109977. }
  109978. declare module BABYLON {
  109979. /**
  109980. * This represents one of the lens effect in a `lensFlareSystem`.
  109981. * It controls one of the indiviual texture used in the effect.
  109982. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  109983. */
  109984. export class LensFlare {
  109985. /**
  109986. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  109987. */
  109988. size: number;
  109989. /**
  109990. * 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.
  109991. */
  109992. position: number;
  109993. /**
  109994. * Define the lens color.
  109995. */
  109996. color: Color3;
  109997. /**
  109998. * Define the lens texture.
  109999. */
  110000. texture: Nullable<Texture>;
  110001. /**
  110002. * Define the alpha mode to render this particular lens.
  110003. */
  110004. alphaMode: number;
  110005. private _system;
  110006. /**
  110007. * Creates a new Lens Flare.
  110008. * This represents one of the lens effect in a `lensFlareSystem`.
  110009. * It controls one of the indiviual texture used in the effect.
  110010. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  110011. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  110012. * @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.
  110013. * @param color Define the lens color
  110014. * @param imgUrl Define the lens texture url
  110015. * @param system Define the `lensFlareSystem` this flare is part of
  110016. * @returns The newly created Lens Flare
  110017. */
  110018. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  110019. /**
  110020. * Instantiates a new Lens Flare.
  110021. * This represents one of the lens effect in a `lensFlareSystem`.
  110022. * It controls one of the indiviual texture used in the effect.
  110023. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  110024. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  110025. * @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.
  110026. * @param color Define the lens color
  110027. * @param imgUrl Define the lens texture url
  110028. * @param system Define the `lensFlareSystem` this flare is part of
  110029. */
  110030. constructor(
  110031. /**
  110032. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  110033. */
  110034. size: number,
  110035. /**
  110036. * 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.
  110037. */
  110038. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  110039. /**
  110040. * Dispose and release the lens flare with its associated resources.
  110041. */
  110042. dispose(): void;
  110043. }
  110044. }
  110045. declare module BABYLON {
  110046. interface AbstractScene {
  110047. /**
  110048. * The list of lens flare system added to the scene
  110049. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  110050. */
  110051. lensFlareSystems: Array<LensFlareSystem>;
  110052. /**
  110053. * Removes the given lens flare system from this scene.
  110054. * @param toRemove The lens flare system to remove
  110055. * @returns The index of the removed lens flare system
  110056. */
  110057. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  110058. /**
  110059. * Adds the given lens flare system to this scene
  110060. * @param newLensFlareSystem The lens flare system to add
  110061. */
  110062. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  110063. /**
  110064. * Gets a lens flare system using its name
  110065. * @param name defines the name to look for
  110066. * @returns the lens flare system or null if not found
  110067. */
  110068. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  110069. /**
  110070. * Gets a lens flare system using its id
  110071. * @param id defines the id to look for
  110072. * @returns the lens flare system or null if not found
  110073. */
  110074. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  110075. }
  110076. /**
  110077. * Defines the lens flare scene component responsible to manage any lens flares
  110078. * in a given scene.
  110079. */
  110080. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  110081. /**
  110082. * The component name helpfull to identify the component in the list of scene components.
  110083. */
  110084. readonly name: string;
  110085. /**
  110086. * The scene the component belongs to.
  110087. */
  110088. scene: Scene;
  110089. /**
  110090. * Creates a new instance of the component for the given scene
  110091. * @param scene Defines the scene to register the component in
  110092. */
  110093. constructor(scene: Scene);
  110094. /**
  110095. * Registers the component in a given scene
  110096. */
  110097. register(): void;
  110098. /**
  110099. * Rebuilds the elements related to this component in case of
  110100. * context lost for instance.
  110101. */
  110102. rebuild(): void;
  110103. /**
  110104. * Adds all the elements from the container to the scene
  110105. * @param container the container holding the elements
  110106. */
  110107. addFromContainer(container: AbstractScene): void;
  110108. /**
  110109. * Removes all the elements in the container from the scene
  110110. * @param container contains the elements to remove
  110111. * @param dispose if the removed element should be disposed (default: false)
  110112. */
  110113. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  110114. /**
  110115. * Serializes the component data to the specified json object
  110116. * @param serializationObject The object to serialize to
  110117. */
  110118. serialize(serializationObject: any): void;
  110119. /**
  110120. * Disposes the component and the associated ressources.
  110121. */
  110122. dispose(): void;
  110123. private _draw;
  110124. }
  110125. }
  110126. declare module BABYLON {
  110127. /**
  110128. * Defines the shadow generator component responsible to manage any shadow generators
  110129. * in a given scene.
  110130. */
  110131. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  110132. /**
  110133. * The component name helpfull to identify the component in the list of scene components.
  110134. */
  110135. readonly name: string;
  110136. /**
  110137. * The scene the component belongs to.
  110138. */
  110139. scene: Scene;
  110140. /**
  110141. * Creates a new instance of the component for the given scene
  110142. * @param scene Defines the scene to register the component in
  110143. */
  110144. constructor(scene: Scene);
  110145. /**
  110146. * Registers the component in a given scene
  110147. */
  110148. register(): void;
  110149. /**
  110150. * Rebuilds the elements related to this component in case of
  110151. * context lost for instance.
  110152. */
  110153. rebuild(): void;
  110154. /**
  110155. * Serializes the component data to the specified json object
  110156. * @param serializationObject The object to serialize to
  110157. */
  110158. serialize(serializationObject: any): void;
  110159. /**
  110160. * Adds all the elements from the container to the scene
  110161. * @param container the container holding the elements
  110162. */
  110163. addFromContainer(container: AbstractScene): void;
  110164. /**
  110165. * Removes all the elements in the container from the scene
  110166. * @param container contains the elements to remove
  110167. * @param dispose if the removed element should be disposed (default: false)
  110168. */
  110169. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  110170. /**
  110171. * Rebuilds the elements related to this component in case of
  110172. * context lost for instance.
  110173. */
  110174. dispose(): void;
  110175. private _gatherRenderTargets;
  110176. }
  110177. }
  110178. declare module BABYLON {
  110179. /**
  110180. * A point light is a light defined by an unique point in world space.
  110181. * The light is emitted in every direction from this point.
  110182. * A good example of a point light is a standard light bulb.
  110183. * Documentation: https://doc.babylonjs.com/babylon101/lights
  110184. */
  110185. export class PointLight extends ShadowLight {
  110186. private _shadowAngle;
  110187. /**
  110188. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  110189. * This specifies what angle the shadow will use to be created.
  110190. *
  110191. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  110192. */
  110193. /**
  110194. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  110195. * This specifies what angle the shadow will use to be created.
  110196. *
  110197. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  110198. */
  110199. shadowAngle: number;
  110200. /**
  110201. * Gets the direction if it has been set.
  110202. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  110203. */
  110204. /**
  110205. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  110206. */
  110207. direction: Vector3;
  110208. /**
  110209. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  110210. * A PointLight emits the light in every direction.
  110211. * It can cast shadows.
  110212. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  110213. * ```javascript
  110214. * var pointLight = new PointLight("pl", camera.position, scene);
  110215. * ```
  110216. * Documentation : https://doc.babylonjs.com/babylon101/lights
  110217. * @param name The light friendly name
  110218. * @param position The position of the point light in the scene
  110219. * @param scene The scene the lights belongs to
  110220. */
  110221. constructor(name: string, position: Vector3, scene: Scene);
  110222. /**
  110223. * Returns the string "PointLight"
  110224. * @returns the class name
  110225. */
  110226. getClassName(): string;
  110227. /**
  110228. * Returns the integer 0.
  110229. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  110230. */
  110231. getTypeID(): number;
  110232. /**
  110233. * Specifies wether or not the shadowmap should be a cube texture.
  110234. * @returns true if the shadowmap needs to be a cube texture.
  110235. */
  110236. needCube(): boolean;
  110237. /**
  110238. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  110239. * @param faceIndex The index of the face we are computed the direction to generate shadow
  110240. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  110241. */
  110242. getShadowDirection(faceIndex?: number): Vector3;
  110243. /**
  110244. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  110245. * - fov = PI / 2
  110246. * - aspect ratio : 1.0
  110247. * - z-near and far equal to the active camera minZ and maxZ.
  110248. * Returns the PointLight.
  110249. */
  110250. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  110251. protected _buildUniformLayout(): void;
  110252. /**
  110253. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  110254. * @param effect The effect to update
  110255. * @param lightIndex The index of the light in the effect to update
  110256. * @returns The point light
  110257. */
  110258. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  110259. /**
  110260. * Prepares the list of defines specific to the light type.
  110261. * @param defines the list of defines
  110262. * @param lightIndex defines the index of the light for the effect
  110263. */
  110264. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  110265. }
  110266. }
  110267. declare module BABYLON {
  110268. /**
  110269. * Header information of HDR texture files.
  110270. */
  110271. export interface HDRInfo {
  110272. /**
  110273. * The height of the texture in pixels.
  110274. */
  110275. height: number;
  110276. /**
  110277. * The width of the texture in pixels.
  110278. */
  110279. width: number;
  110280. /**
  110281. * The index of the beginning of the data in the binary file.
  110282. */
  110283. dataPosition: number;
  110284. }
  110285. /**
  110286. * This groups tools to convert HDR texture to native colors array.
  110287. */
  110288. export class HDRTools {
  110289. private static Ldexp;
  110290. private static Rgbe2float;
  110291. private static readStringLine;
  110292. /**
  110293. * Reads header information from an RGBE texture stored in a native array.
  110294. * More information on this format are available here:
  110295. * https://en.wikipedia.org/wiki/RGBE_image_format
  110296. *
  110297. * @param uint8array The binary file stored in native array.
  110298. * @return The header information.
  110299. */
  110300. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  110301. /**
  110302. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  110303. * This RGBE texture needs to store the information as a panorama.
  110304. *
  110305. * More information on this format are available here:
  110306. * https://en.wikipedia.org/wiki/RGBE_image_format
  110307. *
  110308. * @param buffer The binary file stored in an array buffer.
  110309. * @param size The expected size of the extracted cubemap.
  110310. * @return The Cube Map information.
  110311. */
  110312. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  110313. /**
  110314. * Returns the pixels data extracted from an RGBE texture.
  110315. * This pixels will be stored left to right up to down in the R G B order in one array.
  110316. *
  110317. * More information on this format are available here:
  110318. * https://en.wikipedia.org/wiki/RGBE_image_format
  110319. *
  110320. * @param uint8array The binary file stored in an array buffer.
  110321. * @param hdrInfo The header information of the file.
  110322. * @return The pixels data in RGB right to left up to down order.
  110323. */
  110324. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  110325. private static RGBE_ReadPixels_RLE;
  110326. }
  110327. }
  110328. declare module BABYLON {
  110329. /**
  110330. * This represents a texture coming from an HDR input.
  110331. *
  110332. * The only supported format is currently panorama picture stored in RGBE format.
  110333. * Example of such files can be found on HDRLib: http://hdrlib.com/
  110334. */
  110335. export class HDRCubeTexture extends BaseTexture {
  110336. private static _facesMapping;
  110337. private _generateHarmonics;
  110338. private _noMipmap;
  110339. private _textureMatrix;
  110340. private _size;
  110341. private _onLoad;
  110342. private _onError;
  110343. /**
  110344. * The texture URL.
  110345. */
  110346. url: string;
  110347. /**
  110348. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  110349. */
  110350. coordinatesMode: number;
  110351. protected _isBlocking: boolean;
  110352. /**
  110353. * Sets wether or not the texture is blocking during loading.
  110354. */
  110355. /**
  110356. * Gets wether or not the texture is blocking during loading.
  110357. */
  110358. isBlocking: boolean;
  110359. protected _rotationY: number;
  110360. /**
  110361. * Sets texture matrix rotation angle around Y axis in radians.
  110362. */
  110363. /**
  110364. * Gets texture matrix rotation angle around Y axis radians.
  110365. */
  110366. rotationY: number;
  110367. /**
  110368. * Gets or sets the center of the bounding box associated with the cube texture
  110369. * It must define where the camera used to render the texture was set
  110370. */
  110371. boundingBoxPosition: Vector3;
  110372. private _boundingBoxSize;
  110373. /**
  110374. * Gets or sets the size of the bounding box associated with the cube texture
  110375. * When defined, the cubemap will switch to local mode
  110376. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  110377. * @example https://www.babylonjs-playground.com/#RNASML
  110378. */
  110379. boundingBoxSize: Vector3;
  110380. /**
  110381. * Instantiates an HDRTexture from the following parameters.
  110382. *
  110383. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  110384. * @param scene The scene the texture will be used in
  110385. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  110386. * @param noMipmap Forces to not generate the mipmap if true
  110387. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  110388. * @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)
  110389. * @param reserved Reserved flag for internal use.
  110390. */
  110391. 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>);
  110392. /**
  110393. * Get the current class name of the texture useful for serialization or dynamic coding.
  110394. * @returns "HDRCubeTexture"
  110395. */
  110396. getClassName(): string;
  110397. /**
  110398. * Occurs when the file is raw .hdr file.
  110399. */
  110400. private loadTexture;
  110401. clone(): HDRCubeTexture;
  110402. delayLoad(): void;
  110403. /**
  110404. * Get the texture reflection matrix used to rotate/transform the reflection.
  110405. * @returns the reflection matrix
  110406. */
  110407. getReflectionTextureMatrix(): Matrix;
  110408. /**
  110409. * Set the texture reflection matrix used to rotate/transform the reflection.
  110410. * @param value Define the reflection matrix to set
  110411. */
  110412. setReflectionTextureMatrix(value: Matrix): void;
  110413. /**
  110414. * Parses a JSON representation of an HDR Texture in order to create the texture
  110415. * @param parsedTexture Define the JSON representation
  110416. * @param scene Define the scene the texture should be created in
  110417. * @param rootUrl Define the root url in case we need to load relative dependencies
  110418. * @returns the newly created texture after parsing
  110419. */
  110420. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  110421. serialize(): any;
  110422. }
  110423. }
  110424. declare module BABYLON {
  110425. /**
  110426. * Class used to control physics engine
  110427. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  110428. */
  110429. export class PhysicsEngine implements IPhysicsEngine {
  110430. private _physicsPlugin;
  110431. /**
  110432. * Global value used to control the smallest number supported by the simulation
  110433. */
  110434. static Epsilon: number;
  110435. private _impostors;
  110436. private _joints;
  110437. /**
  110438. * Gets the gravity vector used by the simulation
  110439. */
  110440. gravity: Vector3;
  110441. /**
  110442. * Factory used to create the default physics plugin.
  110443. * @returns The default physics plugin
  110444. */
  110445. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  110446. /**
  110447. * Creates a new Physics Engine
  110448. * @param gravity defines the gravity vector used by the simulation
  110449. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  110450. */
  110451. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  110452. /**
  110453. * Sets the gravity vector used by the simulation
  110454. * @param gravity defines the gravity vector to use
  110455. */
  110456. setGravity(gravity: Vector3): void;
  110457. /**
  110458. * Set the time step of the physics engine.
  110459. * Default is 1/60.
  110460. * To slow it down, enter 1/600 for example.
  110461. * To speed it up, 1/30
  110462. * @param newTimeStep defines the new timestep to apply to this world.
  110463. */
  110464. setTimeStep(newTimeStep?: number): void;
  110465. /**
  110466. * Get the time step of the physics engine.
  110467. * @returns the current time step
  110468. */
  110469. getTimeStep(): number;
  110470. /**
  110471. * Release all resources
  110472. */
  110473. dispose(): void;
  110474. /**
  110475. * Gets the name of the current physics plugin
  110476. * @returns the name of the plugin
  110477. */
  110478. getPhysicsPluginName(): string;
  110479. /**
  110480. * Adding a new impostor for the impostor tracking.
  110481. * This will be done by the impostor itself.
  110482. * @param impostor the impostor to add
  110483. */
  110484. addImpostor(impostor: PhysicsImpostor): void;
  110485. /**
  110486. * Remove an impostor from the engine.
  110487. * This impostor and its mesh will not longer be updated by the physics engine.
  110488. * @param impostor the impostor to remove
  110489. */
  110490. removeImpostor(impostor: PhysicsImpostor): void;
  110491. /**
  110492. * Add a joint to the physics engine
  110493. * @param mainImpostor defines the main impostor to which the joint is added.
  110494. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  110495. * @param joint defines the joint that will connect both impostors.
  110496. */
  110497. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  110498. /**
  110499. * Removes a joint from the simulation
  110500. * @param mainImpostor defines the impostor used with the joint
  110501. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  110502. * @param joint defines the joint to remove
  110503. */
  110504. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  110505. /**
  110506. * Called by the scene. No need to call it.
  110507. * @param delta defines the timespam between frames
  110508. */
  110509. _step(delta: number): void;
  110510. /**
  110511. * Gets the current plugin used to run the simulation
  110512. * @returns current plugin
  110513. */
  110514. getPhysicsPlugin(): IPhysicsEnginePlugin;
  110515. /**
  110516. * Gets the list of physic impostors
  110517. * @returns an array of PhysicsImpostor
  110518. */
  110519. getImpostors(): Array<PhysicsImpostor>;
  110520. /**
  110521. * Gets the impostor for a physics enabled object
  110522. * @param object defines the object impersonated by the impostor
  110523. * @returns the PhysicsImpostor or null if not found
  110524. */
  110525. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  110526. /**
  110527. * Gets the impostor for a physics body object
  110528. * @param body defines physics body used by the impostor
  110529. * @returns the PhysicsImpostor or null if not found
  110530. */
  110531. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  110532. /**
  110533. * Does a raycast in the physics world
  110534. * @param from when should the ray start?
  110535. * @param to when should the ray end?
  110536. * @returns PhysicsRaycastResult
  110537. */
  110538. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  110539. }
  110540. }
  110541. declare module BABYLON {
  110542. /** @hidden */
  110543. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  110544. private _useDeltaForWorldStep;
  110545. world: any;
  110546. name: string;
  110547. private _physicsMaterials;
  110548. private _fixedTimeStep;
  110549. private _cannonRaycastResult;
  110550. private _raycastResult;
  110551. private _removeAfterStep;
  110552. BJSCANNON: any;
  110553. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  110554. setGravity(gravity: Vector3): void;
  110555. setTimeStep(timeStep: number): void;
  110556. getTimeStep(): number;
  110557. executeStep(delta: number): void;
  110558. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  110559. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  110560. generatePhysicsBody(impostor: PhysicsImpostor): void;
  110561. private _processChildMeshes;
  110562. removePhysicsBody(impostor: PhysicsImpostor): void;
  110563. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  110564. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  110565. private _addMaterial;
  110566. private _checkWithEpsilon;
  110567. private _createShape;
  110568. private _createHeightmap;
  110569. private _minus90X;
  110570. private _plus90X;
  110571. private _tmpPosition;
  110572. private _tmpDeltaPosition;
  110573. private _tmpUnityRotation;
  110574. private _updatePhysicsBodyTransformation;
  110575. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  110576. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  110577. isSupported(): boolean;
  110578. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  110579. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  110580. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  110581. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  110582. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  110583. getBodyMass(impostor: PhysicsImpostor): number;
  110584. getBodyFriction(impostor: PhysicsImpostor): number;
  110585. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  110586. getBodyRestitution(impostor: PhysicsImpostor): number;
  110587. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  110588. sleepBody(impostor: PhysicsImpostor): void;
  110589. wakeUpBody(impostor: PhysicsImpostor): void;
  110590. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  110591. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  110592. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  110593. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  110594. getRadius(impostor: PhysicsImpostor): number;
  110595. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  110596. dispose(): void;
  110597. private _extendNamespace;
  110598. /**
  110599. * Does a raycast in the physics world
  110600. * @param from when should the ray start?
  110601. * @param to when should the ray end?
  110602. * @returns PhysicsRaycastResult
  110603. */
  110604. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  110605. }
  110606. }
  110607. declare module BABYLON {
  110608. /** @hidden */
  110609. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  110610. world: any;
  110611. name: string;
  110612. BJSOIMO: any;
  110613. private _raycastResult;
  110614. constructor(iterations?: number, oimoInjection?: any);
  110615. setGravity(gravity: Vector3): void;
  110616. setTimeStep(timeStep: number): void;
  110617. getTimeStep(): number;
  110618. private _tmpImpostorsArray;
  110619. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  110620. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  110621. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  110622. generatePhysicsBody(impostor: PhysicsImpostor): void;
  110623. private _tmpPositionVector;
  110624. removePhysicsBody(impostor: PhysicsImpostor): void;
  110625. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  110626. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  110627. isSupported(): boolean;
  110628. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  110629. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  110630. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  110631. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  110632. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  110633. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  110634. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  110635. getBodyMass(impostor: PhysicsImpostor): number;
  110636. getBodyFriction(impostor: PhysicsImpostor): number;
  110637. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  110638. getBodyRestitution(impostor: PhysicsImpostor): number;
  110639. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  110640. sleepBody(impostor: PhysicsImpostor): void;
  110641. wakeUpBody(impostor: PhysicsImpostor): void;
  110642. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  110643. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  110644. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  110645. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  110646. getRadius(impostor: PhysicsImpostor): number;
  110647. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  110648. dispose(): void;
  110649. /**
  110650. * Does a raycast in the physics world
  110651. * @param from when should the ray start?
  110652. * @param to when should the ray end?
  110653. * @returns PhysicsRaycastResult
  110654. */
  110655. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  110656. }
  110657. }
  110658. declare module BABYLON {
  110659. /**
  110660. * Class containing static functions to help procedurally build meshes
  110661. */
  110662. export class RibbonBuilder {
  110663. /**
  110664. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  110665. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  110666. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  110667. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  110668. * * 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
  110669. * * 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
  110670. * * 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
  110671. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110672. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110673. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  110674. * * 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
  110675. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  110676. * * 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
  110677. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  110678. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110679. * @param name defines the name of the mesh
  110680. * @param options defines the options used to create the mesh
  110681. * @param scene defines the hosting scene
  110682. * @returns the ribbon mesh
  110683. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  110684. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  110685. */
  110686. static CreateRibbon(name: string, options: {
  110687. pathArray: Vector3[][];
  110688. closeArray?: boolean;
  110689. closePath?: boolean;
  110690. offset?: number;
  110691. updatable?: boolean;
  110692. sideOrientation?: number;
  110693. frontUVs?: Vector4;
  110694. backUVs?: Vector4;
  110695. instance?: Mesh;
  110696. invertUV?: boolean;
  110697. uvs?: Vector2[];
  110698. colors?: Color4[];
  110699. }, scene?: Nullable<Scene>): Mesh;
  110700. }
  110701. }
  110702. declare module BABYLON {
  110703. /**
  110704. * Class containing static functions to help procedurally build meshes
  110705. */
  110706. export class ShapeBuilder {
  110707. /**
  110708. * 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.
  110709. * * 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.
  110710. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  110711. * * 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.
  110712. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  110713. * * 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
  110714. * * 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
  110715. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  110716. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110717. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110718. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  110719. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  110720. * @param name defines the name of the mesh
  110721. * @param options defines the options used to create the mesh
  110722. * @param scene defines the hosting scene
  110723. * @returns the extruded shape mesh
  110724. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  110725. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  110726. */
  110727. static ExtrudeShape(name: string, options: {
  110728. shape: Vector3[];
  110729. path: Vector3[];
  110730. scale?: number;
  110731. rotation?: number;
  110732. cap?: number;
  110733. updatable?: boolean;
  110734. sideOrientation?: number;
  110735. frontUVs?: Vector4;
  110736. backUVs?: Vector4;
  110737. instance?: Mesh;
  110738. invertUV?: boolean;
  110739. }, scene?: Nullable<Scene>): Mesh;
  110740. /**
  110741. * Creates an custom extruded shape mesh.
  110742. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  110743. * * 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.
  110744. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  110745. * * 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
  110746. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  110747. * * 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
  110748. * * It must returns a float value that will be the scale value applied to the shape on each path point
  110749. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  110750. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  110751. * * 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
  110752. * * 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
  110753. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  110754. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110755. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110756. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  110757. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110758. * @param name defines the name of the mesh
  110759. * @param options defines the options used to create the mesh
  110760. * @param scene defines the hosting scene
  110761. * @returns the custom extruded shape mesh
  110762. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  110763. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  110764. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  110765. */
  110766. static ExtrudeShapeCustom(name: string, options: {
  110767. shape: Vector3[];
  110768. path: Vector3[];
  110769. scaleFunction?: any;
  110770. rotationFunction?: any;
  110771. ribbonCloseArray?: boolean;
  110772. ribbonClosePath?: boolean;
  110773. cap?: number;
  110774. updatable?: boolean;
  110775. sideOrientation?: number;
  110776. frontUVs?: Vector4;
  110777. backUVs?: Vector4;
  110778. instance?: Mesh;
  110779. invertUV?: boolean;
  110780. }, scene?: Nullable<Scene>): Mesh;
  110781. private static _ExtrudeShapeGeneric;
  110782. }
  110783. }
  110784. declare module BABYLON {
  110785. /**
  110786. * AmmoJS Physics plugin
  110787. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  110788. * @see https://github.com/kripken/ammo.js/
  110789. */
  110790. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  110791. private _useDeltaForWorldStep;
  110792. /**
  110793. * Reference to the Ammo library
  110794. */
  110795. bjsAMMO: any;
  110796. /**
  110797. * Created ammoJS world which physics bodies are added to
  110798. */
  110799. world: any;
  110800. /**
  110801. * Name of the plugin
  110802. */
  110803. name: string;
  110804. private _timeStep;
  110805. private _fixedTimeStep;
  110806. private _maxSteps;
  110807. private _tmpQuaternion;
  110808. private _tmpAmmoTransform;
  110809. private _tmpAmmoQuaternion;
  110810. private _tmpAmmoConcreteContactResultCallback;
  110811. private _collisionConfiguration;
  110812. private _dispatcher;
  110813. private _overlappingPairCache;
  110814. private _solver;
  110815. private _softBodySolver;
  110816. private _tmpAmmoVectorA;
  110817. private _tmpAmmoVectorB;
  110818. private _tmpAmmoVectorC;
  110819. private _tmpAmmoVectorD;
  110820. private _tmpContactCallbackResult;
  110821. private _tmpAmmoVectorRCA;
  110822. private _tmpAmmoVectorRCB;
  110823. private _raycastResult;
  110824. private static readonly DISABLE_COLLISION_FLAG;
  110825. private static readonly KINEMATIC_FLAG;
  110826. private static readonly DISABLE_DEACTIVATION_FLAG;
  110827. /**
  110828. * Initializes the ammoJS plugin
  110829. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  110830. * @param ammoInjection can be used to inject your own ammo reference
  110831. */
  110832. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  110833. /**
  110834. * Sets the gravity of the physics world (m/(s^2))
  110835. * @param gravity Gravity to set
  110836. */
  110837. setGravity(gravity: Vector3): void;
  110838. /**
  110839. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  110840. * @param timeStep timestep to use in seconds
  110841. */
  110842. setTimeStep(timeStep: number): void;
  110843. /**
  110844. * 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)
  110845. * @param fixedTimeStep fixedTimeStep to use in seconds
  110846. */
  110847. setFixedTimeStep(fixedTimeStep: number): void;
  110848. /**
  110849. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  110850. * @param maxSteps the maximum number of steps by the physics engine per frame
  110851. */
  110852. setMaxSteps(maxSteps: number): void;
  110853. /**
  110854. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  110855. * @returns the current timestep in seconds
  110856. */
  110857. getTimeStep(): number;
  110858. private _isImpostorInContact;
  110859. private _isImpostorPairInContact;
  110860. private _stepSimulation;
  110861. /**
  110862. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  110863. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  110864. * After the step the babylon meshes are set to the position of the physics imposters
  110865. * @param delta amount of time to step forward
  110866. * @param impostors array of imposters to update before/after the step
  110867. */
  110868. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  110869. /**
  110870. * Update babylon mesh to match physics world object
  110871. * @param impostor imposter to match
  110872. */
  110873. private _afterSoftStep;
  110874. /**
  110875. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  110876. * @param impostor imposter to match
  110877. */
  110878. private _ropeStep;
  110879. /**
  110880. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  110881. * @param impostor imposter to match
  110882. */
  110883. private _softbodyOrClothStep;
  110884. private _tmpVector;
  110885. private _tmpMatrix;
  110886. /**
  110887. * Applies an impulse on the imposter
  110888. * @param impostor imposter to apply impulse to
  110889. * @param force amount of force to be applied to the imposter
  110890. * @param contactPoint the location to apply the impulse on the imposter
  110891. */
  110892. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  110893. /**
  110894. * Applies a force on the imposter
  110895. * @param impostor imposter to apply force
  110896. * @param force amount of force to be applied to the imposter
  110897. * @param contactPoint the location to apply the force on the imposter
  110898. */
  110899. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  110900. /**
  110901. * Creates a physics body using the plugin
  110902. * @param impostor the imposter to create the physics body on
  110903. */
  110904. generatePhysicsBody(impostor: PhysicsImpostor): void;
  110905. /**
  110906. * Removes the physics body from the imposter and disposes of the body's memory
  110907. * @param impostor imposter to remove the physics body from
  110908. */
  110909. removePhysicsBody(impostor: PhysicsImpostor): void;
  110910. /**
  110911. * Generates a joint
  110912. * @param impostorJoint the imposter joint to create the joint with
  110913. */
  110914. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  110915. /**
  110916. * Removes a joint
  110917. * @param impostorJoint the imposter joint to remove the joint from
  110918. */
  110919. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  110920. private _addMeshVerts;
  110921. /**
  110922. * Initialise the soft body vertices to match its object's (mesh) vertices
  110923. * Softbody vertices (nodes) are in world space and to match this
  110924. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  110925. * @param impostor to create the softbody for
  110926. */
  110927. private _softVertexData;
  110928. /**
  110929. * Create an impostor's soft body
  110930. * @param impostor to create the softbody for
  110931. */
  110932. private _createSoftbody;
  110933. /**
  110934. * Create cloth for an impostor
  110935. * @param impostor to create the softbody for
  110936. */
  110937. private _createCloth;
  110938. /**
  110939. * Create rope for an impostor
  110940. * @param impostor to create the softbody for
  110941. */
  110942. private _createRope;
  110943. private _addHullVerts;
  110944. private _createShape;
  110945. /**
  110946. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  110947. * @param impostor imposter containing the physics body and babylon object
  110948. */
  110949. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  110950. /**
  110951. * Sets the babylon object's position/rotation from the physics body's position/rotation
  110952. * @param impostor imposter containing the physics body and babylon object
  110953. * @param newPosition new position
  110954. * @param newRotation new rotation
  110955. */
  110956. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  110957. /**
  110958. * If this plugin is supported
  110959. * @returns true if its supported
  110960. */
  110961. isSupported(): boolean;
  110962. /**
  110963. * Sets the linear velocity of the physics body
  110964. * @param impostor imposter to set the velocity on
  110965. * @param velocity velocity to set
  110966. */
  110967. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  110968. /**
  110969. * Sets the angular velocity of the physics body
  110970. * @param impostor imposter to set the velocity on
  110971. * @param velocity velocity to set
  110972. */
  110973. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  110974. /**
  110975. * gets the linear velocity
  110976. * @param impostor imposter to get linear velocity from
  110977. * @returns linear velocity
  110978. */
  110979. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  110980. /**
  110981. * gets the angular velocity
  110982. * @param impostor imposter to get angular velocity from
  110983. * @returns angular velocity
  110984. */
  110985. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  110986. /**
  110987. * Sets the mass of physics body
  110988. * @param impostor imposter to set the mass on
  110989. * @param mass mass to set
  110990. */
  110991. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  110992. /**
  110993. * Gets the mass of the physics body
  110994. * @param impostor imposter to get the mass from
  110995. * @returns mass
  110996. */
  110997. getBodyMass(impostor: PhysicsImpostor): number;
  110998. /**
  110999. * Gets friction of the impostor
  111000. * @param impostor impostor to get friction from
  111001. * @returns friction value
  111002. */
  111003. getBodyFriction(impostor: PhysicsImpostor): number;
  111004. /**
  111005. * Sets friction of the impostor
  111006. * @param impostor impostor to set friction on
  111007. * @param friction friction value
  111008. */
  111009. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  111010. /**
  111011. * Gets restitution of the impostor
  111012. * @param impostor impostor to get restitution from
  111013. * @returns restitution value
  111014. */
  111015. getBodyRestitution(impostor: PhysicsImpostor): number;
  111016. /**
  111017. * Sets resitution of the impostor
  111018. * @param impostor impostor to set resitution on
  111019. * @param restitution resitution value
  111020. */
  111021. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  111022. /**
  111023. * Gets pressure inside the impostor
  111024. * @param impostor impostor to get pressure from
  111025. * @returns pressure value
  111026. */
  111027. getBodyPressure(impostor: PhysicsImpostor): number;
  111028. /**
  111029. * Sets pressure inside a soft body impostor
  111030. * Cloth and rope must remain 0 pressure
  111031. * @param impostor impostor to set pressure on
  111032. * @param pressure pressure value
  111033. */
  111034. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  111035. /**
  111036. * Gets stiffness of the impostor
  111037. * @param impostor impostor to get stiffness from
  111038. * @returns pressure value
  111039. */
  111040. getBodyStiffness(impostor: PhysicsImpostor): number;
  111041. /**
  111042. * Sets stiffness of the impostor
  111043. * @param impostor impostor to set stiffness on
  111044. * @param stiffness stiffness value from 0 to 1
  111045. */
  111046. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  111047. /**
  111048. * Gets velocityIterations of the impostor
  111049. * @param impostor impostor to get velocity iterations from
  111050. * @returns velocityIterations value
  111051. */
  111052. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  111053. /**
  111054. * Sets velocityIterations of the impostor
  111055. * @param impostor impostor to set velocity iterations on
  111056. * @param velocityIterations velocityIterations value
  111057. */
  111058. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  111059. /**
  111060. * Gets positionIterations of the impostor
  111061. * @param impostor impostor to get position iterations from
  111062. * @returns positionIterations value
  111063. */
  111064. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  111065. /**
  111066. * Sets positionIterations of the impostor
  111067. * @param impostor impostor to set position on
  111068. * @param positionIterations positionIterations value
  111069. */
  111070. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  111071. /**
  111072. * Append an anchor to a cloth object
  111073. * @param impostor is the cloth impostor to add anchor to
  111074. * @param otherImpostor is the rigid impostor to anchor to
  111075. * @param width ratio across width from 0 to 1
  111076. * @param height ratio up height from 0 to 1
  111077. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  111078. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  111079. */
  111080. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  111081. /**
  111082. * Append an hook to a rope object
  111083. * @param impostor is the rope impostor to add hook to
  111084. * @param otherImpostor is the rigid impostor to hook to
  111085. * @param length ratio along the rope from 0 to 1
  111086. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  111087. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  111088. */
  111089. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  111090. /**
  111091. * Sleeps the physics body and stops it from being active
  111092. * @param impostor impostor to sleep
  111093. */
  111094. sleepBody(impostor: PhysicsImpostor): void;
  111095. /**
  111096. * Activates the physics body
  111097. * @param impostor impostor to activate
  111098. */
  111099. wakeUpBody(impostor: PhysicsImpostor): void;
  111100. /**
  111101. * Updates the distance parameters of the joint
  111102. * @param joint joint to update
  111103. * @param maxDistance maximum distance of the joint
  111104. * @param minDistance minimum distance of the joint
  111105. */
  111106. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  111107. /**
  111108. * Sets a motor on the joint
  111109. * @param joint joint to set motor on
  111110. * @param speed speed of the motor
  111111. * @param maxForce maximum force of the motor
  111112. * @param motorIndex index of the motor
  111113. */
  111114. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  111115. /**
  111116. * Sets the motors limit
  111117. * @param joint joint to set limit on
  111118. * @param upperLimit upper limit
  111119. * @param lowerLimit lower limit
  111120. */
  111121. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  111122. /**
  111123. * Syncs the position and rotation of a mesh with the impostor
  111124. * @param mesh mesh to sync
  111125. * @param impostor impostor to update the mesh with
  111126. */
  111127. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  111128. /**
  111129. * Gets the radius of the impostor
  111130. * @param impostor impostor to get radius from
  111131. * @returns the radius
  111132. */
  111133. getRadius(impostor: PhysicsImpostor): number;
  111134. /**
  111135. * Gets the box size of the impostor
  111136. * @param impostor impostor to get box size from
  111137. * @param result the resulting box size
  111138. */
  111139. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  111140. /**
  111141. * Disposes of the impostor
  111142. */
  111143. dispose(): void;
  111144. /**
  111145. * Does a raycast in the physics world
  111146. * @param from when should the ray start?
  111147. * @param to when should the ray end?
  111148. * @returns PhysicsRaycastResult
  111149. */
  111150. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  111151. }
  111152. }
  111153. declare module BABYLON {
  111154. interface AbstractScene {
  111155. /**
  111156. * The list of reflection probes added to the scene
  111157. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  111158. */
  111159. reflectionProbes: Array<ReflectionProbe>;
  111160. /**
  111161. * Removes the given reflection probe from this scene.
  111162. * @param toRemove The reflection probe to remove
  111163. * @returns The index of the removed reflection probe
  111164. */
  111165. removeReflectionProbe(toRemove: ReflectionProbe): number;
  111166. /**
  111167. * Adds the given reflection probe to this scene.
  111168. * @param newReflectionProbe The reflection probe to add
  111169. */
  111170. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  111171. }
  111172. /**
  111173. * Class used to generate realtime reflection / refraction cube textures
  111174. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  111175. */
  111176. export class ReflectionProbe {
  111177. /** defines the name of the probe */
  111178. name: string;
  111179. private _scene;
  111180. private _renderTargetTexture;
  111181. private _projectionMatrix;
  111182. private _viewMatrix;
  111183. private _target;
  111184. private _add;
  111185. private _attachedMesh;
  111186. private _invertYAxis;
  111187. /** Gets or sets probe position (center of the cube map) */
  111188. position: Vector3;
  111189. /**
  111190. * Creates a new reflection probe
  111191. * @param name defines the name of the probe
  111192. * @param size defines the texture resolution (for each face)
  111193. * @param scene defines the hosting scene
  111194. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  111195. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  111196. */
  111197. constructor(
  111198. /** defines the name of the probe */
  111199. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  111200. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  111201. samples: number;
  111202. /** Gets or sets the refresh rate to use (on every frame by default) */
  111203. refreshRate: number;
  111204. /**
  111205. * Gets the hosting scene
  111206. * @returns a Scene
  111207. */
  111208. getScene(): Scene;
  111209. /** Gets the internal CubeTexture used to render to */
  111210. readonly cubeTexture: RenderTargetTexture;
  111211. /** Gets the list of meshes to render */
  111212. readonly renderList: Nullable<AbstractMesh[]>;
  111213. /**
  111214. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  111215. * @param mesh defines the mesh to attach to
  111216. */
  111217. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  111218. /**
  111219. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  111220. * @param renderingGroupId The rendering group id corresponding to its index
  111221. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  111222. */
  111223. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  111224. /**
  111225. * Clean all associated resources
  111226. */
  111227. dispose(): void;
  111228. /**
  111229. * Converts the reflection probe information to a readable string for debug purpose.
  111230. * @param fullDetails Supports for multiple levels of logging within scene loading
  111231. * @returns the human readable reflection probe info
  111232. */
  111233. toString(fullDetails?: boolean): string;
  111234. /**
  111235. * Get the class name of the relfection probe.
  111236. * @returns "ReflectionProbe"
  111237. */
  111238. getClassName(): string;
  111239. /**
  111240. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  111241. * @returns The JSON representation of the texture
  111242. */
  111243. serialize(): any;
  111244. /**
  111245. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  111246. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  111247. * @param scene Define the scene the parsed reflection probe should be instantiated in
  111248. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  111249. * @returns The parsed reflection probe if successful
  111250. */
  111251. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  111252. }
  111253. }
  111254. declare module BABYLON {
  111255. /** @hidden */
  111256. export var _BabylonLoaderRegistered: boolean;
  111257. }
  111258. declare module BABYLON {
  111259. /**
  111260. * The Physically based simple base material of BJS.
  111261. *
  111262. * This enables better naming and convention enforcements on top of the pbrMaterial.
  111263. * It is used as the base class for both the specGloss and metalRough conventions.
  111264. */
  111265. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  111266. /**
  111267. * Number of Simultaneous lights allowed on the material.
  111268. */
  111269. maxSimultaneousLights: number;
  111270. /**
  111271. * If sets to true, disables all the lights affecting the material.
  111272. */
  111273. disableLighting: boolean;
  111274. /**
  111275. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  111276. */
  111277. environmentTexture: BaseTexture;
  111278. /**
  111279. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  111280. */
  111281. invertNormalMapX: boolean;
  111282. /**
  111283. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  111284. */
  111285. invertNormalMapY: boolean;
  111286. /**
  111287. * Normal map used in the model.
  111288. */
  111289. normalTexture: BaseTexture;
  111290. /**
  111291. * Emissivie color used to self-illuminate the model.
  111292. */
  111293. emissiveColor: Color3;
  111294. /**
  111295. * Emissivie texture used to self-illuminate the model.
  111296. */
  111297. emissiveTexture: BaseTexture;
  111298. /**
  111299. * Occlusion Channel Strenght.
  111300. */
  111301. occlusionStrength: number;
  111302. /**
  111303. * Occlusion Texture of the material (adding extra occlusion effects).
  111304. */
  111305. occlusionTexture: BaseTexture;
  111306. /**
  111307. * Defines the alpha limits in alpha test mode.
  111308. */
  111309. alphaCutOff: number;
  111310. /**
  111311. * Gets the current double sided mode.
  111312. */
  111313. /**
  111314. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  111315. */
  111316. doubleSided: boolean;
  111317. /**
  111318. * Stores the pre-calculated light information of a mesh in a texture.
  111319. */
  111320. lightmapTexture: BaseTexture;
  111321. /**
  111322. * If true, the light map contains occlusion information instead of lighting info.
  111323. */
  111324. useLightmapAsShadowmap: boolean;
  111325. /**
  111326. * Instantiates a new PBRMaterial instance.
  111327. *
  111328. * @param name The material name
  111329. * @param scene The scene the material will be use in.
  111330. */
  111331. constructor(name: string, scene: Scene);
  111332. getClassName(): string;
  111333. }
  111334. }
  111335. declare module BABYLON {
  111336. /**
  111337. * The PBR material of BJS following the metal roughness convention.
  111338. *
  111339. * This fits to the PBR convention in the GLTF definition:
  111340. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  111341. */
  111342. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  111343. /**
  111344. * The base color has two different interpretations depending on the value of metalness.
  111345. * When the material is a metal, the base color is the specific measured reflectance value
  111346. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  111347. * of the material.
  111348. */
  111349. baseColor: Color3;
  111350. /**
  111351. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  111352. * well as opacity information in the alpha channel.
  111353. */
  111354. baseTexture: BaseTexture;
  111355. /**
  111356. * Specifies the metallic scalar value of the material.
  111357. * Can also be used to scale the metalness values of the metallic texture.
  111358. */
  111359. metallic: number;
  111360. /**
  111361. * Specifies the roughness scalar value of the material.
  111362. * Can also be used to scale the roughness values of the metallic texture.
  111363. */
  111364. roughness: number;
  111365. /**
  111366. * Texture containing both the metallic value in the B channel and the
  111367. * roughness value in the G channel to keep better precision.
  111368. */
  111369. metallicRoughnessTexture: BaseTexture;
  111370. /**
  111371. * Instantiates a new PBRMetalRoughnessMaterial instance.
  111372. *
  111373. * @param name The material name
  111374. * @param scene The scene the material will be use in.
  111375. */
  111376. constructor(name: string, scene: Scene);
  111377. /**
  111378. * Return the currrent class name of the material.
  111379. */
  111380. getClassName(): string;
  111381. /**
  111382. * Makes a duplicate of the current material.
  111383. * @param name - name to use for the new material.
  111384. */
  111385. clone(name: string): PBRMetallicRoughnessMaterial;
  111386. /**
  111387. * Serialize the material to a parsable JSON object.
  111388. */
  111389. serialize(): any;
  111390. /**
  111391. * Parses a JSON object correponding to the serialize function.
  111392. */
  111393. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  111394. }
  111395. }
  111396. declare module BABYLON {
  111397. /**
  111398. * The PBR material of BJS following the specular glossiness convention.
  111399. *
  111400. * This fits to the PBR convention in the GLTF definition:
  111401. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  111402. */
  111403. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  111404. /**
  111405. * Specifies the diffuse color of the material.
  111406. */
  111407. diffuseColor: Color3;
  111408. /**
  111409. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  111410. * channel.
  111411. */
  111412. diffuseTexture: BaseTexture;
  111413. /**
  111414. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  111415. */
  111416. specularColor: Color3;
  111417. /**
  111418. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  111419. */
  111420. glossiness: number;
  111421. /**
  111422. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  111423. */
  111424. specularGlossinessTexture: BaseTexture;
  111425. /**
  111426. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  111427. *
  111428. * @param name The material name
  111429. * @param scene The scene the material will be use in.
  111430. */
  111431. constructor(name: string, scene: Scene);
  111432. /**
  111433. * Return the currrent class name of the material.
  111434. */
  111435. getClassName(): string;
  111436. /**
  111437. * Makes a duplicate of the current material.
  111438. * @param name - name to use for the new material.
  111439. */
  111440. clone(name: string): PBRSpecularGlossinessMaterial;
  111441. /**
  111442. * Serialize the material to a parsable JSON object.
  111443. */
  111444. serialize(): any;
  111445. /**
  111446. * Parses a JSON object correponding to the serialize function.
  111447. */
  111448. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  111449. }
  111450. }
  111451. declare module BABYLON {
  111452. /**
  111453. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  111454. * It can help converting any input color in a desired output one. This can then be used to create effects
  111455. * from sepia, black and white to sixties or futuristic rendering...
  111456. *
  111457. * The only supported format is currently 3dl.
  111458. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  111459. */
  111460. export class ColorGradingTexture extends BaseTexture {
  111461. /**
  111462. * The current texture matrix. (will always be identity in color grading texture)
  111463. */
  111464. private _textureMatrix;
  111465. /**
  111466. * The texture URL.
  111467. */
  111468. url: string;
  111469. /**
  111470. * Empty line regex stored for GC.
  111471. */
  111472. private static _noneEmptyLineRegex;
  111473. private _engine;
  111474. /**
  111475. * Instantiates a ColorGradingTexture from the following parameters.
  111476. *
  111477. * @param url The location of the color gradind data (currently only supporting 3dl)
  111478. * @param scene The scene the texture will be used in
  111479. */
  111480. constructor(url: string, scene: Scene);
  111481. /**
  111482. * Returns the texture matrix used in most of the material.
  111483. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  111484. */
  111485. getTextureMatrix(): Matrix;
  111486. /**
  111487. * Occurs when the file being loaded is a .3dl LUT file.
  111488. */
  111489. private load3dlTexture;
  111490. /**
  111491. * Starts the loading process of the texture.
  111492. */
  111493. private loadTexture;
  111494. /**
  111495. * Clones the color gradind texture.
  111496. */
  111497. clone(): ColorGradingTexture;
  111498. /**
  111499. * Called during delayed load for textures.
  111500. */
  111501. delayLoad(): void;
  111502. /**
  111503. * Parses a color grading texture serialized by Babylon.
  111504. * @param parsedTexture The texture information being parsedTexture
  111505. * @param scene The scene to load the texture in
  111506. * @param rootUrl The root url of the data assets to load
  111507. * @return A color gradind texture
  111508. */
  111509. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  111510. /**
  111511. * Serializes the LUT texture to json format.
  111512. */
  111513. serialize(): any;
  111514. }
  111515. }
  111516. declare module BABYLON {
  111517. /**
  111518. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  111519. */
  111520. export class EquiRectangularCubeTexture extends BaseTexture {
  111521. /** The six faces of the cube. */
  111522. private static _FacesMapping;
  111523. private _noMipmap;
  111524. private _onLoad;
  111525. private _onError;
  111526. /** The size of the cubemap. */
  111527. private _size;
  111528. /** The buffer of the image. */
  111529. private _buffer;
  111530. /** The width of the input image. */
  111531. private _width;
  111532. /** The height of the input image. */
  111533. private _height;
  111534. /** The URL to the image. */
  111535. url: string;
  111536. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  111537. coordinatesMode: number;
  111538. /**
  111539. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  111540. * @param url The location of the image
  111541. * @param scene The scene the texture will be used in
  111542. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  111543. * @param noMipmap Forces to not generate the mipmap if true
  111544. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  111545. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  111546. * @param onLoad — defines a callback called when texture is loaded
  111547. * @param onError — defines a callback called if there is an error
  111548. */
  111549. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  111550. /**
  111551. * Load the image data, by putting the image on a canvas and extracting its buffer.
  111552. */
  111553. private loadImage;
  111554. /**
  111555. * Convert the image buffer into a cubemap and create a CubeTexture.
  111556. */
  111557. private loadTexture;
  111558. /**
  111559. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  111560. * @param buffer The ArrayBuffer that should be converted.
  111561. * @returns The buffer as Float32Array.
  111562. */
  111563. private getFloat32ArrayFromArrayBuffer;
  111564. /**
  111565. * Get the current class name of the texture useful for serialization or dynamic coding.
  111566. * @returns "EquiRectangularCubeTexture"
  111567. */
  111568. getClassName(): string;
  111569. /**
  111570. * Create a clone of the current EquiRectangularCubeTexture and return it.
  111571. * @returns A clone of the current EquiRectangularCubeTexture.
  111572. */
  111573. clone(): EquiRectangularCubeTexture;
  111574. }
  111575. }
  111576. declare module BABYLON {
  111577. /**
  111578. * Based on jsTGALoader - Javascript loader for TGA file
  111579. * By Vincent Thibault
  111580. * @see http://blog.robrowser.com/javascript-tga-loader.html
  111581. */
  111582. export class TGATools {
  111583. private static _TYPE_INDEXED;
  111584. private static _TYPE_RGB;
  111585. private static _TYPE_GREY;
  111586. private static _TYPE_RLE_INDEXED;
  111587. private static _TYPE_RLE_RGB;
  111588. private static _TYPE_RLE_GREY;
  111589. private static _ORIGIN_MASK;
  111590. private static _ORIGIN_SHIFT;
  111591. private static _ORIGIN_BL;
  111592. private static _ORIGIN_BR;
  111593. private static _ORIGIN_UL;
  111594. private static _ORIGIN_UR;
  111595. /**
  111596. * Gets the header of a TGA file
  111597. * @param data defines the TGA data
  111598. * @returns the header
  111599. */
  111600. static GetTGAHeader(data: Uint8Array): any;
  111601. /**
  111602. * Uploads TGA content to a Babylon Texture
  111603. * @hidden
  111604. */
  111605. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  111606. /** @hidden */
  111607. 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;
  111608. /** @hidden */
  111609. 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;
  111610. /** @hidden */
  111611. 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;
  111612. /** @hidden */
  111613. 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;
  111614. /** @hidden */
  111615. 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;
  111616. /** @hidden */
  111617. 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;
  111618. }
  111619. }
  111620. declare module BABYLON {
  111621. /**
  111622. * Implementation of the TGA Texture Loader.
  111623. * @hidden
  111624. */
  111625. export class _TGATextureLoader implements IInternalTextureLoader {
  111626. /**
  111627. * Defines wether the loader supports cascade loading the different faces.
  111628. */
  111629. readonly supportCascades: boolean;
  111630. /**
  111631. * This returns if the loader support the current file information.
  111632. * @param extension defines the file extension of the file being loaded
  111633. * @param textureFormatInUse defines the current compressed format in use iun the engine
  111634. * @param fallback defines the fallback internal texture if any
  111635. * @param isBase64 defines whether the texture is encoded as a base64
  111636. * @param isBuffer defines whether the texture data are stored as a buffer
  111637. * @returns true if the loader can load the specified file
  111638. */
  111639. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  111640. /**
  111641. * Transform the url before loading if required.
  111642. * @param rootUrl the url of the texture
  111643. * @param textureFormatInUse defines the current compressed format in use iun the engine
  111644. * @returns the transformed texture
  111645. */
  111646. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  111647. /**
  111648. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  111649. * @param rootUrl the url of the texture
  111650. * @param textureFormatInUse defines the current compressed format in use iun the engine
  111651. * @returns the fallback texture
  111652. */
  111653. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  111654. /**
  111655. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  111656. * @param data contains the texture data
  111657. * @param texture defines the BabylonJS internal texture
  111658. * @param createPolynomials will be true if polynomials have been requested
  111659. * @param onLoad defines the callback to trigger once the texture is ready
  111660. * @param onError defines the callback to trigger in case of error
  111661. */
  111662. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  111663. /**
  111664. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  111665. * @param data contains the texture data
  111666. * @param texture defines the BabylonJS internal texture
  111667. * @param callback defines the method to call once ready to upload
  111668. */
  111669. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  111670. }
  111671. }
  111672. declare module BABYLON {
  111673. /**
  111674. * 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.
  111675. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  111676. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  111677. */
  111678. export class CustomProceduralTexture extends ProceduralTexture {
  111679. private _animate;
  111680. private _time;
  111681. private _config;
  111682. private _texturePath;
  111683. /**
  111684. * Instantiates a new Custom Procedural Texture.
  111685. * 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.
  111686. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  111687. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  111688. * @param name Define the name of the texture
  111689. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  111690. * @param size Define the size of the texture to create
  111691. * @param scene Define the scene the texture belongs to
  111692. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  111693. * @param generateMipMaps Define if the texture should creates mip maps or not
  111694. */
  111695. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  111696. private _loadJson;
  111697. /**
  111698. * Is the texture ready to be used ? (rendered at least once)
  111699. * @returns true if ready, otherwise, false.
  111700. */
  111701. isReady(): boolean;
  111702. /**
  111703. * Render the texture to its associated render target.
  111704. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  111705. */
  111706. render(useCameraPostProcess?: boolean): void;
  111707. /**
  111708. * Update the list of dependant textures samplers in the shader.
  111709. */
  111710. updateTextures(): void;
  111711. /**
  111712. * Update the uniform values of the procedural texture in the shader.
  111713. */
  111714. updateShaderUniforms(): void;
  111715. /**
  111716. * Define if the texture animates or not.
  111717. */
  111718. animate: boolean;
  111719. }
  111720. }
  111721. declare module BABYLON {
  111722. /** @hidden */
  111723. export var noisePixelShader: {
  111724. name: string;
  111725. shader: string;
  111726. };
  111727. }
  111728. declare module BABYLON {
  111729. /**
  111730. * Class used to generate noise procedural textures
  111731. */
  111732. export class NoiseProceduralTexture extends ProceduralTexture {
  111733. private _time;
  111734. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  111735. brightness: number;
  111736. /** Defines the number of octaves to process */
  111737. octaves: number;
  111738. /** Defines the level of persistence (0.8 by default) */
  111739. persistence: number;
  111740. /** Gets or sets animation speed factor (default is 1) */
  111741. animationSpeedFactor: number;
  111742. /**
  111743. * Creates a new NoiseProceduralTexture
  111744. * @param name defines the name fo the texture
  111745. * @param size defines the size of the texture (default is 256)
  111746. * @param scene defines the hosting scene
  111747. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  111748. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  111749. */
  111750. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  111751. private _updateShaderUniforms;
  111752. protected _getDefines(): string;
  111753. /** Generate the current state of the procedural texture */
  111754. render(useCameraPostProcess?: boolean): void;
  111755. /**
  111756. * Serializes this noise procedural texture
  111757. * @returns a serialized noise procedural texture object
  111758. */
  111759. serialize(): any;
  111760. /**
  111761. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  111762. * @param parsedTexture defines parsed texture data
  111763. * @param scene defines the current scene
  111764. * @param rootUrl defines the root URL containing noise procedural texture information
  111765. * @returns a parsed NoiseProceduralTexture
  111766. */
  111767. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  111768. }
  111769. }
  111770. declare module BABYLON {
  111771. /**
  111772. * Raw cube texture where the raw buffers are passed in
  111773. */
  111774. export class RawCubeTexture extends CubeTexture {
  111775. /**
  111776. * Creates a cube texture where the raw buffers are passed in.
  111777. * @param scene defines the scene the texture is attached to
  111778. * @param data defines the array of data to use to create each face
  111779. * @param size defines the size of the textures
  111780. * @param format defines the format of the data
  111781. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  111782. * @param generateMipMaps defines if the engine should generate the mip levels
  111783. * @param invertY defines if data must be stored with Y axis inverted
  111784. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  111785. * @param compression defines the compression used (null by default)
  111786. */
  111787. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  111788. /**
  111789. * Updates the raw cube texture.
  111790. * @param data defines the data to store
  111791. * @param format defines the data format
  111792. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  111793. * @param invertY defines if data must be stored with Y axis inverted
  111794. * @param compression defines the compression used (null by default)
  111795. * @param level defines which level of the texture to update
  111796. */
  111797. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  111798. /**
  111799. * Updates a raw cube texture with RGBD encoded data.
  111800. * @param data defines the array of data [mipmap][face] to use to create each face
  111801. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  111802. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  111803. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  111804. * @returns a promsie that resolves when the operation is complete
  111805. */
  111806. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  111807. /**
  111808. * Clones the raw cube texture.
  111809. * @return a new cube texture
  111810. */
  111811. clone(): CubeTexture;
  111812. /** @hidden */
  111813. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  111814. }
  111815. }
  111816. declare module BABYLON {
  111817. /**
  111818. * Class used to store 3D textures containing user data
  111819. */
  111820. export class RawTexture3D extends Texture {
  111821. /** Gets or sets the texture format to use */
  111822. format: number;
  111823. private _engine;
  111824. /**
  111825. * Create a new RawTexture3D
  111826. * @param data defines the data of the texture
  111827. * @param width defines the width of the texture
  111828. * @param height defines the height of the texture
  111829. * @param depth defines the depth of the texture
  111830. * @param format defines the texture format to use
  111831. * @param scene defines the hosting scene
  111832. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  111833. * @param invertY defines if texture must be stored with Y axis inverted
  111834. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  111835. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  111836. */
  111837. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  111838. /** Gets or sets the texture format to use */
  111839. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  111840. /**
  111841. * Update the texture with new data
  111842. * @param data defines the data to store in the texture
  111843. */
  111844. update(data: ArrayBufferView): void;
  111845. }
  111846. }
  111847. declare module BABYLON {
  111848. /**
  111849. * Creates a refraction texture used by refraction channel of the standard material.
  111850. * It is like a mirror but to see through a material.
  111851. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  111852. */
  111853. export class RefractionTexture extends RenderTargetTexture {
  111854. /**
  111855. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  111856. * 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.
  111857. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  111858. */
  111859. refractionPlane: Plane;
  111860. /**
  111861. * Define how deep under the surface we should see.
  111862. */
  111863. depth: number;
  111864. /**
  111865. * Creates a refraction texture used by refraction channel of the standard material.
  111866. * It is like a mirror but to see through a material.
  111867. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  111868. * @param name Define the texture name
  111869. * @param size Define the size of the underlying texture
  111870. * @param scene Define the scene the refraction belongs to
  111871. * @param generateMipMaps Define if we need to generate mips level for the refraction
  111872. */
  111873. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  111874. /**
  111875. * Clone the refraction texture.
  111876. * @returns the cloned texture
  111877. */
  111878. clone(): RefractionTexture;
  111879. /**
  111880. * Serialize the texture to a JSON representation you could use in Parse later on
  111881. * @returns the serialized JSON representation
  111882. */
  111883. serialize(): any;
  111884. }
  111885. }
  111886. declare module BABYLON {
  111887. /**
  111888. * Defines the options related to the creation of an HtmlElementTexture
  111889. */
  111890. export interface IHtmlElementTextureOptions {
  111891. /**
  111892. * Defines wether mip maps should be created or not.
  111893. */
  111894. generateMipMaps?: boolean;
  111895. /**
  111896. * Defines the sampling mode of the texture.
  111897. */
  111898. samplingMode?: number;
  111899. /**
  111900. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  111901. */
  111902. engine: Nullable<Engine>;
  111903. /**
  111904. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  111905. */
  111906. scene: Nullable<Scene>;
  111907. }
  111908. /**
  111909. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  111910. * To be as efficient as possible depending on your constraints nothing aside the first upload
  111911. * is automatically managed.
  111912. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  111913. * in your application.
  111914. *
  111915. * As the update is not automatic, you need to call them manually.
  111916. */
  111917. export class HtmlElementTexture extends BaseTexture {
  111918. /**
  111919. * The texture URL.
  111920. */
  111921. element: HTMLVideoElement | HTMLCanvasElement;
  111922. private static readonly DefaultOptions;
  111923. private _textureMatrix;
  111924. private _engine;
  111925. private _isVideo;
  111926. private _generateMipMaps;
  111927. private _samplingMode;
  111928. /**
  111929. * Instantiates a HtmlElementTexture from the following parameters.
  111930. *
  111931. * @param name Defines the name of the texture
  111932. * @param element Defines the video or canvas the texture is filled with
  111933. * @param options Defines the other none mandatory texture creation options
  111934. */
  111935. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  111936. private _createInternalTexture;
  111937. /**
  111938. * Returns the texture matrix used in most of the material.
  111939. */
  111940. getTextureMatrix(): Matrix;
  111941. /**
  111942. * Updates the content of the texture.
  111943. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  111944. */
  111945. update(invertY?: Nullable<boolean>): void;
  111946. }
  111947. }
  111948. declare module BABYLON {
  111949. /**
  111950. * Enum used to define the target of a block
  111951. */
  111952. export enum NodeMaterialBlockTargets {
  111953. /** Vertex shader */
  111954. Vertex = 1,
  111955. /** Fragment shader */
  111956. Fragment = 2,
  111957. /** Vertex and Fragment */
  111958. VertexAndFragment = 3
  111959. }
  111960. }
  111961. declare module BABYLON {
  111962. /**
  111963. * Defines the kind of connection point for node based material
  111964. */
  111965. export enum NodeMaterialBlockConnectionPointTypes {
  111966. /** Float */
  111967. Float = 1,
  111968. /** Int */
  111969. Int = 2,
  111970. /** Vector2 */
  111971. Vector2 = 4,
  111972. /** Vector3 */
  111973. Vector3 = 8,
  111974. /** Vector4 */
  111975. Vector4 = 16,
  111976. /** Color3 */
  111977. Color3 = 32,
  111978. /** Color4 */
  111979. Color4 = 64,
  111980. /** Matrix */
  111981. Matrix = 128,
  111982. /** Texture */
  111983. Texture = 256,
  111984. /** Texture3D */
  111985. Texture3D = 512,
  111986. /** Vector3 or Color3 */
  111987. Vector3OrColor3 = 40,
  111988. /** Vector3 or Vector4 */
  111989. Vector3OrVector4 = 24,
  111990. /** Vector4 or Color4 */
  111991. Vector4OrColor4 = 80,
  111992. /** Color3 or Color4 */
  111993. Color3OrColor4 = 96,
  111994. /** Vector3 or Color3 */
  111995. Vector3OrColor3OrVector4OrColor4 = 120
  111996. }
  111997. }
  111998. declare module BABYLON {
  111999. /**
  112000. * Enum used to define well known values e.g. values automatically provided by the system
  112001. */
  112002. export enum NodeMaterialWellKnownValues {
  112003. /** World */
  112004. World = 1,
  112005. /** View */
  112006. View = 2,
  112007. /** Projection */
  112008. Projection = 3,
  112009. /** ViewProjection */
  112010. ViewProjection = 4,
  112011. /** WorldView */
  112012. WorldView = 5,
  112013. /** WorldViewProjection */
  112014. WorldViewProjection = 6,
  112015. /** Will be filled by the block itself */
  112016. Automatic = 7
  112017. }
  112018. }
  112019. declare module BABYLON {
  112020. /**
  112021. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  112022. */
  112023. export enum NodeMaterialBlockConnectionPointMode {
  112024. /** Value is an uniform */
  112025. Uniform = 0,
  112026. /** Value is a mesh attribute */
  112027. Attribute = 1,
  112028. /** Value is a varying between vertex and fragment shaders */
  112029. Varying = 2,
  112030. /** Mode is undefined */
  112031. Undefined = 3
  112032. }
  112033. }
  112034. declare module BABYLON {
  112035. /**
  112036. * Class used to store shared data between 2 NodeMaterialBuildState
  112037. */
  112038. export class NodeMaterialBuildStateSharedData {
  112039. /**
  112040. * Gets the list of emitted varyings
  112041. */
  112042. varyings: string[];
  112043. /**
  112044. * Gets the varying declaration string
  112045. */
  112046. varyingDeclaration: string;
  112047. /**
  112048. * Uniform connection points
  112049. */
  112050. uniformConnectionPoints: NodeMaterialConnectionPoint[];
  112051. /**
  112052. * Bindable blocks (Blocks that need to set data to the effect)
  112053. */
  112054. bindableBlocks: NodeMaterialBlock[];
  112055. /**
  112056. * List of blocks that can provide a compilation fallback
  112057. */
  112058. blocksWithFallbacks: NodeMaterialBlock[];
  112059. /**
  112060. * List of blocks that can provide a define update
  112061. */
  112062. blocksWithDefines: NodeMaterialBlock[];
  112063. /**
  112064. * List of blocks that can provide a repeatable content
  112065. */
  112066. repeatableContentBlocks: NodeMaterialBlock[];
  112067. /**
  112068. * List of blocks that can block the isReady function for the material
  112069. */
  112070. blockingBlocks: NodeMaterialBlock[];
  112071. /**
  112072. * Build Id used to avoid multiple recompilations
  112073. */
  112074. buildId: number;
  112075. /** List of emitted variables */
  112076. variableNames: {
  112077. [key: string]: number;
  112078. };
  112079. /** List of emitted defines */
  112080. defineNames: {
  112081. [key: string]: number;
  112082. };
  112083. /** Should emit comments? */
  112084. emitComments: boolean;
  112085. /** Emit build activity */
  112086. verbose: boolean;
  112087. /**
  112088. * Gets the compilation hints emitted at compilation time
  112089. */
  112090. hints: {
  112091. needWorldViewMatrix: boolean;
  112092. needWorldViewProjectionMatrix: boolean;
  112093. needAlphaBlending: boolean;
  112094. needAlphaTesting: boolean;
  112095. };
  112096. /**
  112097. * List of compilation checks
  112098. */
  112099. checks: {
  112100. emitVertex: boolean;
  112101. emitFragment: boolean;
  112102. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  112103. };
  112104. /** Creates a new shared data */
  112105. constructor();
  112106. /**
  112107. * Emits console errors and exceptions if there is a failing check
  112108. */
  112109. emitErrors(): void;
  112110. }
  112111. }
  112112. declare module BABYLON {
  112113. /**
  112114. * Class used to store node based material build state
  112115. */
  112116. export class NodeMaterialBuildState {
  112117. /**
  112118. * Gets the list of emitted attributes
  112119. */
  112120. attributes: string[];
  112121. /**
  112122. * Gets the list of emitted uniforms
  112123. */
  112124. uniforms: string[];
  112125. /**
  112126. * Gets the list of emitted samplers
  112127. */
  112128. samplers: string[];
  112129. /**
  112130. * Gets the list of emitted functions
  112131. */
  112132. functions: {
  112133. [key: string]: string;
  112134. };
  112135. /**
  112136. * Gets the target of the compilation state
  112137. */
  112138. target: NodeMaterialBlockTargets;
  112139. /**
  112140. * Shared data between multiple NodeMaterialBuildState instances
  112141. */
  112142. sharedData: NodeMaterialBuildStateSharedData;
  112143. /** @hidden */
  112144. _vertexState: NodeMaterialBuildState;
  112145. private _attributeDeclaration;
  112146. private _uniformDeclaration;
  112147. private _samplerDeclaration;
  112148. private _varyingTransfer;
  112149. private _repeatableContentAnchorIndex;
  112150. /** @hidden */
  112151. _builtCompilationString: string;
  112152. /**
  112153. * Gets the emitted compilation strings
  112154. */
  112155. compilationString: string;
  112156. /**
  112157. * Finalize the compilation strings
  112158. * @param state defines the current compilation state
  112159. */
  112160. finalize(state: NodeMaterialBuildState): void;
  112161. /** @hidden */
  112162. readonly _repeatableContentAnchor: string;
  112163. /** @hidden */
  112164. _getFreeVariableName(prefix: string): string;
  112165. /** @hidden */
  112166. _getFreeDefineName(prefix: string): string;
  112167. /** @hidden */
  112168. _excludeVariableName(name: string): void;
  112169. /** @hidden */
  112170. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  112171. /** @hidden */
  112172. _emitFunction(name: string, code: string, comments: string): void;
  112173. /** @hidden */
  112174. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  112175. replaceStrings?: {
  112176. search: RegExp;
  112177. replace: string;
  112178. }[];
  112179. }): string;
  112180. /** @hidden */
  112181. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  112182. repeatKey?: string;
  112183. removeAttributes?: boolean;
  112184. removeUniforms?: boolean;
  112185. removeVaryings?: boolean;
  112186. removeIfDef?: boolean;
  112187. replaceStrings?: {
  112188. search: RegExp;
  112189. replace: string;
  112190. }[];
  112191. }): void;
  112192. /** @hidden */
  112193. _emitVaryings(point: NodeMaterialConnectionPoint, define?: string, force?: boolean, fromFragment?: boolean, replacementName?: string): void;
  112194. private _emitDefine;
  112195. /** @hidden */
  112196. _emitUniformOrAttributes(point: NodeMaterialConnectionPoint, define?: string): void;
  112197. }
  112198. }
  112199. declare module BABYLON {
  112200. /**
  112201. * Root class for all node material optimizers
  112202. */
  112203. export class NodeMaterialOptimizer {
  112204. /**
  112205. * Function used to optimize a NodeMaterial graph
  112206. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  112207. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  112208. */
  112209. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  112210. }
  112211. }
  112212. declare module BABYLON {
  112213. /**
  112214. * Interface used to configure the node material editor
  112215. */
  112216. export interface INodeMaterialEditorOptions {
  112217. /** Define the URl to load node editor script */
  112218. editorURL?: string;
  112219. }
  112220. /** @hidden */
  112221. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  112222. /** BONES */
  112223. NUM_BONE_INFLUENCERS: number;
  112224. BonesPerMesh: number;
  112225. BONETEXTURE: boolean;
  112226. /** MORPH TARGETS */
  112227. MORPHTARGETS: boolean;
  112228. MORPHTARGETS_NORMAL: boolean;
  112229. MORPHTARGETS_TANGENT: boolean;
  112230. NUM_MORPH_INFLUENCERS: number;
  112231. /** IMAGE PROCESSING */
  112232. IMAGEPROCESSING: boolean;
  112233. VIGNETTE: boolean;
  112234. VIGNETTEBLENDMODEMULTIPLY: boolean;
  112235. VIGNETTEBLENDMODEOPAQUE: boolean;
  112236. TONEMAPPING: boolean;
  112237. TONEMAPPING_ACES: boolean;
  112238. CONTRAST: boolean;
  112239. EXPOSURE: boolean;
  112240. COLORCURVES: boolean;
  112241. COLORGRADING: boolean;
  112242. COLORGRADING3D: boolean;
  112243. SAMPLER3DGREENDEPTH: boolean;
  112244. SAMPLER3DBGRMAP: boolean;
  112245. IMAGEPROCESSINGPOSTPROCESS: boolean;
  112246. constructor();
  112247. setValue(name: string, value: boolean): void;
  112248. }
  112249. /**
  112250. * Class used to configure NodeMaterial
  112251. */
  112252. export interface INodeMaterialOptions {
  112253. /**
  112254. * Defines if blocks should emit comments
  112255. */
  112256. emitComments: boolean;
  112257. }
  112258. /**
  112259. * Class used to create a node based material built by assembling shader blocks
  112260. */
  112261. export class NodeMaterial extends PushMaterial {
  112262. private _options;
  112263. private _vertexCompilationState;
  112264. private _fragmentCompilationState;
  112265. private _sharedData;
  112266. private _buildId;
  112267. private _buildWasSuccessful;
  112268. private _cachedWorldViewMatrix;
  112269. private _cachedWorldViewProjectionMatrix;
  112270. private _textureConnectionPoints;
  112271. private _optimizers;
  112272. /** Define the URl to load node editor script */
  112273. static EditorURL: string;
  112274. private BJSNODEMATERIALEDITOR;
  112275. /** Get the inspector from bundle or global */
  112276. private _getGlobalNodeMaterialEditor;
  112277. /**
  112278. * Defines the maximum number of lights that can be used in the material
  112279. */
  112280. maxSimultaneousLights: number;
  112281. /**
  112282. * Observable raised when the material is built
  112283. */
  112284. onBuildObservable: Observable<NodeMaterial>;
  112285. /**
  112286. * Gets or sets the root nodes of the material vertex shader
  112287. */
  112288. _vertexOutputNodes: NodeMaterialBlock[];
  112289. /**
  112290. * Gets or sets the root nodes of the material fragment (pixel) shader
  112291. */
  112292. _fragmentOutputNodes: NodeMaterialBlock[];
  112293. /** Gets or sets options to control the node material overall behavior */
  112294. options: INodeMaterialOptions;
  112295. /**
  112296. * Default configuration related to image processing available in the standard Material.
  112297. */
  112298. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  112299. /**
  112300. * Gets the image processing configuration used either in this material.
  112301. */
  112302. /**
  112303. * Sets the Default image processing configuration used either in the this material.
  112304. *
  112305. * If sets to null, the scene one is in use.
  112306. */
  112307. imageProcessingConfiguration: ImageProcessingConfiguration;
  112308. /**
  112309. * Create a new node based material
  112310. * @param name defines the material name
  112311. * @param scene defines the hosting scene
  112312. * @param options defines creation option
  112313. */
  112314. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  112315. /**
  112316. * Gets the current class name of the material e.g. "NodeMaterial"
  112317. * @returns the class name
  112318. */
  112319. getClassName(): string;
  112320. /**
  112321. * Keep track of the image processing observer to allow dispose and replace.
  112322. */
  112323. private _imageProcessingObserver;
  112324. /**
  112325. * Attaches a new image processing configuration to the Standard Material.
  112326. * @param configuration
  112327. */
  112328. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  112329. /**
  112330. * Adds a new optimizer to the list of optimizers
  112331. * @param optimizer defines the optimizers to add
  112332. * @returns the current material
  112333. */
  112334. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  112335. /**
  112336. * Remove an optimizer from the list of optimizers
  112337. * @param optimizer defines the optimizers to remove
  112338. * @returns the current material
  112339. */
  112340. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  112341. /**
  112342. * Add a new block to the list of output nodes
  112343. * @param node defines the node to add
  112344. * @returns the current material
  112345. */
  112346. addOutputNode(node: NodeMaterialBlock): this;
  112347. /**
  112348. * Remove a block from the list of root nodes
  112349. * @param node defines the node to remove
  112350. * @returns the current material
  112351. */
  112352. removeOutputNode(node: NodeMaterialBlock): this;
  112353. private _addVertexOutputNode;
  112354. private _removeVertexOutputNode;
  112355. private _addFragmentOutputNode;
  112356. private _removeFragmentOutputNode;
  112357. /**
  112358. * Specifies if the material will require alpha blending
  112359. * @returns a boolean specifying if alpha blending is needed
  112360. */
  112361. needAlphaBlending(): boolean;
  112362. /**
  112363. * Specifies if this material should be rendered in alpha test mode
  112364. * @returns a boolean specifying if an alpha test is needed.
  112365. */
  112366. needAlphaTesting(): boolean;
  112367. private _initializeBlock;
  112368. private _resetDualBlocks;
  112369. /**
  112370. * Build the material and generates the inner effect
  112371. * @param verbose defines if the build should log activity
  112372. */
  112373. build(verbose?: boolean): void;
  112374. /**
  112375. * Runs an otpimization phase to try to improve the shader code
  112376. */
  112377. optimize(): void;
  112378. private _prepareDefinesForAttributes;
  112379. /**
  112380. * Get if the submesh is ready to be used and all its information available.
  112381. * Child classes can use it to update shaders
  112382. * @param mesh defines the mesh to check
  112383. * @param subMesh defines which submesh to check
  112384. * @param useInstances specifies that instances should be used
  112385. * @returns a boolean indicating that the submesh is ready or not
  112386. */
  112387. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  112388. /**
  112389. * Binds the world matrix to the material
  112390. * @param world defines the world transformation matrix
  112391. */
  112392. bindOnlyWorldMatrix(world: Matrix): void;
  112393. /**
  112394. * Binds the submesh to this material by preparing the effect and shader to draw
  112395. * @param world defines the world transformation matrix
  112396. * @param mesh defines the mesh containing the submesh
  112397. * @param subMesh defines the submesh to bind the material to
  112398. */
  112399. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  112400. /**
  112401. * Gets the active textures from the material
  112402. * @returns an array of textures
  112403. */
  112404. getActiveTextures(): BaseTexture[];
  112405. /**
  112406. * Specifies if the material uses a texture
  112407. * @param texture defines the texture to check against the material
  112408. * @returns a boolean specifying if the material uses the texture
  112409. */
  112410. hasTexture(texture: BaseTexture): boolean;
  112411. /**
  112412. * Disposes the material
  112413. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  112414. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  112415. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  112416. */
  112417. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  112418. /** Creates the node editor window. */
  112419. private _createNodeEditor;
  112420. /**
  112421. * Launch the node material editor
  112422. * @param config Define the configuration of the editor
  112423. * @return a promise fulfilled when the node editor is visible
  112424. */
  112425. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  112426. }
  112427. }
  112428. declare module BABYLON {
  112429. /**
  112430. * Defines a block that can be used inside a node based material
  112431. */
  112432. export class NodeMaterialBlock {
  112433. private _buildId;
  112434. private _target;
  112435. private _isFinalMerger;
  112436. /** @hidden */
  112437. _inputs: NodeMaterialConnectionPoint[];
  112438. /** @hidden */
  112439. _outputs: NodeMaterialConnectionPoint[];
  112440. /**
  112441. * Gets or sets the name of the block
  112442. */
  112443. name: string;
  112444. /**
  112445. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  112446. */
  112447. readonly isFinalMerger: boolean;
  112448. /**
  112449. * Gets or sets the build Id
  112450. */
  112451. buildId: number;
  112452. /**
  112453. * Gets or sets the target of the block
  112454. */
  112455. target: NodeMaterialBlockTargets;
  112456. /**
  112457. * Gets the list of input points
  112458. */
  112459. readonly inputs: NodeMaterialConnectionPoint[];
  112460. /** Gets the list of output points */
  112461. readonly outputs: NodeMaterialConnectionPoint[];
  112462. /**
  112463. * Find an input by its name
  112464. * @param name defines the name of the input to look for
  112465. * @returns the input or null if not found
  112466. */
  112467. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  112468. /**
  112469. * Find an output by its name
  112470. * @param name defines the name of the outputto look for
  112471. * @returns the output or null if not found
  112472. */
  112473. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  112474. /**
  112475. * Creates a new NodeMaterialBlock
  112476. * @param name defines the block name
  112477. * @param target defines the target of that block (Vertex by default)
  112478. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  112479. */
  112480. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean);
  112481. /**
  112482. * Initialize the block and prepare the context for build
  112483. * @param state defines the state that will be used for the build
  112484. */
  112485. initialize(state: NodeMaterialBuildState): void;
  112486. /**
  112487. * Bind data to effect. Will only be called for blocks with isBindable === true
  112488. * @param effect defines the effect to bind data to
  112489. * @param nodeMaterial defines the hosting NodeMaterial
  112490. * @param mesh defines the mesh that will be rendered
  112491. */
  112492. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  112493. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  112494. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  112495. protected _writeFloat(value: number): string;
  112496. /**
  112497. * Gets the current class name e.g. "NodeMaterialBlock"
  112498. * @returns the class name
  112499. */
  112500. getClassName(): string;
  112501. /**
  112502. * Register a new input. Must be called inside a block constructor
  112503. * @param name defines the connection point name
  112504. * @param type defines the connection point type
  112505. * @param isOptional defines a boolean indicating that this input can be omitted
  112506. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  112507. * @returns the current block
  112508. */
  112509. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  112510. /**
  112511. * Register a new output. Must be called inside a block constructor
  112512. * @param name defines the connection point name
  112513. * @param type defines the connection point type
  112514. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  112515. * @returns the current block
  112516. */
  112517. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  112518. /**
  112519. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  112520. * @param forOutput defines an optional connection point to check compatibility with
  112521. * @returns the first available input or null
  112522. */
  112523. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  112524. /**
  112525. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  112526. * @param forBlock defines an optional block to check compatibility with
  112527. * @returns the first available input or null
  112528. */
  112529. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  112530. /**
  112531. * Connect current block with another block
  112532. * @param other defines the block to connect with
  112533. * @param options define the various options to help pick the right connections
  112534. * @returns the current block
  112535. */
  112536. connectTo(other: NodeMaterialBlock, options?: {
  112537. input?: string;
  112538. output?: string;
  112539. outputSwizzle?: string;
  112540. }): this | undefined;
  112541. protected _buildBlock(state: NodeMaterialBuildState): void;
  112542. /**
  112543. * Add potential fallbacks if shader compilation fails
  112544. * @param mesh defines the mesh to be rendered
  112545. * @param fallbacks defines the current prioritized list of fallbacks
  112546. */
  112547. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  112548. /**
  112549. * Update defines for shader compilation
  112550. * @param mesh defines the mesh to be rendered
  112551. * @param nodeMaterial defines the node material requesting the update
  112552. * @param defines defines the material defines to update
  112553. * @param useInstances specifies that instances should be used
  112554. */
  112555. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  112556. /**
  112557. * Lets the block try to connect some inputs automatically
  112558. */
  112559. autoConfigure(): void;
  112560. /**
  112561. * Function called when a block is declared as repeatable content generator
  112562. * @param vertexShaderState defines the current compilation state for the vertex shader
  112563. * @param fragmentShaderState defines the current compilation state for the fragment shader
  112564. * @param mesh defines the mesh to be rendered
  112565. * @param defines defines the material defines to update
  112566. */
  112567. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  112568. /**
  112569. * Checks if the block is ready
  112570. * @param mesh defines the mesh to be rendered
  112571. * @param nodeMaterial defines the node material requesting the update
  112572. * @param defines defines the material defines to update
  112573. * @param useInstances specifies that instances should be used
  112574. * @returns true if the block is ready
  112575. */
  112576. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  112577. /**
  112578. * Compile the current node and generate the shader code
  112579. * @param state defines the current compilation state (uniforms, samplers, current string)
  112580. * @returns the current block
  112581. */
  112582. build(state: NodeMaterialBuildState): this | undefined;
  112583. }
  112584. }
  112585. declare module BABYLON {
  112586. /**
  112587. * Defines a connection point for a block
  112588. */
  112589. export class NodeMaterialConnectionPoint {
  112590. /** @hidden */
  112591. _ownerBlock: NodeMaterialBlock;
  112592. /** @hidden */
  112593. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  112594. private _associatedVariableName;
  112595. private _endpoints;
  112596. private _storedValue;
  112597. private _valueCallback;
  112598. private _mode;
  112599. /** @hidden */
  112600. _wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  112601. /**
  112602. * Gets or sets the connection point type (default is float)
  112603. */
  112604. type: NodeMaterialBlockConnectionPointTypes;
  112605. /**
  112606. * Gets or sets the connection point name
  112607. */
  112608. name: string;
  112609. /**
  112610. * Gets or sets the swizzle to apply to this connection point when reading or writing
  112611. */
  112612. swizzle: string;
  112613. /**
  112614. * Gets or sets a boolean indicating that this connection point can be omitted
  112615. */
  112616. isOptional: boolean;
  112617. /**
  112618. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  112619. */
  112620. define: string;
  112621. /** Gets or sets the target of that connection point */
  112622. target: NodeMaterialBlockTargets;
  112623. /**
  112624. * Gets or sets the value of that point.
  112625. * Please note that this value will be ignored if valueCallback is defined
  112626. */
  112627. value: any;
  112628. /**
  112629. * Gets or sets a callback used to get the value of that point.
  112630. * Please note that setting this value will force the connection point to ignore the value property
  112631. */
  112632. valueCallback: () => any;
  112633. /**
  112634. * Gets or sets the associated variable name in the shader
  112635. */
  112636. associatedVariableName: string;
  112637. /**
  112638. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  112639. * In this case the connection point name must be the name of the uniform to use.
  112640. * Can only be set on inputs
  112641. */
  112642. isUniform: boolean;
  112643. /**
  112644. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  112645. * In this case the connection point name must be the name of the attribute to use
  112646. * Can only be set on inputs
  112647. */
  112648. isAttribute: boolean;
  112649. /**
  112650. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  112651. * Can only be set on exit points
  112652. */
  112653. isVarying: boolean;
  112654. /** Get the other side of the connection (if any) */
  112655. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  112656. /** Get the block that owns this connection point */
  112657. readonly ownerBlock: NodeMaterialBlock;
  112658. /** Get the block connected on the other side of this connection (if any) */
  112659. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  112660. /** Get the block connected on the endpoints of this connection (if any) */
  112661. readonly connectedBlocks: Array<NodeMaterialBlock>;
  112662. /**
  112663. * Creates a new connection point
  112664. * @param name defines the connection point name
  112665. * @param ownerBlock defines the block hosting this connection point
  112666. */
  112667. constructor(name: string, ownerBlock: NodeMaterialBlock);
  112668. /**
  112669. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  112670. * @returns the class name
  112671. */
  112672. getClassName(): string;
  112673. /**
  112674. * Set the source of this connection point to a vertex attribute
  112675. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  112676. * @returns the current connection point
  112677. */
  112678. setAsAttribute(attributeName?: string): NodeMaterialConnectionPoint;
  112679. /**
  112680. * Set the source of this connection point to a well known value
  112681. * @param value define the well known value to use (world, view, etc...) or null to switch to manual value
  112682. * @returns the current connection point
  112683. */
  112684. setAsWellKnownValue(value: Nullable<NodeMaterialWellKnownValues>): NodeMaterialConnectionPoint;
  112685. /**
  112686. * Gets a boolean indicating that the current connection point is a well known value
  112687. */
  112688. readonly isWellKnownValue: boolean;
  112689. /**
  112690. * Gets or sets the current well known value or null if not defined as well know value
  112691. */
  112692. wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  112693. private _getTypeLength;
  112694. /**
  112695. * Connect this point to another connection point
  112696. * @param connectionPoint defines the other connection point
  112697. * @returns the current connection point
  112698. */
  112699. connectTo(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  112700. /**
  112701. * Disconnect this point from one of his endpoint
  112702. * @param endpoint defines the other connection point
  112703. * @returns the current connection point
  112704. */
  112705. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  112706. /**
  112707. * When connection point is an uniform, this function will send its value to the effect
  112708. * @param effect defines the effect to transmit value to
  112709. * @param world defines the world matrix
  112710. * @param worldView defines the worldxview matrix
  112711. * @param worldViewProjection defines the worldxviewxprojection matrix
  112712. */
  112713. transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  112714. /**
  112715. * When connection point is an uniform, this function will send its value to the effect
  112716. * @param effect defines the effect to transmit value to
  112717. * @param scene defines the hosting scene
  112718. */
  112719. transmit(effect: Effect, scene: Scene): void;
  112720. }
  112721. }
  112722. declare module BABYLON {
  112723. /**
  112724. * Block used to output the vertex position
  112725. */
  112726. export class VertexOutputBlock extends NodeMaterialBlock {
  112727. /**
  112728. * Creates a new VertexOutputBlock
  112729. * @param name defines the block name
  112730. */
  112731. constructor(name: string);
  112732. /**
  112733. * Gets the current class name
  112734. * @returns the class name
  112735. */
  112736. getClassName(): string;
  112737. /**
  112738. * Gets the vector input component
  112739. */
  112740. readonly vector: NodeMaterialConnectionPoint;
  112741. protected _buildBlock(state: NodeMaterialBuildState): this;
  112742. }
  112743. }
  112744. declare module BABYLON {
  112745. /**
  112746. * Block used to add support for vertex skinning (bones)
  112747. */
  112748. export class BonesBlock extends NodeMaterialBlock {
  112749. /**
  112750. * Creates a new BonesBlock
  112751. * @param name defines the block name
  112752. */
  112753. constructor(name: string);
  112754. /**
  112755. * Initialize the block and prepare the context for build
  112756. * @param state defines the state that will be used for the build
  112757. */
  112758. initialize(state: NodeMaterialBuildState): void;
  112759. /**
  112760. * Gets the current class name
  112761. * @returns the class name
  112762. */
  112763. getClassName(): string;
  112764. /**
  112765. * Gets the matrix indices input component
  112766. */
  112767. readonly matricesIndices: NodeMaterialConnectionPoint;
  112768. /**
  112769. * Gets the matrix weights input component
  112770. */
  112771. readonly matricesWeights: NodeMaterialConnectionPoint;
  112772. /**
  112773. * Gets the extra matrix indices input component
  112774. */
  112775. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  112776. /**
  112777. * Gets the extra matrix weights input component
  112778. */
  112779. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  112780. /**
  112781. * Gets the world input component
  112782. */
  112783. readonly world: NodeMaterialConnectionPoint;
  112784. autoConfigure(): void;
  112785. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  112786. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  112787. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  112788. protected _buildBlock(state: NodeMaterialBuildState): this;
  112789. }
  112790. }
  112791. declare module BABYLON {
  112792. /**
  112793. * Block used to add support for instances
  112794. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  112795. */
  112796. export class InstancesBlock extends NodeMaterialBlock {
  112797. /**
  112798. * Creates a new InstancesBlock
  112799. * @param name defines the block name
  112800. */
  112801. constructor(name: string);
  112802. /**
  112803. * Gets the current class name
  112804. * @returns the class name
  112805. */
  112806. getClassName(): string;
  112807. /**
  112808. * Gets the first world row input component
  112809. */
  112810. readonly world0: NodeMaterialConnectionPoint;
  112811. /**
  112812. * Gets the second world row input component
  112813. */
  112814. readonly world1: NodeMaterialConnectionPoint;
  112815. /**
  112816. * Gets the third world row input component
  112817. */
  112818. readonly world2: NodeMaterialConnectionPoint;
  112819. /**
  112820. * Gets the forth world row input component
  112821. */
  112822. readonly world3: NodeMaterialConnectionPoint;
  112823. /**
  112824. * Gets the world input component
  112825. */
  112826. readonly world: NodeMaterialConnectionPoint;
  112827. /**
  112828. * Gets the output component
  112829. */
  112830. readonly output: NodeMaterialConnectionPoint;
  112831. autoConfigure(): void;
  112832. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  112833. protected _buildBlock(state: NodeMaterialBuildState): this;
  112834. }
  112835. }
  112836. declare module BABYLON {
  112837. /**
  112838. * Block used to add morph targets support to vertex shader
  112839. */
  112840. export class MorphTargetsBlock extends NodeMaterialBlock {
  112841. private _repeatableContentAnchor;
  112842. private _repeatebleContentGenerated;
  112843. /**
  112844. * Create a new MorphTargetsBlock
  112845. * @param name defines the block name
  112846. */
  112847. constructor(name: string);
  112848. /**
  112849. * Gets the current class name
  112850. * @returns the class name
  112851. */
  112852. getClassName(): string;
  112853. /**
  112854. * Gets the position input component
  112855. */
  112856. readonly position: NodeMaterialConnectionPoint;
  112857. /**
  112858. * Gets the normal input component
  112859. */
  112860. readonly normal: NodeMaterialConnectionPoint;
  112861. /**
  112862. * Gets the tangent input component
  112863. */
  112864. readonly tangent: NodeMaterialConnectionPoint;
  112865. /**
  112866. * Gets the position output component
  112867. */
  112868. readonly positionOutput: NodeMaterialConnectionPoint;
  112869. /**
  112870. * Gets the normal output component
  112871. */
  112872. readonly normalOutput: NodeMaterialConnectionPoint;
  112873. /**
  112874. * Gets the tangent output component
  112875. */
  112876. readonly tangentOutput: NodeMaterialConnectionPoint;
  112877. initialize(state: NodeMaterialBuildState): void;
  112878. autoConfigure(): void;
  112879. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  112880. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  112881. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  112882. protected _buildBlock(state: NodeMaterialBuildState): this;
  112883. }
  112884. }
  112885. declare module BABYLON {
  112886. /**
  112887. * Block used to output the final color
  112888. */
  112889. export class FragmentOutputBlock extends NodeMaterialBlock {
  112890. /**
  112891. * Gets or sets a boolean indicating if this block will output an alpha value
  112892. */
  112893. alphaBlendingEnabled: boolean;
  112894. /**
  112895. * Create a new FragmentOutputBlock
  112896. * @param name defines the block name
  112897. */
  112898. constructor(name: string);
  112899. /**
  112900. * Gets the current class name
  112901. * @returns the class name
  112902. */
  112903. getClassName(): string;
  112904. /**
  112905. * Gets the color input component
  112906. */
  112907. readonly color: NodeMaterialConnectionPoint;
  112908. protected _buildBlock(state: NodeMaterialBuildState): this;
  112909. }
  112910. }
  112911. declare module BABYLON {
  112912. /**
  112913. * Block used to add an alpha test in the fragment shader
  112914. */
  112915. export class AlphaTestBlock extends NodeMaterialBlock {
  112916. /**
  112917. * Gets or sets the alpha value where alpha testing happens
  112918. */
  112919. alphaCutOff: number;
  112920. /**
  112921. * Create a new AlphaTestBlock
  112922. * @param name defines the block name
  112923. */
  112924. constructor(name: string);
  112925. /**
  112926. * Gets the current class name
  112927. * @returns the class name
  112928. */
  112929. getClassName(): string;
  112930. /**
  112931. * Gets the color input component
  112932. */
  112933. readonly color: NodeMaterialConnectionPoint;
  112934. protected _buildBlock(state: NodeMaterialBuildState): this;
  112935. }
  112936. }
  112937. declare module BABYLON {
  112938. /**
  112939. * Block used to create a Color4 out of 4 inputs (one for each component)
  112940. */
  112941. export class RGBAMergerBlock extends NodeMaterialBlock {
  112942. /**
  112943. * Create a new RGBAMergerBlock
  112944. * @param name defines the block name
  112945. */
  112946. constructor(name: string);
  112947. /**
  112948. * Gets the current class name
  112949. * @returns the class name
  112950. */
  112951. getClassName(): string;
  112952. /**
  112953. * Gets the R input component
  112954. */
  112955. readonly r: NodeMaterialConnectionPoint;
  112956. /**
  112957. * Gets the G input component
  112958. */
  112959. readonly g: NodeMaterialConnectionPoint;
  112960. /**
  112961. * Gets the B input component
  112962. */
  112963. readonly b: NodeMaterialConnectionPoint;
  112964. /**
  112965. * Gets the RGB input component
  112966. */
  112967. readonly rgb: NodeMaterialConnectionPoint;
  112968. /**
  112969. * Gets the R input component
  112970. */
  112971. readonly a: NodeMaterialConnectionPoint;
  112972. protected _buildBlock(state: NodeMaterialBuildState): this;
  112973. }
  112974. }
  112975. declare module BABYLON {
  112976. /**
  112977. * Block used to create a Color3 out of 3 inputs (one for each component)
  112978. */
  112979. export class RGBMergerBlock extends NodeMaterialBlock {
  112980. /**
  112981. * Create a new RGBMergerBlock
  112982. * @param name defines the block name
  112983. */
  112984. constructor(name: string);
  112985. /**
  112986. * Gets the current class name
  112987. * @returns the class name
  112988. */
  112989. getClassName(): string;
  112990. /**
  112991. * Gets the R component input
  112992. */
  112993. readonly r: NodeMaterialConnectionPoint;
  112994. /**
  112995. * Gets the G component input
  112996. */
  112997. readonly g: NodeMaterialConnectionPoint;
  112998. /**
  112999. * Gets the B component input
  113000. */
  113001. readonly b: NodeMaterialConnectionPoint;
  113002. protected _buildBlock(state: NodeMaterialBuildState): this;
  113003. }
  113004. }
  113005. declare module BABYLON {
  113006. /**
  113007. * Block used to expand a Color4 or a Vector4 into 4 outputs (one for each component)
  113008. */
  113009. export class RGBASplitterBlock extends NodeMaterialBlock {
  113010. /**
  113011. * Create a new RGBASplitterBlock
  113012. * @param name defines the block name
  113013. */
  113014. constructor(name: string);
  113015. /**
  113016. * Gets the current class name
  113017. * @returns the class name
  113018. */
  113019. getClassName(): string;
  113020. /**
  113021. * Gets the input component
  113022. */
  113023. readonly input: NodeMaterialConnectionPoint;
  113024. protected _buildBlock(state: NodeMaterialBuildState): this;
  113025. }
  113026. }
  113027. declare module BABYLON {
  113028. /**
  113029. * Block used to expand a Color3 or a Vector3 into 3 outputs (one for each component)
  113030. */
  113031. export class RGBSplitterBlock extends NodeMaterialBlock {
  113032. /**
  113033. * Create a new RGBSplitterBlock
  113034. * @param name defines the block name
  113035. */
  113036. constructor(name: string);
  113037. /**
  113038. * Gets the current class name
  113039. * @returns the class name
  113040. */
  113041. getClassName(): string;
  113042. /**
  113043. * Gets the input component
  113044. */
  113045. readonly input: NodeMaterialConnectionPoint;
  113046. protected _buildBlock(state: NodeMaterialBuildState): this;
  113047. }
  113048. }
  113049. declare module BABYLON {
  113050. /**
  113051. * Block used to read a texture from a sampler
  113052. */
  113053. export class TextureBlock extends NodeMaterialBlock {
  113054. private _defineName;
  113055. /**
  113056. * Gets or sets a boolean indicating that the block can automatically fetch the texture matrix
  113057. */
  113058. autoConnectTextureMatrix: boolean;
  113059. /**
  113060. * Gets or sets a boolean indicating that the block can automatically select the uv channel based on texture
  113061. */
  113062. autoSelectUV: boolean;
  113063. /**
  113064. * Create a new TextureBlock
  113065. * @param name defines the block name
  113066. */
  113067. constructor(name: string);
  113068. /**
  113069. * Gets the current class name
  113070. * @returns the class name
  113071. */
  113072. getClassName(): string;
  113073. /**
  113074. * Gets the uv input component
  113075. */
  113076. readonly uv: NodeMaterialConnectionPoint;
  113077. /**
  113078. * Gets the texture information input component
  113079. */
  113080. readonly textureInfo: NodeMaterialConnectionPoint;
  113081. /**
  113082. * Gets the transformed uv input component
  113083. */
  113084. readonly transformedUV: NodeMaterialConnectionPoint;
  113085. /**
  113086. * Gets the texture input component
  113087. */
  113088. readonly texture: NodeMaterialConnectionPoint;
  113089. /**
  113090. * Gets the texture transform input component
  113091. */
  113092. readonly textureTransform: NodeMaterialConnectionPoint;
  113093. autoConfigure(): void;
  113094. initialize(state: NodeMaterialBuildState): void;
  113095. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  113096. isReady(): boolean;
  113097. private _injectVertexCode;
  113098. protected _buildBlock(state: NodeMaterialBuildState): this;
  113099. }
  113100. }
  113101. declare module BABYLON {
  113102. /**
  113103. * Block used to add image processing support to fragment shader
  113104. */
  113105. export class ImageProcessingBlock extends NodeMaterialBlock {
  113106. /**
  113107. * Create a new ImageProcessingBlock
  113108. * @param name defines the block name
  113109. */
  113110. constructor(name: string);
  113111. /**
  113112. * Gets the current class name
  113113. * @returns the class name
  113114. */
  113115. getClassName(): string;
  113116. /**
  113117. * Gets the color input component
  113118. */
  113119. readonly color: NodeMaterialConnectionPoint;
  113120. /**
  113121. * Initialize the block and prepare the context for build
  113122. * @param state defines the state that will be used for the build
  113123. */
  113124. initialize(state: NodeMaterialBuildState): void;
  113125. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  113126. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  113127. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  113128. protected _buildBlock(state: NodeMaterialBuildState): this;
  113129. }
  113130. }
  113131. declare module BABYLON {
  113132. /**
  113133. * Block used to add support for scene fog
  113134. */
  113135. export class FogBlock extends NodeMaterialBlock {
  113136. /**
  113137. * Create a new FogBlock
  113138. * @param name defines the block name
  113139. */
  113140. constructor(name: string);
  113141. /**
  113142. * Gets the current class name
  113143. * @returns the class name
  113144. */
  113145. getClassName(): string;
  113146. /**
  113147. * Gets the world position input component
  113148. */
  113149. readonly worldPosition: NodeMaterialConnectionPoint;
  113150. /**
  113151. * Gets the view input component
  113152. */
  113153. readonly view: NodeMaterialConnectionPoint;
  113154. /**
  113155. * Gets the color input component
  113156. */
  113157. readonly color: NodeMaterialConnectionPoint;
  113158. /**
  113159. * Gets the fog color input component
  113160. */
  113161. readonly fogColor: NodeMaterialConnectionPoint;
  113162. /**
  113163. * Gets the for parameter input component
  113164. */
  113165. readonly fogParameters: NodeMaterialConnectionPoint;
  113166. autoConfigure(): void;
  113167. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  113168. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  113169. protected _buildBlock(state: NodeMaterialBuildState): this;
  113170. }
  113171. }
  113172. declare module BABYLON {
  113173. /**
  113174. * Block used to multiply 2 vector4
  113175. */
  113176. export class MultiplyBlock extends NodeMaterialBlock {
  113177. /**
  113178. * Creates a new MultiplyBlock
  113179. * @param name defines the block name
  113180. */
  113181. constructor(name: string);
  113182. /**
  113183. * Gets the current class name
  113184. * @returns the class name
  113185. */
  113186. getClassName(): string;
  113187. /**
  113188. * Gets the left operand input component
  113189. */
  113190. readonly left: NodeMaterialConnectionPoint;
  113191. /**
  113192. * Gets the right operand input component
  113193. */
  113194. readonly right: NodeMaterialConnectionPoint;
  113195. protected _buildBlock(state: NodeMaterialBuildState): this;
  113196. }
  113197. }
  113198. declare module BABYLON {
  113199. /**
  113200. * Block used to add 2 vector4
  113201. */
  113202. export class AddBlock extends NodeMaterialBlock {
  113203. /**
  113204. * Creates a new AddBlock
  113205. * @param name defines the block name
  113206. */
  113207. constructor(name: string);
  113208. /**
  113209. * Gets the current class name
  113210. * @returns the class name
  113211. */
  113212. getClassName(): string;
  113213. /**
  113214. * Gets the left operand input component
  113215. */
  113216. readonly left: NodeMaterialConnectionPoint;
  113217. /**
  113218. * Gets the right operand input component
  113219. */
  113220. readonly right: NodeMaterialConnectionPoint;
  113221. protected _buildBlock(state: NodeMaterialBuildState): this;
  113222. }
  113223. }
  113224. declare module BABYLON {
  113225. /**
  113226. * Block used to clamp a float
  113227. */
  113228. export class ClampBlock extends NodeMaterialBlock {
  113229. /** Gets or sets the minimum range */
  113230. minimum: number;
  113231. /** Gets or sets the maximum range */
  113232. maximum: number;
  113233. /**
  113234. * Creates a new ClampBlock
  113235. * @param name defines the block name
  113236. */
  113237. constructor(name: string);
  113238. /**
  113239. * Gets the current class name
  113240. * @returns the class name
  113241. */
  113242. getClassName(): string;
  113243. /**
  113244. * Gets the value input component
  113245. */
  113246. readonly value: NodeMaterialConnectionPoint;
  113247. protected _buildBlock(state: NodeMaterialBuildState): this;
  113248. }
  113249. }
  113250. declare module BABYLON {
  113251. /**
  113252. * Block used to transform a vector2 with a matrix
  113253. */
  113254. export class Vector2TransformBlock extends NodeMaterialBlock {
  113255. /**
  113256. * Defines the value to use to complement Vector2 to transform it to a Vector4
  113257. */
  113258. complementZ: number;
  113259. /**
  113260. * Defines the value to use to complement Vector2 to transform it to a Vector4
  113261. */
  113262. complementW: number;
  113263. /**
  113264. * Creates a new Vector2TransformBlock
  113265. * @param name defines the block name
  113266. */
  113267. constructor(name: string);
  113268. /**
  113269. * Gets the vector input
  113270. */
  113271. readonly vector: NodeMaterialConnectionPoint;
  113272. /**
  113273. * Gets the matrix transform input
  113274. */
  113275. readonly transform: NodeMaterialConnectionPoint;
  113276. /**
  113277. * Gets the current class name
  113278. * @returns the class name
  113279. */
  113280. getClassName(): string;
  113281. protected _buildBlock(state: NodeMaterialBuildState): this;
  113282. }
  113283. }
  113284. declare module BABYLON {
  113285. /**
  113286. * Block used to transform a vector3 with a matrix
  113287. */
  113288. export class Vector3TransformBlock extends NodeMaterialBlock {
  113289. /**
  113290. * Defines the value to use to complement Vector3 to transform it to a Vector4
  113291. */
  113292. complement: number;
  113293. /**
  113294. * Creates a new Vector3TransformBlock
  113295. * @param name defines the block name
  113296. */
  113297. constructor(name: string);
  113298. /**
  113299. * Gets the vector input
  113300. */
  113301. readonly vector: NodeMaterialConnectionPoint;
  113302. /**
  113303. * Gets the matrix transform input
  113304. */
  113305. readonly transform: NodeMaterialConnectionPoint;
  113306. /**
  113307. * Gets the current class name
  113308. * @returns the class name
  113309. */
  113310. getClassName(): string;
  113311. protected _buildBlock(state: NodeMaterialBuildState): this;
  113312. }
  113313. }
  113314. declare module BABYLON {
  113315. /**
  113316. * Block used to transform a vector4 with a matrix
  113317. */
  113318. export class Vector4TransformBlock extends NodeMaterialBlock {
  113319. /**
  113320. * Defines the value to use to complement Vector3 to transform it to a Vector4
  113321. */
  113322. complementW: number;
  113323. /**
  113324. * Creates a new Vector4TransformBlock
  113325. * @param name defines the block name
  113326. */
  113327. constructor(name: string);
  113328. /**
  113329. * Gets the current class name
  113330. * @returns the class name
  113331. */
  113332. getClassName(): string;
  113333. /**
  113334. * Gets the vector input
  113335. */
  113336. readonly vector: NodeMaterialConnectionPoint;
  113337. /**
  113338. * Gets the matrix transform input
  113339. */
  113340. readonly transform: NodeMaterialConnectionPoint;
  113341. protected _buildBlock(state: NodeMaterialBuildState): this;
  113342. }
  113343. }
  113344. declare module BABYLON {
  113345. /**
  113346. * Block used to multiply two matrices
  113347. */
  113348. export class MatrixMultiplicationBlock extends NodeMaterialBlock {
  113349. /**
  113350. * Creates a new MatrixMultiplicationBlock
  113351. * @param name defines the block name
  113352. */
  113353. constructor(name: string);
  113354. /**
  113355. * Gets the left operand
  113356. */
  113357. readonly left: NodeMaterialConnectionPoint;
  113358. /**
  113359. * Gets the right operand
  113360. */
  113361. readonly right: NodeMaterialConnectionPoint;
  113362. /**
  113363. * Gets the current class name
  113364. * @returns the class name
  113365. */
  113366. getClassName(): string;
  113367. protected _buildBlock(state: NodeMaterialBuildState): this;
  113368. }
  113369. }
  113370. declare module BABYLON {
  113371. /**
  113372. * Helper class to push actions to a pool of workers.
  113373. */
  113374. export class WorkerPool implements IDisposable {
  113375. private _workerInfos;
  113376. private _pendingActions;
  113377. /**
  113378. * Constructor
  113379. * @param workers Array of workers to use for actions
  113380. */
  113381. constructor(workers: Array<Worker>);
  113382. /**
  113383. * Terminates all workers and clears any pending actions.
  113384. */
  113385. dispose(): void;
  113386. /**
  113387. * Pushes an action to the worker pool. If all the workers are active, the action will be
  113388. * pended until a worker has completed its action.
  113389. * @param action The action to perform. Call onComplete when the action is complete.
  113390. */
  113391. push(action: (worker: Worker, onComplete: () => void) => void): void;
  113392. private _execute;
  113393. }
  113394. }
  113395. declare module BABYLON {
  113396. /**
  113397. * Configuration for Draco compression
  113398. */
  113399. export interface IDracoCompressionConfiguration {
  113400. /**
  113401. * Configuration for the decoder.
  113402. */
  113403. decoder: {
  113404. /**
  113405. * The url to the WebAssembly module.
  113406. */
  113407. wasmUrl?: string;
  113408. /**
  113409. * The url to the WebAssembly binary.
  113410. */
  113411. wasmBinaryUrl?: string;
  113412. /**
  113413. * The url to the fallback JavaScript module.
  113414. */
  113415. fallbackUrl?: string;
  113416. };
  113417. }
  113418. /**
  113419. * Draco compression (https://google.github.io/draco/)
  113420. *
  113421. * This class wraps the Draco module.
  113422. *
  113423. * **Encoder**
  113424. *
  113425. * The encoder is not currently implemented.
  113426. *
  113427. * **Decoder**
  113428. *
  113429. * 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.
  113430. *
  113431. * To update the configuration, use the following code:
  113432. * ```javascript
  113433. * DracoCompression.Configuration = {
  113434. * decoder: {
  113435. * wasmUrl: "<url to the WebAssembly library>",
  113436. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  113437. * fallbackUrl: "<url to the fallback JavaScript library>",
  113438. * }
  113439. * };
  113440. * ```
  113441. *
  113442. * 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.
  113443. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  113444. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  113445. *
  113446. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  113447. * ```javascript
  113448. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  113449. * ```
  113450. *
  113451. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  113452. */
  113453. export class DracoCompression implements IDisposable {
  113454. private _workerPoolPromise?;
  113455. private _decoderModulePromise?;
  113456. /**
  113457. * The configuration. Defaults to the following urls:
  113458. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  113459. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  113460. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  113461. */
  113462. static Configuration: IDracoCompressionConfiguration;
  113463. /**
  113464. * Returns true if the decoder configuration is available.
  113465. */
  113466. static readonly DecoderAvailable: boolean;
  113467. /**
  113468. * Default number of workers to create when creating the draco compression object.
  113469. */
  113470. static DefaultNumWorkers: number;
  113471. private static GetDefaultNumWorkers;
  113472. private static _Default;
  113473. /**
  113474. * Default instance for the draco compression object.
  113475. */
  113476. static readonly Default: DracoCompression;
  113477. /**
  113478. * Constructor
  113479. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  113480. */
  113481. constructor(numWorkers?: number);
  113482. /**
  113483. * Stop all async operations and release resources.
  113484. */
  113485. dispose(): void;
  113486. /**
  113487. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  113488. * @returns a promise that resolves when ready
  113489. */
  113490. whenReadyAsync(): Promise<void>;
  113491. /**
  113492. * Decode Draco compressed mesh data to vertex data.
  113493. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  113494. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  113495. * @returns A promise that resolves with the decoded vertex data
  113496. */
  113497. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  113498. [kind: string]: number;
  113499. }): Promise<VertexData>;
  113500. }
  113501. }
  113502. declare module BABYLON {
  113503. /**
  113504. * Class for building Constructive Solid Geometry
  113505. */
  113506. export class CSG {
  113507. private polygons;
  113508. /**
  113509. * The world matrix
  113510. */
  113511. matrix: Matrix;
  113512. /**
  113513. * Stores the position
  113514. */
  113515. position: Vector3;
  113516. /**
  113517. * Stores the rotation
  113518. */
  113519. rotation: Vector3;
  113520. /**
  113521. * Stores the rotation quaternion
  113522. */
  113523. rotationQuaternion: Nullable<Quaternion>;
  113524. /**
  113525. * Stores the scaling vector
  113526. */
  113527. scaling: Vector3;
  113528. /**
  113529. * Convert the Mesh to CSG
  113530. * @param mesh The Mesh to convert to CSG
  113531. * @returns A new CSG from the Mesh
  113532. */
  113533. static FromMesh(mesh: Mesh): CSG;
  113534. /**
  113535. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  113536. * @param polygons Polygons used to construct a CSG solid
  113537. */
  113538. private static FromPolygons;
  113539. /**
  113540. * Clones, or makes a deep copy, of the CSG
  113541. * @returns A new CSG
  113542. */
  113543. clone(): CSG;
  113544. /**
  113545. * Unions this CSG with another CSG
  113546. * @param csg The CSG to union against this CSG
  113547. * @returns The unioned CSG
  113548. */
  113549. union(csg: CSG): CSG;
  113550. /**
  113551. * Unions this CSG with another CSG in place
  113552. * @param csg The CSG to union against this CSG
  113553. */
  113554. unionInPlace(csg: CSG): void;
  113555. /**
  113556. * Subtracts this CSG with another CSG
  113557. * @param csg The CSG to subtract against this CSG
  113558. * @returns A new CSG
  113559. */
  113560. subtract(csg: CSG): CSG;
  113561. /**
  113562. * Subtracts this CSG with another CSG in place
  113563. * @param csg The CSG to subtact against this CSG
  113564. */
  113565. subtractInPlace(csg: CSG): void;
  113566. /**
  113567. * Intersect this CSG with another CSG
  113568. * @param csg The CSG to intersect against this CSG
  113569. * @returns A new CSG
  113570. */
  113571. intersect(csg: CSG): CSG;
  113572. /**
  113573. * Intersects this CSG with another CSG in place
  113574. * @param csg The CSG to intersect against this CSG
  113575. */
  113576. intersectInPlace(csg: CSG): void;
  113577. /**
  113578. * Return a new CSG solid with solid and empty space switched. This solid is
  113579. * not modified.
  113580. * @returns A new CSG solid with solid and empty space switched
  113581. */
  113582. inverse(): CSG;
  113583. /**
  113584. * Inverses the CSG in place
  113585. */
  113586. inverseInPlace(): void;
  113587. /**
  113588. * This is used to keep meshes transformations so they can be restored
  113589. * when we build back a Babylon Mesh
  113590. * NB : All CSG operations are performed in world coordinates
  113591. * @param csg The CSG to copy the transform attributes from
  113592. * @returns This CSG
  113593. */
  113594. copyTransformAttributes(csg: CSG): CSG;
  113595. /**
  113596. * Build Raw mesh from CSG
  113597. * Coordinates here are in world space
  113598. * @param name The name of the mesh geometry
  113599. * @param scene The Scene
  113600. * @param keepSubMeshes Specifies if the submeshes should be kept
  113601. * @returns A new Mesh
  113602. */
  113603. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  113604. /**
  113605. * Build Mesh from CSG taking material and transforms into account
  113606. * @param name The name of the Mesh
  113607. * @param material The material of the Mesh
  113608. * @param scene The Scene
  113609. * @param keepSubMeshes Specifies if submeshes should be kept
  113610. * @returns The new Mesh
  113611. */
  113612. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  113613. }
  113614. }
  113615. declare module BABYLON {
  113616. /**
  113617. * Class used to create a trail following a mesh
  113618. */
  113619. export class TrailMesh extends Mesh {
  113620. private _generator;
  113621. private _autoStart;
  113622. private _running;
  113623. private _diameter;
  113624. private _length;
  113625. private _sectionPolygonPointsCount;
  113626. private _sectionVectors;
  113627. private _sectionNormalVectors;
  113628. private _beforeRenderObserver;
  113629. /**
  113630. * @constructor
  113631. * @param name The value used by scene.getMeshByName() to do a lookup.
  113632. * @param generator The mesh to generate a trail.
  113633. * @param scene The scene to add this mesh to.
  113634. * @param diameter Diameter of trailing mesh. Default is 1.
  113635. * @param length Length of trailing mesh. Default is 60.
  113636. * @param autoStart Automatically start trailing mesh. Default true.
  113637. */
  113638. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  113639. /**
  113640. * "TrailMesh"
  113641. * @returns "TrailMesh"
  113642. */
  113643. getClassName(): string;
  113644. private _createMesh;
  113645. /**
  113646. * Start trailing mesh.
  113647. */
  113648. start(): void;
  113649. /**
  113650. * Stop trailing mesh.
  113651. */
  113652. stop(): void;
  113653. /**
  113654. * Update trailing mesh geometry.
  113655. */
  113656. update(): void;
  113657. /**
  113658. * Returns a new TrailMesh object.
  113659. * @param name is a string, the name given to the new mesh
  113660. * @param newGenerator use new generator object for cloned trail mesh
  113661. * @returns a new mesh
  113662. */
  113663. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  113664. /**
  113665. * Serializes this trail mesh
  113666. * @param serializationObject object to write serialization to
  113667. */
  113668. serialize(serializationObject: any): void;
  113669. /**
  113670. * Parses a serialized trail mesh
  113671. * @param parsedMesh the serialized mesh
  113672. * @param scene the scene to create the trail mesh in
  113673. * @returns the created trail mesh
  113674. */
  113675. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  113676. }
  113677. }
  113678. declare module BABYLON {
  113679. /**
  113680. * Class containing static functions to help procedurally build meshes
  113681. */
  113682. export class TiledBoxBuilder {
  113683. /**
  113684. * Creates a box mesh
  113685. * 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)
  113686. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  113687. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  113688. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  113689. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  113690. * @param name defines the name of the mesh
  113691. * @param options defines the options used to create the mesh
  113692. * @param scene defines the hosting scene
  113693. * @returns the box mesh
  113694. */
  113695. static CreateTiledBox(name: string, options: {
  113696. pattern?: number;
  113697. width?: number;
  113698. height?: number;
  113699. depth?: number;
  113700. tileSize?: number;
  113701. tileWidth?: number;
  113702. tileHeight?: number;
  113703. alignHorizontal?: number;
  113704. alignVertical?: number;
  113705. faceUV?: Vector4[];
  113706. faceColors?: Color4[];
  113707. sideOrientation?: number;
  113708. updatable?: boolean;
  113709. }, scene?: Nullable<Scene>): Mesh;
  113710. }
  113711. }
  113712. declare module BABYLON {
  113713. /**
  113714. * Class containing static functions to help procedurally build meshes
  113715. */
  113716. export class TorusKnotBuilder {
  113717. /**
  113718. * Creates a torus knot mesh
  113719. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  113720. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  113721. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  113722. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  113723. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  113724. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  113725. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  113726. * @param name defines the name of the mesh
  113727. * @param options defines the options used to create the mesh
  113728. * @param scene defines the hosting scene
  113729. * @returns the torus knot mesh
  113730. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  113731. */
  113732. static CreateTorusKnot(name: string, options: {
  113733. radius?: number;
  113734. tube?: number;
  113735. radialSegments?: number;
  113736. tubularSegments?: number;
  113737. p?: number;
  113738. q?: number;
  113739. updatable?: boolean;
  113740. sideOrientation?: number;
  113741. frontUVs?: Vector4;
  113742. backUVs?: Vector4;
  113743. }, scene: any): Mesh;
  113744. }
  113745. }
  113746. declare module BABYLON {
  113747. /**
  113748. * Polygon
  113749. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  113750. */
  113751. export class Polygon {
  113752. /**
  113753. * Creates a rectangle
  113754. * @param xmin bottom X coord
  113755. * @param ymin bottom Y coord
  113756. * @param xmax top X coord
  113757. * @param ymax top Y coord
  113758. * @returns points that make the resulting rectation
  113759. */
  113760. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  113761. /**
  113762. * Creates a circle
  113763. * @param radius radius of circle
  113764. * @param cx scale in x
  113765. * @param cy scale in y
  113766. * @param numberOfSides number of sides that make up the circle
  113767. * @returns points that make the resulting circle
  113768. */
  113769. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  113770. /**
  113771. * Creates a polygon from input string
  113772. * @param input Input polygon data
  113773. * @returns the parsed points
  113774. */
  113775. static Parse(input: string): Vector2[];
  113776. /**
  113777. * Starts building a polygon from x and y coordinates
  113778. * @param x x coordinate
  113779. * @param y y coordinate
  113780. * @returns the started path2
  113781. */
  113782. static StartingAt(x: number, y: number): Path2;
  113783. }
  113784. /**
  113785. * Builds a polygon
  113786. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  113787. */
  113788. export class PolygonMeshBuilder {
  113789. private _points;
  113790. private _outlinepoints;
  113791. private _holes;
  113792. private _name;
  113793. private _scene;
  113794. private _epoints;
  113795. private _eholes;
  113796. private _addToepoint;
  113797. /**
  113798. * Babylon reference to the earcut plugin.
  113799. */
  113800. bjsEarcut: any;
  113801. /**
  113802. * Creates a PolygonMeshBuilder
  113803. * @param name name of the builder
  113804. * @param contours Path of the polygon
  113805. * @param scene scene to add to when creating the mesh
  113806. * @param earcutInjection can be used to inject your own earcut reference
  113807. */
  113808. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  113809. /**
  113810. * Adds a whole within the polygon
  113811. * @param hole Array of points defining the hole
  113812. * @returns this
  113813. */
  113814. addHole(hole: Vector2[]): PolygonMeshBuilder;
  113815. /**
  113816. * Creates the polygon
  113817. * @param updatable If the mesh should be updatable
  113818. * @param depth The depth of the mesh created
  113819. * @returns the created mesh
  113820. */
  113821. build(updatable?: boolean, depth?: number): Mesh;
  113822. /**
  113823. * Creates the polygon
  113824. * @param depth The depth of the mesh created
  113825. * @returns the created VertexData
  113826. */
  113827. buildVertexData(depth?: number): VertexData;
  113828. /**
  113829. * Adds a side to the polygon
  113830. * @param positions points that make the polygon
  113831. * @param normals normals of the polygon
  113832. * @param uvs uvs of the polygon
  113833. * @param indices indices of the polygon
  113834. * @param bounds bounds of the polygon
  113835. * @param points points of the polygon
  113836. * @param depth depth of the polygon
  113837. * @param flip flip of the polygon
  113838. */
  113839. private addSide;
  113840. }
  113841. }
  113842. declare module BABYLON {
  113843. /**
  113844. * Class containing static functions to help procedurally build meshes
  113845. */
  113846. export class PolygonBuilder {
  113847. /**
  113848. * Creates a polygon mesh
  113849. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  113850. * * 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
  113851. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  113852. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  113853. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  113854. * * Remember you can only change the shape positions, not their number when updating a polygon
  113855. * @param name defines the name of the mesh
  113856. * @param options defines the options used to create the mesh
  113857. * @param scene defines the hosting scene
  113858. * @param earcutInjection can be used to inject your own earcut reference
  113859. * @returns the polygon mesh
  113860. */
  113861. static CreatePolygon(name: string, options: {
  113862. shape: Vector3[];
  113863. holes?: Vector3[][];
  113864. depth?: number;
  113865. faceUV?: Vector4[];
  113866. faceColors?: Color4[];
  113867. updatable?: boolean;
  113868. sideOrientation?: number;
  113869. frontUVs?: Vector4;
  113870. backUVs?: Vector4;
  113871. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  113872. /**
  113873. * Creates an extruded polygon mesh, with depth in the Y direction.
  113874. * * 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)
  113875. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  113876. * @param name defines the name of the mesh
  113877. * @param options defines the options used to create the mesh
  113878. * @param scene defines the hosting scene
  113879. * @param earcutInjection can be used to inject your own earcut reference
  113880. * @returns the polygon mesh
  113881. */
  113882. static ExtrudePolygon(name: string, options: {
  113883. shape: Vector3[];
  113884. holes?: Vector3[][];
  113885. depth?: number;
  113886. faceUV?: Vector4[];
  113887. faceColors?: Color4[];
  113888. updatable?: boolean;
  113889. sideOrientation?: number;
  113890. frontUVs?: Vector4;
  113891. backUVs?: Vector4;
  113892. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  113893. }
  113894. }
  113895. declare module BABYLON {
  113896. /**
  113897. * Class containing static functions to help procedurally build meshes
  113898. */
  113899. export class LatheBuilder {
  113900. /**
  113901. * Creates lathe mesh.
  113902. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  113903. * * 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
  113904. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  113905. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  113906. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  113907. * * 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
  113908. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  113909. * * 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
  113910. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  113911. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  113912. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  113913. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  113914. * @param name defines the name of the mesh
  113915. * @param options defines the options used to create the mesh
  113916. * @param scene defines the hosting scene
  113917. * @returns the lathe mesh
  113918. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  113919. */
  113920. static CreateLathe(name: string, options: {
  113921. shape: Vector3[];
  113922. radius?: number;
  113923. tessellation?: number;
  113924. clip?: number;
  113925. arc?: number;
  113926. closed?: boolean;
  113927. updatable?: boolean;
  113928. sideOrientation?: number;
  113929. frontUVs?: Vector4;
  113930. backUVs?: Vector4;
  113931. cap?: number;
  113932. invertUV?: boolean;
  113933. }, scene?: Nullable<Scene>): Mesh;
  113934. }
  113935. }
  113936. declare module BABYLON {
  113937. /**
  113938. * Class containing static functions to help procedurally build meshes
  113939. */
  113940. export class TiledPlaneBuilder {
  113941. /**
  113942. * Creates a tiled plane mesh
  113943. * * The parameter `pattern` will, depending on value, do nothing or
  113944. * * * flip (reflect about central vertical) alternate tiles across and up
  113945. * * * flip every tile on alternate rows
  113946. * * * rotate (180 degs) alternate tiles across and up
  113947. * * * rotate every tile on alternate rows
  113948. * * * flip and rotate alternate tiles across and up
  113949. * * * flip and rotate every tile on alternate rows
  113950. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  113951. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  113952. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  113953. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  113954. * * 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)
  113955. * * 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)
  113956. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  113957. * @param name defines the name of the mesh
  113958. * @param options defines the options used to create the mesh
  113959. * @param scene defines the hosting scene
  113960. * @returns the box mesh
  113961. */
  113962. static CreateTiledPlane(name: string, options: {
  113963. pattern?: number;
  113964. tileSize?: number;
  113965. tileWidth?: number;
  113966. tileHeight?: number;
  113967. size?: number;
  113968. width?: number;
  113969. height?: number;
  113970. alignHorizontal?: number;
  113971. alignVertical?: number;
  113972. sideOrientation?: number;
  113973. frontUVs?: Vector4;
  113974. backUVs?: Vector4;
  113975. updatable?: boolean;
  113976. }, scene?: Nullable<Scene>): Mesh;
  113977. }
  113978. }
  113979. declare module BABYLON {
  113980. /**
  113981. * Class containing static functions to help procedurally build meshes
  113982. */
  113983. export class TubeBuilder {
  113984. /**
  113985. * Creates a tube mesh.
  113986. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  113987. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  113988. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  113989. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  113990. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  113991. * * 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)
  113992. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  113993. * * 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
  113994. * * 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
  113995. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  113996. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  113997. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  113998. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  113999. * @param name defines the name of the mesh
  114000. * @param options defines the options used to create the mesh
  114001. * @param scene defines the hosting scene
  114002. * @returns the tube mesh
  114003. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  114004. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  114005. */
  114006. static CreateTube(name: string, options: {
  114007. path: Vector3[];
  114008. radius?: number;
  114009. tessellation?: number;
  114010. radiusFunction?: {
  114011. (i: number, distance: number): number;
  114012. };
  114013. cap?: number;
  114014. arc?: number;
  114015. updatable?: boolean;
  114016. sideOrientation?: number;
  114017. frontUVs?: Vector4;
  114018. backUVs?: Vector4;
  114019. instance?: Mesh;
  114020. invertUV?: boolean;
  114021. }, scene?: Nullable<Scene>): Mesh;
  114022. }
  114023. }
  114024. declare module BABYLON {
  114025. /**
  114026. * Class containing static functions to help procedurally build meshes
  114027. */
  114028. export class IcoSphereBuilder {
  114029. /**
  114030. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  114031. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  114032. * * 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`)
  114033. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  114034. * * 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
  114035. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  114036. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  114037. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  114038. * @param name defines the name of the mesh
  114039. * @param options defines the options used to create the mesh
  114040. * @param scene defines the hosting scene
  114041. * @returns the icosahedron mesh
  114042. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  114043. */
  114044. static CreateIcoSphere(name: string, options: {
  114045. radius?: number;
  114046. radiusX?: number;
  114047. radiusY?: number;
  114048. radiusZ?: number;
  114049. flat?: boolean;
  114050. subdivisions?: number;
  114051. sideOrientation?: number;
  114052. frontUVs?: Vector4;
  114053. backUVs?: Vector4;
  114054. updatable?: boolean;
  114055. }, scene?: Nullable<Scene>): Mesh;
  114056. }
  114057. }
  114058. declare module BABYLON {
  114059. /**
  114060. * Class containing static functions to help procedurally build meshes
  114061. */
  114062. export class DecalBuilder {
  114063. /**
  114064. * Creates a decal mesh.
  114065. * 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
  114066. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  114067. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  114068. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  114069. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  114070. * @param name defines the name of the mesh
  114071. * @param sourceMesh defines the mesh where the decal must be applied
  114072. * @param options defines the options used to create the mesh
  114073. * @param scene defines the hosting scene
  114074. * @returns the decal mesh
  114075. * @see https://doc.babylonjs.com/how_to/decals
  114076. */
  114077. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  114078. position?: Vector3;
  114079. normal?: Vector3;
  114080. size?: Vector3;
  114081. angle?: number;
  114082. }): Mesh;
  114083. }
  114084. }
  114085. declare module BABYLON {
  114086. /**
  114087. * Class containing static functions to help procedurally build meshes
  114088. */
  114089. export class MeshBuilder {
  114090. /**
  114091. * Creates a box mesh
  114092. * * The parameter `size` sets the size (float) of each box side (default 1)
  114093. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  114094. * * 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)
  114095. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  114096. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  114097. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  114098. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  114099. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  114100. * @param name defines the name of the mesh
  114101. * @param options defines the options used to create the mesh
  114102. * @param scene defines the hosting scene
  114103. * @returns the box mesh
  114104. */
  114105. static CreateBox(name: string, options: {
  114106. size?: number;
  114107. width?: number;
  114108. height?: number;
  114109. depth?: number;
  114110. faceUV?: Vector4[];
  114111. faceColors?: Color4[];
  114112. sideOrientation?: number;
  114113. frontUVs?: Vector4;
  114114. backUVs?: Vector4;
  114115. updatable?: boolean;
  114116. }, scene?: Nullable<Scene>): Mesh;
  114117. /**
  114118. * Creates a tiled box mesh
  114119. * * faceTiles sets the pattern, tile size and number of tiles for a face
  114120. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  114121. * @param name defines the name of the mesh
  114122. * @param options defines the options used to create the mesh
  114123. * @param scene defines the hosting scene
  114124. * @returns the tiled box mesh
  114125. */
  114126. static CreateTiledBox(name: string, options: {
  114127. pattern?: number;
  114128. size?: number;
  114129. width?: number;
  114130. height?: number;
  114131. depth: number;
  114132. tileSize?: number;
  114133. tileWidth?: number;
  114134. tileHeight?: number;
  114135. faceUV?: Vector4[];
  114136. faceColors?: Color4[];
  114137. alignHorizontal?: number;
  114138. alignVertical?: number;
  114139. sideOrientation?: number;
  114140. updatable?: boolean;
  114141. }, scene?: Nullable<Scene>): Mesh;
  114142. /**
  114143. * Creates a sphere mesh
  114144. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  114145. * * 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`)
  114146. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  114147. * * 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
  114148. * * 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)
  114149. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  114150. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  114151. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  114152. * @param name defines the name of the mesh
  114153. * @param options defines the options used to create the mesh
  114154. * @param scene defines the hosting scene
  114155. * @returns the sphere mesh
  114156. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  114157. */
  114158. static CreateSphere(name: string, options: {
  114159. segments?: number;
  114160. diameter?: number;
  114161. diameterX?: number;
  114162. diameterY?: number;
  114163. diameterZ?: number;
  114164. arc?: number;
  114165. slice?: number;
  114166. sideOrientation?: number;
  114167. frontUVs?: Vector4;
  114168. backUVs?: Vector4;
  114169. updatable?: boolean;
  114170. }, scene?: Nullable<Scene>): Mesh;
  114171. /**
  114172. * Creates a plane polygonal mesh. By default, this is a disc
  114173. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  114174. * * 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
  114175. * * 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
  114176. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  114177. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  114178. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  114179. * @param name defines the name of the mesh
  114180. * @param options defines the options used to create the mesh
  114181. * @param scene defines the hosting scene
  114182. * @returns the plane polygonal mesh
  114183. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  114184. */
  114185. static CreateDisc(name: string, options: {
  114186. radius?: number;
  114187. tessellation?: number;
  114188. arc?: number;
  114189. updatable?: boolean;
  114190. sideOrientation?: number;
  114191. frontUVs?: Vector4;
  114192. backUVs?: Vector4;
  114193. }, scene?: Nullable<Scene>): Mesh;
  114194. /**
  114195. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  114196. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  114197. * * 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`)
  114198. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  114199. * * 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
  114200. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  114201. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  114202. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  114203. * @param name defines the name of the mesh
  114204. * @param options defines the options used to create the mesh
  114205. * @param scene defines the hosting scene
  114206. * @returns the icosahedron mesh
  114207. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  114208. */
  114209. static CreateIcoSphere(name: string, options: {
  114210. radius?: number;
  114211. radiusX?: number;
  114212. radiusY?: number;
  114213. radiusZ?: number;
  114214. flat?: boolean;
  114215. subdivisions?: number;
  114216. sideOrientation?: number;
  114217. frontUVs?: Vector4;
  114218. backUVs?: Vector4;
  114219. updatable?: boolean;
  114220. }, scene?: Nullable<Scene>): Mesh;
  114221. /**
  114222. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  114223. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  114224. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  114225. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  114226. * * 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
  114227. * * 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
  114228. * * 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
  114229. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  114230. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  114231. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  114232. * * 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
  114233. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  114234. * * 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
  114235. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  114236. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  114237. * @param name defines the name of the mesh
  114238. * @param options defines the options used to create the mesh
  114239. * @param scene defines the hosting scene
  114240. * @returns the ribbon mesh
  114241. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  114242. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  114243. */
  114244. static CreateRibbon(name: string, options: {
  114245. pathArray: Vector3[][];
  114246. closeArray?: boolean;
  114247. closePath?: boolean;
  114248. offset?: number;
  114249. updatable?: boolean;
  114250. sideOrientation?: number;
  114251. frontUVs?: Vector4;
  114252. backUVs?: Vector4;
  114253. instance?: Mesh;
  114254. invertUV?: boolean;
  114255. uvs?: Vector2[];
  114256. colors?: Color4[];
  114257. }, scene?: Nullable<Scene>): Mesh;
  114258. /**
  114259. * Creates a cylinder or a cone mesh
  114260. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  114261. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  114262. * * 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.
  114263. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  114264. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  114265. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  114266. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  114267. * * 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).
  114268. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  114269. * * 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).
  114270. * * 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
  114271. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  114272. * * 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
  114273. * * 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.
  114274. * * If `enclose` is false, a ring surface is one element.
  114275. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  114276. * * 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
  114277. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  114278. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  114279. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  114280. * @param name defines the name of the mesh
  114281. * @param options defines the options used to create the mesh
  114282. * @param scene defines the hosting scene
  114283. * @returns the cylinder mesh
  114284. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  114285. */
  114286. static CreateCylinder(name: string, options: {
  114287. height?: number;
  114288. diameterTop?: number;
  114289. diameterBottom?: number;
  114290. diameter?: number;
  114291. tessellation?: number;
  114292. subdivisions?: number;
  114293. arc?: number;
  114294. faceColors?: Color4[];
  114295. faceUV?: Vector4[];
  114296. updatable?: boolean;
  114297. hasRings?: boolean;
  114298. enclose?: boolean;
  114299. cap?: number;
  114300. sideOrientation?: number;
  114301. frontUVs?: Vector4;
  114302. backUVs?: Vector4;
  114303. }, scene?: Nullable<Scene>): Mesh;
  114304. /**
  114305. * Creates a torus mesh
  114306. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  114307. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  114308. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  114309. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  114310. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  114311. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  114312. * @param name defines the name of the mesh
  114313. * @param options defines the options used to create the mesh
  114314. * @param scene defines the hosting scene
  114315. * @returns the torus mesh
  114316. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  114317. */
  114318. static CreateTorus(name: string, options: {
  114319. diameter?: number;
  114320. thickness?: number;
  114321. tessellation?: number;
  114322. updatable?: boolean;
  114323. sideOrientation?: number;
  114324. frontUVs?: Vector4;
  114325. backUVs?: Vector4;
  114326. }, scene?: Nullable<Scene>): Mesh;
  114327. /**
  114328. * Creates a torus knot mesh
  114329. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  114330. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  114331. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  114332. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  114333. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  114334. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  114335. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  114336. * @param name defines the name of the mesh
  114337. * @param options defines the options used to create the mesh
  114338. * @param scene defines the hosting scene
  114339. * @returns the torus knot mesh
  114340. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  114341. */
  114342. static CreateTorusKnot(name: string, options: {
  114343. radius?: number;
  114344. tube?: number;
  114345. radialSegments?: number;
  114346. tubularSegments?: number;
  114347. p?: number;
  114348. q?: number;
  114349. updatable?: boolean;
  114350. sideOrientation?: number;
  114351. frontUVs?: Vector4;
  114352. backUVs?: Vector4;
  114353. }, scene?: Nullable<Scene>): Mesh;
  114354. /**
  114355. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  114356. * * 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
  114357. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  114358. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  114359. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  114360. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  114361. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  114362. * * 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
  114363. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  114364. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  114365. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  114366. * @param name defines the name of the new line system
  114367. * @param options defines the options used to create the line system
  114368. * @param scene defines the hosting scene
  114369. * @returns a new line system mesh
  114370. */
  114371. static CreateLineSystem(name: string, options: {
  114372. lines: Vector3[][];
  114373. updatable?: boolean;
  114374. instance?: Nullable<LinesMesh>;
  114375. colors?: Nullable<Color4[][]>;
  114376. useVertexAlpha?: boolean;
  114377. }, scene: Nullable<Scene>): LinesMesh;
  114378. /**
  114379. * Creates a line mesh
  114380. * 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
  114381. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  114382. * * The parameter `points` is an array successive Vector3
  114383. * * 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
  114384. * * The optional parameter `colors` is an array of successive Color4, one per line point
  114385. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  114386. * * When updating an instance, remember that only point positions can change, not the number of points
  114387. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  114388. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  114389. * @param name defines the name of the new line system
  114390. * @param options defines the options used to create the line system
  114391. * @param scene defines the hosting scene
  114392. * @returns a new line mesh
  114393. */
  114394. static CreateLines(name: string, options: {
  114395. points: Vector3[];
  114396. updatable?: boolean;
  114397. instance?: Nullable<LinesMesh>;
  114398. colors?: Color4[];
  114399. useVertexAlpha?: boolean;
  114400. }, scene?: Nullable<Scene>): LinesMesh;
  114401. /**
  114402. * Creates a dashed line mesh
  114403. * * 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
  114404. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  114405. * * The parameter `points` is an array successive Vector3
  114406. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  114407. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  114408. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  114409. * * 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
  114410. * * When updating an instance, remember that only point positions can change, not the number of points
  114411. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  114412. * @param name defines the name of the mesh
  114413. * @param options defines the options used to create the mesh
  114414. * @param scene defines the hosting scene
  114415. * @returns the dashed line mesh
  114416. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  114417. */
  114418. static CreateDashedLines(name: string, options: {
  114419. points: Vector3[];
  114420. dashSize?: number;
  114421. gapSize?: number;
  114422. dashNb?: number;
  114423. updatable?: boolean;
  114424. instance?: LinesMesh;
  114425. }, scene?: Nullable<Scene>): LinesMesh;
  114426. /**
  114427. * 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.
  114428. * * 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.
  114429. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  114430. * * 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.
  114431. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  114432. * * 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
  114433. * * 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
  114434. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  114435. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  114436. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  114437. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  114438. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  114439. * @param name defines the name of the mesh
  114440. * @param options defines the options used to create the mesh
  114441. * @param scene defines the hosting scene
  114442. * @returns the extruded shape mesh
  114443. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  114444. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  114445. */
  114446. static ExtrudeShape(name: string, options: {
  114447. shape: Vector3[];
  114448. path: Vector3[];
  114449. scale?: number;
  114450. rotation?: number;
  114451. cap?: number;
  114452. updatable?: boolean;
  114453. sideOrientation?: number;
  114454. frontUVs?: Vector4;
  114455. backUVs?: Vector4;
  114456. instance?: Mesh;
  114457. invertUV?: boolean;
  114458. }, scene?: Nullable<Scene>): Mesh;
  114459. /**
  114460. * Creates an custom extruded shape mesh.
  114461. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  114462. * * 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.
  114463. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  114464. * * 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
  114465. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  114466. * * 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
  114467. * * It must returns a float value that will be the scale value applied to the shape on each path point
  114468. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  114469. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  114470. * * 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
  114471. * * 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
  114472. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  114473. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  114474. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  114475. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  114476. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  114477. * @param name defines the name of the mesh
  114478. * @param options defines the options used to create the mesh
  114479. * @param scene defines the hosting scene
  114480. * @returns the custom extruded shape mesh
  114481. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  114482. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  114483. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  114484. */
  114485. static ExtrudeShapeCustom(name: string, options: {
  114486. shape: Vector3[];
  114487. path: Vector3[];
  114488. scaleFunction?: any;
  114489. rotationFunction?: any;
  114490. ribbonCloseArray?: boolean;
  114491. ribbonClosePath?: boolean;
  114492. cap?: number;
  114493. updatable?: boolean;
  114494. sideOrientation?: number;
  114495. frontUVs?: Vector4;
  114496. backUVs?: Vector4;
  114497. instance?: Mesh;
  114498. invertUV?: boolean;
  114499. }, scene?: Nullable<Scene>): Mesh;
  114500. /**
  114501. * Creates lathe mesh.
  114502. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  114503. * * 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
  114504. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  114505. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  114506. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  114507. * * 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
  114508. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  114509. * * 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
  114510. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  114511. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  114512. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  114513. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  114514. * @param name defines the name of the mesh
  114515. * @param options defines the options used to create the mesh
  114516. * @param scene defines the hosting scene
  114517. * @returns the lathe mesh
  114518. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  114519. */
  114520. static CreateLathe(name: string, options: {
  114521. shape: Vector3[];
  114522. radius?: number;
  114523. tessellation?: number;
  114524. clip?: number;
  114525. arc?: number;
  114526. closed?: boolean;
  114527. updatable?: boolean;
  114528. sideOrientation?: number;
  114529. frontUVs?: Vector4;
  114530. backUVs?: Vector4;
  114531. cap?: number;
  114532. invertUV?: boolean;
  114533. }, scene?: Nullable<Scene>): Mesh;
  114534. /**
  114535. * Creates a tiled plane mesh
  114536. * * You can set a limited pattern arrangement with the tiles
  114537. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  114538. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  114539. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  114540. * @param name defines the name of the mesh
  114541. * @param options defines the options used to create the mesh
  114542. * @param scene defines the hosting scene
  114543. * @returns the plane mesh
  114544. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  114545. */
  114546. static CreateTiledPlane(name: string, options: {
  114547. pattern?: number;
  114548. tileSize?: number;
  114549. tileWidth?: number;
  114550. tileHeight?: number;
  114551. size?: number;
  114552. width?: number;
  114553. height?: number;
  114554. alignHorizontal?: number;
  114555. alignVertical?: number;
  114556. sideOrientation?: number;
  114557. frontUVs?: Vector4;
  114558. backUVs?: Vector4;
  114559. updatable?: boolean;
  114560. }, scene?: Nullable<Scene>): Mesh;
  114561. /**
  114562. * Creates a plane mesh
  114563. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  114564. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  114565. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  114566. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  114567. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  114568. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  114569. * @param name defines the name of the mesh
  114570. * @param options defines the options used to create the mesh
  114571. * @param scene defines the hosting scene
  114572. * @returns the plane mesh
  114573. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  114574. */
  114575. static CreatePlane(name: string, options: {
  114576. size?: number;
  114577. width?: number;
  114578. height?: number;
  114579. sideOrientation?: number;
  114580. frontUVs?: Vector4;
  114581. backUVs?: Vector4;
  114582. updatable?: boolean;
  114583. sourcePlane?: Plane;
  114584. }, scene?: Nullable<Scene>): Mesh;
  114585. /**
  114586. * Creates a ground mesh
  114587. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  114588. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  114589. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  114590. * @param name defines the name of the mesh
  114591. * @param options defines the options used to create the mesh
  114592. * @param scene defines the hosting scene
  114593. * @returns the ground mesh
  114594. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  114595. */
  114596. static CreateGround(name: string, options: {
  114597. width?: number;
  114598. height?: number;
  114599. subdivisions?: number;
  114600. subdivisionsX?: number;
  114601. subdivisionsY?: number;
  114602. updatable?: boolean;
  114603. }, scene?: Nullable<Scene>): Mesh;
  114604. /**
  114605. * Creates a tiled ground mesh
  114606. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  114607. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  114608. * * 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
  114609. * * 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
  114610. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  114611. * @param name defines the name of the mesh
  114612. * @param options defines the options used to create the mesh
  114613. * @param scene defines the hosting scene
  114614. * @returns the tiled ground mesh
  114615. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  114616. */
  114617. static CreateTiledGround(name: string, options: {
  114618. xmin: number;
  114619. zmin: number;
  114620. xmax: number;
  114621. zmax: number;
  114622. subdivisions?: {
  114623. w: number;
  114624. h: number;
  114625. };
  114626. precision?: {
  114627. w: number;
  114628. h: number;
  114629. };
  114630. updatable?: boolean;
  114631. }, scene?: Nullable<Scene>): Mesh;
  114632. /**
  114633. * Creates a ground mesh from a height map
  114634. * * The parameter `url` sets the URL of the height map image resource.
  114635. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  114636. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  114637. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  114638. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  114639. * * 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.
  114640. * * 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).
  114641. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  114642. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  114643. * @param name defines the name of the mesh
  114644. * @param url defines the url to the height map
  114645. * @param options defines the options used to create the mesh
  114646. * @param scene defines the hosting scene
  114647. * @returns the ground mesh
  114648. * @see https://doc.babylonjs.com/babylon101/height_map
  114649. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  114650. */
  114651. static CreateGroundFromHeightMap(name: string, url: string, options: {
  114652. width?: number;
  114653. height?: number;
  114654. subdivisions?: number;
  114655. minHeight?: number;
  114656. maxHeight?: number;
  114657. colorFilter?: Color3;
  114658. alphaFilter?: number;
  114659. updatable?: boolean;
  114660. onReady?: (mesh: GroundMesh) => void;
  114661. }, scene?: Nullable<Scene>): GroundMesh;
  114662. /**
  114663. * Creates a polygon mesh
  114664. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  114665. * * 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
  114666. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  114667. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  114668. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  114669. * * Remember you can only change the shape positions, not their number when updating a polygon
  114670. * @param name defines the name of the mesh
  114671. * @param options defines the options used to create the mesh
  114672. * @param scene defines the hosting scene
  114673. * @param earcutInjection can be used to inject your own earcut reference
  114674. * @returns the polygon mesh
  114675. */
  114676. static CreatePolygon(name: string, options: {
  114677. shape: Vector3[];
  114678. holes?: Vector3[][];
  114679. depth?: number;
  114680. faceUV?: Vector4[];
  114681. faceColors?: Color4[];
  114682. updatable?: boolean;
  114683. sideOrientation?: number;
  114684. frontUVs?: Vector4;
  114685. backUVs?: Vector4;
  114686. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  114687. /**
  114688. * Creates an extruded polygon mesh, with depth in the Y direction.
  114689. * * 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)
  114690. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  114691. * @param name defines the name of the mesh
  114692. * @param options defines the options used to create the mesh
  114693. * @param scene defines the hosting scene
  114694. * @param earcutInjection can be used to inject your own earcut reference
  114695. * @returns the polygon mesh
  114696. */
  114697. static ExtrudePolygon(name: string, options: {
  114698. shape: Vector3[];
  114699. holes?: Vector3[][];
  114700. depth?: number;
  114701. faceUV?: Vector4[];
  114702. faceColors?: Color4[];
  114703. updatable?: boolean;
  114704. sideOrientation?: number;
  114705. frontUVs?: Vector4;
  114706. backUVs?: Vector4;
  114707. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  114708. /**
  114709. * Creates a tube mesh.
  114710. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  114711. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  114712. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  114713. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  114714. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  114715. * * 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)
  114716. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  114717. * * 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
  114718. * * 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
  114719. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  114720. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  114721. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  114722. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  114723. * @param name defines the name of the mesh
  114724. * @param options defines the options used to create the mesh
  114725. * @param scene defines the hosting scene
  114726. * @returns the tube mesh
  114727. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  114728. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  114729. */
  114730. static CreateTube(name: string, options: {
  114731. path: Vector3[];
  114732. radius?: number;
  114733. tessellation?: number;
  114734. radiusFunction?: {
  114735. (i: number, distance: number): number;
  114736. };
  114737. cap?: number;
  114738. arc?: number;
  114739. updatable?: boolean;
  114740. sideOrientation?: number;
  114741. frontUVs?: Vector4;
  114742. backUVs?: Vector4;
  114743. instance?: Mesh;
  114744. invertUV?: boolean;
  114745. }, scene?: Nullable<Scene>): Mesh;
  114746. /**
  114747. * Creates a polyhedron mesh
  114748. * * 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
  114749. * * The parameter `size` (positive float, default 1) sets the polygon size
  114750. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  114751. * * 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`
  114752. * * 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
  114753. * * 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)`)
  114754. * * 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
  114755. * * 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
  114756. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  114757. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  114758. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  114759. * @param name defines the name of the mesh
  114760. * @param options defines the options used to create the mesh
  114761. * @param scene defines the hosting scene
  114762. * @returns the polyhedron mesh
  114763. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  114764. */
  114765. static CreatePolyhedron(name: string, options: {
  114766. type?: number;
  114767. size?: number;
  114768. sizeX?: number;
  114769. sizeY?: number;
  114770. sizeZ?: number;
  114771. custom?: any;
  114772. faceUV?: Vector4[];
  114773. faceColors?: Color4[];
  114774. flat?: boolean;
  114775. updatable?: boolean;
  114776. sideOrientation?: number;
  114777. frontUVs?: Vector4;
  114778. backUVs?: Vector4;
  114779. }, scene?: Nullable<Scene>): Mesh;
  114780. /**
  114781. * Creates a decal mesh.
  114782. * 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
  114783. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  114784. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  114785. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  114786. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  114787. * @param name defines the name of the mesh
  114788. * @param sourceMesh defines the mesh where the decal must be applied
  114789. * @param options defines the options used to create the mesh
  114790. * @param scene defines the hosting scene
  114791. * @returns the decal mesh
  114792. * @see https://doc.babylonjs.com/how_to/decals
  114793. */
  114794. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  114795. position?: Vector3;
  114796. normal?: Vector3;
  114797. size?: Vector3;
  114798. angle?: number;
  114799. }): Mesh;
  114800. }
  114801. }
  114802. declare module BABYLON {
  114803. /**
  114804. * A simplifier interface for future simplification implementations
  114805. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  114806. */
  114807. export interface ISimplifier {
  114808. /**
  114809. * Simplification of a given mesh according to the given settings.
  114810. * Since this requires computation, it is assumed that the function runs async.
  114811. * @param settings The settings of the simplification, including quality and distance
  114812. * @param successCallback A callback that will be called after the mesh was simplified.
  114813. * @param errorCallback in case of an error, this callback will be called. optional.
  114814. */
  114815. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  114816. }
  114817. /**
  114818. * Expected simplification settings.
  114819. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  114820. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  114821. */
  114822. export interface ISimplificationSettings {
  114823. /**
  114824. * Gets or sets the expected quality
  114825. */
  114826. quality: number;
  114827. /**
  114828. * Gets or sets the distance when this optimized version should be used
  114829. */
  114830. distance: number;
  114831. /**
  114832. * Gets an already optimized mesh
  114833. */
  114834. optimizeMesh?: boolean;
  114835. }
  114836. /**
  114837. * Class used to specify simplification options
  114838. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  114839. */
  114840. export class SimplificationSettings implements ISimplificationSettings {
  114841. /** expected quality */
  114842. quality: number;
  114843. /** distance when this optimized version should be used */
  114844. distance: number;
  114845. /** already optimized mesh */
  114846. optimizeMesh?: boolean | undefined;
  114847. /**
  114848. * Creates a SimplificationSettings
  114849. * @param quality expected quality
  114850. * @param distance distance when this optimized version should be used
  114851. * @param optimizeMesh already optimized mesh
  114852. */
  114853. constructor(
  114854. /** expected quality */
  114855. quality: number,
  114856. /** distance when this optimized version should be used */
  114857. distance: number,
  114858. /** already optimized mesh */
  114859. optimizeMesh?: boolean | undefined);
  114860. }
  114861. /**
  114862. * Interface used to define a simplification task
  114863. */
  114864. export interface ISimplificationTask {
  114865. /**
  114866. * Array of settings
  114867. */
  114868. settings: Array<ISimplificationSettings>;
  114869. /**
  114870. * Simplification type
  114871. */
  114872. simplificationType: SimplificationType;
  114873. /**
  114874. * Mesh to simplify
  114875. */
  114876. mesh: Mesh;
  114877. /**
  114878. * Callback called on success
  114879. */
  114880. successCallback?: () => void;
  114881. /**
  114882. * Defines if parallel processing can be used
  114883. */
  114884. parallelProcessing: boolean;
  114885. }
  114886. /**
  114887. * Queue used to order the simplification tasks
  114888. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  114889. */
  114890. export class SimplificationQueue {
  114891. private _simplificationArray;
  114892. /**
  114893. * Gets a boolean indicating that the process is still running
  114894. */
  114895. running: boolean;
  114896. /**
  114897. * Creates a new queue
  114898. */
  114899. constructor();
  114900. /**
  114901. * Adds a new simplification task
  114902. * @param task defines a task to add
  114903. */
  114904. addTask(task: ISimplificationTask): void;
  114905. /**
  114906. * Execute next task
  114907. */
  114908. executeNext(): void;
  114909. /**
  114910. * Execute a simplification task
  114911. * @param task defines the task to run
  114912. */
  114913. runSimplification(task: ISimplificationTask): void;
  114914. private getSimplifier;
  114915. }
  114916. /**
  114917. * The implemented types of simplification
  114918. * At the moment only Quadratic Error Decimation is implemented
  114919. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  114920. */
  114921. export enum SimplificationType {
  114922. /** Quadratic error decimation */
  114923. QUADRATIC = 0
  114924. }
  114925. }
  114926. declare module BABYLON {
  114927. interface Scene {
  114928. /** @hidden (Backing field) */
  114929. _simplificationQueue: SimplificationQueue;
  114930. /**
  114931. * Gets or sets the simplification queue attached to the scene
  114932. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  114933. */
  114934. simplificationQueue: SimplificationQueue;
  114935. }
  114936. interface Mesh {
  114937. /**
  114938. * Simplify the mesh according to the given array of settings.
  114939. * Function will return immediately and will simplify async
  114940. * @param settings a collection of simplification settings
  114941. * @param parallelProcessing should all levels calculate parallel or one after the other
  114942. * @param simplificationType the type of simplification to run
  114943. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  114944. * @returns the current mesh
  114945. */
  114946. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  114947. }
  114948. /**
  114949. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  114950. * created in a scene
  114951. */
  114952. export class SimplicationQueueSceneComponent implements ISceneComponent {
  114953. /**
  114954. * The component name helpfull to identify the component in the list of scene components.
  114955. */
  114956. readonly name: string;
  114957. /**
  114958. * The scene the component belongs to.
  114959. */
  114960. scene: Scene;
  114961. /**
  114962. * Creates a new instance of the component for the given scene
  114963. * @param scene Defines the scene to register the component in
  114964. */
  114965. constructor(scene: Scene);
  114966. /**
  114967. * Registers the component in a given scene
  114968. */
  114969. register(): void;
  114970. /**
  114971. * Rebuilds the elements related to this component in case of
  114972. * context lost for instance.
  114973. */
  114974. rebuild(): void;
  114975. /**
  114976. * Disposes the component and the associated ressources
  114977. */
  114978. dispose(): void;
  114979. private _beforeCameraUpdate;
  114980. }
  114981. }
  114982. declare module BABYLON {
  114983. /**
  114984. * Class used to enable access to IndexedDB
  114985. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  114986. */
  114987. export class Database implements IOfflineProvider {
  114988. private _callbackManifestChecked;
  114989. private _currentSceneUrl;
  114990. private _db;
  114991. private _enableSceneOffline;
  114992. private _enableTexturesOffline;
  114993. private _manifestVersionFound;
  114994. private _mustUpdateRessources;
  114995. private _hasReachedQuota;
  114996. private _isSupported;
  114997. private _idbFactory;
  114998. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  114999. private static IsUASupportingBlobStorage;
  115000. /**
  115001. * Gets a boolean indicating if Database storate is enabled (off by default)
  115002. */
  115003. static IDBStorageEnabled: boolean;
  115004. /**
  115005. * Gets a boolean indicating if scene must be saved in the database
  115006. */
  115007. readonly enableSceneOffline: boolean;
  115008. /**
  115009. * Gets a boolean indicating if textures must be saved in the database
  115010. */
  115011. readonly enableTexturesOffline: boolean;
  115012. /**
  115013. * Creates a new Database
  115014. * @param urlToScene defines the url to load the scene
  115015. * @param callbackManifestChecked defines the callback to use when manifest is checked
  115016. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  115017. */
  115018. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  115019. private static _ParseURL;
  115020. private static _ReturnFullUrlLocation;
  115021. private _checkManifestFile;
  115022. /**
  115023. * Open the database and make it available
  115024. * @param successCallback defines the callback to call on success
  115025. * @param errorCallback defines the callback to call on error
  115026. */
  115027. open(successCallback: () => void, errorCallback: () => void): void;
  115028. /**
  115029. * Loads an image from the database
  115030. * @param url defines the url to load from
  115031. * @param image defines the target DOM image
  115032. */
  115033. loadImage(url: string, image: HTMLImageElement): void;
  115034. private _loadImageFromDBAsync;
  115035. private _saveImageIntoDBAsync;
  115036. private _checkVersionFromDB;
  115037. private _loadVersionFromDBAsync;
  115038. private _saveVersionIntoDBAsync;
  115039. /**
  115040. * Loads a file from database
  115041. * @param url defines the URL to load from
  115042. * @param sceneLoaded defines a callback to call on success
  115043. * @param progressCallBack defines a callback to call when progress changed
  115044. * @param errorCallback defines a callback to call on error
  115045. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  115046. */
  115047. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  115048. private _loadFileAsync;
  115049. private _saveFileAsync;
  115050. /**
  115051. * Validates if xhr data is correct
  115052. * @param xhr defines the request to validate
  115053. * @param dataType defines the expected data type
  115054. * @returns true if data is correct
  115055. */
  115056. private static _ValidateXHRData;
  115057. }
  115058. }
  115059. declare module BABYLON {
  115060. /** @hidden */
  115061. export var gpuUpdateParticlesPixelShader: {
  115062. name: string;
  115063. shader: string;
  115064. };
  115065. }
  115066. declare module BABYLON {
  115067. /** @hidden */
  115068. export var gpuUpdateParticlesVertexShader: {
  115069. name: string;
  115070. shader: string;
  115071. };
  115072. }
  115073. declare module BABYLON {
  115074. /** @hidden */
  115075. export var clipPlaneFragmentDeclaration2: {
  115076. name: string;
  115077. shader: string;
  115078. };
  115079. }
  115080. declare module BABYLON {
  115081. /** @hidden */
  115082. export var gpuRenderParticlesPixelShader: {
  115083. name: string;
  115084. shader: string;
  115085. };
  115086. }
  115087. declare module BABYLON {
  115088. /** @hidden */
  115089. export var clipPlaneVertexDeclaration2: {
  115090. name: string;
  115091. shader: string;
  115092. };
  115093. }
  115094. declare module BABYLON {
  115095. /** @hidden */
  115096. export var gpuRenderParticlesVertexShader: {
  115097. name: string;
  115098. shader: string;
  115099. };
  115100. }
  115101. declare module BABYLON {
  115102. /**
  115103. * This represents a GPU particle system in Babylon
  115104. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  115105. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  115106. */
  115107. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  115108. /**
  115109. * The layer mask we are rendering the particles through.
  115110. */
  115111. layerMask: number;
  115112. private _capacity;
  115113. private _activeCount;
  115114. private _currentActiveCount;
  115115. private _accumulatedCount;
  115116. private _renderEffect;
  115117. private _updateEffect;
  115118. private _buffer0;
  115119. private _buffer1;
  115120. private _spriteBuffer;
  115121. private _updateVAO;
  115122. private _renderVAO;
  115123. private _targetIndex;
  115124. private _sourceBuffer;
  115125. private _targetBuffer;
  115126. private _engine;
  115127. private _currentRenderId;
  115128. private _started;
  115129. private _stopped;
  115130. private _timeDelta;
  115131. private _randomTexture;
  115132. private _randomTexture2;
  115133. private _attributesStrideSize;
  115134. private _updateEffectOptions;
  115135. private _randomTextureSize;
  115136. private _actualFrame;
  115137. private readonly _rawTextureWidth;
  115138. /**
  115139. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  115140. */
  115141. static readonly IsSupported: boolean;
  115142. /**
  115143. * An event triggered when the system is disposed.
  115144. */
  115145. onDisposeObservable: Observable<GPUParticleSystem>;
  115146. /**
  115147. * Gets the maximum number of particles active at the same time.
  115148. * @returns The max number of active particles.
  115149. */
  115150. getCapacity(): number;
  115151. /**
  115152. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  115153. * to override the particles.
  115154. */
  115155. forceDepthWrite: boolean;
  115156. /**
  115157. * Gets or set the number of active particles
  115158. */
  115159. activeParticleCount: number;
  115160. private _preWarmDone;
  115161. /**
  115162. * Is this system ready to be used/rendered
  115163. * @return true if the system is ready
  115164. */
  115165. isReady(): boolean;
  115166. /**
  115167. * Gets if the system has been started. (Note: this will still be true after stop is called)
  115168. * @returns True if it has been started, otherwise false.
  115169. */
  115170. isStarted(): boolean;
  115171. /**
  115172. * Starts the particle system and begins to emit
  115173. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  115174. */
  115175. start(delay?: number): void;
  115176. /**
  115177. * Stops the particle system.
  115178. */
  115179. stop(): void;
  115180. /**
  115181. * Remove all active particles
  115182. */
  115183. reset(): void;
  115184. /**
  115185. * Returns the string "GPUParticleSystem"
  115186. * @returns a string containing the class name
  115187. */
  115188. getClassName(): string;
  115189. private _colorGradientsTexture;
  115190. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  115191. /**
  115192. * Adds a new color gradient
  115193. * @param gradient defines the gradient to use (between 0 and 1)
  115194. * @param color1 defines the color to affect to the specified gradient
  115195. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  115196. * @returns the current particle system
  115197. */
  115198. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  115199. /**
  115200. * Remove a specific color gradient
  115201. * @param gradient defines the gradient to remove
  115202. * @returns the current particle system
  115203. */
  115204. removeColorGradient(gradient: number): GPUParticleSystem;
  115205. private _angularSpeedGradientsTexture;
  115206. private _sizeGradientsTexture;
  115207. private _velocityGradientsTexture;
  115208. private _limitVelocityGradientsTexture;
  115209. private _dragGradientsTexture;
  115210. private _addFactorGradient;
  115211. /**
  115212. * Adds a new size gradient
  115213. * @param gradient defines the gradient to use (between 0 and 1)
  115214. * @param factor defines the size factor to affect to the specified gradient
  115215. * @returns the current particle system
  115216. */
  115217. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  115218. /**
  115219. * Remove a specific size gradient
  115220. * @param gradient defines the gradient to remove
  115221. * @returns the current particle system
  115222. */
  115223. removeSizeGradient(gradient: number): GPUParticleSystem;
  115224. /**
  115225. * Adds a new angular speed gradient
  115226. * @param gradient defines the gradient to use (between 0 and 1)
  115227. * @param factor defines the angular speed to affect to the specified gradient
  115228. * @returns the current particle system
  115229. */
  115230. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  115231. /**
  115232. * Remove a specific angular speed gradient
  115233. * @param gradient defines the gradient to remove
  115234. * @returns the current particle system
  115235. */
  115236. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  115237. /**
  115238. * Adds a new velocity gradient
  115239. * @param gradient defines the gradient to use (between 0 and 1)
  115240. * @param factor defines the velocity to affect to the specified gradient
  115241. * @returns the current particle system
  115242. */
  115243. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  115244. /**
  115245. * Remove a specific velocity gradient
  115246. * @param gradient defines the gradient to remove
  115247. * @returns the current particle system
  115248. */
  115249. removeVelocityGradient(gradient: number): GPUParticleSystem;
  115250. /**
  115251. * Adds a new limit velocity gradient
  115252. * @param gradient defines the gradient to use (between 0 and 1)
  115253. * @param factor defines the limit velocity value to affect to the specified gradient
  115254. * @returns the current particle system
  115255. */
  115256. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  115257. /**
  115258. * Remove a specific limit velocity gradient
  115259. * @param gradient defines the gradient to remove
  115260. * @returns the current particle system
  115261. */
  115262. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  115263. /**
  115264. * Adds a new drag gradient
  115265. * @param gradient defines the gradient to use (between 0 and 1)
  115266. * @param factor defines the drag value to affect to the specified gradient
  115267. * @returns the current particle system
  115268. */
  115269. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  115270. /**
  115271. * Remove a specific drag gradient
  115272. * @param gradient defines the gradient to remove
  115273. * @returns the current particle system
  115274. */
  115275. removeDragGradient(gradient: number): GPUParticleSystem;
  115276. /**
  115277. * Not supported by GPUParticleSystem
  115278. * @param gradient defines the gradient to use (between 0 and 1)
  115279. * @param factor defines the emit rate value to affect to the specified gradient
  115280. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  115281. * @returns the current particle system
  115282. */
  115283. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  115284. /**
  115285. * Not supported by GPUParticleSystem
  115286. * @param gradient defines the gradient to remove
  115287. * @returns the current particle system
  115288. */
  115289. removeEmitRateGradient(gradient: number): IParticleSystem;
  115290. /**
  115291. * Not supported by GPUParticleSystem
  115292. * @param gradient defines the gradient to use (between 0 and 1)
  115293. * @param factor defines the start size value to affect to the specified gradient
  115294. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  115295. * @returns the current particle system
  115296. */
  115297. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  115298. /**
  115299. * Not supported by GPUParticleSystem
  115300. * @param gradient defines the gradient to remove
  115301. * @returns the current particle system
  115302. */
  115303. removeStartSizeGradient(gradient: number): IParticleSystem;
  115304. /**
  115305. * Not supported by GPUParticleSystem
  115306. * @param gradient defines the gradient to use (between 0 and 1)
  115307. * @param min defines the color remap minimal range
  115308. * @param max defines the color remap maximal range
  115309. * @returns the current particle system
  115310. */
  115311. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  115312. /**
  115313. * Not supported by GPUParticleSystem
  115314. * @param gradient defines the gradient to remove
  115315. * @returns the current particle system
  115316. */
  115317. removeColorRemapGradient(): IParticleSystem;
  115318. /**
  115319. * Not supported by GPUParticleSystem
  115320. * @param gradient defines the gradient to use (between 0 and 1)
  115321. * @param min defines the alpha remap minimal range
  115322. * @param max defines the alpha remap maximal range
  115323. * @returns the current particle system
  115324. */
  115325. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  115326. /**
  115327. * Not supported by GPUParticleSystem
  115328. * @param gradient defines the gradient to remove
  115329. * @returns the current particle system
  115330. */
  115331. removeAlphaRemapGradient(): IParticleSystem;
  115332. /**
  115333. * Not supported by GPUParticleSystem
  115334. * @param gradient defines the gradient to use (between 0 and 1)
  115335. * @param color defines the color to affect to the specified gradient
  115336. * @returns the current particle system
  115337. */
  115338. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  115339. /**
  115340. * Not supported by GPUParticleSystem
  115341. * @param gradient defines the gradient to remove
  115342. * @returns the current particle system
  115343. */
  115344. removeRampGradient(): IParticleSystem;
  115345. /**
  115346. * Not supported by GPUParticleSystem
  115347. * @returns the list of ramp gradients
  115348. */
  115349. getRampGradients(): Nullable<Array<Color3Gradient>>;
  115350. /**
  115351. * Not supported by GPUParticleSystem
  115352. * Gets or sets a boolean indicating that ramp gradients must be used
  115353. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  115354. */
  115355. useRampGradients: boolean;
  115356. /**
  115357. * Not supported by GPUParticleSystem
  115358. * @param gradient defines the gradient to use (between 0 and 1)
  115359. * @param factor defines the life time factor to affect to the specified gradient
  115360. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  115361. * @returns the current particle system
  115362. */
  115363. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  115364. /**
  115365. * Not supported by GPUParticleSystem
  115366. * @param gradient defines the gradient to remove
  115367. * @returns the current particle system
  115368. */
  115369. removeLifeTimeGradient(gradient: number): IParticleSystem;
  115370. /**
  115371. * Instantiates a GPU particle system.
  115372. * 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.
  115373. * @param name The name of the particle system
  115374. * @param options The options used to create the system
  115375. * @param scene The scene the particle system belongs to
  115376. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  115377. */
  115378. constructor(name: string, options: Partial<{
  115379. capacity: number;
  115380. randomTextureSize: number;
  115381. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  115382. protected _reset(): void;
  115383. private _createUpdateVAO;
  115384. private _createRenderVAO;
  115385. private _initialize;
  115386. /** @hidden */
  115387. _recreateUpdateEffect(): void;
  115388. /** @hidden */
  115389. _recreateRenderEffect(): void;
  115390. /**
  115391. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  115392. * @param preWarm defines if we are in the pre-warmimg phase
  115393. */
  115394. animate(preWarm?: boolean): void;
  115395. private _createFactorGradientTexture;
  115396. private _createSizeGradientTexture;
  115397. private _createAngularSpeedGradientTexture;
  115398. private _createVelocityGradientTexture;
  115399. private _createLimitVelocityGradientTexture;
  115400. private _createDragGradientTexture;
  115401. private _createColorGradientTexture;
  115402. /**
  115403. * Renders the particle system in its current state
  115404. * @param preWarm defines if the system should only update the particles but not render them
  115405. * @returns the current number of particles
  115406. */
  115407. render(preWarm?: boolean): number;
  115408. /**
  115409. * Rebuilds the particle system
  115410. */
  115411. rebuild(): void;
  115412. private _releaseBuffers;
  115413. private _releaseVAOs;
  115414. /**
  115415. * Disposes the particle system and free the associated resources
  115416. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  115417. */
  115418. dispose(disposeTexture?: boolean): void;
  115419. /**
  115420. * Clones the particle system.
  115421. * @param name The name of the cloned object
  115422. * @param newEmitter The new emitter to use
  115423. * @returns the cloned particle system
  115424. */
  115425. clone(name: string, newEmitter: any): GPUParticleSystem;
  115426. /**
  115427. * Serializes the particle system to a JSON object.
  115428. * @returns the JSON object
  115429. */
  115430. serialize(): any;
  115431. /**
  115432. * Parses a JSON object to create a GPU particle system.
  115433. * @param parsedParticleSystem The JSON object to parse
  115434. * @param scene The scene to create the particle system in
  115435. * @param rootUrl The root url to use to load external dependencies like texture
  115436. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  115437. * @returns the parsed GPU particle system
  115438. */
  115439. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  115440. }
  115441. }
  115442. declare module BABYLON {
  115443. /**
  115444. * Represents a set of particle systems working together to create a specific effect
  115445. */
  115446. export class ParticleSystemSet implements IDisposable {
  115447. private _emitterCreationOptions;
  115448. private _emitterNode;
  115449. /**
  115450. * Gets the particle system list
  115451. */
  115452. systems: IParticleSystem[];
  115453. /**
  115454. * Gets the emitter node used with this set
  115455. */
  115456. readonly emitterNode: Nullable<TransformNode>;
  115457. /**
  115458. * Creates a new emitter mesh as a sphere
  115459. * @param options defines the options used to create the sphere
  115460. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  115461. * @param scene defines the hosting scene
  115462. */
  115463. setEmitterAsSphere(options: {
  115464. diameter: number;
  115465. segments: number;
  115466. color: Color3;
  115467. }, renderingGroupId: number, scene: Scene): void;
  115468. /**
  115469. * Starts all particle systems of the set
  115470. * @param emitter defines an optional mesh to use as emitter for the particle systems
  115471. */
  115472. start(emitter?: AbstractMesh): void;
  115473. /**
  115474. * Release all associated resources
  115475. */
  115476. dispose(): void;
  115477. /**
  115478. * Serialize the set into a JSON compatible object
  115479. * @returns a JSON compatible representation of the set
  115480. */
  115481. serialize(): any;
  115482. /**
  115483. * Parse a new ParticleSystemSet from a serialized source
  115484. * @param data defines a JSON compatible representation of the set
  115485. * @param scene defines the hosting scene
  115486. * @param gpu defines if we want GPU particles or CPU particles
  115487. * @returns a new ParticleSystemSet
  115488. */
  115489. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  115490. }
  115491. }
  115492. declare module BABYLON {
  115493. /**
  115494. * This class is made for on one-liner static method to help creating particle system set.
  115495. */
  115496. export class ParticleHelper {
  115497. /**
  115498. * Gets or sets base Assets URL
  115499. */
  115500. static BaseAssetsUrl: string;
  115501. /**
  115502. * Create a default particle system that you can tweak
  115503. * @param emitter defines the emitter to use
  115504. * @param capacity defines the system capacity (default is 500 particles)
  115505. * @param scene defines the hosting scene
  115506. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  115507. * @returns the new Particle system
  115508. */
  115509. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  115510. /**
  115511. * This is the main static method (one-liner) of this helper to create different particle systems
  115512. * @param type This string represents the type to the particle system to create
  115513. * @param scene The scene where the particle system should live
  115514. * @param gpu If the system will use gpu
  115515. * @returns the ParticleSystemSet created
  115516. */
  115517. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  115518. /**
  115519. * Static function used to export a particle system to a ParticleSystemSet variable.
  115520. * Please note that the emitter shape is not exported
  115521. * @param systems defines the particle systems to export
  115522. * @returns the created particle system set
  115523. */
  115524. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  115525. }
  115526. }
  115527. declare module BABYLON {
  115528. interface Engine {
  115529. /**
  115530. * Create an effect to use with particle systems.
  115531. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  115532. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  115533. * @param uniformsNames defines a list of attribute names
  115534. * @param samplers defines an array of string used to represent textures
  115535. * @param defines defines the string containing the defines to use to compile the shaders
  115536. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  115537. * @param onCompiled defines a function to call when the effect creation is successful
  115538. * @param onError defines a function to call when the effect creation has failed
  115539. * @returns the new Effect
  115540. */
  115541. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  115542. }
  115543. interface Mesh {
  115544. /**
  115545. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  115546. * @returns an array of IParticleSystem
  115547. */
  115548. getEmittedParticleSystems(): IParticleSystem[];
  115549. /**
  115550. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  115551. * @returns an array of IParticleSystem
  115552. */
  115553. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  115554. }
  115555. /**
  115556. * @hidden
  115557. */
  115558. export var _IDoNeedToBeInTheBuild: number;
  115559. }
  115560. declare module BABYLON {
  115561. interface Scene {
  115562. /** @hidden (Backing field) */
  115563. _physicsEngine: Nullable<IPhysicsEngine>;
  115564. /**
  115565. * Gets the current physics engine
  115566. * @returns a IPhysicsEngine or null if none attached
  115567. */
  115568. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  115569. /**
  115570. * Enables physics to the current scene
  115571. * @param gravity defines the scene's gravity for the physics engine
  115572. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  115573. * @return a boolean indicating if the physics engine was initialized
  115574. */
  115575. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  115576. /**
  115577. * Disables and disposes the physics engine associated with the scene
  115578. */
  115579. disablePhysicsEngine(): void;
  115580. /**
  115581. * Gets a boolean indicating if there is an active physics engine
  115582. * @returns a boolean indicating if there is an active physics engine
  115583. */
  115584. isPhysicsEnabled(): boolean;
  115585. /**
  115586. * Deletes a physics compound impostor
  115587. * @param compound defines the compound to delete
  115588. */
  115589. deleteCompoundImpostor(compound: any): void;
  115590. /**
  115591. * An event triggered when physic simulation is about to be run
  115592. */
  115593. onBeforePhysicsObservable: Observable<Scene>;
  115594. /**
  115595. * An event triggered when physic simulation has been done
  115596. */
  115597. onAfterPhysicsObservable: Observable<Scene>;
  115598. }
  115599. interface AbstractMesh {
  115600. /** @hidden */
  115601. _physicsImpostor: Nullable<PhysicsImpostor>;
  115602. /**
  115603. * Gets or sets impostor used for physic simulation
  115604. * @see http://doc.babylonjs.com/features/physics_engine
  115605. */
  115606. physicsImpostor: Nullable<PhysicsImpostor>;
  115607. /**
  115608. * Gets the current physics impostor
  115609. * @see http://doc.babylonjs.com/features/physics_engine
  115610. * @returns a physics impostor or null
  115611. */
  115612. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  115613. /** Apply a physic impulse to the mesh
  115614. * @param force defines the force to apply
  115615. * @param contactPoint defines where to apply the force
  115616. * @returns the current mesh
  115617. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  115618. */
  115619. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  115620. /**
  115621. * Creates a physic joint between two meshes
  115622. * @param otherMesh defines the other mesh to use
  115623. * @param pivot1 defines the pivot to use on this mesh
  115624. * @param pivot2 defines the pivot to use on the other mesh
  115625. * @param options defines additional options (can be plugin dependent)
  115626. * @returns the current mesh
  115627. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  115628. */
  115629. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  115630. /** @hidden */
  115631. _disposePhysicsObserver: Nullable<Observer<Node>>;
  115632. }
  115633. /**
  115634. * Defines the physics engine scene component responsible to manage a physics engine
  115635. */
  115636. export class PhysicsEngineSceneComponent implements ISceneComponent {
  115637. /**
  115638. * The component name helpful to identify the component in the list of scene components.
  115639. */
  115640. readonly name: string;
  115641. /**
  115642. * The scene the component belongs to.
  115643. */
  115644. scene: Scene;
  115645. /**
  115646. * Creates a new instance of the component for the given scene
  115647. * @param scene Defines the scene to register the component in
  115648. */
  115649. constructor(scene: Scene);
  115650. /**
  115651. * Registers the component in a given scene
  115652. */
  115653. register(): void;
  115654. /**
  115655. * Rebuilds the elements related to this component in case of
  115656. * context lost for instance.
  115657. */
  115658. rebuild(): void;
  115659. /**
  115660. * Disposes the component and the associated ressources
  115661. */
  115662. dispose(): void;
  115663. }
  115664. }
  115665. declare module BABYLON {
  115666. /**
  115667. * A helper for physics simulations
  115668. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  115669. */
  115670. export class PhysicsHelper {
  115671. private _scene;
  115672. private _physicsEngine;
  115673. /**
  115674. * Initializes the Physics helper
  115675. * @param scene Babylon.js scene
  115676. */
  115677. constructor(scene: Scene);
  115678. /**
  115679. * Applies a radial explosion impulse
  115680. * @param origin the origin of the explosion
  115681. * @param radiusOrEventOptions the radius or the options of radial explosion
  115682. * @param strength the explosion strength
  115683. * @param falloff possible options: Constant & Linear. Defaults to Constant
  115684. * @returns A physics radial explosion event, or null
  115685. */
  115686. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  115687. /**
  115688. * Applies a radial explosion force
  115689. * @param origin the origin of the explosion
  115690. * @param radiusOrEventOptions the radius or the options of radial explosion
  115691. * @param strength the explosion strength
  115692. * @param falloff possible options: Constant & Linear. Defaults to Constant
  115693. * @returns A physics radial explosion event, or null
  115694. */
  115695. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  115696. /**
  115697. * Creates a gravitational field
  115698. * @param origin the origin of the explosion
  115699. * @param radiusOrEventOptions the radius or the options of radial explosion
  115700. * @param strength the explosion strength
  115701. * @param falloff possible options: Constant & Linear. Defaults to Constant
  115702. * @returns A physics gravitational field event, or null
  115703. */
  115704. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  115705. /**
  115706. * Creates a physics updraft event
  115707. * @param origin the origin of the updraft
  115708. * @param radiusOrEventOptions the radius or the options of the updraft
  115709. * @param strength the strength of the updraft
  115710. * @param height the height of the updraft
  115711. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  115712. * @returns A physics updraft event, or null
  115713. */
  115714. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  115715. /**
  115716. * Creates a physics vortex event
  115717. * @param origin the of the vortex
  115718. * @param radiusOrEventOptions the radius or the options of the vortex
  115719. * @param strength the strength of the vortex
  115720. * @param height the height of the vortex
  115721. * @returns a Physics vortex event, or null
  115722. * A physics vortex event or null
  115723. */
  115724. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  115725. }
  115726. /**
  115727. * Represents a physics radial explosion event
  115728. */
  115729. class PhysicsRadialExplosionEvent {
  115730. private _scene;
  115731. private _options;
  115732. private _sphere;
  115733. private _dataFetched;
  115734. /**
  115735. * Initializes a radial explosioin event
  115736. * @param _scene BabylonJS scene
  115737. * @param _options The options for the vortex event
  115738. */
  115739. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  115740. /**
  115741. * Returns the data related to the radial explosion event (sphere).
  115742. * @returns The radial explosion event data
  115743. */
  115744. getData(): PhysicsRadialExplosionEventData;
  115745. /**
  115746. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  115747. * @param impostor A physics imposter
  115748. * @param origin the origin of the explosion
  115749. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  115750. */
  115751. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  115752. /**
  115753. * Triggers affecterd impostors callbacks
  115754. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  115755. */
  115756. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  115757. /**
  115758. * Disposes the sphere.
  115759. * @param force Specifies if the sphere should be disposed by force
  115760. */
  115761. dispose(force?: boolean): void;
  115762. /*** Helpers ***/
  115763. private _prepareSphere;
  115764. private _intersectsWithSphere;
  115765. }
  115766. /**
  115767. * Represents a gravitational field event
  115768. */
  115769. class PhysicsGravitationalFieldEvent {
  115770. private _physicsHelper;
  115771. private _scene;
  115772. private _origin;
  115773. private _options;
  115774. private _tickCallback;
  115775. private _sphere;
  115776. private _dataFetched;
  115777. /**
  115778. * Initializes the physics gravitational field event
  115779. * @param _physicsHelper A physics helper
  115780. * @param _scene BabylonJS scene
  115781. * @param _origin The origin position of the gravitational field event
  115782. * @param _options The options for the vortex event
  115783. */
  115784. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  115785. /**
  115786. * Returns the data related to the gravitational field event (sphere).
  115787. * @returns A gravitational field event
  115788. */
  115789. getData(): PhysicsGravitationalFieldEventData;
  115790. /**
  115791. * Enables the gravitational field.
  115792. */
  115793. enable(): void;
  115794. /**
  115795. * Disables the gravitational field.
  115796. */
  115797. disable(): void;
  115798. /**
  115799. * Disposes the sphere.
  115800. * @param force The force to dispose from the gravitational field event
  115801. */
  115802. dispose(force?: boolean): void;
  115803. private _tick;
  115804. }
  115805. /**
  115806. * Represents a physics updraft event
  115807. */
  115808. class PhysicsUpdraftEvent {
  115809. private _scene;
  115810. private _origin;
  115811. private _options;
  115812. private _physicsEngine;
  115813. private _originTop;
  115814. private _originDirection;
  115815. private _tickCallback;
  115816. private _cylinder;
  115817. private _cylinderPosition;
  115818. private _dataFetched;
  115819. /**
  115820. * Initializes the physics updraft event
  115821. * @param _scene BabylonJS scene
  115822. * @param _origin The origin position of the updraft
  115823. * @param _options The options for the updraft event
  115824. */
  115825. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  115826. /**
  115827. * Returns the data related to the updraft event (cylinder).
  115828. * @returns A physics updraft event
  115829. */
  115830. getData(): PhysicsUpdraftEventData;
  115831. /**
  115832. * Enables the updraft.
  115833. */
  115834. enable(): void;
  115835. /**
  115836. * Disables the updraft.
  115837. */
  115838. disable(): void;
  115839. /**
  115840. * Disposes the cylinder.
  115841. * @param force Specifies if the updraft should be disposed by force
  115842. */
  115843. dispose(force?: boolean): void;
  115844. private getImpostorHitData;
  115845. private _tick;
  115846. /*** Helpers ***/
  115847. private _prepareCylinder;
  115848. private _intersectsWithCylinder;
  115849. }
  115850. /**
  115851. * Represents a physics vortex event
  115852. */
  115853. class PhysicsVortexEvent {
  115854. private _scene;
  115855. private _origin;
  115856. private _options;
  115857. private _physicsEngine;
  115858. private _originTop;
  115859. private _tickCallback;
  115860. private _cylinder;
  115861. private _cylinderPosition;
  115862. private _dataFetched;
  115863. /**
  115864. * Initializes the physics vortex event
  115865. * @param _scene The BabylonJS scene
  115866. * @param _origin The origin position of the vortex
  115867. * @param _options The options for the vortex event
  115868. */
  115869. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  115870. /**
  115871. * Returns the data related to the vortex event (cylinder).
  115872. * @returns The physics vortex event data
  115873. */
  115874. getData(): PhysicsVortexEventData;
  115875. /**
  115876. * Enables the vortex.
  115877. */
  115878. enable(): void;
  115879. /**
  115880. * Disables the cortex.
  115881. */
  115882. disable(): void;
  115883. /**
  115884. * Disposes the sphere.
  115885. * @param force
  115886. */
  115887. dispose(force?: boolean): void;
  115888. private getImpostorHitData;
  115889. private _tick;
  115890. /*** Helpers ***/
  115891. private _prepareCylinder;
  115892. private _intersectsWithCylinder;
  115893. }
  115894. /**
  115895. * Options fot the radial explosion event
  115896. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  115897. */
  115898. export class PhysicsRadialExplosionEventOptions {
  115899. /**
  115900. * The radius of the sphere for the radial explosion.
  115901. */
  115902. radius: number;
  115903. /**
  115904. * The strenth of the explosion.
  115905. */
  115906. strength: number;
  115907. /**
  115908. * The strenght of the force in correspondence to the distance of the affected object
  115909. */
  115910. falloff: PhysicsRadialImpulseFalloff;
  115911. /**
  115912. * Sphere options for the radial explosion.
  115913. */
  115914. sphere: {
  115915. segments: number;
  115916. diameter: number;
  115917. };
  115918. /**
  115919. * Sphere options for the radial explosion.
  115920. */
  115921. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  115922. }
  115923. /**
  115924. * Options fot the updraft event
  115925. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  115926. */
  115927. export class PhysicsUpdraftEventOptions {
  115928. /**
  115929. * The radius of the cylinder for the vortex
  115930. */
  115931. radius: number;
  115932. /**
  115933. * The strenth of the updraft.
  115934. */
  115935. strength: number;
  115936. /**
  115937. * The height of the cylinder for the updraft.
  115938. */
  115939. height: number;
  115940. /**
  115941. * The mode for the the updraft.
  115942. */
  115943. updraftMode: PhysicsUpdraftMode;
  115944. }
  115945. /**
  115946. * Options fot the vortex event
  115947. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  115948. */
  115949. export class PhysicsVortexEventOptions {
  115950. /**
  115951. * The radius of the cylinder for the vortex
  115952. */
  115953. radius: number;
  115954. /**
  115955. * The strenth of the vortex.
  115956. */
  115957. strength: number;
  115958. /**
  115959. * The height of the cylinder for the vortex.
  115960. */
  115961. height: number;
  115962. /**
  115963. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  115964. */
  115965. centripetalForceThreshold: number;
  115966. /**
  115967. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  115968. */
  115969. centripetalForceMultiplier: number;
  115970. /**
  115971. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  115972. */
  115973. centrifugalForceMultiplier: number;
  115974. /**
  115975. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  115976. */
  115977. updraftForceMultiplier: number;
  115978. }
  115979. /**
  115980. * The strenght of the force in correspondence to the distance of the affected object
  115981. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  115982. */
  115983. export enum PhysicsRadialImpulseFalloff {
  115984. /** Defines that impulse is constant in strength across it's whole radius */
  115985. Constant = 0,
  115986. /** Defines that impulse gets weaker if it's further from the origin */
  115987. Linear = 1
  115988. }
  115989. /**
  115990. * The strength of the force in correspondence to the distance of the affected object
  115991. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  115992. */
  115993. export enum PhysicsUpdraftMode {
  115994. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  115995. Center = 0,
  115996. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  115997. Perpendicular = 1
  115998. }
  115999. /**
  116000. * Interface for a physics hit data
  116001. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  116002. */
  116003. export interface PhysicsHitData {
  116004. /**
  116005. * The force applied at the contact point
  116006. */
  116007. force: Vector3;
  116008. /**
  116009. * The contact point
  116010. */
  116011. contactPoint: Vector3;
  116012. /**
  116013. * The distance from the origin to the contact point
  116014. */
  116015. distanceFromOrigin: number;
  116016. }
  116017. /**
  116018. * Interface for radial explosion event data
  116019. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  116020. */
  116021. export interface PhysicsRadialExplosionEventData {
  116022. /**
  116023. * A sphere used for the radial explosion event
  116024. */
  116025. sphere: Mesh;
  116026. }
  116027. /**
  116028. * Interface for gravitational field event data
  116029. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  116030. */
  116031. export interface PhysicsGravitationalFieldEventData {
  116032. /**
  116033. * A sphere mesh used for the gravitational field event
  116034. */
  116035. sphere: Mesh;
  116036. }
  116037. /**
  116038. * Interface for updraft event data
  116039. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  116040. */
  116041. export interface PhysicsUpdraftEventData {
  116042. /**
  116043. * A cylinder used for the updraft event
  116044. */
  116045. cylinder: Mesh;
  116046. }
  116047. /**
  116048. * Interface for vortex event data
  116049. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  116050. */
  116051. export interface PhysicsVortexEventData {
  116052. /**
  116053. * A cylinder used for the vortex event
  116054. */
  116055. cylinder: Mesh;
  116056. }
  116057. /**
  116058. * Interface for an affected physics impostor
  116059. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  116060. */
  116061. export interface PhysicsAffectedImpostorWithData {
  116062. /**
  116063. * The impostor affected by the effect
  116064. */
  116065. impostor: PhysicsImpostor;
  116066. /**
  116067. * The data about the hit/horce from the explosion
  116068. */
  116069. hitData: PhysicsHitData;
  116070. }
  116071. }
  116072. declare module BABYLON {
  116073. /** @hidden */
  116074. export var blackAndWhitePixelShader: {
  116075. name: string;
  116076. shader: string;
  116077. };
  116078. }
  116079. declare module BABYLON {
  116080. /**
  116081. * Post process used to render in black and white
  116082. */
  116083. export class BlackAndWhitePostProcess extends PostProcess {
  116084. /**
  116085. * Linear about to convert he result to black and white (default: 1)
  116086. */
  116087. degree: number;
  116088. /**
  116089. * Creates a black and white post process
  116090. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  116091. * @param name The name of the effect.
  116092. * @param options The required width/height ratio to downsize to before computing the render pass.
  116093. * @param camera The camera to apply the render pass to.
  116094. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  116095. * @param engine The engine which the post process will be applied. (default: current engine)
  116096. * @param reusable If the post process can be reused on the same frame. (default: false)
  116097. */
  116098. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  116099. }
  116100. }
  116101. declare module BABYLON {
  116102. /**
  116103. * This represents a set of one or more post processes in Babylon.
  116104. * A post process can be used to apply a shader to a texture after it is rendered.
  116105. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  116106. */
  116107. export class PostProcessRenderEffect {
  116108. private _postProcesses;
  116109. private _getPostProcesses;
  116110. private _singleInstance;
  116111. private _cameras;
  116112. private _indicesForCamera;
  116113. /**
  116114. * Name of the effect
  116115. * @hidden
  116116. */
  116117. _name: string;
  116118. /**
  116119. * Instantiates a post process render effect.
  116120. * A post process can be used to apply a shader to a texture after it is rendered.
  116121. * @param engine The engine the effect is tied to
  116122. * @param name The name of the effect
  116123. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  116124. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  116125. */
  116126. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  116127. /**
  116128. * Checks if all the post processes in the effect are supported.
  116129. */
  116130. readonly isSupported: boolean;
  116131. /**
  116132. * Updates the current state of the effect
  116133. * @hidden
  116134. */
  116135. _update(): void;
  116136. /**
  116137. * Attaches the effect on cameras
  116138. * @param cameras The camera to attach to.
  116139. * @hidden
  116140. */
  116141. _attachCameras(cameras: Camera): void;
  116142. /**
  116143. * Attaches the effect on cameras
  116144. * @param cameras The camera to attach to.
  116145. * @hidden
  116146. */
  116147. _attachCameras(cameras: Camera[]): void;
  116148. /**
  116149. * Detaches the effect on cameras
  116150. * @param cameras The camera to detatch from.
  116151. * @hidden
  116152. */
  116153. _detachCameras(cameras: Camera): void;
  116154. /**
  116155. * Detatches the effect on cameras
  116156. * @param cameras The camera to detatch from.
  116157. * @hidden
  116158. */
  116159. _detachCameras(cameras: Camera[]): void;
  116160. /**
  116161. * Enables the effect on given cameras
  116162. * @param cameras The camera to enable.
  116163. * @hidden
  116164. */
  116165. _enable(cameras: Camera): void;
  116166. /**
  116167. * Enables the effect on given cameras
  116168. * @param cameras The camera to enable.
  116169. * @hidden
  116170. */
  116171. _enable(cameras: Nullable<Camera[]>): void;
  116172. /**
  116173. * Disables the effect on the given cameras
  116174. * @param cameras The camera to disable.
  116175. * @hidden
  116176. */
  116177. _disable(cameras: Camera): void;
  116178. /**
  116179. * Disables the effect on the given cameras
  116180. * @param cameras The camera to disable.
  116181. * @hidden
  116182. */
  116183. _disable(cameras: Nullable<Camera[]>): void;
  116184. /**
  116185. * Gets a list of the post processes contained in the effect.
  116186. * @param camera The camera to get the post processes on.
  116187. * @returns The list of the post processes in the effect.
  116188. */
  116189. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  116190. }
  116191. }
  116192. declare module BABYLON {
  116193. /** @hidden */
  116194. export var extractHighlightsPixelShader: {
  116195. name: string;
  116196. shader: string;
  116197. };
  116198. }
  116199. declare module BABYLON {
  116200. /**
  116201. * 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.
  116202. */
  116203. export class ExtractHighlightsPostProcess extends PostProcess {
  116204. /**
  116205. * The luminance threshold, pixels below this value will be set to black.
  116206. */
  116207. threshold: number;
  116208. /** @hidden */
  116209. _exposure: number;
  116210. /**
  116211. * Post process which has the input texture to be used when performing highlight extraction
  116212. * @hidden
  116213. */
  116214. _inputPostProcess: Nullable<PostProcess>;
  116215. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  116216. }
  116217. }
  116218. declare module BABYLON {
  116219. /** @hidden */
  116220. export var bloomMergePixelShader: {
  116221. name: string;
  116222. shader: string;
  116223. };
  116224. }
  116225. declare module BABYLON {
  116226. /**
  116227. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  116228. */
  116229. export class BloomMergePostProcess extends PostProcess {
  116230. /** Weight of the bloom to be added to the original input. */
  116231. weight: number;
  116232. /**
  116233. * Creates a new instance of @see BloomMergePostProcess
  116234. * @param name The name of the effect.
  116235. * @param originalFromInput Post process which's input will be used for the merge.
  116236. * @param blurred Blurred highlights post process which's output will be used.
  116237. * @param weight Weight of the bloom to be added to the original input.
  116238. * @param options The required width/height ratio to downsize to before computing the render pass.
  116239. * @param camera The camera to apply the render pass to.
  116240. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  116241. * @param engine The engine which the post process will be applied. (default: current engine)
  116242. * @param reusable If the post process can be reused on the same frame. (default: false)
  116243. * @param textureType Type of textures used when performing the post process. (default: 0)
  116244. * @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)
  116245. */
  116246. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  116247. /** Weight of the bloom to be added to the original input. */
  116248. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  116249. }
  116250. }
  116251. declare module BABYLON {
  116252. /**
  116253. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  116254. */
  116255. export class BloomEffect extends PostProcessRenderEffect {
  116256. private bloomScale;
  116257. /**
  116258. * @hidden Internal
  116259. */
  116260. _effects: Array<PostProcess>;
  116261. /**
  116262. * @hidden Internal
  116263. */
  116264. _downscale: ExtractHighlightsPostProcess;
  116265. private _blurX;
  116266. private _blurY;
  116267. private _merge;
  116268. /**
  116269. * The luminance threshold to find bright areas of the image to bloom.
  116270. */
  116271. threshold: number;
  116272. /**
  116273. * The strength of the bloom.
  116274. */
  116275. weight: number;
  116276. /**
  116277. * Specifies the size of the bloom blur kernel, relative to the final output size
  116278. */
  116279. kernel: number;
  116280. /**
  116281. * Creates a new instance of @see BloomEffect
  116282. * @param scene The scene the effect belongs to.
  116283. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  116284. * @param bloomKernel The size of the kernel to be used when applying the blur.
  116285. * @param bloomWeight The the strength of bloom.
  116286. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  116287. * @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)
  116288. */
  116289. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  116290. /**
  116291. * Disposes each of the internal effects for a given camera.
  116292. * @param camera The camera to dispose the effect on.
  116293. */
  116294. disposeEffects(camera: Camera): void;
  116295. /**
  116296. * @hidden Internal
  116297. */
  116298. _updateEffects(): void;
  116299. /**
  116300. * Internal
  116301. * @returns if all the contained post processes are ready.
  116302. * @hidden
  116303. */
  116304. _isReady(): boolean;
  116305. }
  116306. }
  116307. declare module BABYLON {
  116308. /** @hidden */
  116309. export var chromaticAberrationPixelShader: {
  116310. name: string;
  116311. shader: string;
  116312. };
  116313. }
  116314. declare module BABYLON {
  116315. /**
  116316. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  116317. */
  116318. export class ChromaticAberrationPostProcess extends PostProcess {
  116319. /**
  116320. * The amount of seperation of rgb channels (default: 30)
  116321. */
  116322. aberrationAmount: number;
  116323. /**
  116324. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  116325. */
  116326. radialIntensity: number;
  116327. /**
  116328. * 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))
  116329. */
  116330. direction: Vector2;
  116331. /**
  116332. * 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))
  116333. */
  116334. centerPosition: Vector2;
  116335. /**
  116336. * Creates a new instance ChromaticAberrationPostProcess
  116337. * @param name The name of the effect.
  116338. * @param screenWidth The width of the screen to apply the effect on.
  116339. * @param screenHeight The height of the screen to apply the effect on.
  116340. * @param options The required width/height ratio to downsize to before computing the render pass.
  116341. * @param camera The camera to apply the render pass to.
  116342. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  116343. * @param engine The engine which the post process will be applied. (default: current engine)
  116344. * @param reusable If the post process can be reused on the same frame. (default: false)
  116345. * @param textureType Type of textures used when performing the post process. (default: 0)
  116346. * @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)
  116347. */
  116348. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  116349. }
  116350. }
  116351. declare module BABYLON {
  116352. /** @hidden */
  116353. export var circleOfConfusionPixelShader: {
  116354. name: string;
  116355. shader: string;
  116356. };
  116357. }
  116358. declare module BABYLON {
  116359. /**
  116360. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  116361. */
  116362. export class CircleOfConfusionPostProcess extends PostProcess {
  116363. /**
  116364. * 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.
  116365. */
  116366. lensSize: number;
  116367. /**
  116368. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  116369. */
  116370. fStop: number;
  116371. /**
  116372. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  116373. */
  116374. focusDistance: number;
  116375. /**
  116376. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  116377. */
  116378. focalLength: number;
  116379. private _depthTexture;
  116380. /**
  116381. * Creates a new instance CircleOfConfusionPostProcess
  116382. * @param name The name of the effect.
  116383. * @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.
  116384. * @param options The required width/height ratio to downsize to before computing the render pass.
  116385. * @param camera The camera to apply the render pass to.
  116386. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  116387. * @param engine The engine which the post process will be applied. (default: current engine)
  116388. * @param reusable If the post process can be reused on the same frame. (default: false)
  116389. * @param textureType Type of textures used when performing the post process. (default: 0)
  116390. * @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)
  116391. */
  116392. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  116393. /**
  116394. * 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.
  116395. */
  116396. depthTexture: RenderTargetTexture;
  116397. }
  116398. }
  116399. declare module BABYLON {
  116400. /** @hidden */
  116401. export var colorCorrectionPixelShader: {
  116402. name: string;
  116403. shader: string;
  116404. };
  116405. }
  116406. declare module BABYLON {
  116407. /**
  116408. *
  116409. * This post-process allows the modification of rendered colors by using
  116410. * a 'look-up table' (LUT). This effect is also called Color Grading.
  116411. *
  116412. * The object needs to be provided an url to a texture containing the color
  116413. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  116414. * Use an image editing software to tweak the LUT to match your needs.
  116415. *
  116416. * For an example of a color LUT, see here:
  116417. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  116418. * For explanations on color grading, see here:
  116419. * @see http://udn.epicgames.com/Three/ColorGrading.html
  116420. *
  116421. */
  116422. export class ColorCorrectionPostProcess extends PostProcess {
  116423. private _colorTableTexture;
  116424. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  116425. }
  116426. }
  116427. declare module BABYLON {
  116428. /** @hidden */
  116429. export var convolutionPixelShader: {
  116430. name: string;
  116431. shader: string;
  116432. };
  116433. }
  116434. declare module BABYLON {
  116435. /**
  116436. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  116437. * input texture to perform effects such as edge detection or sharpening
  116438. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  116439. */
  116440. export class ConvolutionPostProcess extends PostProcess {
  116441. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  116442. kernel: number[];
  116443. /**
  116444. * Creates a new instance ConvolutionPostProcess
  116445. * @param name The name of the effect.
  116446. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  116447. * @param options The required width/height ratio to downsize to before computing the render pass.
  116448. * @param camera The camera to apply the render pass to.
  116449. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  116450. * @param engine The engine which the post process will be applied. (default: current engine)
  116451. * @param reusable If the post process can be reused on the same frame. (default: false)
  116452. * @param textureType Type of textures used when performing the post process. (default: 0)
  116453. */
  116454. constructor(name: string,
  116455. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  116456. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  116457. /**
  116458. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  116459. */
  116460. static EdgeDetect0Kernel: number[];
  116461. /**
  116462. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  116463. */
  116464. static EdgeDetect1Kernel: number[];
  116465. /**
  116466. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  116467. */
  116468. static EdgeDetect2Kernel: number[];
  116469. /**
  116470. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  116471. */
  116472. static SharpenKernel: number[];
  116473. /**
  116474. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  116475. */
  116476. static EmbossKernel: number[];
  116477. /**
  116478. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  116479. */
  116480. static GaussianKernel: number[];
  116481. }
  116482. }
  116483. declare module BABYLON {
  116484. /**
  116485. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  116486. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  116487. * based on samples that have a large difference in distance than the center pixel.
  116488. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  116489. */
  116490. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  116491. direction: Vector2;
  116492. /**
  116493. * Creates a new instance CircleOfConfusionPostProcess
  116494. * @param name The name of the effect.
  116495. * @param scene The scene the effect belongs to.
  116496. * @param direction The direction the blur should be applied.
  116497. * @param kernel The size of the kernel used to blur.
  116498. * @param options The required width/height ratio to downsize to before computing the render pass.
  116499. * @param camera The camera to apply the render pass to.
  116500. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  116501. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  116502. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  116503. * @param engine The engine which the post process will be applied. (default: current engine)
  116504. * @param reusable If the post process can be reused on the same frame. (default: false)
  116505. * @param textureType Type of textures used when performing the post process. (default: 0)
  116506. * @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)
  116507. */
  116508. 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);
  116509. }
  116510. }
  116511. declare module BABYLON {
  116512. /** @hidden */
  116513. export var depthOfFieldMergePixelShader: {
  116514. name: string;
  116515. shader: string;
  116516. };
  116517. }
  116518. declare module BABYLON {
  116519. /**
  116520. * Options to be set when merging outputs from the default pipeline.
  116521. */
  116522. export class DepthOfFieldMergePostProcessOptions {
  116523. /**
  116524. * The original image to merge on top of
  116525. */
  116526. originalFromInput: PostProcess;
  116527. /**
  116528. * Parameters to perform the merge of the depth of field effect
  116529. */
  116530. depthOfField?: {
  116531. circleOfConfusion: PostProcess;
  116532. blurSteps: Array<PostProcess>;
  116533. };
  116534. /**
  116535. * Parameters to perform the merge of bloom effect
  116536. */
  116537. bloom?: {
  116538. blurred: PostProcess;
  116539. weight: number;
  116540. };
  116541. }
  116542. /**
  116543. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  116544. */
  116545. export class DepthOfFieldMergePostProcess extends PostProcess {
  116546. private blurSteps;
  116547. /**
  116548. * Creates a new instance of DepthOfFieldMergePostProcess
  116549. * @param name The name of the effect.
  116550. * @param originalFromInput Post process which's input will be used for the merge.
  116551. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  116552. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  116553. * @param options The required width/height ratio to downsize to before computing the render pass.
  116554. * @param camera The camera to apply the render pass to.
  116555. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  116556. * @param engine The engine which the post process will be applied. (default: current engine)
  116557. * @param reusable If the post process can be reused on the same frame. (default: false)
  116558. * @param textureType Type of textures used when performing the post process. (default: 0)
  116559. * @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)
  116560. */
  116561. 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);
  116562. /**
  116563. * Updates the effect with the current post process compile time values and recompiles the shader.
  116564. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  116565. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  116566. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  116567. * @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
  116568. * @param onCompiled Called when the shader has been compiled.
  116569. * @param onError Called if there is an error when compiling a shader.
  116570. */
  116571. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  116572. }
  116573. }
  116574. declare module BABYLON {
  116575. /**
  116576. * Specifies the level of max blur that should be applied when using the depth of field effect
  116577. */
  116578. export enum DepthOfFieldEffectBlurLevel {
  116579. /**
  116580. * Subtle blur
  116581. */
  116582. Low = 0,
  116583. /**
  116584. * Medium blur
  116585. */
  116586. Medium = 1,
  116587. /**
  116588. * Large blur
  116589. */
  116590. High = 2
  116591. }
  116592. /**
  116593. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  116594. */
  116595. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  116596. private _circleOfConfusion;
  116597. /**
  116598. * @hidden Internal, blurs from high to low
  116599. */
  116600. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  116601. private _depthOfFieldBlurY;
  116602. private _dofMerge;
  116603. /**
  116604. * @hidden Internal post processes in depth of field effect
  116605. */
  116606. _effects: Array<PostProcess>;
  116607. /**
  116608. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  116609. */
  116610. focalLength: number;
  116611. /**
  116612. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  116613. */
  116614. fStop: number;
  116615. /**
  116616. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  116617. */
  116618. focusDistance: number;
  116619. /**
  116620. * 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.
  116621. */
  116622. lensSize: number;
  116623. /**
  116624. * Creates a new instance DepthOfFieldEffect
  116625. * @param scene The scene the effect belongs to.
  116626. * @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.
  116627. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  116628. * @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)
  116629. */
  116630. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  116631. /**
  116632. * Get the current class name of the current effet
  116633. * @returns "DepthOfFieldEffect"
  116634. */
  116635. getClassName(): string;
  116636. /**
  116637. * 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.
  116638. */
  116639. depthTexture: RenderTargetTexture;
  116640. /**
  116641. * Disposes each of the internal effects for a given camera.
  116642. * @param camera The camera to dispose the effect on.
  116643. */
  116644. disposeEffects(camera: Camera): void;
  116645. /**
  116646. * @hidden Internal
  116647. */
  116648. _updateEffects(): void;
  116649. /**
  116650. * Internal
  116651. * @returns if all the contained post processes are ready.
  116652. * @hidden
  116653. */
  116654. _isReady(): boolean;
  116655. }
  116656. }
  116657. declare module BABYLON {
  116658. /** @hidden */
  116659. export var displayPassPixelShader: {
  116660. name: string;
  116661. shader: string;
  116662. };
  116663. }
  116664. declare module BABYLON {
  116665. /**
  116666. * DisplayPassPostProcess which produces an output the same as it's input
  116667. */
  116668. export class DisplayPassPostProcess extends PostProcess {
  116669. /**
  116670. * Creates the DisplayPassPostProcess
  116671. * @param name The name of the effect.
  116672. * @param options The required width/height ratio to downsize to before computing the render pass.
  116673. * @param camera The camera to apply the render pass to.
  116674. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  116675. * @param engine The engine which the post process will be applied. (default: current engine)
  116676. * @param reusable If the post process can be reused on the same frame. (default: false)
  116677. */
  116678. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  116679. }
  116680. }
  116681. declare module BABYLON {
  116682. /** @hidden */
  116683. export var filterPixelShader: {
  116684. name: string;
  116685. shader: string;
  116686. };
  116687. }
  116688. declare module BABYLON {
  116689. /**
  116690. * Applies a kernel filter to the image
  116691. */
  116692. export class FilterPostProcess extends PostProcess {
  116693. /** The matrix to be applied to the image */
  116694. kernelMatrix: Matrix;
  116695. /**
  116696. *
  116697. * @param name The name of the effect.
  116698. * @param kernelMatrix The matrix to be applied to the image
  116699. * @param options The required width/height ratio to downsize to before computing the render pass.
  116700. * @param camera The camera to apply the render pass to.
  116701. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  116702. * @param engine The engine which the post process will be applied. (default: current engine)
  116703. * @param reusable If the post process can be reused on the same frame. (default: false)
  116704. */
  116705. constructor(name: string,
  116706. /** The matrix to be applied to the image */
  116707. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  116708. }
  116709. }
  116710. declare module BABYLON {
  116711. /** @hidden */
  116712. export var fxaaPixelShader: {
  116713. name: string;
  116714. shader: string;
  116715. };
  116716. }
  116717. declare module BABYLON {
  116718. /** @hidden */
  116719. export var fxaaVertexShader: {
  116720. name: string;
  116721. shader: string;
  116722. };
  116723. }
  116724. declare module BABYLON {
  116725. /**
  116726. * Fxaa post process
  116727. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  116728. */
  116729. export class FxaaPostProcess extends PostProcess {
  116730. /** @hidden */
  116731. texelWidth: number;
  116732. /** @hidden */
  116733. texelHeight: number;
  116734. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  116735. private _getDefines;
  116736. }
  116737. }
  116738. declare module BABYLON {
  116739. /** @hidden */
  116740. export var grainPixelShader: {
  116741. name: string;
  116742. shader: string;
  116743. };
  116744. }
  116745. declare module BABYLON {
  116746. /**
  116747. * The GrainPostProcess adds noise to the image at mid luminance levels
  116748. */
  116749. export class GrainPostProcess extends PostProcess {
  116750. /**
  116751. * The intensity of the grain added (default: 30)
  116752. */
  116753. intensity: number;
  116754. /**
  116755. * If the grain should be randomized on every frame
  116756. */
  116757. animated: boolean;
  116758. /**
  116759. * Creates a new instance of @see GrainPostProcess
  116760. * @param name The name of the effect.
  116761. * @param options The required width/height ratio to downsize to before computing the render pass.
  116762. * @param camera The camera to apply the render pass to.
  116763. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  116764. * @param engine The engine which the post process will be applied. (default: current engine)
  116765. * @param reusable If the post process can be reused on the same frame. (default: false)
  116766. * @param textureType Type of textures used when performing the post process. (default: 0)
  116767. * @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)
  116768. */
  116769. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  116770. }
  116771. }
  116772. declare module BABYLON {
  116773. /** @hidden */
  116774. export var highlightsPixelShader: {
  116775. name: string;
  116776. shader: string;
  116777. };
  116778. }
  116779. declare module BABYLON {
  116780. /**
  116781. * Extracts highlights from the image
  116782. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  116783. */
  116784. export class HighlightsPostProcess extends PostProcess {
  116785. /**
  116786. * Extracts highlights from the image
  116787. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  116788. * @param name The name of the effect.
  116789. * @param options The required width/height ratio to downsize to before computing the render pass.
  116790. * @param camera The camera to apply the render pass to.
  116791. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  116792. * @param engine The engine which the post process will be applied. (default: current engine)
  116793. * @param reusable If the post process can be reused on the same frame. (default: false)
  116794. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  116795. */
  116796. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  116797. }
  116798. }
  116799. declare module BABYLON {
  116800. /** @hidden */
  116801. export var mrtFragmentDeclaration: {
  116802. name: string;
  116803. shader: string;
  116804. };
  116805. }
  116806. declare module BABYLON {
  116807. /** @hidden */
  116808. export var geometryPixelShader: {
  116809. name: string;
  116810. shader: string;
  116811. };
  116812. }
  116813. declare module BABYLON {
  116814. /** @hidden */
  116815. export var geometryVertexShader: {
  116816. name: string;
  116817. shader: string;
  116818. };
  116819. }
  116820. declare module BABYLON {
  116821. /** @hidden */
  116822. interface ISavedTransformationMatrix {
  116823. world: Matrix;
  116824. viewProjection: Matrix;
  116825. }
  116826. /**
  116827. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  116828. */
  116829. export class GeometryBufferRenderer {
  116830. /**
  116831. * Constant used to retrieve the position texture index in the G-Buffer textures array
  116832. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  116833. */
  116834. static readonly POSITION_TEXTURE_TYPE: number;
  116835. /**
  116836. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  116837. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  116838. */
  116839. static readonly VELOCITY_TEXTURE_TYPE: number;
  116840. /**
  116841. * Dictionary used to store the previous transformation matrices of each rendered mesh
  116842. * in order to compute objects velocities when enableVelocity is set to "true"
  116843. * @hidden
  116844. */
  116845. _previousTransformationMatrices: {
  116846. [index: number]: ISavedTransformationMatrix;
  116847. };
  116848. /**
  116849. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  116850. * in order to compute objects velocities when enableVelocity is set to "true"
  116851. * @hidden
  116852. */
  116853. _previousBonesTransformationMatrices: {
  116854. [index: number]: Float32Array;
  116855. };
  116856. /**
  116857. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  116858. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  116859. */
  116860. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  116861. private _scene;
  116862. private _multiRenderTarget;
  116863. private _ratio;
  116864. private _enablePosition;
  116865. private _enableVelocity;
  116866. private _positionIndex;
  116867. private _velocityIndex;
  116868. protected _effect: Effect;
  116869. protected _cachedDefines: string;
  116870. /**
  116871. * Set the render list (meshes to be rendered) used in the G buffer.
  116872. */
  116873. renderList: Mesh[];
  116874. /**
  116875. * Gets wether or not G buffer are supported by the running hardware.
  116876. * This requires draw buffer supports
  116877. */
  116878. readonly isSupported: boolean;
  116879. /**
  116880. * Returns the index of the given texture type in the G-Buffer textures array
  116881. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  116882. * @returns the index of the given texture type in the G-Buffer textures array
  116883. */
  116884. getTextureIndex(textureType: number): number;
  116885. /**
  116886. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  116887. */
  116888. /**
  116889. * Sets whether or not objects positions are enabled for the G buffer.
  116890. */
  116891. enablePosition: boolean;
  116892. /**
  116893. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  116894. */
  116895. /**
  116896. * Sets wether or not objects velocities are enabled for the G buffer.
  116897. */
  116898. enableVelocity: boolean;
  116899. /**
  116900. * Gets the scene associated with the buffer.
  116901. */
  116902. readonly scene: Scene;
  116903. /**
  116904. * Gets the ratio used by the buffer during its creation.
  116905. * How big is the buffer related to the main canvas.
  116906. */
  116907. readonly ratio: number;
  116908. /** @hidden */
  116909. static _SceneComponentInitialization: (scene: Scene) => void;
  116910. /**
  116911. * Creates a new G Buffer for the scene
  116912. * @param scene The scene the buffer belongs to
  116913. * @param ratio How big is the buffer related to the main canvas.
  116914. */
  116915. constructor(scene: Scene, ratio?: number);
  116916. /**
  116917. * Checks wether everything is ready to render a submesh to the G buffer.
  116918. * @param subMesh the submesh to check readiness for
  116919. * @param useInstances is the mesh drawn using instance or not
  116920. * @returns true if ready otherwise false
  116921. */
  116922. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  116923. /**
  116924. * Gets the current underlying G Buffer.
  116925. * @returns the buffer
  116926. */
  116927. getGBuffer(): MultiRenderTarget;
  116928. /**
  116929. * Gets the number of samples used to render the buffer (anti aliasing).
  116930. */
  116931. /**
  116932. * Sets the number of samples used to render the buffer (anti aliasing).
  116933. */
  116934. samples: number;
  116935. /**
  116936. * Disposes the renderer and frees up associated resources.
  116937. */
  116938. dispose(): void;
  116939. protected _createRenderTargets(): void;
  116940. private _copyBonesTransformationMatrices;
  116941. }
  116942. }
  116943. declare module BABYLON {
  116944. interface Scene {
  116945. /** @hidden (Backing field) */
  116946. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  116947. /**
  116948. * Gets or Sets the current geometry buffer associated to the scene.
  116949. */
  116950. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  116951. /**
  116952. * Enables a GeometryBufferRender and associates it with the scene
  116953. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  116954. * @returns the GeometryBufferRenderer
  116955. */
  116956. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  116957. /**
  116958. * Disables the GeometryBufferRender associated with the scene
  116959. */
  116960. disableGeometryBufferRenderer(): void;
  116961. }
  116962. /**
  116963. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  116964. * in several rendering techniques.
  116965. */
  116966. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  116967. /**
  116968. * The component name helpful to identify the component in the list of scene components.
  116969. */
  116970. readonly name: string;
  116971. /**
  116972. * The scene the component belongs to.
  116973. */
  116974. scene: Scene;
  116975. /**
  116976. * Creates a new instance of the component for the given scene
  116977. * @param scene Defines the scene to register the component in
  116978. */
  116979. constructor(scene: Scene);
  116980. /**
  116981. * Registers the component in a given scene
  116982. */
  116983. register(): void;
  116984. /**
  116985. * Rebuilds the elements related to this component in case of
  116986. * context lost for instance.
  116987. */
  116988. rebuild(): void;
  116989. /**
  116990. * Disposes the component and the associated ressources
  116991. */
  116992. dispose(): void;
  116993. private _gatherRenderTargets;
  116994. }
  116995. }
  116996. declare module BABYLON {
  116997. /** @hidden */
  116998. export var motionBlurPixelShader: {
  116999. name: string;
  117000. shader: string;
  117001. };
  117002. }
  117003. declare module BABYLON {
  117004. /**
  117005. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  117006. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  117007. * As an example, all you have to do is to create the post-process:
  117008. * var mb = new BABYLON.MotionBlurPostProcess(
  117009. * 'mb', // The name of the effect.
  117010. * scene, // The scene containing the objects to blur according to their velocity.
  117011. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  117012. * camera // The camera to apply the render pass to.
  117013. * );
  117014. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  117015. */
  117016. export class MotionBlurPostProcess extends PostProcess {
  117017. /**
  117018. * Defines how much the image is blurred by the movement. Default value is equal to 1
  117019. */
  117020. motionStrength: number;
  117021. /**
  117022. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  117023. */
  117024. /**
  117025. * Sets the number of iterations to be used for motion blur quality
  117026. */
  117027. motionBlurSamples: number;
  117028. private _motionBlurSamples;
  117029. private _geometryBufferRenderer;
  117030. /**
  117031. * Creates a new instance MotionBlurPostProcess
  117032. * @param name The name of the effect.
  117033. * @param scene The scene containing the objects to blur according to their velocity.
  117034. * @param options The required width/height ratio to downsize to before computing the render pass.
  117035. * @param camera The camera to apply the render pass to.
  117036. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  117037. * @param engine The engine which the post process will be applied. (default: current engine)
  117038. * @param reusable If the post process can be reused on the same frame. (default: false)
  117039. * @param textureType Type of textures used when performing the post process. (default: 0)
  117040. * @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)
  117041. */
  117042. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  117043. /**
  117044. * Excludes the given skinned mesh from computing bones velocities.
  117045. * 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.
  117046. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  117047. */
  117048. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  117049. /**
  117050. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  117051. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  117052. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  117053. */
  117054. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  117055. /**
  117056. * Disposes the post process.
  117057. * @param camera The camera to dispose the post process on.
  117058. */
  117059. dispose(camera?: Camera): void;
  117060. }
  117061. }
  117062. declare module BABYLON {
  117063. /** @hidden */
  117064. export var refractionPixelShader: {
  117065. name: string;
  117066. shader: string;
  117067. };
  117068. }
  117069. declare module BABYLON {
  117070. /**
  117071. * Post process which applies a refractin texture
  117072. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  117073. */
  117074. export class RefractionPostProcess extends PostProcess {
  117075. /** the base color of the refraction (used to taint the rendering) */
  117076. color: Color3;
  117077. /** simulated refraction depth */
  117078. depth: number;
  117079. /** the coefficient of the base color (0 to remove base color tainting) */
  117080. colorLevel: number;
  117081. private _refTexture;
  117082. private _ownRefractionTexture;
  117083. /**
  117084. * Gets or sets the refraction texture
  117085. * Please note that you are responsible for disposing the texture if you set it manually
  117086. */
  117087. refractionTexture: Texture;
  117088. /**
  117089. * Initializes the RefractionPostProcess
  117090. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  117091. * @param name The name of the effect.
  117092. * @param refractionTextureUrl Url of the refraction texture to use
  117093. * @param color the base color of the refraction (used to taint the rendering)
  117094. * @param depth simulated refraction depth
  117095. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  117096. * @param camera The camera to apply the render pass to.
  117097. * @param options The required width/height ratio to downsize to before computing the render pass.
  117098. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  117099. * @param engine The engine which the post process will be applied. (default: current engine)
  117100. * @param reusable If the post process can be reused on the same frame. (default: false)
  117101. */
  117102. constructor(name: string, refractionTextureUrl: string,
  117103. /** the base color of the refraction (used to taint the rendering) */
  117104. color: Color3,
  117105. /** simulated refraction depth */
  117106. depth: number,
  117107. /** the coefficient of the base color (0 to remove base color tainting) */
  117108. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  117109. /**
  117110. * Disposes of the post process
  117111. * @param camera Camera to dispose post process on
  117112. */
  117113. dispose(camera: Camera): void;
  117114. }
  117115. }
  117116. declare module BABYLON {
  117117. /** @hidden */
  117118. export var sharpenPixelShader: {
  117119. name: string;
  117120. shader: string;
  117121. };
  117122. }
  117123. declare module BABYLON {
  117124. /**
  117125. * The SharpenPostProcess applies a sharpen kernel to every pixel
  117126. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  117127. */
  117128. export class SharpenPostProcess extends PostProcess {
  117129. /**
  117130. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  117131. */
  117132. colorAmount: number;
  117133. /**
  117134. * How much sharpness should be applied (default: 0.3)
  117135. */
  117136. edgeAmount: number;
  117137. /**
  117138. * Creates a new instance ConvolutionPostProcess
  117139. * @param name The name of the effect.
  117140. * @param options The required width/height ratio to downsize to before computing the render pass.
  117141. * @param camera The camera to apply the render pass to.
  117142. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  117143. * @param engine The engine which the post process will be applied. (default: current engine)
  117144. * @param reusable If the post process can be reused on the same frame. (default: false)
  117145. * @param textureType Type of textures used when performing the post process. (default: 0)
  117146. * @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)
  117147. */
  117148. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  117149. }
  117150. }
  117151. declare module BABYLON {
  117152. /**
  117153. * PostProcessRenderPipeline
  117154. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  117155. */
  117156. export class PostProcessRenderPipeline {
  117157. private engine;
  117158. private _renderEffects;
  117159. private _renderEffectsForIsolatedPass;
  117160. /**
  117161. * List of inspectable custom properties (used by the Inspector)
  117162. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  117163. */
  117164. inspectableCustomProperties: IInspectable[];
  117165. /**
  117166. * @hidden
  117167. */
  117168. protected _cameras: Camera[];
  117169. /** @hidden */
  117170. _name: string;
  117171. /**
  117172. * Gets pipeline name
  117173. */
  117174. readonly name: string;
  117175. /**
  117176. * Initializes a PostProcessRenderPipeline
  117177. * @param engine engine to add the pipeline to
  117178. * @param name name of the pipeline
  117179. */
  117180. constructor(engine: Engine, name: string);
  117181. /**
  117182. * Gets the class name
  117183. * @returns "PostProcessRenderPipeline"
  117184. */
  117185. getClassName(): string;
  117186. /**
  117187. * If all the render effects in the pipeline are supported
  117188. */
  117189. readonly isSupported: boolean;
  117190. /**
  117191. * Adds an effect to the pipeline
  117192. * @param renderEffect the effect to add
  117193. */
  117194. addEffect(renderEffect: PostProcessRenderEffect): void;
  117195. /** @hidden */
  117196. _rebuild(): void;
  117197. /** @hidden */
  117198. _enableEffect(renderEffectName: string, cameras: Camera): void;
  117199. /** @hidden */
  117200. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  117201. /** @hidden */
  117202. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  117203. /** @hidden */
  117204. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  117205. /** @hidden */
  117206. _attachCameras(cameras: Camera, unique: boolean): void;
  117207. /** @hidden */
  117208. _attachCameras(cameras: Camera[], unique: boolean): void;
  117209. /** @hidden */
  117210. _detachCameras(cameras: Camera): void;
  117211. /** @hidden */
  117212. _detachCameras(cameras: Nullable<Camera[]>): void;
  117213. /** @hidden */
  117214. _update(): void;
  117215. /** @hidden */
  117216. _reset(): void;
  117217. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  117218. /**
  117219. * Disposes of the pipeline
  117220. */
  117221. dispose(): void;
  117222. }
  117223. }
  117224. declare module BABYLON {
  117225. /**
  117226. * PostProcessRenderPipelineManager class
  117227. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  117228. */
  117229. export class PostProcessRenderPipelineManager {
  117230. private _renderPipelines;
  117231. /**
  117232. * Initializes a PostProcessRenderPipelineManager
  117233. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  117234. */
  117235. constructor();
  117236. /**
  117237. * Gets the list of supported render pipelines
  117238. */
  117239. readonly supportedPipelines: PostProcessRenderPipeline[];
  117240. /**
  117241. * Adds a pipeline to the manager
  117242. * @param renderPipeline The pipeline to add
  117243. */
  117244. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  117245. /**
  117246. * Attaches a camera to the pipeline
  117247. * @param renderPipelineName The name of the pipeline to attach to
  117248. * @param cameras the camera to attach
  117249. * @param unique if the camera can be attached multiple times to the pipeline
  117250. */
  117251. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  117252. /**
  117253. * Detaches a camera from the pipeline
  117254. * @param renderPipelineName The name of the pipeline to detach from
  117255. * @param cameras the camera to detach
  117256. */
  117257. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  117258. /**
  117259. * Enables an effect by name on a pipeline
  117260. * @param renderPipelineName the name of the pipeline to enable the effect in
  117261. * @param renderEffectName the name of the effect to enable
  117262. * @param cameras the cameras that the effect should be enabled on
  117263. */
  117264. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  117265. /**
  117266. * Disables an effect by name on a pipeline
  117267. * @param renderPipelineName the name of the pipeline to disable the effect in
  117268. * @param renderEffectName the name of the effect to disable
  117269. * @param cameras the cameras that the effect should be disabled on
  117270. */
  117271. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  117272. /**
  117273. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  117274. */
  117275. update(): void;
  117276. /** @hidden */
  117277. _rebuild(): void;
  117278. /**
  117279. * Disposes of the manager and pipelines
  117280. */
  117281. dispose(): void;
  117282. }
  117283. }
  117284. declare module BABYLON {
  117285. interface Scene {
  117286. /** @hidden (Backing field) */
  117287. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  117288. /**
  117289. * Gets the postprocess render pipeline manager
  117290. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  117291. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  117292. */
  117293. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  117294. }
  117295. /**
  117296. * Defines the Render Pipeline scene component responsible to rendering pipelines
  117297. */
  117298. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  117299. /**
  117300. * The component name helpfull to identify the component in the list of scene components.
  117301. */
  117302. readonly name: string;
  117303. /**
  117304. * The scene the component belongs to.
  117305. */
  117306. scene: Scene;
  117307. /**
  117308. * Creates a new instance of the component for the given scene
  117309. * @param scene Defines the scene to register the component in
  117310. */
  117311. constructor(scene: Scene);
  117312. /**
  117313. * Registers the component in a given scene
  117314. */
  117315. register(): void;
  117316. /**
  117317. * Rebuilds the elements related to this component in case of
  117318. * context lost for instance.
  117319. */
  117320. rebuild(): void;
  117321. /**
  117322. * Disposes the component and the associated ressources
  117323. */
  117324. dispose(): void;
  117325. private _gatherRenderTargets;
  117326. }
  117327. }
  117328. declare module BABYLON {
  117329. /**
  117330. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  117331. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  117332. */
  117333. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  117334. private _scene;
  117335. private _camerasToBeAttached;
  117336. /**
  117337. * ID of the sharpen post process,
  117338. */
  117339. private readonly SharpenPostProcessId;
  117340. /**
  117341. * @ignore
  117342. * ID of the image processing post process;
  117343. */
  117344. readonly ImageProcessingPostProcessId: string;
  117345. /**
  117346. * @ignore
  117347. * ID of the Fast Approximate Anti-Aliasing post process;
  117348. */
  117349. readonly FxaaPostProcessId: string;
  117350. /**
  117351. * ID of the chromatic aberration post process,
  117352. */
  117353. private readonly ChromaticAberrationPostProcessId;
  117354. /**
  117355. * ID of the grain post process
  117356. */
  117357. private readonly GrainPostProcessId;
  117358. /**
  117359. * Sharpen post process which will apply a sharpen convolution to enhance edges
  117360. */
  117361. sharpen: SharpenPostProcess;
  117362. private _sharpenEffect;
  117363. private bloom;
  117364. /**
  117365. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  117366. */
  117367. depthOfField: DepthOfFieldEffect;
  117368. /**
  117369. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  117370. */
  117371. fxaa: FxaaPostProcess;
  117372. /**
  117373. * Image post processing pass used to perform operations such as tone mapping or color grading.
  117374. */
  117375. imageProcessing: ImageProcessingPostProcess;
  117376. /**
  117377. * Chromatic aberration post process which will shift rgb colors in the image
  117378. */
  117379. chromaticAberration: ChromaticAberrationPostProcess;
  117380. private _chromaticAberrationEffect;
  117381. /**
  117382. * Grain post process which add noise to the image
  117383. */
  117384. grain: GrainPostProcess;
  117385. private _grainEffect;
  117386. /**
  117387. * Glow post process which adds a glow to emissive areas of the image
  117388. */
  117389. private _glowLayer;
  117390. /**
  117391. * Animations which can be used to tweak settings over a period of time
  117392. */
  117393. animations: Animation[];
  117394. private _imageProcessingConfigurationObserver;
  117395. private _sharpenEnabled;
  117396. private _bloomEnabled;
  117397. private _depthOfFieldEnabled;
  117398. private _depthOfFieldBlurLevel;
  117399. private _fxaaEnabled;
  117400. private _imageProcessingEnabled;
  117401. private _defaultPipelineTextureType;
  117402. private _bloomScale;
  117403. private _chromaticAberrationEnabled;
  117404. private _grainEnabled;
  117405. private _buildAllowed;
  117406. /**
  117407. * Gets active scene
  117408. */
  117409. readonly scene: Scene;
  117410. /**
  117411. * Enable or disable the sharpen process from the pipeline
  117412. */
  117413. sharpenEnabled: boolean;
  117414. private _resizeObserver;
  117415. private _hardwareScaleLevel;
  117416. private _bloomKernel;
  117417. /**
  117418. * Specifies the size of the bloom blur kernel, relative to the final output size
  117419. */
  117420. bloomKernel: number;
  117421. /**
  117422. * Specifies the weight of the bloom in the final rendering
  117423. */
  117424. private _bloomWeight;
  117425. /**
  117426. * Specifies the luma threshold for the area that will be blurred by the bloom
  117427. */
  117428. private _bloomThreshold;
  117429. private _hdr;
  117430. /**
  117431. * The strength of the bloom.
  117432. */
  117433. bloomWeight: number;
  117434. /**
  117435. * The strength of the bloom.
  117436. */
  117437. bloomThreshold: number;
  117438. /**
  117439. * The scale of the bloom, lower value will provide better performance.
  117440. */
  117441. bloomScale: number;
  117442. /**
  117443. * Enable or disable the bloom from the pipeline
  117444. */
  117445. bloomEnabled: boolean;
  117446. private _rebuildBloom;
  117447. /**
  117448. * If the depth of field is enabled.
  117449. */
  117450. depthOfFieldEnabled: boolean;
  117451. /**
  117452. * Blur level of the depth of field effect. (Higher blur will effect performance)
  117453. */
  117454. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  117455. /**
  117456. * If the anti aliasing is enabled.
  117457. */
  117458. fxaaEnabled: boolean;
  117459. private _samples;
  117460. /**
  117461. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  117462. */
  117463. samples: number;
  117464. /**
  117465. * If image processing is enabled.
  117466. */
  117467. imageProcessingEnabled: boolean;
  117468. /**
  117469. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  117470. */
  117471. glowLayerEnabled: boolean;
  117472. /**
  117473. * Gets the glow layer (or null if not defined)
  117474. */
  117475. readonly glowLayer: Nullable<GlowLayer>;
  117476. /**
  117477. * Enable or disable the chromaticAberration process from the pipeline
  117478. */
  117479. chromaticAberrationEnabled: boolean;
  117480. /**
  117481. * Enable or disable the grain process from the pipeline
  117482. */
  117483. grainEnabled: boolean;
  117484. /**
  117485. * @constructor
  117486. * @param name - The rendering pipeline name (default: "")
  117487. * @param hdr - If high dynamic range textures should be used (default: true)
  117488. * @param scene - The scene linked to this pipeline (default: the last created scene)
  117489. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  117490. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  117491. */
  117492. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  117493. /**
  117494. * Get the class name
  117495. * @returns "DefaultRenderingPipeline"
  117496. */
  117497. getClassName(): string;
  117498. /**
  117499. * Force the compilation of the entire pipeline.
  117500. */
  117501. prepare(): void;
  117502. private _hasCleared;
  117503. private _prevPostProcess;
  117504. private _prevPrevPostProcess;
  117505. private _setAutoClearAndTextureSharing;
  117506. private _depthOfFieldSceneObserver;
  117507. private _buildPipeline;
  117508. private _disposePostProcesses;
  117509. /**
  117510. * Adds a camera to the pipeline
  117511. * @param camera the camera to be added
  117512. */
  117513. addCamera(camera: Camera): void;
  117514. /**
  117515. * Removes a camera from the pipeline
  117516. * @param camera the camera to remove
  117517. */
  117518. removeCamera(camera: Camera): void;
  117519. /**
  117520. * Dispose of the pipeline and stop all post processes
  117521. */
  117522. dispose(): void;
  117523. /**
  117524. * Serialize the rendering pipeline (Used when exporting)
  117525. * @returns the serialized object
  117526. */
  117527. serialize(): any;
  117528. /**
  117529. * Parse the serialized pipeline
  117530. * @param source Source pipeline.
  117531. * @param scene The scene to load the pipeline to.
  117532. * @param rootUrl The URL of the serialized pipeline.
  117533. * @returns An instantiated pipeline from the serialized object.
  117534. */
  117535. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  117536. }
  117537. }
  117538. declare module BABYLON {
  117539. /** @hidden */
  117540. export var lensHighlightsPixelShader: {
  117541. name: string;
  117542. shader: string;
  117543. };
  117544. }
  117545. declare module BABYLON {
  117546. /** @hidden */
  117547. export var depthOfFieldPixelShader: {
  117548. name: string;
  117549. shader: string;
  117550. };
  117551. }
  117552. declare module BABYLON {
  117553. /**
  117554. * BABYLON.JS Chromatic Aberration GLSL Shader
  117555. * Author: Olivier Guyot
  117556. * Separates very slightly R, G and B colors on the edges of the screen
  117557. * Inspired by Francois Tarlier & Martins Upitis
  117558. */
  117559. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  117560. /**
  117561. * @ignore
  117562. * The chromatic aberration PostProcess id in the pipeline
  117563. */
  117564. LensChromaticAberrationEffect: string;
  117565. /**
  117566. * @ignore
  117567. * The highlights enhancing PostProcess id in the pipeline
  117568. */
  117569. HighlightsEnhancingEffect: string;
  117570. /**
  117571. * @ignore
  117572. * The depth-of-field PostProcess id in the pipeline
  117573. */
  117574. LensDepthOfFieldEffect: string;
  117575. private _scene;
  117576. private _depthTexture;
  117577. private _grainTexture;
  117578. private _chromaticAberrationPostProcess;
  117579. private _highlightsPostProcess;
  117580. private _depthOfFieldPostProcess;
  117581. private _edgeBlur;
  117582. private _grainAmount;
  117583. private _chromaticAberration;
  117584. private _distortion;
  117585. private _highlightsGain;
  117586. private _highlightsThreshold;
  117587. private _dofDistance;
  117588. private _dofAperture;
  117589. private _dofDarken;
  117590. private _dofPentagon;
  117591. private _blurNoise;
  117592. /**
  117593. * @constructor
  117594. *
  117595. * Effect parameters are as follow:
  117596. * {
  117597. * chromatic_aberration: number; // from 0 to x (1 for realism)
  117598. * edge_blur: number; // from 0 to x (1 for realism)
  117599. * distortion: number; // from 0 to x (1 for realism)
  117600. * grain_amount: number; // from 0 to 1
  117601. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  117602. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  117603. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  117604. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  117605. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  117606. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  117607. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  117608. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  117609. * }
  117610. * Note: if an effect parameter is unset, effect is disabled
  117611. *
  117612. * @param name The rendering pipeline name
  117613. * @param parameters - An object containing all parameters (see above)
  117614. * @param scene The scene linked to this pipeline
  117615. * @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)
  117616. * @param cameras The array of cameras that the rendering pipeline will be attached to
  117617. */
  117618. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  117619. /**
  117620. * Get the class name
  117621. * @returns "LensRenderingPipeline"
  117622. */
  117623. getClassName(): string;
  117624. /**
  117625. * Gets associated scene
  117626. */
  117627. readonly scene: Scene;
  117628. /**
  117629. * Gets or sets the edge blur
  117630. */
  117631. edgeBlur: number;
  117632. /**
  117633. * Gets or sets the grain amount
  117634. */
  117635. grainAmount: number;
  117636. /**
  117637. * Gets or sets the chromatic aberration amount
  117638. */
  117639. chromaticAberration: number;
  117640. /**
  117641. * Gets or sets the depth of field aperture
  117642. */
  117643. dofAperture: number;
  117644. /**
  117645. * Gets or sets the edge distortion
  117646. */
  117647. edgeDistortion: number;
  117648. /**
  117649. * Gets or sets the depth of field distortion
  117650. */
  117651. dofDistortion: number;
  117652. /**
  117653. * Gets or sets the darken out of focus amount
  117654. */
  117655. darkenOutOfFocus: number;
  117656. /**
  117657. * Gets or sets a boolean indicating if blur noise is enabled
  117658. */
  117659. blurNoise: boolean;
  117660. /**
  117661. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  117662. */
  117663. pentagonBokeh: boolean;
  117664. /**
  117665. * Gets or sets the highlight grain amount
  117666. */
  117667. highlightsGain: number;
  117668. /**
  117669. * Gets or sets the highlight threshold
  117670. */
  117671. highlightsThreshold: number;
  117672. /**
  117673. * Sets the amount of blur at the edges
  117674. * @param amount blur amount
  117675. */
  117676. setEdgeBlur(amount: number): void;
  117677. /**
  117678. * Sets edge blur to 0
  117679. */
  117680. disableEdgeBlur(): void;
  117681. /**
  117682. * Sets the amout of grain
  117683. * @param amount Amount of grain
  117684. */
  117685. setGrainAmount(amount: number): void;
  117686. /**
  117687. * Set grain amount to 0
  117688. */
  117689. disableGrain(): void;
  117690. /**
  117691. * Sets the chromatic aberration amount
  117692. * @param amount amount of chromatic aberration
  117693. */
  117694. setChromaticAberration(amount: number): void;
  117695. /**
  117696. * Sets chromatic aberration amount to 0
  117697. */
  117698. disableChromaticAberration(): void;
  117699. /**
  117700. * Sets the EdgeDistortion amount
  117701. * @param amount amount of EdgeDistortion
  117702. */
  117703. setEdgeDistortion(amount: number): void;
  117704. /**
  117705. * Sets edge distortion to 0
  117706. */
  117707. disableEdgeDistortion(): void;
  117708. /**
  117709. * Sets the FocusDistance amount
  117710. * @param amount amount of FocusDistance
  117711. */
  117712. setFocusDistance(amount: number): void;
  117713. /**
  117714. * Disables depth of field
  117715. */
  117716. disableDepthOfField(): void;
  117717. /**
  117718. * Sets the Aperture amount
  117719. * @param amount amount of Aperture
  117720. */
  117721. setAperture(amount: number): void;
  117722. /**
  117723. * Sets the DarkenOutOfFocus amount
  117724. * @param amount amount of DarkenOutOfFocus
  117725. */
  117726. setDarkenOutOfFocus(amount: number): void;
  117727. private _pentagonBokehIsEnabled;
  117728. /**
  117729. * Creates a pentagon bokeh effect
  117730. */
  117731. enablePentagonBokeh(): void;
  117732. /**
  117733. * Disables the pentagon bokeh effect
  117734. */
  117735. disablePentagonBokeh(): void;
  117736. /**
  117737. * Enables noise blur
  117738. */
  117739. enableNoiseBlur(): void;
  117740. /**
  117741. * Disables noise blur
  117742. */
  117743. disableNoiseBlur(): void;
  117744. /**
  117745. * Sets the HighlightsGain amount
  117746. * @param amount amount of HighlightsGain
  117747. */
  117748. setHighlightsGain(amount: number): void;
  117749. /**
  117750. * Sets the HighlightsThreshold amount
  117751. * @param amount amount of HighlightsThreshold
  117752. */
  117753. setHighlightsThreshold(amount: number): void;
  117754. /**
  117755. * Disables highlights
  117756. */
  117757. disableHighlights(): void;
  117758. /**
  117759. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  117760. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  117761. */
  117762. dispose(disableDepthRender?: boolean): void;
  117763. private _createChromaticAberrationPostProcess;
  117764. private _createHighlightsPostProcess;
  117765. private _createDepthOfFieldPostProcess;
  117766. private _createGrainTexture;
  117767. }
  117768. }
  117769. declare module BABYLON {
  117770. /** @hidden */
  117771. export var ssao2PixelShader: {
  117772. name: string;
  117773. shader: string;
  117774. };
  117775. }
  117776. declare module BABYLON {
  117777. /** @hidden */
  117778. export var ssaoCombinePixelShader: {
  117779. name: string;
  117780. shader: string;
  117781. };
  117782. }
  117783. declare module BABYLON {
  117784. /**
  117785. * Render pipeline to produce ssao effect
  117786. */
  117787. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  117788. /**
  117789. * @ignore
  117790. * The PassPostProcess id in the pipeline that contains the original scene color
  117791. */
  117792. SSAOOriginalSceneColorEffect: string;
  117793. /**
  117794. * @ignore
  117795. * The SSAO PostProcess id in the pipeline
  117796. */
  117797. SSAORenderEffect: string;
  117798. /**
  117799. * @ignore
  117800. * The horizontal blur PostProcess id in the pipeline
  117801. */
  117802. SSAOBlurHRenderEffect: string;
  117803. /**
  117804. * @ignore
  117805. * The vertical blur PostProcess id in the pipeline
  117806. */
  117807. SSAOBlurVRenderEffect: string;
  117808. /**
  117809. * @ignore
  117810. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  117811. */
  117812. SSAOCombineRenderEffect: string;
  117813. /**
  117814. * The output strength of the SSAO post-process. Default value is 1.0.
  117815. */
  117816. totalStrength: number;
  117817. /**
  117818. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  117819. */
  117820. maxZ: number;
  117821. /**
  117822. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  117823. */
  117824. minZAspect: number;
  117825. private _samples;
  117826. /**
  117827. * Number of samples used for the SSAO calculations. Default value is 8
  117828. */
  117829. samples: number;
  117830. private _textureSamples;
  117831. /**
  117832. * Number of samples to use for antialiasing
  117833. */
  117834. textureSamples: number;
  117835. /**
  117836. * Ratio object used for SSAO ratio and blur ratio
  117837. */
  117838. private _ratio;
  117839. /**
  117840. * Dynamically generated sphere sampler.
  117841. */
  117842. private _sampleSphere;
  117843. /**
  117844. * Blur filter offsets
  117845. */
  117846. private _samplerOffsets;
  117847. private _expensiveBlur;
  117848. /**
  117849. * If bilateral blur should be used
  117850. */
  117851. expensiveBlur: boolean;
  117852. /**
  117853. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  117854. */
  117855. radius: number;
  117856. /**
  117857. * The base color of the SSAO post-process
  117858. * The final result is "base + ssao" between [0, 1]
  117859. */
  117860. base: number;
  117861. /**
  117862. * Support test.
  117863. */
  117864. static readonly IsSupported: boolean;
  117865. private _scene;
  117866. private _depthTexture;
  117867. private _normalTexture;
  117868. private _randomTexture;
  117869. private _originalColorPostProcess;
  117870. private _ssaoPostProcess;
  117871. private _blurHPostProcess;
  117872. private _blurVPostProcess;
  117873. private _ssaoCombinePostProcess;
  117874. private _firstUpdate;
  117875. /**
  117876. * Gets active scene
  117877. */
  117878. readonly scene: Scene;
  117879. /**
  117880. * @constructor
  117881. * @param name The rendering pipeline name
  117882. * @param scene The scene linked to this pipeline
  117883. * @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 }
  117884. * @param cameras The array of cameras that the rendering pipeline will be attached to
  117885. */
  117886. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  117887. /**
  117888. * Get the class name
  117889. * @returns "SSAO2RenderingPipeline"
  117890. */
  117891. getClassName(): string;
  117892. /**
  117893. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  117894. */
  117895. dispose(disableGeometryBufferRenderer?: boolean): void;
  117896. private _createBlurPostProcess;
  117897. /** @hidden */
  117898. _rebuild(): void;
  117899. private _bits;
  117900. private _radicalInverse_VdC;
  117901. private _hammersley;
  117902. private _hemisphereSample_uniform;
  117903. private _generateHemisphere;
  117904. private _createSSAOPostProcess;
  117905. private _createSSAOCombinePostProcess;
  117906. private _createRandomTexture;
  117907. /**
  117908. * Serialize the rendering pipeline (Used when exporting)
  117909. * @returns the serialized object
  117910. */
  117911. serialize(): any;
  117912. /**
  117913. * Parse the serialized pipeline
  117914. * @param source Source pipeline.
  117915. * @param scene The scene to load the pipeline to.
  117916. * @param rootUrl The URL of the serialized pipeline.
  117917. * @returns An instantiated pipeline from the serialized object.
  117918. */
  117919. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  117920. }
  117921. }
  117922. declare module BABYLON {
  117923. /** @hidden */
  117924. export var ssaoPixelShader: {
  117925. name: string;
  117926. shader: string;
  117927. };
  117928. }
  117929. declare module BABYLON {
  117930. /**
  117931. * Render pipeline to produce ssao effect
  117932. */
  117933. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  117934. /**
  117935. * @ignore
  117936. * The PassPostProcess id in the pipeline that contains the original scene color
  117937. */
  117938. SSAOOriginalSceneColorEffect: string;
  117939. /**
  117940. * @ignore
  117941. * The SSAO PostProcess id in the pipeline
  117942. */
  117943. SSAORenderEffect: string;
  117944. /**
  117945. * @ignore
  117946. * The horizontal blur PostProcess id in the pipeline
  117947. */
  117948. SSAOBlurHRenderEffect: string;
  117949. /**
  117950. * @ignore
  117951. * The vertical blur PostProcess id in the pipeline
  117952. */
  117953. SSAOBlurVRenderEffect: string;
  117954. /**
  117955. * @ignore
  117956. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  117957. */
  117958. SSAOCombineRenderEffect: string;
  117959. /**
  117960. * The output strength of the SSAO post-process. Default value is 1.0.
  117961. */
  117962. totalStrength: number;
  117963. /**
  117964. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  117965. */
  117966. radius: number;
  117967. /**
  117968. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  117969. * Must not be equal to fallOff and superior to fallOff.
  117970. * Default value is 0.0075
  117971. */
  117972. area: number;
  117973. /**
  117974. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  117975. * Must not be equal to area and inferior to area.
  117976. * Default value is 0.000001
  117977. */
  117978. fallOff: number;
  117979. /**
  117980. * The base color of the SSAO post-process
  117981. * The final result is "base + ssao" between [0, 1]
  117982. */
  117983. base: number;
  117984. private _scene;
  117985. private _depthTexture;
  117986. private _randomTexture;
  117987. private _originalColorPostProcess;
  117988. private _ssaoPostProcess;
  117989. private _blurHPostProcess;
  117990. private _blurVPostProcess;
  117991. private _ssaoCombinePostProcess;
  117992. private _firstUpdate;
  117993. /**
  117994. * Gets active scene
  117995. */
  117996. readonly scene: Scene;
  117997. /**
  117998. * @constructor
  117999. * @param name - The rendering pipeline name
  118000. * @param scene - The scene linked to this pipeline
  118001. * @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 }
  118002. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  118003. */
  118004. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  118005. /**
  118006. * Get the class name
  118007. * @returns "SSAORenderingPipeline"
  118008. */
  118009. getClassName(): string;
  118010. /**
  118011. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  118012. */
  118013. dispose(disableDepthRender?: boolean): void;
  118014. private _createBlurPostProcess;
  118015. /** @hidden */
  118016. _rebuild(): void;
  118017. private _createSSAOPostProcess;
  118018. private _createSSAOCombinePostProcess;
  118019. private _createRandomTexture;
  118020. }
  118021. }
  118022. declare module BABYLON {
  118023. /** @hidden */
  118024. export var standardPixelShader: {
  118025. name: string;
  118026. shader: string;
  118027. };
  118028. }
  118029. declare module BABYLON {
  118030. /**
  118031. * Standard rendering pipeline
  118032. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  118033. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  118034. */
  118035. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  118036. /**
  118037. * Public members
  118038. */
  118039. /**
  118040. * Post-process which contains the original scene color before the pipeline applies all the effects
  118041. */
  118042. originalPostProcess: Nullable<PostProcess>;
  118043. /**
  118044. * Post-process used to down scale an image x4
  118045. */
  118046. downSampleX4PostProcess: Nullable<PostProcess>;
  118047. /**
  118048. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  118049. */
  118050. brightPassPostProcess: Nullable<PostProcess>;
  118051. /**
  118052. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  118053. */
  118054. blurHPostProcesses: PostProcess[];
  118055. /**
  118056. * Post-process array storing all the vertical blur post-processes used by the pipeline
  118057. */
  118058. blurVPostProcesses: PostProcess[];
  118059. /**
  118060. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  118061. */
  118062. textureAdderPostProcess: Nullable<PostProcess>;
  118063. /**
  118064. * Post-process used to create volumetric lighting effect
  118065. */
  118066. volumetricLightPostProcess: Nullable<PostProcess>;
  118067. /**
  118068. * Post-process used to smooth the previous volumetric light post-process on the X axis
  118069. */
  118070. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  118071. /**
  118072. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  118073. */
  118074. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  118075. /**
  118076. * Post-process used to merge the volumetric light effect and the real scene color
  118077. */
  118078. volumetricLightMergePostProces: Nullable<PostProcess>;
  118079. /**
  118080. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  118081. */
  118082. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  118083. /**
  118084. * Base post-process used to calculate the average luminance of the final image for HDR
  118085. */
  118086. luminancePostProcess: Nullable<PostProcess>;
  118087. /**
  118088. * Post-processes used to create down sample post-processes in order to get
  118089. * the average luminance of the final image for HDR
  118090. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  118091. */
  118092. luminanceDownSamplePostProcesses: PostProcess[];
  118093. /**
  118094. * Post-process used to create a HDR effect (light adaptation)
  118095. */
  118096. hdrPostProcess: Nullable<PostProcess>;
  118097. /**
  118098. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  118099. */
  118100. textureAdderFinalPostProcess: Nullable<PostProcess>;
  118101. /**
  118102. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  118103. */
  118104. lensFlareFinalPostProcess: Nullable<PostProcess>;
  118105. /**
  118106. * Post-process used to merge the final HDR post-process and the real scene color
  118107. */
  118108. hdrFinalPostProcess: Nullable<PostProcess>;
  118109. /**
  118110. * Post-process used to create a lens flare effect
  118111. */
  118112. lensFlarePostProcess: Nullable<PostProcess>;
  118113. /**
  118114. * Post-process that merges the result of the lens flare post-process and the real scene color
  118115. */
  118116. lensFlareComposePostProcess: Nullable<PostProcess>;
  118117. /**
  118118. * Post-process used to create a motion blur effect
  118119. */
  118120. motionBlurPostProcess: Nullable<PostProcess>;
  118121. /**
  118122. * Post-process used to create a depth of field effect
  118123. */
  118124. depthOfFieldPostProcess: Nullable<PostProcess>;
  118125. /**
  118126. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  118127. */
  118128. fxaaPostProcess: Nullable<FxaaPostProcess>;
  118129. /**
  118130. * Represents the brightness threshold in order to configure the illuminated surfaces
  118131. */
  118132. brightThreshold: number;
  118133. /**
  118134. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  118135. */
  118136. blurWidth: number;
  118137. /**
  118138. * Sets if the blur for highlighted surfaces must be only horizontal
  118139. */
  118140. horizontalBlur: boolean;
  118141. /**
  118142. * Gets the overall exposure used by the pipeline
  118143. */
  118144. /**
  118145. * Sets the overall exposure used by the pipeline
  118146. */
  118147. exposure: number;
  118148. /**
  118149. * Texture used typically to simulate "dirty" on camera lens
  118150. */
  118151. lensTexture: Nullable<Texture>;
  118152. /**
  118153. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  118154. */
  118155. volumetricLightCoefficient: number;
  118156. /**
  118157. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  118158. */
  118159. volumetricLightPower: number;
  118160. /**
  118161. * Used the set the blur intensity to smooth the volumetric lights
  118162. */
  118163. volumetricLightBlurScale: number;
  118164. /**
  118165. * Light (spot or directional) used to generate the volumetric lights rays
  118166. * The source light must have a shadow generate so the pipeline can get its
  118167. * depth map
  118168. */
  118169. sourceLight: Nullable<SpotLight | DirectionalLight>;
  118170. /**
  118171. * For eye adaptation, represents the minimum luminance the eye can see
  118172. */
  118173. hdrMinimumLuminance: number;
  118174. /**
  118175. * For eye adaptation, represents the decrease luminance speed
  118176. */
  118177. hdrDecreaseRate: number;
  118178. /**
  118179. * For eye adaptation, represents the increase luminance speed
  118180. */
  118181. hdrIncreaseRate: number;
  118182. /**
  118183. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  118184. */
  118185. /**
  118186. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  118187. */
  118188. hdrAutoExposure: boolean;
  118189. /**
  118190. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  118191. */
  118192. lensColorTexture: Nullable<Texture>;
  118193. /**
  118194. * The overall strengh for the lens flare effect
  118195. */
  118196. lensFlareStrength: number;
  118197. /**
  118198. * Dispersion coefficient for lens flare ghosts
  118199. */
  118200. lensFlareGhostDispersal: number;
  118201. /**
  118202. * Main lens flare halo width
  118203. */
  118204. lensFlareHaloWidth: number;
  118205. /**
  118206. * Based on the lens distortion effect, defines how much the lens flare result
  118207. * is distorted
  118208. */
  118209. lensFlareDistortionStrength: number;
  118210. /**
  118211. * Lens star texture must be used to simulate rays on the flares and is available
  118212. * in the documentation
  118213. */
  118214. lensStarTexture: Nullable<Texture>;
  118215. /**
  118216. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  118217. * flare effect by taking account of the dirt texture
  118218. */
  118219. lensFlareDirtTexture: Nullable<Texture>;
  118220. /**
  118221. * Represents the focal length for the depth of field effect
  118222. */
  118223. depthOfFieldDistance: number;
  118224. /**
  118225. * Represents the blur intensity for the blurred part of the depth of field effect
  118226. */
  118227. depthOfFieldBlurWidth: number;
  118228. /**
  118229. * Gets how much the image is blurred by the movement while using the motion blur post-process
  118230. */
  118231. /**
  118232. * Sets how much the image is blurred by the movement while using the motion blur post-process
  118233. */
  118234. motionStrength: number;
  118235. /**
  118236. * Gets wether or not the motion blur post-process is object based or screen based.
  118237. */
  118238. /**
  118239. * Sets wether or not the motion blur post-process should be object based or screen based
  118240. */
  118241. objectBasedMotionBlur: boolean;
  118242. /**
  118243. * List of animations for the pipeline (IAnimatable implementation)
  118244. */
  118245. animations: Animation[];
  118246. /**
  118247. * Private members
  118248. */
  118249. private _scene;
  118250. private _currentDepthOfFieldSource;
  118251. private _basePostProcess;
  118252. private _fixedExposure;
  118253. private _currentExposure;
  118254. private _hdrAutoExposure;
  118255. private _hdrCurrentLuminance;
  118256. private _motionStrength;
  118257. private _isObjectBasedMotionBlur;
  118258. private _floatTextureType;
  118259. private _ratio;
  118260. private _bloomEnabled;
  118261. private _depthOfFieldEnabled;
  118262. private _vlsEnabled;
  118263. private _lensFlareEnabled;
  118264. private _hdrEnabled;
  118265. private _motionBlurEnabled;
  118266. private _fxaaEnabled;
  118267. private _motionBlurSamples;
  118268. private _volumetricLightStepsCount;
  118269. private _samples;
  118270. /**
  118271. * @ignore
  118272. * Specifies if the bloom pipeline is enabled
  118273. */
  118274. BloomEnabled: boolean;
  118275. /**
  118276. * @ignore
  118277. * Specifies if the depth of field pipeline is enabed
  118278. */
  118279. DepthOfFieldEnabled: boolean;
  118280. /**
  118281. * @ignore
  118282. * Specifies if the lens flare pipeline is enabed
  118283. */
  118284. LensFlareEnabled: boolean;
  118285. /**
  118286. * @ignore
  118287. * Specifies if the HDR pipeline is enabled
  118288. */
  118289. HDREnabled: boolean;
  118290. /**
  118291. * @ignore
  118292. * Specifies if the volumetric lights scattering effect is enabled
  118293. */
  118294. VLSEnabled: boolean;
  118295. /**
  118296. * @ignore
  118297. * Specifies if the motion blur effect is enabled
  118298. */
  118299. MotionBlurEnabled: boolean;
  118300. /**
  118301. * Specifies if anti-aliasing is enabled
  118302. */
  118303. fxaaEnabled: boolean;
  118304. /**
  118305. * Specifies the number of steps used to calculate the volumetric lights
  118306. * Typically in interval [50, 200]
  118307. */
  118308. volumetricLightStepsCount: number;
  118309. /**
  118310. * Specifies the number of samples used for the motion blur effect
  118311. * Typically in interval [16, 64]
  118312. */
  118313. motionBlurSamples: number;
  118314. /**
  118315. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  118316. */
  118317. samples: number;
  118318. /**
  118319. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  118320. * @constructor
  118321. * @param name The rendering pipeline name
  118322. * @param scene The scene linked to this pipeline
  118323. * @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)
  118324. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  118325. * @param cameras The array of cameras that the rendering pipeline will be attached to
  118326. */
  118327. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  118328. private _buildPipeline;
  118329. private _createDownSampleX4PostProcess;
  118330. private _createBrightPassPostProcess;
  118331. private _createBlurPostProcesses;
  118332. private _createTextureAdderPostProcess;
  118333. private _createVolumetricLightPostProcess;
  118334. private _createLuminancePostProcesses;
  118335. private _createHdrPostProcess;
  118336. private _createLensFlarePostProcess;
  118337. private _createDepthOfFieldPostProcess;
  118338. private _createMotionBlurPostProcess;
  118339. private _getDepthTexture;
  118340. private _disposePostProcesses;
  118341. /**
  118342. * Dispose of the pipeline and stop all post processes
  118343. */
  118344. dispose(): void;
  118345. /**
  118346. * Serialize the rendering pipeline (Used when exporting)
  118347. * @returns the serialized object
  118348. */
  118349. serialize(): any;
  118350. /**
  118351. * Parse the serialized pipeline
  118352. * @param source Source pipeline.
  118353. * @param scene The scene to load the pipeline to.
  118354. * @param rootUrl The URL of the serialized pipeline.
  118355. * @returns An instantiated pipeline from the serialized object.
  118356. */
  118357. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  118358. /**
  118359. * Luminance steps
  118360. */
  118361. static LuminanceSteps: number;
  118362. }
  118363. }
  118364. declare module BABYLON {
  118365. /** @hidden */
  118366. export var tonemapPixelShader: {
  118367. name: string;
  118368. shader: string;
  118369. };
  118370. }
  118371. declare module BABYLON {
  118372. /** Defines operator used for tonemapping */
  118373. export enum TonemappingOperator {
  118374. /** Hable */
  118375. Hable = 0,
  118376. /** Reinhard */
  118377. Reinhard = 1,
  118378. /** HejiDawson */
  118379. HejiDawson = 2,
  118380. /** Photographic */
  118381. Photographic = 3
  118382. }
  118383. /**
  118384. * Defines a post process to apply tone mapping
  118385. */
  118386. export class TonemapPostProcess extends PostProcess {
  118387. private _operator;
  118388. /** Defines the required exposure adjustement */
  118389. exposureAdjustment: number;
  118390. /**
  118391. * Creates a new TonemapPostProcess
  118392. * @param name defines the name of the postprocess
  118393. * @param _operator defines the operator to use
  118394. * @param exposureAdjustment defines the required exposure adjustement
  118395. * @param camera defines the camera to use (can be null)
  118396. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  118397. * @param engine defines the hosting engine (can be ignore if camera is set)
  118398. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  118399. */
  118400. constructor(name: string, _operator: TonemappingOperator,
  118401. /** Defines the required exposure adjustement */
  118402. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  118403. }
  118404. }
  118405. declare module BABYLON {
  118406. /** @hidden */
  118407. export var depthVertexShader: {
  118408. name: string;
  118409. shader: string;
  118410. };
  118411. }
  118412. declare module BABYLON {
  118413. /** @hidden */
  118414. export var volumetricLightScatteringPixelShader: {
  118415. name: string;
  118416. shader: string;
  118417. };
  118418. }
  118419. declare module BABYLON {
  118420. /** @hidden */
  118421. export var volumetricLightScatteringPassPixelShader: {
  118422. name: string;
  118423. shader: string;
  118424. };
  118425. }
  118426. declare module BABYLON {
  118427. /**
  118428. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  118429. */
  118430. export class VolumetricLightScatteringPostProcess extends PostProcess {
  118431. private _volumetricLightScatteringPass;
  118432. private _volumetricLightScatteringRTT;
  118433. private _viewPort;
  118434. private _screenCoordinates;
  118435. private _cachedDefines;
  118436. /**
  118437. * If not undefined, the mesh position is computed from the attached node position
  118438. */
  118439. attachedNode: {
  118440. position: Vector3;
  118441. };
  118442. /**
  118443. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  118444. */
  118445. customMeshPosition: Vector3;
  118446. /**
  118447. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  118448. */
  118449. useCustomMeshPosition: boolean;
  118450. /**
  118451. * If the post-process should inverse the light scattering direction
  118452. */
  118453. invert: boolean;
  118454. /**
  118455. * The internal mesh used by the post-process
  118456. */
  118457. mesh: Mesh;
  118458. /**
  118459. * @hidden
  118460. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  118461. */
  118462. useDiffuseColor: boolean;
  118463. /**
  118464. * Array containing the excluded meshes not rendered in the internal pass
  118465. */
  118466. excludedMeshes: AbstractMesh[];
  118467. /**
  118468. * Controls the overall intensity of the post-process
  118469. */
  118470. exposure: number;
  118471. /**
  118472. * Dissipates each sample's contribution in range [0, 1]
  118473. */
  118474. decay: number;
  118475. /**
  118476. * Controls the overall intensity of each sample
  118477. */
  118478. weight: number;
  118479. /**
  118480. * Controls the density of each sample
  118481. */
  118482. density: number;
  118483. /**
  118484. * @constructor
  118485. * @param name The post-process name
  118486. * @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)
  118487. * @param camera The camera that the post-process will be attached to
  118488. * @param mesh The mesh used to create the light scattering
  118489. * @param samples The post-process quality, default 100
  118490. * @param samplingModeThe post-process filtering mode
  118491. * @param engine The babylon engine
  118492. * @param reusable If the post-process is reusable
  118493. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  118494. */
  118495. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  118496. /**
  118497. * Returns the string "VolumetricLightScatteringPostProcess"
  118498. * @returns "VolumetricLightScatteringPostProcess"
  118499. */
  118500. getClassName(): string;
  118501. private _isReady;
  118502. /**
  118503. * Sets the new light position for light scattering effect
  118504. * @param position The new custom light position
  118505. */
  118506. setCustomMeshPosition(position: Vector3): void;
  118507. /**
  118508. * Returns the light position for light scattering effect
  118509. * @return Vector3 The custom light position
  118510. */
  118511. getCustomMeshPosition(): Vector3;
  118512. /**
  118513. * Disposes the internal assets and detaches the post-process from the camera
  118514. */
  118515. dispose(camera: Camera): void;
  118516. /**
  118517. * Returns the render target texture used by the post-process
  118518. * @return the render target texture used by the post-process
  118519. */
  118520. getPass(): RenderTargetTexture;
  118521. private _meshExcluded;
  118522. private _createPass;
  118523. private _updateMeshScreenCoordinates;
  118524. /**
  118525. * Creates a default mesh for the Volumeric Light Scattering post-process
  118526. * @param name The mesh name
  118527. * @param scene The scene where to create the mesh
  118528. * @return the default mesh
  118529. */
  118530. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  118531. }
  118532. }
  118533. declare module BABYLON {
  118534. interface Scene {
  118535. /** @hidden (Backing field) */
  118536. _boundingBoxRenderer: BoundingBoxRenderer;
  118537. /** @hidden (Backing field) */
  118538. _forceShowBoundingBoxes: boolean;
  118539. /**
  118540. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  118541. */
  118542. forceShowBoundingBoxes: boolean;
  118543. /**
  118544. * Gets the bounding box renderer associated with the scene
  118545. * @returns a BoundingBoxRenderer
  118546. */
  118547. getBoundingBoxRenderer(): BoundingBoxRenderer;
  118548. }
  118549. interface AbstractMesh {
  118550. /** @hidden (Backing field) */
  118551. _showBoundingBox: boolean;
  118552. /**
  118553. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  118554. */
  118555. showBoundingBox: boolean;
  118556. }
  118557. /**
  118558. * Component responsible of rendering the bounding box of the meshes in a scene.
  118559. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  118560. */
  118561. export class BoundingBoxRenderer implements ISceneComponent {
  118562. /**
  118563. * The component name helpfull to identify the component in the list of scene components.
  118564. */
  118565. readonly name: string;
  118566. /**
  118567. * The scene the component belongs to.
  118568. */
  118569. scene: Scene;
  118570. /**
  118571. * Color of the bounding box lines placed in front of an object
  118572. */
  118573. frontColor: Color3;
  118574. /**
  118575. * Color of the bounding box lines placed behind an object
  118576. */
  118577. backColor: Color3;
  118578. /**
  118579. * Defines if the renderer should show the back lines or not
  118580. */
  118581. showBackLines: boolean;
  118582. /**
  118583. * @hidden
  118584. */
  118585. renderList: SmartArray<BoundingBox>;
  118586. private _colorShader;
  118587. private _vertexBuffers;
  118588. private _indexBuffer;
  118589. /**
  118590. * Instantiates a new bounding box renderer in a scene.
  118591. * @param scene the scene the renderer renders in
  118592. */
  118593. constructor(scene: Scene);
  118594. /**
  118595. * Registers the component in a given scene
  118596. */
  118597. register(): void;
  118598. private _evaluateSubMesh;
  118599. private _activeMesh;
  118600. private _prepareRessources;
  118601. private _createIndexBuffer;
  118602. /**
  118603. * Rebuilds the elements related to this component in case of
  118604. * context lost for instance.
  118605. */
  118606. rebuild(): void;
  118607. /**
  118608. * @hidden
  118609. */
  118610. reset(): void;
  118611. /**
  118612. * Render the bounding boxes of a specific rendering group
  118613. * @param renderingGroupId defines the rendering group to render
  118614. */
  118615. render(renderingGroupId: number): void;
  118616. /**
  118617. * In case of occlusion queries, we can render the occlusion bounding box through this method
  118618. * @param mesh Define the mesh to render the occlusion bounding box for
  118619. */
  118620. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  118621. /**
  118622. * Dispose and release the resources attached to this renderer.
  118623. */
  118624. dispose(): void;
  118625. }
  118626. }
  118627. declare module BABYLON {
  118628. /** @hidden */
  118629. export var depthPixelShader: {
  118630. name: string;
  118631. shader: string;
  118632. };
  118633. }
  118634. declare module BABYLON {
  118635. /**
  118636. * This represents a depth renderer in Babylon.
  118637. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  118638. */
  118639. export class DepthRenderer {
  118640. private _scene;
  118641. private _depthMap;
  118642. private _effect;
  118643. private _cachedDefines;
  118644. private _camera;
  118645. /**
  118646. * Specifiess that the depth renderer will only be used within
  118647. * the camera it is created for.
  118648. * This can help forcing its rendering during the camera processing.
  118649. */
  118650. useOnlyInActiveCamera: boolean;
  118651. /** @hidden */
  118652. static _SceneComponentInitialization: (scene: Scene) => void;
  118653. /**
  118654. * Instantiates a depth renderer
  118655. * @param scene The scene the renderer belongs to
  118656. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  118657. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  118658. */
  118659. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  118660. /**
  118661. * Creates the depth rendering effect and checks if the effect is ready.
  118662. * @param subMesh The submesh to be used to render the depth map of
  118663. * @param useInstances If multiple world instances should be used
  118664. * @returns if the depth renderer is ready to render the depth map
  118665. */
  118666. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  118667. /**
  118668. * Gets the texture which the depth map will be written to.
  118669. * @returns The depth map texture
  118670. */
  118671. getDepthMap(): RenderTargetTexture;
  118672. /**
  118673. * Disposes of the depth renderer.
  118674. */
  118675. dispose(): void;
  118676. }
  118677. }
  118678. declare module BABYLON {
  118679. interface Scene {
  118680. /** @hidden (Backing field) */
  118681. _depthRenderer: {
  118682. [id: string]: DepthRenderer;
  118683. };
  118684. /**
  118685. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  118686. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  118687. * @returns the created depth renderer
  118688. */
  118689. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  118690. /**
  118691. * Disables a depth renderer for a given camera
  118692. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  118693. */
  118694. disableDepthRenderer(camera?: Nullable<Camera>): void;
  118695. }
  118696. /**
  118697. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  118698. * in several rendering techniques.
  118699. */
  118700. export class DepthRendererSceneComponent implements ISceneComponent {
  118701. /**
  118702. * The component name helpfull to identify the component in the list of scene components.
  118703. */
  118704. readonly name: string;
  118705. /**
  118706. * The scene the component belongs to.
  118707. */
  118708. scene: Scene;
  118709. /**
  118710. * Creates a new instance of the component for the given scene
  118711. * @param scene Defines the scene to register the component in
  118712. */
  118713. constructor(scene: Scene);
  118714. /**
  118715. * Registers the component in a given scene
  118716. */
  118717. register(): void;
  118718. /**
  118719. * Rebuilds the elements related to this component in case of
  118720. * context lost for instance.
  118721. */
  118722. rebuild(): void;
  118723. /**
  118724. * Disposes the component and the associated ressources
  118725. */
  118726. dispose(): void;
  118727. private _gatherRenderTargets;
  118728. private _gatherActiveCameraRenderTargets;
  118729. }
  118730. }
  118731. declare module BABYLON {
  118732. /** @hidden */
  118733. export var outlinePixelShader: {
  118734. name: string;
  118735. shader: string;
  118736. };
  118737. }
  118738. declare module BABYLON {
  118739. /** @hidden */
  118740. export var outlineVertexShader: {
  118741. name: string;
  118742. shader: string;
  118743. };
  118744. }
  118745. declare module BABYLON {
  118746. interface Scene {
  118747. /** @hidden */
  118748. _outlineRenderer: OutlineRenderer;
  118749. /**
  118750. * Gets the outline renderer associated with the scene
  118751. * @returns a OutlineRenderer
  118752. */
  118753. getOutlineRenderer(): OutlineRenderer;
  118754. }
  118755. interface AbstractMesh {
  118756. /** @hidden (Backing field) */
  118757. _renderOutline: boolean;
  118758. /**
  118759. * Gets or sets a boolean indicating if the outline must be rendered as well
  118760. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  118761. */
  118762. renderOutline: boolean;
  118763. /** @hidden (Backing field) */
  118764. _renderOverlay: boolean;
  118765. /**
  118766. * Gets or sets a boolean indicating if the overlay must be rendered as well
  118767. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  118768. */
  118769. renderOverlay: boolean;
  118770. }
  118771. /**
  118772. * This class is responsible to draw bothe outline/overlay of meshes.
  118773. * It should not be used directly but through the available method on mesh.
  118774. */
  118775. export class OutlineRenderer implements ISceneComponent {
  118776. /**
  118777. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  118778. */
  118779. private static _StencilReference;
  118780. /**
  118781. * The name of the component. Each component must have a unique name.
  118782. */
  118783. name: string;
  118784. /**
  118785. * The scene the component belongs to.
  118786. */
  118787. scene: Scene;
  118788. /**
  118789. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  118790. */
  118791. zOffset: number;
  118792. private _engine;
  118793. private _effect;
  118794. private _cachedDefines;
  118795. private _savedDepthWrite;
  118796. /**
  118797. * Instantiates a new outline renderer. (There could be only one per scene).
  118798. * @param scene Defines the scene it belongs to
  118799. */
  118800. constructor(scene: Scene);
  118801. /**
  118802. * Register the component to one instance of a scene.
  118803. */
  118804. register(): void;
  118805. /**
  118806. * Rebuilds the elements related to this component in case of
  118807. * context lost for instance.
  118808. */
  118809. rebuild(): void;
  118810. /**
  118811. * Disposes the component and the associated ressources.
  118812. */
  118813. dispose(): void;
  118814. /**
  118815. * Renders the outline in the canvas.
  118816. * @param subMesh Defines the sumesh to render
  118817. * @param batch Defines the batch of meshes in case of instances
  118818. * @param useOverlay Defines if the rendering is for the overlay or the outline
  118819. */
  118820. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  118821. /**
  118822. * Returns whether or not the outline renderer is ready for a given submesh.
  118823. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  118824. * @param subMesh Defines the submesh to check readyness for
  118825. * @param useInstances Defines wheter wee are trying to render instances or not
  118826. * @returns true if ready otherwise false
  118827. */
  118828. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  118829. private _beforeRenderingMesh;
  118830. private _afterRenderingMesh;
  118831. }
  118832. }
  118833. declare module BABYLON {
  118834. /**
  118835. * Defines the list of states available for a task inside a AssetsManager
  118836. */
  118837. export enum AssetTaskState {
  118838. /**
  118839. * Initialization
  118840. */
  118841. INIT = 0,
  118842. /**
  118843. * Running
  118844. */
  118845. RUNNING = 1,
  118846. /**
  118847. * Done
  118848. */
  118849. DONE = 2,
  118850. /**
  118851. * Error
  118852. */
  118853. ERROR = 3
  118854. }
  118855. /**
  118856. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  118857. */
  118858. export abstract class AbstractAssetTask {
  118859. /**
  118860. * Task name
  118861. */ name: string;
  118862. /**
  118863. * Callback called when the task is successful
  118864. */
  118865. onSuccess: (task: any) => void;
  118866. /**
  118867. * Callback called when the task is not successful
  118868. */
  118869. onError: (task: any, message?: string, exception?: any) => void;
  118870. /**
  118871. * Creates a new AssetsManager
  118872. * @param name defines the name of the task
  118873. */
  118874. constructor(
  118875. /**
  118876. * Task name
  118877. */ name: string);
  118878. private _isCompleted;
  118879. private _taskState;
  118880. private _errorObject;
  118881. /**
  118882. * Get if the task is completed
  118883. */
  118884. readonly isCompleted: boolean;
  118885. /**
  118886. * Gets the current state of the task
  118887. */
  118888. readonly taskState: AssetTaskState;
  118889. /**
  118890. * Gets the current error object (if task is in error)
  118891. */
  118892. readonly errorObject: {
  118893. message?: string;
  118894. exception?: any;
  118895. };
  118896. /**
  118897. * Internal only
  118898. * @hidden
  118899. */
  118900. _setErrorObject(message?: string, exception?: any): void;
  118901. /**
  118902. * Execute the current task
  118903. * @param scene defines the scene where you want your assets to be loaded
  118904. * @param onSuccess is a callback called when the task is successfully executed
  118905. * @param onError is a callback called if an error occurs
  118906. */
  118907. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  118908. /**
  118909. * Execute the current task
  118910. * @param scene defines the scene where you want your assets to be loaded
  118911. * @param onSuccess is a callback called when the task is successfully executed
  118912. * @param onError is a callback called if an error occurs
  118913. */
  118914. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  118915. /**
  118916. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  118917. * This can be used with failed tasks that have the reason for failure fixed.
  118918. */
  118919. reset(): void;
  118920. private onErrorCallback;
  118921. private onDoneCallback;
  118922. }
  118923. /**
  118924. * Define the interface used by progress events raised during assets loading
  118925. */
  118926. export interface IAssetsProgressEvent {
  118927. /**
  118928. * Defines the number of remaining tasks to process
  118929. */
  118930. remainingCount: number;
  118931. /**
  118932. * Defines the total number of tasks
  118933. */
  118934. totalCount: number;
  118935. /**
  118936. * Defines the task that was just processed
  118937. */
  118938. task: AbstractAssetTask;
  118939. }
  118940. /**
  118941. * Class used to share progress information about assets loading
  118942. */
  118943. export class AssetsProgressEvent implements IAssetsProgressEvent {
  118944. /**
  118945. * Defines the number of remaining tasks to process
  118946. */
  118947. remainingCount: number;
  118948. /**
  118949. * Defines the total number of tasks
  118950. */
  118951. totalCount: number;
  118952. /**
  118953. * Defines the task that was just processed
  118954. */
  118955. task: AbstractAssetTask;
  118956. /**
  118957. * Creates a AssetsProgressEvent
  118958. * @param remainingCount defines the number of remaining tasks to process
  118959. * @param totalCount defines the total number of tasks
  118960. * @param task defines the task that was just processed
  118961. */
  118962. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  118963. }
  118964. /**
  118965. * Define a task used by AssetsManager to load meshes
  118966. */
  118967. export class MeshAssetTask extends AbstractAssetTask {
  118968. /**
  118969. * Defines the name of the task
  118970. */
  118971. name: string;
  118972. /**
  118973. * Defines the list of mesh's names you want to load
  118974. */
  118975. meshesNames: any;
  118976. /**
  118977. * Defines the root url to use as a base to load your meshes and associated resources
  118978. */
  118979. rootUrl: string;
  118980. /**
  118981. * Defines the filename of the scene to load from
  118982. */
  118983. sceneFilename: string;
  118984. /**
  118985. * Gets the list of loaded meshes
  118986. */
  118987. loadedMeshes: Array<AbstractMesh>;
  118988. /**
  118989. * Gets the list of loaded particle systems
  118990. */
  118991. loadedParticleSystems: Array<IParticleSystem>;
  118992. /**
  118993. * Gets the list of loaded skeletons
  118994. */
  118995. loadedSkeletons: Array<Skeleton>;
  118996. /**
  118997. * Gets the list of loaded animation groups
  118998. */
  118999. loadedAnimationGroups: Array<AnimationGroup>;
  119000. /**
  119001. * Callback called when the task is successful
  119002. */
  119003. onSuccess: (task: MeshAssetTask) => void;
  119004. /**
  119005. * Callback called when the task is successful
  119006. */
  119007. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  119008. /**
  119009. * Creates a new MeshAssetTask
  119010. * @param name defines the name of the task
  119011. * @param meshesNames defines the list of mesh's names you want to load
  119012. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  119013. * @param sceneFilename defines the filename of the scene to load from
  119014. */
  119015. constructor(
  119016. /**
  119017. * Defines the name of the task
  119018. */
  119019. name: string,
  119020. /**
  119021. * Defines the list of mesh's names you want to load
  119022. */
  119023. meshesNames: any,
  119024. /**
  119025. * Defines the root url to use as a base to load your meshes and associated resources
  119026. */
  119027. rootUrl: string,
  119028. /**
  119029. * Defines the filename of the scene to load from
  119030. */
  119031. sceneFilename: string);
  119032. /**
  119033. * Execute the current task
  119034. * @param scene defines the scene where you want your assets to be loaded
  119035. * @param onSuccess is a callback called when the task is successfully executed
  119036. * @param onError is a callback called if an error occurs
  119037. */
  119038. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  119039. }
  119040. /**
  119041. * Define a task used by AssetsManager to load text content
  119042. */
  119043. export class TextFileAssetTask extends AbstractAssetTask {
  119044. /**
  119045. * Defines the name of the task
  119046. */
  119047. name: string;
  119048. /**
  119049. * Defines the location of the file to load
  119050. */
  119051. url: string;
  119052. /**
  119053. * Gets the loaded text string
  119054. */
  119055. text: string;
  119056. /**
  119057. * Callback called when the task is successful
  119058. */
  119059. onSuccess: (task: TextFileAssetTask) => void;
  119060. /**
  119061. * Callback called when the task is successful
  119062. */
  119063. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  119064. /**
  119065. * Creates a new TextFileAssetTask object
  119066. * @param name defines the name of the task
  119067. * @param url defines the location of the file to load
  119068. */
  119069. constructor(
  119070. /**
  119071. * Defines the name of the task
  119072. */
  119073. name: string,
  119074. /**
  119075. * Defines the location of the file to load
  119076. */
  119077. url: string);
  119078. /**
  119079. * Execute the current task
  119080. * @param scene defines the scene where you want your assets to be loaded
  119081. * @param onSuccess is a callback called when the task is successfully executed
  119082. * @param onError is a callback called if an error occurs
  119083. */
  119084. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  119085. }
  119086. /**
  119087. * Define a task used by AssetsManager to load binary data
  119088. */
  119089. export class BinaryFileAssetTask extends AbstractAssetTask {
  119090. /**
  119091. * Defines the name of the task
  119092. */
  119093. name: string;
  119094. /**
  119095. * Defines the location of the file to load
  119096. */
  119097. url: string;
  119098. /**
  119099. * Gets the lodaded data (as an array buffer)
  119100. */
  119101. data: ArrayBuffer;
  119102. /**
  119103. * Callback called when the task is successful
  119104. */
  119105. onSuccess: (task: BinaryFileAssetTask) => void;
  119106. /**
  119107. * Callback called when the task is successful
  119108. */
  119109. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  119110. /**
  119111. * Creates a new BinaryFileAssetTask object
  119112. * @param name defines the name of the new task
  119113. * @param url defines the location of the file to load
  119114. */
  119115. constructor(
  119116. /**
  119117. * Defines the name of the task
  119118. */
  119119. name: string,
  119120. /**
  119121. * Defines the location of the file to load
  119122. */
  119123. url: string);
  119124. /**
  119125. * Execute the current task
  119126. * @param scene defines the scene where you want your assets to be loaded
  119127. * @param onSuccess is a callback called when the task is successfully executed
  119128. * @param onError is a callback called if an error occurs
  119129. */
  119130. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  119131. }
  119132. /**
  119133. * Define a task used by AssetsManager to load images
  119134. */
  119135. export class ImageAssetTask extends AbstractAssetTask {
  119136. /**
  119137. * Defines the name of the task
  119138. */
  119139. name: string;
  119140. /**
  119141. * Defines the location of the image to load
  119142. */
  119143. url: string;
  119144. /**
  119145. * Gets the loaded images
  119146. */
  119147. image: HTMLImageElement;
  119148. /**
  119149. * Callback called when the task is successful
  119150. */
  119151. onSuccess: (task: ImageAssetTask) => void;
  119152. /**
  119153. * Callback called when the task is successful
  119154. */
  119155. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  119156. /**
  119157. * Creates a new ImageAssetTask
  119158. * @param name defines the name of the task
  119159. * @param url defines the location of the image to load
  119160. */
  119161. constructor(
  119162. /**
  119163. * Defines the name of the task
  119164. */
  119165. name: string,
  119166. /**
  119167. * Defines the location of the image to load
  119168. */
  119169. url: string);
  119170. /**
  119171. * Execute the current task
  119172. * @param scene defines the scene where you want your assets to be loaded
  119173. * @param onSuccess is a callback called when the task is successfully executed
  119174. * @param onError is a callback called if an error occurs
  119175. */
  119176. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  119177. }
  119178. /**
  119179. * Defines the interface used by texture loading tasks
  119180. */
  119181. export interface ITextureAssetTask<TEX extends BaseTexture> {
  119182. /**
  119183. * Gets the loaded texture
  119184. */
  119185. texture: TEX;
  119186. }
  119187. /**
  119188. * Define a task used by AssetsManager to load 2D textures
  119189. */
  119190. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  119191. /**
  119192. * Defines the name of the task
  119193. */
  119194. name: string;
  119195. /**
  119196. * Defines the location of the file to load
  119197. */
  119198. url: string;
  119199. /**
  119200. * Defines if mipmap should not be generated (default is false)
  119201. */
  119202. noMipmap?: boolean | undefined;
  119203. /**
  119204. * Defines if texture must be inverted on Y axis (default is false)
  119205. */
  119206. invertY?: boolean | undefined;
  119207. /**
  119208. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  119209. */
  119210. samplingMode: number;
  119211. /**
  119212. * Gets the loaded texture
  119213. */
  119214. texture: Texture;
  119215. /**
  119216. * Callback called when the task is successful
  119217. */
  119218. onSuccess: (task: TextureAssetTask) => void;
  119219. /**
  119220. * Callback called when the task is successful
  119221. */
  119222. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  119223. /**
  119224. * Creates a new TextureAssetTask object
  119225. * @param name defines the name of the task
  119226. * @param url defines the location of the file to load
  119227. * @param noMipmap defines if mipmap should not be generated (default is false)
  119228. * @param invertY defines if texture must be inverted on Y axis (default is false)
  119229. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  119230. */
  119231. constructor(
  119232. /**
  119233. * Defines the name of the task
  119234. */
  119235. name: string,
  119236. /**
  119237. * Defines the location of the file to load
  119238. */
  119239. url: string,
  119240. /**
  119241. * Defines if mipmap should not be generated (default is false)
  119242. */
  119243. noMipmap?: boolean | undefined,
  119244. /**
  119245. * Defines if texture must be inverted on Y axis (default is false)
  119246. */
  119247. invertY?: boolean | undefined,
  119248. /**
  119249. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  119250. */
  119251. samplingMode?: number);
  119252. /**
  119253. * Execute the current task
  119254. * @param scene defines the scene where you want your assets to be loaded
  119255. * @param onSuccess is a callback called when the task is successfully executed
  119256. * @param onError is a callback called if an error occurs
  119257. */
  119258. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  119259. }
  119260. /**
  119261. * Define a task used by AssetsManager to load cube textures
  119262. */
  119263. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  119264. /**
  119265. * Defines the name of the task
  119266. */
  119267. name: string;
  119268. /**
  119269. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  119270. */
  119271. url: string;
  119272. /**
  119273. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  119274. */
  119275. extensions?: string[] | undefined;
  119276. /**
  119277. * Defines if mipmaps should not be generated (default is false)
  119278. */
  119279. noMipmap?: boolean | undefined;
  119280. /**
  119281. * Defines the explicit list of files (undefined by default)
  119282. */
  119283. files?: string[] | undefined;
  119284. /**
  119285. * Gets the loaded texture
  119286. */
  119287. texture: CubeTexture;
  119288. /**
  119289. * Callback called when the task is successful
  119290. */
  119291. onSuccess: (task: CubeTextureAssetTask) => void;
  119292. /**
  119293. * Callback called when the task is successful
  119294. */
  119295. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  119296. /**
  119297. * Creates a new CubeTextureAssetTask
  119298. * @param name defines the name of the task
  119299. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  119300. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  119301. * @param noMipmap defines if mipmaps should not be generated (default is false)
  119302. * @param files defines the explicit list of files (undefined by default)
  119303. */
  119304. constructor(
  119305. /**
  119306. * Defines the name of the task
  119307. */
  119308. name: string,
  119309. /**
  119310. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  119311. */
  119312. url: string,
  119313. /**
  119314. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  119315. */
  119316. extensions?: string[] | undefined,
  119317. /**
  119318. * Defines if mipmaps should not be generated (default is false)
  119319. */
  119320. noMipmap?: boolean | undefined,
  119321. /**
  119322. * Defines the explicit list of files (undefined by default)
  119323. */
  119324. files?: string[] | undefined);
  119325. /**
  119326. * Execute the current task
  119327. * @param scene defines the scene where you want your assets to be loaded
  119328. * @param onSuccess is a callback called when the task is successfully executed
  119329. * @param onError is a callback called if an error occurs
  119330. */
  119331. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  119332. }
  119333. /**
  119334. * Define a task used by AssetsManager to load HDR cube textures
  119335. */
  119336. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  119337. /**
  119338. * Defines the name of the task
  119339. */
  119340. name: string;
  119341. /**
  119342. * Defines the location of the file to load
  119343. */
  119344. url: string;
  119345. /**
  119346. * Defines the desired size (the more it increases the longer the generation will be)
  119347. */
  119348. size: number;
  119349. /**
  119350. * Defines if mipmaps should not be generated (default is false)
  119351. */
  119352. noMipmap: boolean;
  119353. /**
  119354. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  119355. */
  119356. generateHarmonics: boolean;
  119357. /**
  119358. * 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)
  119359. */
  119360. gammaSpace: boolean;
  119361. /**
  119362. * Internal Use Only
  119363. */
  119364. reserved: boolean;
  119365. /**
  119366. * Gets the loaded texture
  119367. */
  119368. texture: HDRCubeTexture;
  119369. /**
  119370. * Callback called when the task is successful
  119371. */
  119372. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  119373. /**
  119374. * Callback called when the task is successful
  119375. */
  119376. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  119377. /**
  119378. * Creates a new HDRCubeTextureAssetTask object
  119379. * @param name defines the name of the task
  119380. * @param url defines the location of the file to load
  119381. * @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.
  119382. * @param noMipmap defines if mipmaps should not be generated (default is false)
  119383. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  119384. * @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)
  119385. * @param reserved Internal use only
  119386. */
  119387. constructor(
  119388. /**
  119389. * Defines the name of the task
  119390. */
  119391. name: string,
  119392. /**
  119393. * Defines the location of the file to load
  119394. */
  119395. url: string,
  119396. /**
  119397. * Defines the desired size (the more it increases the longer the generation will be)
  119398. */
  119399. size: number,
  119400. /**
  119401. * Defines if mipmaps should not be generated (default is false)
  119402. */
  119403. noMipmap?: boolean,
  119404. /**
  119405. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  119406. */
  119407. generateHarmonics?: boolean,
  119408. /**
  119409. * 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)
  119410. */
  119411. gammaSpace?: boolean,
  119412. /**
  119413. * Internal Use Only
  119414. */
  119415. reserved?: boolean);
  119416. /**
  119417. * Execute the current task
  119418. * @param scene defines the scene where you want your assets to be loaded
  119419. * @param onSuccess is a callback called when the task is successfully executed
  119420. * @param onError is a callback called if an error occurs
  119421. */
  119422. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  119423. }
  119424. /**
  119425. * Define a task used by AssetsManager to load Equirectangular cube textures
  119426. */
  119427. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  119428. /**
  119429. * Defines the name of the task
  119430. */
  119431. name: string;
  119432. /**
  119433. * Defines the location of the file to load
  119434. */
  119435. url: string;
  119436. /**
  119437. * Defines the desired size (the more it increases the longer the generation will be)
  119438. */
  119439. size: number;
  119440. /**
  119441. * Defines if mipmaps should not be generated (default is false)
  119442. */
  119443. noMipmap: boolean;
  119444. /**
  119445. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  119446. * but the standard material would require them in Gamma space) (default is true)
  119447. */
  119448. gammaSpace: boolean;
  119449. /**
  119450. * Gets the loaded texture
  119451. */
  119452. texture: EquiRectangularCubeTexture;
  119453. /**
  119454. * Callback called when the task is successful
  119455. */
  119456. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  119457. /**
  119458. * Callback called when the task is successful
  119459. */
  119460. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  119461. /**
  119462. * Creates a new EquiRectangularCubeTextureAssetTask object
  119463. * @param name defines the name of the task
  119464. * @param url defines the location of the file to load
  119465. * @param size defines the desired size (the more it increases the longer the generation will be)
  119466. * If the size is omitted this implies you are using a preprocessed cubemap.
  119467. * @param noMipmap defines if mipmaps should not be generated (default is false)
  119468. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  119469. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  119470. * (default is true)
  119471. */
  119472. constructor(
  119473. /**
  119474. * Defines the name of the task
  119475. */
  119476. name: string,
  119477. /**
  119478. * Defines the location of the file to load
  119479. */
  119480. url: string,
  119481. /**
  119482. * Defines the desired size (the more it increases the longer the generation will be)
  119483. */
  119484. size: number,
  119485. /**
  119486. * Defines if mipmaps should not be generated (default is false)
  119487. */
  119488. noMipmap?: boolean,
  119489. /**
  119490. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  119491. * but the standard material would require them in Gamma space) (default is true)
  119492. */
  119493. gammaSpace?: boolean);
  119494. /**
  119495. * Execute the current task
  119496. * @param scene defines the scene where you want your assets to be loaded
  119497. * @param onSuccess is a callback called when the task is successfully executed
  119498. * @param onError is a callback called if an error occurs
  119499. */
  119500. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  119501. }
  119502. /**
  119503. * This class can be used to easily import assets into a scene
  119504. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  119505. */
  119506. export class AssetsManager {
  119507. private _scene;
  119508. private _isLoading;
  119509. protected _tasks: AbstractAssetTask[];
  119510. protected _waitingTasksCount: number;
  119511. protected _totalTasksCount: number;
  119512. /**
  119513. * Callback called when all tasks are processed
  119514. */
  119515. onFinish: (tasks: AbstractAssetTask[]) => void;
  119516. /**
  119517. * Callback called when a task is successful
  119518. */
  119519. onTaskSuccess: (task: AbstractAssetTask) => void;
  119520. /**
  119521. * Callback called when a task had an error
  119522. */
  119523. onTaskError: (task: AbstractAssetTask) => void;
  119524. /**
  119525. * Callback called when a task is done (whatever the result is)
  119526. */
  119527. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  119528. /**
  119529. * Observable called when all tasks are processed
  119530. */
  119531. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  119532. /**
  119533. * Observable called when a task had an error
  119534. */
  119535. onTaskErrorObservable: Observable<AbstractAssetTask>;
  119536. /**
  119537. * Observable called when all tasks were executed
  119538. */
  119539. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  119540. /**
  119541. * Observable called when a task is done (whatever the result is)
  119542. */
  119543. onProgressObservable: Observable<IAssetsProgressEvent>;
  119544. /**
  119545. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  119546. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  119547. */
  119548. useDefaultLoadingScreen: boolean;
  119549. /**
  119550. * Creates a new AssetsManager
  119551. * @param scene defines the scene to work on
  119552. */
  119553. constructor(scene: Scene);
  119554. /**
  119555. * Add a MeshAssetTask to the list of active tasks
  119556. * @param taskName defines the name of the new task
  119557. * @param meshesNames defines the name of meshes to load
  119558. * @param rootUrl defines the root url to use to locate files
  119559. * @param sceneFilename defines the filename of the scene file
  119560. * @returns a new MeshAssetTask object
  119561. */
  119562. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  119563. /**
  119564. * Add a TextFileAssetTask to the list of active tasks
  119565. * @param taskName defines the name of the new task
  119566. * @param url defines the url of the file to load
  119567. * @returns a new TextFileAssetTask object
  119568. */
  119569. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  119570. /**
  119571. * Add a BinaryFileAssetTask to the list of active tasks
  119572. * @param taskName defines the name of the new task
  119573. * @param url defines the url of the file to load
  119574. * @returns a new BinaryFileAssetTask object
  119575. */
  119576. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  119577. /**
  119578. * Add a ImageAssetTask to the list of active tasks
  119579. * @param taskName defines the name of the new task
  119580. * @param url defines the url of the file to load
  119581. * @returns a new ImageAssetTask object
  119582. */
  119583. addImageTask(taskName: string, url: string): ImageAssetTask;
  119584. /**
  119585. * Add a TextureAssetTask to the list of active tasks
  119586. * @param taskName defines the name of the new task
  119587. * @param url defines the url of the file to load
  119588. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  119589. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  119590. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  119591. * @returns a new TextureAssetTask object
  119592. */
  119593. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  119594. /**
  119595. * Add a CubeTextureAssetTask to the list of active tasks
  119596. * @param taskName defines the name of the new task
  119597. * @param url defines the url of the file to load
  119598. * @param extensions defines the extension to use to load the cube map (can be null)
  119599. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  119600. * @param files defines the list of files to load (can be null)
  119601. * @returns a new CubeTextureAssetTask object
  119602. */
  119603. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  119604. /**
  119605. *
  119606. * Add a HDRCubeTextureAssetTask to the list of active tasks
  119607. * @param taskName defines the name of the new task
  119608. * @param url defines the url of the file to load
  119609. * @param size defines the size you want for the cubemap (can be null)
  119610. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  119611. * @param generateHarmonics defines if you want to automatically generate (true by default)
  119612. * @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)
  119613. * @param reserved Internal use only
  119614. * @returns a new HDRCubeTextureAssetTask object
  119615. */
  119616. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  119617. /**
  119618. *
  119619. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  119620. * @param taskName defines the name of the new task
  119621. * @param url defines the url of the file to load
  119622. * @param size defines the size you want for the cubemap (can be null)
  119623. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  119624. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  119625. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  119626. * @returns a new EquiRectangularCubeTextureAssetTask object
  119627. */
  119628. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  119629. /**
  119630. * Remove a task from the assets manager.
  119631. * @param task the task to remove
  119632. */
  119633. removeTask(task: AbstractAssetTask): void;
  119634. private _decreaseWaitingTasksCount;
  119635. private _runTask;
  119636. /**
  119637. * Reset the AssetsManager and remove all tasks
  119638. * @return the current instance of the AssetsManager
  119639. */
  119640. reset(): AssetsManager;
  119641. /**
  119642. * Start the loading process
  119643. * @return the current instance of the AssetsManager
  119644. */
  119645. load(): AssetsManager;
  119646. /**
  119647. * Start the loading process as an async operation
  119648. * @return a promise returning the list of failed tasks
  119649. */
  119650. loadAsync(): Promise<void>;
  119651. }
  119652. }
  119653. declare module BABYLON {
  119654. /**
  119655. * Wrapper class for promise with external resolve and reject.
  119656. */
  119657. export class Deferred<T> {
  119658. /**
  119659. * The promise associated with this deferred object.
  119660. */
  119661. readonly promise: Promise<T>;
  119662. private _resolve;
  119663. private _reject;
  119664. /**
  119665. * The resolve method of the promise associated with this deferred object.
  119666. */
  119667. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  119668. /**
  119669. * The reject method of the promise associated with this deferred object.
  119670. */
  119671. readonly reject: (reason?: any) => void;
  119672. /**
  119673. * Constructor for this deferred object.
  119674. */
  119675. constructor();
  119676. }
  119677. }
  119678. declare module BABYLON {
  119679. /**
  119680. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  119681. */
  119682. export class MeshExploder {
  119683. private _centerMesh;
  119684. private _meshes;
  119685. private _meshesOrigins;
  119686. private _toCenterVectors;
  119687. private _scaledDirection;
  119688. private _newPosition;
  119689. private _centerPosition;
  119690. /**
  119691. * Explodes meshes from a center mesh.
  119692. * @param meshes The meshes to explode.
  119693. * @param centerMesh The mesh to be center of explosion.
  119694. */
  119695. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  119696. private _setCenterMesh;
  119697. /**
  119698. * Get class name
  119699. * @returns "MeshExploder"
  119700. */
  119701. getClassName(): string;
  119702. /**
  119703. * "Exploded meshes"
  119704. * @returns Array of meshes with the centerMesh at index 0.
  119705. */
  119706. getMeshes(): Array<Mesh>;
  119707. /**
  119708. * Explodes meshes giving a specific direction
  119709. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  119710. */
  119711. explode(direction?: number): void;
  119712. }
  119713. }
  119714. declare module BABYLON {
  119715. /**
  119716. * Class used to help managing file picking and drag'n'drop
  119717. */
  119718. export class FilesInput {
  119719. /**
  119720. * List of files ready to be loaded
  119721. */
  119722. static readonly FilesToLoad: {
  119723. [key: string]: File;
  119724. };
  119725. /**
  119726. * Callback called when a file is processed
  119727. */
  119728. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  119729. private _engine;
  119730. private _currentScene;
  119731. private _sceneLoadedCallback;
  119732. private _progressCallback;
  119733. private _additionalRenderLoopLogicCallback;
  119734. private _textureLoadingCallback;
  119735. private _startingProcessingFilesCallback;
  119736. private _onReloadCallback;
  119737. private _errorCallback;
  119738. private _elementToMonitor;
  119739. private _sceneFileToLoad;
  119740. private _filesToLoad;
  119741. /**
  119742. * Creates a new FilesInput
  119743. * @param engine defines the rendering engine
  119744. * @param scene defines the hosting scene
  119745. * @param sceneLoadedCallback callback called when scene is loaded
  119746. * @param progressCallback callback called to track progress
  119747. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  119748. * @param textureLoadingCallback callback called when a texture is loading
  119749. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  119750. * @param onReloadCallback callback called when a reload is requested
  119751. * @param errorCallback callback call if an error occurs
  119752. */
  119753. 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);
  119754. private _dragEnterHandler;
  119755. private _dragOverHandler;
  119756. private _dropHandler;
  119757. /**
  119758. * Calls this function to listen to drag'n'drop events on a specific DOM element
  119759. * @param elementToMonitor defines the DOM element to track
  119760. */
  119761. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  119762. /**
  119763. * Release all associated resources
  119764. */
  119765. dispose(): void;
  119766. private renderFunction;
  119767. private drag;
  119768. private drop;
  119769. private _traverseFolder;
  119770. private _processFiles;
  119771. /**
  119772. * Load files from a drop event
  119773. * @param event defines the drop event to use as source
  119774. */
  119775. loadFiles(event: any): void;
  119776. private _processReload;
  119777. /**
  119778. * Reload the current scene from the loaded files
  119779. */
  119780. reload(): void;
  119781. }
  119782. }
  119783. declare module BABYLON {
  119784. /**
  119785. * Defines the root class used to create scene optimization to use with SceneOptimizer
  119786. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  119787. */
  119788. export class SceneOptimization {
  119789. /**
  119790. * Defines the priority of this optimization (0 by default which means first in the list)
  119791. */
  119792. priority: number;
  119793. /**
  119794. * Gets a string describing the action executed by the current optimization
  119795. * @returns description string
  119796. */
  119797. getDescription(): string;
  119798. /**
  119799. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  119800. * @param scene defines the current scene where to apply this optimization
  119801. * @param optimizer defines the current optimizer
  119802. * @returns true if everything that can be done was applied
  119803. */
  119804. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  119805. /**
  119806. * Creates the SceneOptimization object
  119807. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  119808. * @param desc defines the description associated with the optimization
  119809. */
  119810. constructor(
  119811. /**
  119812. * Defines the priority of this optimization (0 by default which means first in the list)
  119813. */
  119814. priority?: number);
  119815. }
  119816. /**
  119817. * Defines an optimization used to reduce the size of render target textures
  119818. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  119819. */
  119820. export class TextureOptimization extends SceneOptimization {
  119821. /**
  119822. * Defines the priority of this optimization (0 by default which means first in the list)
  119823. */
  119824. priority: number;
  119825. /**
  119826. * 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
  119827. */
  119828. maximumSize: number;
  119829. /**
  119830. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  119831. */
  119832. step: number;
  119833. /**
  119834. * Gets a string describing the action executed by the current optimization
  119835. * @returns description string
  119836. */
  119837. getDescription(): string;
  119838. /**
  119839. * Creates the TextureOptimization object
  119840. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  119841. * @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
  119842. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  119843. */
  119844. constructor(
  119845. /**
  119846. * Defines the priority of this optimization (0 by default which means first in the list)
  119847. */
  119848. priority?: number,
  119849. /**
  119850. * 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
  119851. */
  119852. maximumSize?: number,
  119853. /**
  119854. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  119855. */
  119856. step?: number);
  119857. /**
  119858. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  119859. * @param scene defines the current scene where to apply this optimization
  119860. * @param optimizer defines the current optimizer
  119861. * @returns true if everything that can be done was applied
  119862. */
  119863. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  119864. }
  119865. /**
  119866. * Defines an optimization used to increase or decrease the rendering resolution
  119867. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  119868. */
  119869. export class HardwareScalingOptimization extends SceneOptimization {
  119870. /**
  119871. * Defines the priority of this optimization (0 by default which means first in the list)
  119872. */
  119873. priority: number;
  119874. /**
  119875. * Defines the maximum scale to use (2 by default)
  119876. */
  119877. maximumScale: number;
  119878. /**
  119879. * Defines the step to use between two passes (0.5 by default)
  119880. */
  119881. step: number;
  119882. private _currentScale;
  119883. private _directionOffset;
  119884. /**
  119885. * Gets a string describing the action executed by the current optimization
  119886. * @return description string
  119887. */
  119888. getDescription(): string;
  119889. /**
  119890. * Creates the HardwareScalingOptimization object
  119891. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  119892. * @param maximumScale defines the maximum scale to use (2 by default)
  119893. * @param step defines the step to use between two passes (0.5 by default)
  119894. */
  119895. constructor(
  119896. /**
  119897. * Defines the priority of this optimization (0 by default which means first in the list)
  119898. */
  119899. priority?: number,
  119900. /**
  119901. * Defines the maximum scale to use (2 by default)
  119902. */
  119903. maximumScale?: number,
  119904. /**
  119905. * Defines the step to use between two passes (0.5 by default)
  119906. */
  119907. step?: number);
  119908. /**
  119909. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  119910. * @param scene defines the current scene where to apply this optimization
  119911. * @param optimizer defines the current optimizer
  119912. * @returns true if everything that can be done was applied
  119913. */
  119914. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  119915. }
  119916. /**
  119917. * Defines an optimization used to remove shadows
  119918. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  119919. */
  119920. export class ShadowsOptimization extends SceneOptimization {
  119921. /**
  119922. * Gets a string describing the action executed by the current optimization
  119923. * @return description string
  119924. */
  119925. getDescription(): string;
  119926. /**
  119927. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  119928. * @param scene defines the current scene where to apply this optimization
  119929. * @param optimizer defines the current optimizer
  119930. * @returns true if everything that can be done was applied
  119931. */
  119932. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  119933. }
  119934. /**
  119935. * Defines an optimization used to turn post-processes off
  119936. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  119937. */
  119938. export class PostProcessesOptimization extends SceneOptimization {
  119939. /**
  119940. * Gets a string describing the action executed by the current optimization
  119941. * @return description string
  119942. */
  119943. getDescription(): string;
  119944. /**
  119945. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  119946. * @param scene defines the current scene where to apply this optimization
  119947. * @param optimizer defines the current optimizer
  119948. * @returns true if everything that can be done was applied
  119949. */
  119950. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  119951. }
  119952. /**
  119953. * Defines an optimization used to turn lens flares off
  119954. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  119955. */
  119956. export class LensFlaresOptimization extends SceneOptimization {
  119957. /**
  119958. * Gets a string describing the action executed by the current optimization
  119959. * @return description string
  119960. */
  119961. getDescription(): string;
  119962. /**
  119963. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  119964. * @param scene defines the current scene where to apply this optimization
  119965. * @param optimizer defines the current optimizer
  119966. * @returns true if everything that can be done was applied
  119967. */
  119968. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  119969. }
  119970. /**
  119971. * Defines an optimization based on user defined callback.
  119972. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  119973. */
  119974. export class CustomOptimization extends SceneOptimization {
  119975. /**
  119976. * Callback called to apply the custom optimization.
  119977. */
  119978. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  119979. /**
  119980. * Callback called to get custom description
  119981. */
  119982. onGetDescription: () => string;
  119983. /**
  119984. * Gets a string describing the action executed by the current optimization
  119985. * @returns description string
  119986. */
  119987. getDescription(): string;
  119988. /**
  119989. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  119990. * @param scene defines the current scene where to apply this optimization
  119991. * @param optimizer defines the current optimizer
  119992. * @returns true if everything that can be done was applied
  119993. */
  119994. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  119995. }
  119996. /**
  119997. * Defines an optimization used to turn particles off
  119998. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  119999. */
  120000. export class ParticlesOptimization extends SceneOptimization {
  120001. /**
  120002. * Gets a string describing the action executed by the current optimization
  120003. * @return description string
  120004. */
  120005. getDescription(): string;
  120006. /**
  120007. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  120008. * @param scene defines the current scene where to apply this optimization
  120009. * @param optimizer defines the current optimizer
  120010. * @returns true if everything that can be done was applied
  120011. */
  120012. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  120013. }
  120014. /**
  120015. * Defines an optimization used to turn render targets off
  120016. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  120017. */
  120018. export class RenderTargetsOptimization extends SceneOptimization {
  120019. /**
  120020. * Gets a string describing the action executed by the current optimization
  120021. * @return description string
  120022. */
  120023. getDescription(): string;
  120024. /**
  120025. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  120026. * @param scene defines the current scene where to apply this optimization
  120027. * @param optimizer defines the current optimizer
  120028. * @returns true if everything that can be done was applied
  120029. */
  120030. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  120031. }
  120032. /**
  120033. * Defines an optimization used to merge meshes with compatible materials
  120034. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  120035. */
  120036. export class MergeMeshesOptimization extends SceneOptimization {
  120037. private static _UpdateSelectionTree;
  120038. /**
  120039. * Gets or sets a boolean which defines if optimization octree has to be updated
  120040. */
  120041. /**
  120042. * Gets or sets a boolean which defines if optimization octree has to be updated
  120043. */
  120044. static UpdateSelectionTree: boolean;
  120045. /**
  120046. * Gets a string describing the action executed by the current optimization
  120047. * @return description string
  120048. */
  120049. getDescription(): string;
  120050. private _canBeMerged;
  120051. /**
  120052. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  120053. * @param scene defines the current scene where to apply this optimization
  120054. * @param optimizer defines the current optimizer
  120055. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  120056. * @returns true if everything that can be done was applied
  120057. */
  120058. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  120059. }
  120060. /**
  120061. * Defines a list of options used by SceneOptimizer
  120062. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  120063. */
  120064. export class SceneOptimizerOptions {
  120065. /**
  120066. * Defines the target frame rate to reach (60 by default)
  120067. */
  120068. targetFrameRate: number;
  120069. /**
  120070. * Defines the interval between two checkes (2000ms by default)
  120071. */
  120072. trackerDuration: number;
  120073. /**
  120074. * Gets the list of optimizations to apply
  120075. */
  120076. optimizations: SceneOptimization[];
  120077. /**
  120078. * Creates a new list of options used by SceneOptimizer
  120079. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  120080. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  120081. */
  120082. constructor(
  120083. /**
  120084. * Defines the target frame rate to reach (60 by default)
  120085. */
  120086. targetFrameRate?: number,
  120087. /**
  120088. * Defines the interval between two checkes (2000ms by default)
  120089. */
  120090. trackerDuration?: number);
  120091. /**
  120092. * Add a new optimization
  120093. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  120094. * @returns the current SceneOptimizerOptions
  120095. */
  120096. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  120097. /**
  120098. * Add a new custom optimization
  120099. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  120100. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  120101. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  120102. * @returns the current SceneOptimizerOptions
  120103. */
  120104. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  120105. /**
  120106. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  120107. * @param targetFrameRate defines the target frame rate (60 by default)
  120108. * @returns a SceneOptimizerOptions object
  120109. */
  120110. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  120111. /**
  120112. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  120113. * @param targetFrameRate defines the target frame rate (60 by default)
  120114. * @returns a SceneOptimizerOptions object
  120115. */
  120116. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  120117. /**
  120118. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  120119. * @param targetFrameRate defines the target frame rate (60 by default)
  120120. * @returns a SceneOptimizerOptions object
  120121. */
  120122. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  120123. }
  120124. /**
  120125. * Class used to run optimizations in order to reach a target frame rate
  120126. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  120127. */
  120128. export class SceneOptimizer implements IDisposable {
  120129. private _isRunning;
  120130. private _options;
  120131. private _scene;
  120132. private _currentPriorityLevel;
  120133. private _targetFrameRate;
  120134. private _trackerDuration;
  120135. private _currentFrameRate;
  120136. private _sceneDisposeObserver;
  120137. private _improvementMode;
  120138. /**
  120139. * Defines an observable called when the optimizer reaches the target frame rate
  120140. */
  120141. onSuccessObservable: Observable<SceneOptimizer>;
  120142. /**
  120143. * Defines an observable called when the optimizer enables an optimization
  120144. */
  120145. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  120146. /**
  120147. * Defines an observable called when the optimizer is not able to reach the target frame rate
  120148. */
  120149. onFailureObservable: Observable<SceneOptimizer>;
  120150. /**
  120151. * Gets a boolean indicating if the optimizer is in improvement mode
  120152. */
  120153. readonly isInImprovementMode: boolean;
  120154. /**
  120155. * Gets the current priority level (0 at start)
  120156. */
  120157. readonly currentPriorityLevel: number;
  120158. /**
  120159. * Gets the current frame rate checked by the SceneOptimizer
  120160. */
  120161. readonly currentFrameRate: number;
  120162. /**
  120163. * Gets or sets the current target frame rate (60 by default)
  120164. */
  120165. /**
  120166. * Gets or sets the current target frame rate (60 by default)
  120167. */
  120168. targetFrameRate: number;
  120169. /**
  120170. * Gets or sets the current interval between two checks (every 2000ms by default)
  120171. */
  120172. /**
  120173. * Gets or sets the current interval between two checks (every 2000ms by default)
  120174. */
  120175. trackerDuration: number;
  120176. /**
  120177. * Gets the list of active optimizations
  120178. */
  120179. readonly optimizations: SceneOptimization[];
  120180. /**
  120181. * Creates a new SceneOptimizer
  120182. * @param scene defines the scene to work on
  120183. * @param options defines the options to use with the SceneOptimizer
  120184. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  120185. * @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)
  120186. */
  120187. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  120188. /**
  120189. * Stops the current optimizer
  120190. */
  120191. stop(): void;
  120192. /**
  120193. * Reset the optimizer to initial step (current priority level = 0)
  120194. */
  120195. reset(): void;
  120196. /**
  120197. * Start the optimizer. By default it will try to reach a specific framerate
  120198. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  120199. */
  120200. start(): void;
  120201. private _checkCurrentState;
  120202. /**
  120203. * Release all resources
  120204. */
  120205. dispose(): void;
  120206. /**
  120207. * Helper function to create a SceneOptimizer with one single line of code
  120208. * @param scene defines the scene to work on
  120209. * @param options defines the options to use with the SceneOptimizer
  120210. * @param onSuccess defines a callback to call on success
  120211. * @param onFailure defines a callback to call on failure
  120212. * @returns the new SceneOptimizer object
  120213. */
  120214. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  120215. }
  120216. }
  120217. declare module BABYLON {
  120218. /**
  120219. * Class used to serialize a scene into a string
  120220. */
  120221. export class SceneSerializer {
  120222. /**
  120223. * Clear cache used by a previous serialization
  120224. */
  120225. static ClearCache(): void;
  120226. /**
  120227. * Serialize a scene into a JSON compatible object
  120228. * @param scene defines the scene to serialize
  120229. * @returns a JSON compatible object
  120230. */
  120231. static Serialize(scene: Scene): any;
  120232. /**
  120233. * Serialize a mesh into a JSON compatible object
  120234. * @param toSerialize defines the mesh to serialize
  120235. * @param withParents defines if parents must be serialized as well
  120236. * @param withChildren defines if children must be serialized as well
  120237. * @returns a JSON compatible object
  120238. */
  120239. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  120240. }
  120241. }
  120242. declare module BABYLON {
  120243. /**
  120244. * Class used to host texture specific utilities
  120245. */
  120246. export class TextureTools {
  120247. /**
  120248. * Uses the GPU to create a copy texture rescaled at a given size
  120249. * @param texture Texture to copy from
  120250. * @param width defines the desired width
  120251. * @param height defines the desired height
  120252. * @param useBilinearMode defines if bilinear mode has to be used
  120253. * @return the generated texture
  120254. */
  120255. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  120256. }
  120257. }
  120258. declare module BABYLON {
  120259. /**
  120260. * This represents the different options avilable for the video capture.
  120261. */
  120262. export interface VideoRecorderOptions {
  120263. /** Defines the mime type of the video */
  120264. mimeType: string;
  120265. /** Defines the video the video should be recorded at */
  120266. fps: number;
  120267. /** Defines the chunk size for the recording data */
  120268. recordChunckSize: number;
  120269. /** The audio tracks to attach to the record */
  120270. audioTracks?: MediaStreamTrack[];
  120271. }
  120272. /**
  120273. * This can helps recording videos from BabylonJS.
  120274. * This is based on the available WebRTC functionalities of the browser.
  120275. *
  120276. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  120277. */
  120278. export class VideoRecorder {
  120279. private static readonly _defaultOptions;
  120280. /**
  120281. * Returns wehther or not the VideoRecorder is available in your browser.
  120282. * @param engine Defines the Babylon Engine to check the support for
  120283. * @returns true if supported otherwise false
  120284. */
  120285. static IsSupported(engine: Engine): boolean;
  120286. private readonly _options;
  120287. private _canvas;
  120288. private _mediaRecorder;
  120289. private _recordedChunks;
  120290. private _fileName;
  120291. private _resolve;
  120292. private _reject;
  120293. /**
  120294. * True wether a recording is already in progress.
  120295. */
  120296. readonly isRecording: boolean;
  120297. /**
  120298. * Create a new VideoCapture object which can help converting what you see in Babylon to
  120299. * a video file.
  120300. * @param engine Defines the BabylonJS Engine you wish to record
  120301. * @param options Defines options that can be used to customized the capture
  120302. */
  120303. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  120304. /**
  120305. * Stops the current recording before the default capture timeout passed in the startRecording
  120306. * functions.
  120307. */
  120308. stopRecording(): void;
  120309. /**
  120310. * Starts recording the canvas for a max duration specified in parameters.
  120311. * @param fileName Defines the name of the file to be downloaded when the recording stop. If null no automatic download will start and you can rely on the promise to get the data back.
  120312. * @param maxDuration Defines the maximum recording time in seconds.
  120313. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  120314. * @return a promise callback at the end of the recording with the video data in Blob.
  120315. */
  120316. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  120317. /**
  120318. * Releases internal resources used during the recording.
  120319. */
  120320. dispose(): void;
  120321. private _handleDataAvailable;
  120322. private _handleError;
  120323. private _handleStop;
  120324. }
  120325. }
  120326. declare module BABYLON {
  120327. /**
  120328. * Class containing a set of static utilities functions for screenshots
  120329. */
  120330. export class ScreenshotTools {
  120331. /**
  120332. * Captures a screenshot of the current rendering
  120333. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  120334. * @param engine defines the rendering engine
  120335. * @param camera defines the source camera
  120336. * @param size This parameter can be set to a single number or to an object with the
  120337. * following (optional) properties: precision, width, height. If a single number is passed,
  120338. * it will be used for both width and height. If an object is passed, the screenshot size
  120339. * will be derived from the parameters. The precision property is a multiplier allowing
  120340. * rendering at a higher or lower resolution
  120341. * @param successCallback defines the callback receives a single parameter which contains the
  120342. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  120343. * src parameter of an <img> to display it
  120344. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  120345. * Check your browser for supported MIME types
  120346. */
  120347. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  120348. /**
  120349. * Generates an image screenshot from the specified camera.
  120350. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  120351. * @param engine The engine to use for rendering
  120352. * @param camera The camera to use for rendering
  120353. * @param size This parameter can be set to a single number or to an object with the
  120354. * following (optional) properties: precision, width, height. If a single number is passed,
  120355. * it will be used for both width and height. If an object is passed, the screenshot size
  120356. * will be derived from the parameters. The precision property is a multiplier allowing
  120357. * rendering at a higher or lower resolution
  120358. * @param successCallback The callback receives a single parameter which contains the
  120359. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  120360. * src parameter of an <img> to display it
  120361. * @param mimeType The MIME type of the screenshot image (default: image/png).
  120362. * Check your browser for supported MIME types
  120363. * @param samples Texture samples (default: 1)
  120364. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  120365. * @param fileName A name for for the downloaded file.
  120366. */
  120367. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  120368. }
  120369. }
  120370. declare module BABYLON {
  120371. /**
  120372. * A cursor which tracks a point on a path
  120373. */
  120374. export class PathCursor {
  120375. private path;
  120376. /**
  120377. * Stores path cursor callbacks for when an onchange event is triggered
  120378. */
  120379. private _onchange;
  120380. /**
  120381. * The value of the path cursor
  120382. */
  120383. value: number;
  120384. /**
  120385. * The animation array of the path cursor
  120386. */
  120387. animations: Animation[];
  120388. /**
  120389. * Initializes the path cursor
  120390. * @param path The path to track
  120391. */
  120392. constructor(path: Path2);
  120393. /**
  120394. * Gets the cursor point on the path
  120395. * @returns A point on the path cursor at the cursor location
  120396. */
  120397. getPoint(): Vector3;
  120398. /**
  120399. * Moves the cursor ahead by the step amount
  120400. * @param step The amount to move the cursor forward
  120401. * @returns This path cursor
  120402. */
  120403. moveAhead(step?: number): PathCursor;
  120404. /**
  120405. * Moves the cursor behind by the step amount
  120406. * @param step The amount to move the cursor back
  120407. * @returns This path cursor
  120408. */
  120409. moveBack(step?: number): PathCursor;
  120410. /**
  120411. * Moves the cursor by the step amount
  120412. * If the step amount is greater than one, an exception is thrown
  120413. * @param step The amount to move the cursor
  120414. * @returns This path cursor
  120415. */
  120416. move(step: number): PathCursor;
  120417. /**
  120418. * Ensures that the value is limited between zero and one
  120419. * @returns This path cursor
  120420. */
  120421. private ensureLimits;
  120422. /**
  120423. * Runs onchange callbacks on change (used by the animation engine)
  120424. * @returns This path cursor
  120425. */
  120426. private raiseOnChange;
  120427. /**
  120428. * Executes a function on change
  120429. * @param f A path cursor onchange callback
  120430. * @returns This path cursor
  120431. */
  120432. onchange(f: (cursor: PathCursor) => void): PathCursor;
  120433. }
  120434. }
  120435. declare module BABYLON {
  120436. /** @hidden */
  120437. export var blurPixelShader: {
  120438. name: string;
  120439. shader: string;
  120440. };
  120441. }
  120442. declare module BABYLON {
  120443. /** @hidden */
  120444. export var bones300Declaration: {
  120445. name: string;
  120446. shader: string;
  120447. };
  120448. }
  120449. declare module BABYLON {
  120450. /** @hidden */
  120451. export var instances300Declaration: {
  120452. name: string;
  120453. shader: string;
  120454. };
  120455. }
  120456. declare module BABYLON {
  120457. /** @hidden */
  120458. export var pointCloudVertexDeclaration: {
  120459. name: string;
  120460. shader: string;
  120461. };
  120462. }
  120463. // Mixins
  120464. interface Window {
  120465. mozIndexedDB: IDBFactory;
  120466. webkitIndexedDB: IDBFactory;
  120467. msIndexedDB: IDBFactory;
  120468. webkitURL: typeof URL;
  120469. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  120470. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  120471. WebGLRenderingContext: WebGLRenderingContext;
  120472. MSGesture: MSGesture;
  120473. CANNON: any;
  120474. AudioContext: AudioContext;
  120475. webkitAudioContext: AudioContext;
  120476. PointerEvent: any;
  120477. Math: Math;
  120478. Uint8Array: Uint8ArrayConstructor;
  120479. Float32Array: Float32ArrayConstructor;
  120480. mozURL: typeof URL;
  120481. msURL: typeof URL;
  120482. VRFrameData: any; // WebVR, from specs 1.1
  120483. DracoDecoderModule: any;
  120484. setImmediate(handler: (...args: any[]) => void): number;
  120485. }
  120486. interface HTMLCanvasElement {
  120487. requestPointerLock(): void;
  120488. msRequestPointerLock?(): void;
  120489. mozRequestPointerLock?(): void;
  120490. webkitRequestPointerLock?(): void;
  120491. /** Track wether a record is in progress */
  120492. isRecording: boolean;
  120493. /** Capture Stream method defined by some browsers */
  120494. captureStream(fps?: number): MediaStream;
  120495. }
  120496. interface CanvasRenderingContext2D {
  120497. msImageSmoothingEnabled: boolean;
  120498. }
  120499. interface MouseEvent {
  120500. mozMovementX: number;
  120501. mozMovementY: number;
  120502. webkitMovementX: number;
  120503. webkitMovementY: number;
  120504. msMovementX: number;
  120505. msMovementY: number;
  120506. }
  120507. interface Navigator {
  120508. mozGetVRDevices: (any: any) => any;
  120509. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  120510. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  120511. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  120512. webkitGetGamepads(): Gamepad[];
  120513. msGetGamepads(): Gamepad[];
  120514. webkitGamepads(): Gamepad[];
  120515. }
  120516. interface HTMLVideoElement {
  120517. mozSrcObject: any;
  120518. }
  120519. interface Math {
  120520. fround(x: number): number;
  120521. imul(a: number, b: number): number;
  120522. }
  120523. interface WebGLRenderingContext {
  120524. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  120525. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  120526. vertexAttribDivisor(index: number, divisor: number): void;
  120527. createVertexArray(): any;
  120528. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  120529. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  120530. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  120531. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  120532. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  120533. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  120534. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  120535. // Queries
  120536. createQuery(): WebGLQuery;
  120537. deleteQuery(query: WebGLQuery): void;
  120538. beginQuery(target: number, query: WebGLQuery): void;
  120539. endQuery(target: number): void;
  120540. getQueryParameter(query: WebGLQuery, pname: number): any;
  120541. getQuery(target: number, pname: number): any;
  120542. MAX_SAMPLES: number;
  120543. RGBA8: number;
  120544. READ_FRAMEBUFFER: number;
  120545. DRAW_FRAMEBUFFER: number;
  120546. UNIFORM_BUFFER: number;
  120547. HALF_FLOAT_OES: number;
  120548. RGBA16F: number;
  120549. RGBA32F: number;
  120550. R32F: number;
  120551. RG32F: number;
  120552. RGB32F: number;
  120553. R16F: number;
  120554. RG16F: number;
  120555. RGB16F: number;
  120556. RED: number;
  120557. RG: number;
  120558. R8: number;
  120559. RG8: number;
  120560. UNSIGNED_INT_24_8: number;
  120561. DEPTH24_STENCIL8: number;
  120562. /* Multiple Render Targets */
  120563. drawBuffers(buffers: number[]): void;
  120564. readBuffer(src: number): void;
  120565. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  120566. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  120567. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  120568. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  120569. // Occlusion Query
  120570. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  120571. ANY_SAMPLES_PASSED: number;
  120572. QUERY_RESULT_AVAILABLE: number;
  120573. QUERY_RESULT: number;
  120574. }
  120575. interface WebGLProgram {
  120576. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  120577. }
  120578. interface EXT_disjoint_timer_query {
  120579. QUERY_COUNTER_BITS_EXT: number;
  120580. TIME_ELAPSED_EXT: number;
  120581. TIMESTAMP_EXT: number;
  120582. GPU_DISJOINT_EXT: number;
  120583. QUERY_RESULT_EXT: number;
  120584. QUERY_RESULT_AVAILABLE_EXT: number;
  120585. queryCounterEXT(query: WebGLQuery, target: number): void;
  120586. createQueryEXT(): WebGLQuery;
  120587. beginQueryEXT(target: number, query: WebGLQuery): void;
  120588. endQueryEXT(target: number): void;
  120589. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  120590. deleteQueryEXT(query: WebGLQuery): void;
  120591. }
  120592. interface WebGLUniformLocation {
  120593. _currentState: any;
  120594. }
  120595. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  120596. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  120597. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  120598. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  120599. interface WebGLRenderingContext {
  120600. readonly RASTERIZER_DISCARD: number;
  120601. readonly DEPTH_COMPONENT24: number;
  120602. readonly TEXTURE_3D: number;
  120603. readonly TEXTURE_2D_ARRAY: number;
  120604. readonly TEXTURE_COMPARE_FUNC: number;
  120605. readonly TEXTURE_COMPARE_MODE: number;
  120606. readonly COMPARE_REF_TO_TEXTURE: number;
  120607. readonly TEXTURE_WRAP_R: number;
  120608. readonly HALF_FLOAT: number;
  120609. readonly RGB8: number;
  120610. readonly RED_INTEGER: number;
  120611. readonly RG_INTEGER: number;
  120612. readonly RGB_INTEGER: number;
  120613. readonly RGBA_INTEGER: number;
  120614. readonly R8_SNORM: number;
  120615. readonly RG8_SNORM: number;
  120616. readonly RGB8_SNORM: number;
  120617. readonly RGBA8_SNORM: number;
  120618. readonly R8I: number;
  120619. readonly RG8I: number;
  120620. readonly RGB8I: number;
  120621. readonly RGBA8I: number;
  120622. readonly R8UI: number;
  120623. readonly RG8UI: number;
  120624. readonly RGB8UI: number;
  120625. readonly RGBA8UI: number;
  120626. readonly R16I: number;
  120627. readonly RG16I: number;
  120628. readonly RGB16I: number;
  120629. readonly RGBA16I: number;
  120630. readonly R16UI: number;
  120631. readonly RG16UI: number;
  120632. readonly RGB16UI: number;
  120633. readonly RGBA16UI: number;
  120634. readonly R32I: number;
  120635. readonly RG32I: number;
  120636. readonly RGB32I: number;
  120637. readonly RGBA32I: number;
  120638. readonly R32UI: number;
  120639. readonly RG32UI: number;
  120640. readonly RGB32UI: number;
  120641. readonly RGBA32UI: number;
  120642. readonly RGB10_A2UI: number;
  120643. readonly R11F_G11F_B10F: number;
  120644. readonly RGB9_E5: number;
  120645. readonly RGB10_A2: number;
  120646. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  120647. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  120648. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  120649. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  120650. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  120651. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  120652. 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;
  120653. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  120654. readonly TRANSFORM_FEEDBACK: number;
  120655. readonly INTERLEAVED_ATTRIBS: number;
  120656. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  120657. createTransformFeedback(): WebGLTransformFeedback;
  120658. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  120659. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  120660. beginTransformFeedback(primitiveMode: number): void;
  120661. endTransformFeedback(): void;
  120662. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  120663. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  120664. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  120665. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  120666. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  120667. }
  120668. interface ImageBitmap {
  120669. readonly width: number;
  120670. readonly height: number;
  120671. close(): void;
  120672. }
  120673. interface WebGLQuery extends WebGLObject {
  120674. }
  120675. declare var WebGLQuery: {
  120676. prototype: WebGLQuery;
  120677. new(): WebGLQuery;
  120678. };
  120679. interface WebGLSampler extends WebGLObject {
  120680. }
  120681. declare var WebGLSampler: {
  120682. prototype: WebGLSampler;
  120683. new(): WebGLSampler;
  120684. };
  120685. interface WebGLSync extends WebGLObject {
  120686. }
  120687. declare var WebGLSync: {
  120688. prototype: WebGLSync;
  120689. new(): WebGLSync;
  120690. };
  120691. interface WebGLTransformFeedback extends WebGLObject {
  120692. }
  120693. declare var WebGLTransformFeedback: {
  120694. prototype: WebGLTransformFeedback;
  120695. new(): WebGLTransformFeedback;
  120696. };
  120697. interface WebGLVertexArrayObject extends WebGLObject {
  120698. }
  120699. declare var WebGLVertexArrayObject: {
  120700. prototype: WebGLVertexArrayObject;
  120701. new(): WebGLVertexArrayObject;
  120702. };
  120703. // Type definitions for WebVR API
  120704. // Project: https://w3c.github.io/webvr/
  120705. // Definitions by: six a <https://github.com/lostfictions>
  120706. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  120707. interface VRDisplay extends EventTarget {
  120708. /**
  120709. * Dictionary of capabilities describing the VRDisplay.
  120710. */
  120711. readonly capabilities: VRDisplayCapabilities;
  120712. /**
  120713. * z-depth defining the far plane of the eye view frustum
  120714. * enables mapping of values in the render target depth
  120715. * attachment to scene coordinates. Initially set to 10000.0.
  120716. */
  120717. depthFar: number;
  120718. /**
  120719. * z-depth defining the near plane of the eye view frustum
  120720. * enables mapping of values in the render target depth
  120721. * attachment to scene coordinates. Initially set to 0.01.
  120722. */
  120723. depthNear: number;
  120724. /**
  120725. * An identifier for this distinct VRDisplay. Used as an
  120726. * association point in the Gamepad API.
  120727. */
  120728. readonly displayId: number;
  120729. /**
  120730. * A display name, a user-readable name identifying it.
  120731. */
  120732. readonly displayName: string;
  120733. readonly isConnected: boolean;
  120734. readonly isPresenting: boolean;
  120735. /**
  120736. * If this VRDisplay supports room-scale experiences, the optional
  120737. * stage attribute contains details on the room-scale parameters.
  120738. */
  120739. readonly stageParameters: VRStageParameters | null;
  120740. /**
  120741. * Passing the value returned by `requestAnimationFrame` to
  120742. * `cancelAnimationFrame` will unregister the callback.
  120743. * @param handle Define the hanle of the request to cancel
  120744. */
  120745. cancelAnimationFrame(handle: number): void;
  120746. /**
  120747. * Stops presenting to the VRDisplay.
  120748. * @returns a promise to know when it stopped
  120749. */
  120750. exitPresent(): Promise<void>;
  120751. /**
  120752. * Return the current VREyeParameters for the given eye.
  120753. * @param whichEye Define the eye we want the parameter for
  120754. * @returns the eye parameters
  120755. */
  120756. getEyeParameters(whichEye: string): VREyeParameters;
  120757. /**
  120758. * Populates the passed VRFrameData with the information required to render
  120759. * the current frame.
  120760. * @param frameData Define the data structure to populate
  120761. * @returns true if ok otherwise false
  120762. */
  120763. getFrameData(frameData: VRFrameData): boolean;
  120764. /**
  120765. * Get the layers currently being presented.
  120766. * @returns the list of VR layers
  120767. */
  120768. getLayers(): VRLayer[];
  120769. /**
  120770. * Return a VRPose containing the future predicted pose of the VRDisplay
  120771. * when the current frame will be presented. The value returned will not
  120772. * change until JavaScript has returned control to the browser.
  120773. *
  120774. * The VRPose will contain the position, orientation, velocity,
  120775. * and acceleration of each of these properties.
  120776. * @returns the pose object
  120777. */
  120778. getPose(): VRPose;
  120779. /**
  120780. * Return the current instantaneous pose of the VRDisplay, with no
  120781. * prediction applied.
  120782. * @returns the current instantaneous pose
  120783. */
  120784. getImmediatePose(): VRPose;
  120785. /**
  120786. * The callback passed to `requestAnimationFrame` will be called
  120787. * any time a new frame should be rendered. When the VRDisplay is
  120788. * presenting the callback will be called at the native refresh
  120789. * rate of the HMD. When not presenting this function acts
  120790. * identically to how window.requestAnimationFrame acts. Content should
  120791. * make no assumptions of frame rate or vsync behavior as the HMD runs
  120792. * asynchronously from other displays and at differing refresh rates.
  120793. * @param callback Define the eaction to run next frame
  120794. * @returns the request handle it
  120795. */
  120796. requestAnimationFrame(callback: FrameRequestCallback): number;
  120797. /**
  120798. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  120799. * Repeat calls while already presenting will update the VRLayers being displayed.
  120800. * @param layers Define the list of layer to present
  120801. * @returns a promise to know when the request has been fulfilled
  120802. */
  120803. requestPresent(layers: VRLayer[]): Promise<void>;
  120804. /**
  120805. * Reset the pose for this display, treating its current position and
  120806. * orientation as the "origin/zero" values. VRPose.position,
  120807. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  120808. * updated when calling resetPose(). This should be called in only
  120809. * sitting-space experiences.
  120810. */
  120811. resetPose(): void;
  120812. /**
  120813. * The VRLayer provided to the VRDisplay will be captured and presented
  120814. * in the HMD. Calling this function has the same effect on the source
  120815. * canvas as any other operation that uses its source image, and canvases
  120816. * created without preserveDrawingBuffer set to true will be cleared.
  120817. * @param pose Define the pose to submit
  120818. */
  120819. submitFrame(pose?: VRPose): void;
  120820. }
  120821. declare var VRDisplay: {
  120822. prototype: VRDisplay;
  120823. new(): VRDisplay;
  120824. };
  120825. interface VRLayer {
  120826. leftBounds?: number[] | Float32Array | null;
  120827. rightBounds?: number[] | Float32Array | null;
  120828. source?: HTMLCanvasElement | null;
  120829. }
  120830. interface VRDisplayCapabilities {
  120831. readonly canPresent: boolean;
  120832. readonly hasExternalDisplay: boolean;
  120833. readonly hasOrientation: boolean;
  120834. readonly hasPosition: boolean;
  120835. readonly maxLayers: number;
  120836. }
  120837. interface VREyeParameters {
  120838. /** @deprecated */
  120839. readonly fieldOfView: VRFieldOfView;
  120840. readonly offset: Float32Array;
  120841. readonly renderHeight: number;
  120842. readonly renderWidth: number;
  120843. }
  120844. interface VRFieldOfView {
  120845. readonly downDegrees: number;
  120846. readonly leftDegrees: number;
  120847. readonly rightDegrees: number;
  120848. readonly upDegrees: number;
  120849. }
  120850. interface VRFrameData {
  120851. readonly leftProjectionMatrix: Float32Array;
  120852. readonly leftViewMatrix: Float32Array;
  120853. readonly pose: VRPose;
  120854. readonly rightProjectionMatrix: Float32Array;
  120855. readonly rightViewMatrix: Float32Array;
  120856. readonly timestamp: number;
  120857. }
  120858. interface VRPose {
  120859. readonly angularAcceleration: Float32Array | null;
  120860. readonly angularVelocity: Float32Array | null;
  120861. readonly linearAcceleration: Float32Array | null;
  120862. readonly linearVelocity: Float32Array | null;
  120863. readonly orientation: Float32Array | null;
  120864. readonly position: Float32Array | null;
  120865. readonly timestamp: number;
  120866. }
  120867. interface VRStageParameters {
  120868. sittingToStandingTransform?: Float32Array;
  120869. sizeX?: number;
  120870. sizeY?: number;
  120871. }
  120872. interface Navigator {
  120873. getVRDisplays(): Promise<VRDisplay[]>;
  120874. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  120875. }
  120876. interface Window {
  120877. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  120878. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  120879. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  120880. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  120881. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  120882. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  120883. }
  120884. interface Gamepad {
  120885. readonly displayId: number;
  120886. }
  120887. interface XRDevice {
  120888. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  120889. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  120890. }
  120891. interface XRSession {
  120892. getInputSources(): Array<any>;
  120893. baseLayer: XRWebGLLayer;
  120894. requestFrameOfReference(type: string): Promise<void>;
  120895. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  120896. end(): Promise<void>;
  120897. requestAnimationFrame: Function;
  120898. addEventListener: Function;
  120899. }
  120900. interface XRSessionCreationOptions {
  120901. outputContext?: WebGLRenderingContext | null;
  120902. immersive?: boolean;
  120903. environmentIntegration?: boolean;
  120904. }
  120905. interface XRLayer {
  120906. getViewport: Function;
  120907. framebufferWidth: number;
  120908. framebufferHeight: number;
  120909. }
  120910. interface XRView {
  120911. projectionMatrix: Float32Array;
  120912. }
  120913. interface XRFrame {
  120914. getDevicePose: Function;
  120915. getInputPose: Function;
  120916. views: Array<XRView>;
  120917. baseLayer: XRLayer;
  120918. }
  120919. interface XRFrameOfReference {
  120920. }
  120921. interface XRWebGLLayer extends XRLayer {
  120922. framebuffer: WebGLFramebuffer;
  120923. }
  120924. declare var XRWebGLLayer: {
  120925. prototype: XRWebGLLayer;
  120926. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  120927. };